@needle-tools/engine 5.1.0-experimental.1 → 5.1.0-experimental.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{needle-engine.bundle-JZXX6OjM.js → needle-engine.bundle-Cp6RtfsD.js} +643 -625
- package/dist/{needle-engine.bundle-CaHKqc30.umd.cjs → needle-engine.bundle-DQE5rl-V.umd.cjs} +85 -85
- package/dist/{needle-engine.bundle-BiCxyTBE.min.js → needle-engine.bundle-EFFJgRPu.min.js} +88 -88
- package/dist/needle-engine.d.ts +22 -22
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/three.js +1 -1
- package/dist/three.min.js +18 -18
- package/dist/three.umd.cjs +29 -29
- package/lib/engine/engine_context.js +2 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.js +21 -3
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/js-extensions/RGBAColor.js +2 -2
- package/lib/engine/js-extensions/RGBAColor.js.map +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +12 -8
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/package.json +2 -2
- package/src/engine/engine_context.ts +2 -2
- package/src/engine/engine_serialization_builtin_serializer.ts +17 -3
- package/src/engine/js-extensions/RGBAColor.ts +6 -2
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +11 -8
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
- package/dist/generateMeshBVH.worker-DT9A2Hrc.js +0 -1
package/dist/three.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var ho=typeof document<"u"?document.currentScript:null;const Wr="183.2",Cy={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Ny={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ry=0,vp=1,Iy=2,pS=3,mS=0,ul=1,Yp=2,Yo=3,is=0,An=1,Ri=2,Di=0,nr=1,uu=2,Mp=3,Sp=4,Zp=5,gS=6,Qs=100,Py=101,Ly=102,Fy=103,Jp=104,Dy=200,Uy=201,Oy=202,By=203,du=204,fu=205,zy=206,Vy=207,ky=208,Gy=209,Hy=210,Wy=211,Xy=212,$y=213,qy=214,bl=0,Tl=1,wl=2,rr=3,Al=4,El=5,Cl=6,Nl=7,uc=0,Yy=1,Zy=2,di=0,Wu=1,Xu=2,jp=3,$u=4,Kp=5,qu=6,Yu=7,bp="attached",Jy="detached",Zu=300,ss=301,or=302,Jo=303,jo=304,to=306,oa=1e3,Bn=1001,aa=1002,Xe=1003,Ju=1004,jy=1004,zr=1005,xS=1005,Fe=1006,Ko=1007,yS=1007,Li=1008,Ky=1008,Un=1009,Qp=1010,tm=1011,la=1012,ju=1013,ii=1014,Tn=1015,Ui=1016,Ku=1017,Qu=1018,Yr=1020,td=35902,ed=35899,em=1021,nd=1022,wn=1023,Oi=1026,Cs=1027,dc=1028,Ma=1029,ar=1030,fc=1031,_S=1032,pc=1033,Qo=33776,ta=33777,dl=33778,ea=33779,Rl=35840,pu=35841,Il=35842,Pl=35843,Ll=36196,Fl=37492,Dl=37496,Ul=37488,Ol=37489,Bl=37490,zl=37491,Vl=37808,mu=37809,gu=37810,xu=37811,kl=37812,yu=37813,_u=37814,vu=37815,Mu=37816,Su=37817,bu=37818,Tu=37819,wu=37820,Au=37821,Gl=36492,Eu=36494,Hl=36495,Wl=36283,Xl=36284,$l=36285,ql=36286,nm=2200,im=2201,Qy=2202,ca=2300,Yl=2301,su=2302,Tp=2303,Vr=2400,kr=2401,Zl=2402,id=2500,sm=2501,t_=0,e_=1,n_=2,rm=3200,i_=3201,vS=3202,MS=3203,ur=0,s_=1,Ki="",Fn="srgb",lr="srgb-linear",Jl="linear",_e="srgb",SS="",bS="rg",TS="ga",r_=0,Ks=7680,o_=7681,a_=7682,l_=7683,c_=34055,h_=34056,u_=5386,d_=512,f_=513,p_=514,m_=515,g_=516,x_=517,y_=518,Cu=519,__=512,v_=513,M_=514,sd=515,S_=516,b_=517,rd=518,T_=519,jl=35044,w_=35048,wS=35040,AS=35045,ES=35049,CS=35041,NS=35046,RS=35050,IS=35042,PS="100",Nu="300 es",ti=2e3,Zr=2001,LS={COMPUTE:"compute",RENDER:"render"},FS={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},DS={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},US={TEXTURE_COMPARE:"depthTextureCompare"};function OS(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}const BS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Zo(r,t){return new BS[r](t)}function A_(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Kl(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function E_(){const r=Kl("canvas");return r.style.display="block",r}const Xg={};let cr=null;function zS(r){cr=r}function VS(){return cr}function Ql(...r){const t="THREE."+r.shift();cr?cr("log",t,...r):console.log(t,...r)}function C_(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function pt(...r){r=C_(r);const t="THREE."+r.shift();if(cr)cr("warn",t,...r);else{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function Vt(...r){r=C_(r);const t="THREE."+r.shift();if(cr)cr("error",t,...r);else{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function tc(...r){const t=r.join(" ");t in Xg||(Xg[t]=!0,pt(...r))}function kS(r,t,e){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}const GS={[bl]:Tl,[wl]:Cl,[Al]:Nl,[rr]:El,[Tl]:bl,[Cl]:wl,[Nl]:Al,[El]:rr};let Bi=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const i=n[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}};const _n=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let $g=1234567;const Xr=Math.PI/180,ha=180/Math.PI;function ei(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(_n[r&255]+_n[r>>8&255]+_n[r>>16&255]+_n[r>>24&255]+"-"+_n[t&255]+_n[t>>8&255]+"-"+_n[t>>16&15|64]+_n[t>>24&255]+"-"+_n[e&63|128]+_n[e>>8&255]+"-"+_n[e>>16&255]+_n[e>>24&255]+_n[n&255]+_n[n>>8&255]+_n[n>>16&255]+_n[n>>24&255]).toLowerCase()}function Jt(r,t,e){return Math.max(t,Math.min(e,r))}function om(r,t){return(r%t+t)%t}function HS(r,t,e,n,i){return n+(r-t)*(i-n)/(e-t)}function WS(r,t,e){return r!==t?(e-r)/(t-r):0}function fl(r,t,e){return(1-e)*r+e*t}function XS(r,t,e,n){return fl(r,t,1-Math.exp(-e*n))}function $S(r,t=1){return t-Math.abs(om(r,t*2)-t)}function qS(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function YS(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function ZS(r,t){return r+Math.floor(Math.random()*(t-r+1))}function JS(r,t){return r+Math.random()*(t-r)}function jS(r){return r*(.5-Math.random())}function KS(r){r!==void 0&&($g=r);let t=$g+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function QS(r){return r*Xr}function tb(r){return r*ha}function eb(r){return(r&r-1)===0&&r!==0}function nb(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function ib(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function sb(r,t,e,n,i){const s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),c=s((t+n)/2),h=o((t+n)/2),u=s((t-n)/2),d=o((t-n)/2),f=s((n-t)/2),p=o((n-t)/2);switch(i){case"XYX":r.set(a*h,l*u,l*d,a*c);break;case"YZY":r.set(l*d,a*h,l*u,a*c);break;case"ZXZ":r.set(l*u,l*d,a*h,a*c);break;case"XZX":r.set(a*h,l*p,l*f,a*c);break;case"YXY":r.set(l*f,a*h,l*p,a*c);break;case"ZYZ":r.set(l*p,l*f,a*h,a*c);break;default:pt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function On(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function le(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const N_={DEG2RAD:Xr,RAD2DEG:ha,generateUUID:ei,clamp:Jt,euclideanModulo:om,mapLinear:HS,inverseLerp:WS,lerp:fl,damp:XS,pingpong:$S,smoothstep:qS,smootherstep:YS,randInt:ZS,randFloat:JS,randFloatSpread:jS,seededRandom:KS,degToRad:QS,radToDeg:tb,isPowerOfTwo:eb,ceilPowerOfTwo:nb,floorPowerOfTwo:ib,setQuaternionFromProperEuler:sb,normalize:le,denormalize:On};let tt=class R_{constructor(t=0,e=0){R_.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,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=Jt(this.x,t.x,e.x),this.y=Jt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Jt(this.x,t,e),this.y=Jt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Jt(n,t,e))}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 n=this.dot(t)/e;return Math.acos(Jt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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 n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*n-o*i+t.x,this.y=s*i+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},En=class{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,o,a){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3],d=s[o+0],f=s[o+1],p=s[o+2],x=s[o+3];if(u!==x||l!==d||c!==f||h!==p){let g=l*d+c*f+h*p+u*x;g<0&&(d=-d,f=-f,p=-p,x=-x,g=-g);let m=1-a;if(g<.9995){const y=Math.acos(g),v=Math.sin(y);m=Math.sin(m*y)/v,a=Math.sin(a*y)/v,l=l*m+d*a,c=c*m+f*a,h=h*m+p*a,u=u*m+x*a}else{l=l*m+d*a,c=c*m+f*a,h=h*m+p*a,u=u*m+x*a;const y=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=y,c*=y,h*=y,u*=y}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+h*u+l*f-c*d,t[e+1]=l*p+h*d+c*u-a*f,t[e+2]=c*p+h*f+a*d-l*u,t[e+3]=h*p-a*u-l*d-c*f,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,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,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 n=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(i/2),u=a(s/2),d=l(n/2),f=l(i/2),p=l(s/2);switch(o){case"XYZ":this._x=d*h*u+c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u+d*f*p;break;case"YZX":this._x=d*h*u+c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u-d*f*p;break;case"XZY":this._x=d*h*u-c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u+d*f*p;break;default:pt("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+a+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(n>a&&n>u){const f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>u){const f=2*Math.sqrt(1+a-n-u);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Jt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),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 n=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-n*c,this._z=s*h+o*c+n*l-i*a,this._w=o*h-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,s=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,i=-i,s=-s,o=-o,a=-a);let l=1-e;if(a<.9995){const c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+i*e,this._z=this._z*l+s*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+i*e,this._z=this._z*l+s*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}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}},R=class I_{constructor(t=0,e=0,n=0){I_.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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(qg.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(qg.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*i-a*n),h=2*(a*e-s*i),u=2*(s*n-o*e);return this.x=e+l*c+o*u-a*h,this.y=n+l*h+a*c-s*u,this.z=i+l*u+s*h-o*c,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,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,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=Jt(this.x,t.x,e.x),this.y=Jt(this.y,t.y,e.y),this.z=Jt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Jt(this.x,t,e),this.y=Jt(this.y,t,e),this.z=Jt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Jt(n,t,e))}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Zd.copy(this).projectOnVector(t),this.sub(Zd)}reflect(t){return this.sub(Zd.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 n=this.dot(t)/e;return Math.acos(Jt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,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(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Zd=new R,qg=new En;let ae=class P_{constructor(t,e,n,i,s,o,a,l,c){P_.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,o,a,l,c)}set(t,e,n,i,s,o,a,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=s,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.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 n=t.elements,i=e.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],p=n[8],x=i[0],g=i[3],m=i[6],y=i[1],v=i[4],_=i[7],w=i[2],T=i[5],E=i[8];return s[0]=o*x+a*y+l*w,s[3]=o*g+a*v+l*T,s[6]=o*m+a*_+l*E,s[1]=c*x+h*y+u*w,s[4]=c*g+h*v+u*T,s[7]=c*m+h*_+u*E,s[2]=d*x+f*y+p*w,s[5]=d*g+f*v+p*T,s[8]=d*m+f*_+p*E,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],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*s*h+n*a*l+i*s*c-i*o*l}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*o-a*c,d=a*l-h*s,f=c*s-o*l,p=e*u+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/p;return t[0]=u*x,t[1]=(i*c-h*n)*x,t[2]=(a*n-i*o)*x,t[3]=d*x,t[4]=(h*e-i*l)*x,t[5]=(i*s-a*e)*x,t[6]=f*x,t[7]=(n*l-c*e)*x,t[8]=(o*e-n*s)*x,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,n,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Jd.makeScale(t,e)),this}rotate(t){return this.premultiply(Jd.makeRotation(-t)),this}translate(t,e){return this.premultiply(Jd.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),n=Math.sin(t);return this.set(e,-n,0,n,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,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};const Jd=new ae,Yg=new ae().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Zg=new ae().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rb(){const r={enabled:!0,workingColorSpace:lr,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===_e&&(i.r=Is(i.r),i.g=Is(i.g),i.b=Is(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===_e&&(i.r=na(i.r),i.g=na(i.g),i.b=na(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Ki?Jl:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return tc("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return tc("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[lr]:{primaries:t,whitePoint:n,transfer:Jl,toXYZ:Yg,fromXYZ:Zg,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Fn},outputColorSpaceConfig:{drawingBufferColorSpace:Fn}},[Fn]:{primaries:t,whitePoint:n,transfer:_e,toXYZ:Yg,fromXYZ:Zg,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Fn}}}),r}const fe=rb();function Is(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function na(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let uo,am=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{uo===void 0&&(uo=Kl("canvas")),uo.width=t.width,uo.height=t.height;const i=uo.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=uo}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Kl("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Is(s[o]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Is(e[n]/255)*255):e[n]=Is(e[n]);return{data:e,width:t.width,height:t.height}}else return pt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},ob=0,Ns=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ob++}),this.uuid=ei(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(jd(i[o].image)):s.push(jd(i[o]))}else s=jd(i);n.url=s}return e||(t.images[this.uuid]=n),n}};function jd(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?am.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(pt("Texture: Unable to serialize Texture."),{})}let ab=0;const Kd=new R;let rn=class ru extends Bi{constructor(t=ru.DEFAULT_IMAGE,e=ru.DEFAULT_MAPPING,n=Bn,i=Bn,s=Fe,o=Li,a=wn,l=Un,c=ru.DEFAULT_ANISOTROPY,h=Ki){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ab++}),this.uuid=ei(),this.name="",this.source=new Ns(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new tt(0,0),this.repeat=new tt(1,1),this.center=new tt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ae,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Kd).x}get height(){return this.source.getSize(Kd).y}get depth(){return this.source.getSize(Kd).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){pt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){pt(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Zu)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case oa:t.x=t.x-Math.floor(t.x);break;case Bn:t.x=t.x<0?0:1;break;case aa: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 oa:t.y=t.y-Math.floor(t.y);break;case Bn:t.y=t.y<0?0:1;break;case aa: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)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};rn.DEFAULT_IMAGE=null;rn.DEFAULT_MAPPING=Zu;rn.DEFAULT_ANISOTROPY=4;let Le=class L_{constructor(t=0,e=0,n=0,i=1){L_.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=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;case 3:this.w=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;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}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!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=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.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=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.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,s;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],p=l[9],x=l[2],g=l[6],m=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(p+g)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const v=(c+1)/2,_=(f+1)/2,w=(m+1)/2,T=(h+d)/4,E=(u+x)/4,M=(p+g)/4;return v>_&&v>w?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=T/n,s=E/n):_>w?_<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(_),n=T/i,s=M/i):w<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),n=E/s,i=M/s),this.set(n,i,s,e),this}let y=Math.sqrt((g-p)*(g-p)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-x)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}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.w=Math.min(this.w,t.w),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.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Jt(this.x,t.x,e.x),this.y=Jt(this.y,t.y,e.y),this.z=Jt(this.z,t.z,e.z),this.w=Jt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Jt(this.x,t,e),this.y=Jt(this.y,t,e),this.z=Jt(this.z,t,e),this.w=Jt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Jt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},lm=class extends Bi{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fe,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Le(0,0,t,e),this.scissorTest=!1,this.viewport=new Le(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},s=new rn(i),o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){const e={minFilter:Fe,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new Ns(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}};class qn extends lm{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}let od=class extends rn{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Xe,this.minFilter=Xe,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}};class lb extends qn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new od(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class mc extends rn{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Xe,this.minFilter=Xe,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class cb extends qn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new mc(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}let Qt=class wp{constructor(t,e,n,i,s,o,a,l,c,h,u,d,f,p,x,g){wp.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,n,i,s,o,a,l,c,h,u,d,f,p,x,g)}set(t,e,n,i,s,o,a,l,c,h,u,d,f,p,x,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=p,m[11]=x,m[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 wp().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[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,n){return this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();const e=this.elements,n=t.elements,i=1/fo.setFromMatrixColumn(t,0).length(),s=1/fo.setFromMatrixColumn(t,1).length(),o=1/fo.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,s=t.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=o*h,f=o*u,p=a*h,x=a*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+p*c,e[5]=d-x*c,e[9]=-a*l,e[2]=x-d*c,e[6]=p+f*c,e[10]=o*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,p=c*h,x=c*u;e[0]=d+x*a,e[4]=p*a-f,e[8]=o*c,e[1]=o*u,e[5]=o*h,e[9]=-a,e[2]=f*a-p,e[6]=x+d*a,e[10]=o*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,p=c*h,x=c*u;e[0]=d-x*a,e[4]=-o*u,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*h,e[9]=x-d*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const d=o*h,f=o*u,p=a*h,x=a*u;e[0]=l*h,e[4]=p*c-f,e[8]=d*c+x,e[1]=l*u,e[5]=x*c+d,e[9]=f*c-p,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const d=o*l,f=o*c,p=a*l,x=a*c;e[0]=l*h,e[4]=x-d*u,e[8]=p*u+f,e[1]=u,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=f*u+p,e[10]=d-x*u}else if(t.order==="XZY"){const d=o*l,f=o*c,p=a*l,x=a*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+x,e[5]=o*h,e[9]=f*u-p,e[2]=p*u-f,e[6]=a*h,e[10]=x*u+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(hb,t,ub)}lookAt(t,e,n){const i=this.elements;return Zn.subVectors(t,e),Zn.lengthSq()===0&&(Zn.z=1),Zn.normalize(),Bs.crossVectors(n,Zn),Bs.lengthSq()===0&&(Math.abs(n.z)===1?Zn.x+=1e-4:Zn.z+=1e-4,Zn.normalize(),Bs.crossVectors(n,Zn)),Bs.normalize(),Dc.crossVectors(Zn,Bs),i[0]=Bs.x,i[4]=Dc.x,i[8]=Zn.x,i[1]=Bs.y,i[5]=Dc.y,i[9]=Zn.y,i[2]=Bs.z,i[6]=Dc.z,i[10]=Zn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],p=n[2],x=n[6],g=n[10],m=n[14],y=n[3],v=n[7],_=n[11],w=n[15],T=i[0],E=i[4],M=i[8],b=i[12],P=i[1],N=i[5],L=i[9],U=i[13],V=i[2],O=i[6],k=i[10],G=i[14],it=i[3],nt=i[7],mt=i[11],xt=i[15];return s[0]=o*T+a*P+l*V+c*it,s[4]=o*E+a*N+l*O+c*nt,s[8]=o*M+a*L+l*k+c*mt,s[12]=o*b+a*U+l*G+c*xt,s[1]=h*T+u*P+d*V+f*it,s[5]=h*E+u*N+d*O+f*nt,s[9]=h*M+u*L+d*k+f*mt,s[13]=h*b+u*U+d*G+f*xt,s[2]=p*T+x*P+g*V+m*it,s[6]=p*E+x*N+g*O+m*nt,s[10]=p*M+x*L+g*k+m*mt,s[14]=p*b+x*U+g*G+m*xt,s[3]=y*T+v*P+_*V+w*it,s[7]=y*E+v*N+_*O+w*nt,s[11]=y*M+v*L+_*k+w*mt,s[15]=y*b+v*U+_*G+w*xt,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],n=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],p=t[3],x=t[7],g=t[11],m=t[15],y=l*f-c*d,v=a*f-c*u,_=a*d-l*u,w=o*f-c*h,T=o*d-l*h,E=o*u-a*h;return e*(x*y-g*v+m*_)-n*(p*y-g*w+m*T)+i*(p*v-x*w+m*E)-s*(p*_-x*T+g*E)}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,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],p=t[12],x=t[13],g=t[14],m=t[15],y=e*a-n*o,v=e*l-i*o,_=e*c-s*o,w=n*l-i*a,T=n*c-s*a,E=i*c-s*l,M=h*x-u*p,b=h*g-d*p,P=h*m-f*p,N=u*g-d*x,L=u*m-f*x,U=d*m-f*g,V=y*U-v*L+_*N+w*P-T*b+E*M;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/V;return t[0]=(a*U-l*L+c*N)*O,t[1]=(i*L-n*U-s*N)*O,t[2]=(x*E-g*T+m*w)*O,t[3]=(d*T-u*E-f*w)*O,t[4]=(l*P-o*U-c*b)*O,t[5]=(e*U-i*P+s*b)*O,t[6]=(g*_-p*E-m*v)*O,t[7]=(h*E-d*_+f*v)*O,t[8]=(o*L-a*P+c*M)*O,t[9]=(n*P-e*L-s*M)*O,t[10]=(p*T-x*_+m*y)*O,t[11]=(u*_-h*T-f*y)*O,t[12]=(a*b-o*N-l*M)*O,t[13]=(e*N-n*b+i*M)*O,t[14]=(x*v-p*w-g*y)*O,t[15]=(h*w-u*v+d*y)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),s=1-n,o=t.x,a=t.y,l=t.z,c=s*o,h=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+n,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,o){return this.set(1,n,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,h=o+o,u=a+a,d=s*c,f=s*h,p=s*u,x=o*h,g=o*u,m=a*u,y=l*c,v=l*h,_=l*u,w=n.x,T=n.y,E=n.z;return i[0]=(1-(x+m))*w,i[1]=(f+_)*w,i[2]=(p-v)*w,i[3]=0,i[4]=(f-_)*T,i[5]=(1-(d+m))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+v)*E,i[9]=(g-y)*E,i[10]=(1-(d+x))*E,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const s=this.determinant();if(s===0)return n.set(1,1,1),e.identity(),this;let o=fo.set(i[0],i[1],i[2]).length();const a=fo.set(i[4],i[5],i[6]).length(),l=fo.set(i[8],i[9],i[10]).length();s<0&&(o=-o),bi.copy(this);const c=1/o,h=1/a,u=1/l;return bi.elements[0]*=c,bi.elements[1]*=c,bi.elements[2]*=c,bi.elements[4]*=h,bi.elements[5]*=h,bi.elements[6]*=h,bi.elements[8]*=u,bi.elements[9]*=u,bi.elements[10]*=u,e.setFromRotationMatrix(bi),n.x=o,n.y=a,n.z=l,this}makePerspective(t,e,n,i,s,o,a=ti,l=!1){const c=this.elements,h=2*s/(e-t),u=2*s/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i);let p,x;if(l)p=s/(o-s),x=o*s/(o-s);else if(a===ti)p=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(a===Zr)p=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,s,o,a=ti,l=!1){const c=this.elements,h=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),f=-(n+i)/(n-i);let p,x;if(l)p=1/(o-s),x=o/(o-s);else if(a===ti)p=-2/(o-s),x=-(o+s)/(o-s);else if(a===Zr)p=-1/(o-s),x=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}};const fo=new R,bi=new Qt,hb=new R(0,0,0),ub=new R(1,1,1),Bs=new R,Dc=new R,Zn=new R,Jg=new Qt,jg=new En;let mi=class F_{constructor(t=0,e=0,n=0,i=F_.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,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,n=!0){const i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(Jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Jt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Jt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Jt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:pt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Jg.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Jg,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return jg.setFromEuler(this),this.setFromQuaternion(jg,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}};mi.DEFAULT_ORDER="XYZ";let gc=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},db=0;const Kg=new R,po=new En,fs=new Qt,Uc=new R,Oa=new R,fb=new R,pb=new En,Qg=new R(1,0,0),t0=new R(0,1,0),e0=new R(0,0,1),n0={type:"added"},mb={type:"removed"},mo={type:"childadded",child:null},Qd={type:"childremoved",child:null};let ve=class ou extends Bi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:db++}),this.uuid=ei(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ou.DEFAULT_UP.clone();const t=new R,e=new mi,n=new En,i=new R(1,1,1);function s(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Qt},normalMatrix:{value:new ae}}),this.matrix=new Qt,this.matrixWorld=new Qt,this.matrixAutoUpdate=ou.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ou.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return po.setFromAxisAngle(t,e),this.quaternion.multiply(po),this}rotateOnWorldAxis(t,e){return po.setFromAxisAngle(t,e),this.quaternion.premultiply(po),this}rotateX(t){return this.rotateOnAxis(Qg,t)}rotateY(t){return this.rotateOnAxis(t0,t)}rotateZ(t){return this.rotateOnAxis(e0,t)}translateOnAxis(t,e){return Kg.copy(t).applyQuaternion(this.quaternion),this.position.add(Kg.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Qg,t)}translateY(t){return this.translateOnAxis(t0,t)}translateZ(t){return this.translateOnAxis(e0,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(fs.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Uc.copy(t):Uc.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Oa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?fs.lookAt(Oa,Uc,this.up):fs.lookAt(Uc,Oa,this.up),this.quaternion.setFromRotationMatrix(fs),i&&(fs.extractRotation(i.matrixWorld),po.setFromRotationMatrix(fs),this.quaternion.premultiply(po.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Vt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(n0),mo.child=t,this.dispatchEvent(mo),mo.child=null):Vt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(mb),Qd.child=t,this.dispatchEvent(Qd),Qd.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),fs.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),fs.multiply(t.parent.matrixWorld)),t.applyMatrix4(fs),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(n0),mo.child=t,this.dispatchEvent(mo),mo.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,t,fb),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,pb,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,i=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*i,s[13]+=n-s[1]*e-s[5]*n-s[9]*i,s[14]+=i-s[2]*e-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(t.shapes,u)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),h=o(t.images),u=o(t.shapes),d=o(t.skeletons),f=o(t.animations),p=o(t.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}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),t.pivot!==null&&(this.pivot=t.pivot.clone()),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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}};ve.DEFAULT_UP=new R(0,1,0);ve.DEFAULT_MATRIX_AUTO_UPDATE=!0;ve.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Gr extends ve{constructor(){super(),this.isGroup=!0,this.type="Group"}}const gb={type:"move"};class au{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Gr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(const x of t.hand.values()){const g=e.getJointPose(x,n),m=this._getHandJoint(c,x);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,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));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(gb)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Gr;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const D_={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},zs={h:0,s:0,l:0},Oc={h:0,s:0,l:0};function tf(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}let wt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Fn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,fe.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=fe.workingColorSpace){return this.r=t,this.g=e,this.b=n,fe.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=fe.workingColorSpace){if(t=om(t,1),e=Jt(e,0,1),n=Jt(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,o=2*n-s;this.r=tf(o,s,t+1/3),this.g=tf(o,s,t),this.b=tf(o,s,t-1/3)}return fe.colorSpaceToWorking(this,i),this}setStyle(t,e=Fn){function n(s){s!==void 0&&parseFloat(s)<1&&pt("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:pt("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);pt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Fn){const n=D_[t.toLowerCase()];return n!==void 0?this.setHex(n,e):pt("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=Is(t.r),this.g=Is(t.g),this.b=Is(t.b),this}copyLinearToSRGB(t){return this.r=na(t.r),this.g=na(t.g),this.b=na(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Fn){return fe.workingToColorSpace(vn.copy(this),t),Math.round(Jt(vn.r*255,0,255))*65536+Math.round(Jt(vn.g*255,0,255))*256+Math.round(Jt(vn.b*255,0,255))}getHexString(t=Fn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=fe.workingColorSpace){fe.workingToColorSpace(vn.copy(this),e);const n=vn.r,i=vn.g,s=vn.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=fe.workingColorSpace){return fe.workingToColorSpace(vn.copy(this),e),t.r=vn.r,t.g=vn.g,t.b=vn.b,t}getStyle(t=Fn){fe.workingToColorSpace(vn.copy(this),t);const e=vn.r,n=vn.g,i=vn.b;return t!==Fn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(zs),this.setHSL(zs.h+t,zs.s+e,zs.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(zs),t.getHSL(Oc);const n=fl(zs.h,Oc.h,e),i=fl(zs.s,Oc.s,e),s=fl(zs.l,Oc.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const vn=new wt;wt.NAMES=D_;class ad{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new wt(t),this.density=e}clone(){return new ad(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let cm=class U_{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new wt(t),this.near=e,this.far=n}clone(){return new U_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class hm extends ve{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new mi,this.environmentIntensity=1,this.environmentRotation=new mi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const Ti=new R,ps=new R,ef=new R,ms=new R,go=new R,xo=new R,i0=new R,nf=new R,sf=new R,rf=new R,of=new Le,af=new Le,lf=new Le;let ws=class $o{constructor(t=new R,e=new R,n=new R){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Ti.subVectors(t,e),i.cross(Ti);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){Ti.subVectors(i,e),ps.subVectors(n,e),ef.subVectors(t,e);const o=Ti.dot(Ti),a=Ti.dot(ps),l=Ti.dot(ef),c=ps.dot(ps),h=ps.dot(ef),u=o*c-a*a;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(c*l-a*h)*d,p=(o*h-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,ms)===null?!1:ms.x>=0&&ms.y>=0&&ms.x+ms.y<=1}static getInterpolation(t,e,n,i,s,o,a,l){return this.getBarycoord(t,e,n,i,ms)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,ms.x),l.addScaledVector(o,ms.y),l.addScaledVector(a,ms.z),l)}static getInterpolatedAttribute(t,e,n,i,s,o){return of.setScalar(0),af.setScalar(0),lf.setScalar(0),of.fromBufferAttribute(t,e),af.fromBufferAttribute(t,n),lf.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(of,s.x),o.addScaledVector(af,s.y),o.addScaledVector(lf,s.z),o}static isFrontFacing(t,e,n,i){return Ti.subVectors(n,e),ps.subVectors(t,e),Ti.cross(ps).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ti.subVectors(this.c,this.b),ps.subVectors(this.a,this.b),Ti.cross(ps).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return $o.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return $o.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return $o.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return $o.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return $o.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,s=this.c;let o,a;go.subVectors(i,n),xo.subVectors(s,n),nf.subVectors(t,n);const l=go.dot(nf),c=xo.dot(nf);if(l<=0&&c<=0)return e.copy(n);sf.subVectors(t,i);const h=go.dot(sf),u=xo.dot(sf);if(h>=0&&u<=h)return e.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(n).addScaledVector(go,o);rf.subVectors(t,s);const f=go.dot(rf),p=xo.dot(rf);if(p>=0&&f<=p)return e.copy(s);const x=f*c-l*p;if(x<=0&&c>=0&&p<=0)return a=c/(c-p),e.copy(n).addScaledVector(xo,a);const g=h*p-f*u;if(g<=0&&u-h>=0&&f-p>=0)return i0.subVectors(s,i),a=(u-h)/(u-h+(f-p)),e.copy(i).addScaledVector(i0,a);const m=1/(g+x+d);return o=x*m,a=d*m,e.copy(n).addScaledVector(go,o).addScaledVector(xo,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},mn=class{constructor(t=new R(1/0,1/0,1/0),e=new R(-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,n=t.length;e<n;e+=3)this.expandByPoint(wi.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(wi.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=wi.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,wi):wi.fromBufferAttribute(s,o),wi.applyMatrix4(t.matrixWorld),this.expandByPoint(wi);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Bc.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Bc.copy(n.boundingBox)),Bc.applyMatrix4(t.matrixWorld),this.union(Bc)}const i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.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.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,wi),wi.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ba),zc.subVectors(this.max,Ba),yo.subVectors(t.a,Ba),_o.subVectors(t.b,Ba),vo.subVectors(t.c,Ba),Vs.subVectors(_o,yo),ks.subVectors(vo,_o),yr.subVectors(yo,vo);let e=[0,-Vs.z,Vs.y,0,-ks.z,ks.y,0,-yr.z,yr.y,Vs.z,0,-Vs.x,ks.z,0,-ks.x,yr.z,0,-yr.x,-Vs.y,Vs.x,0,-ks.y,ks.x,0,-yr.y,yr.x,0];return!cf(e,yo,_o,vo,zc)||(e=[1,0,0,0,1,0,0,0,1],!cf(e,yo,_o,vo,zc))?!1:(Vc.crossVectors(Vs,ks),e=[Vc.x,Vc.y,Vc.z],cf(e,yo,_o,vo,zc))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,wi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(wi).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:(gs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),gs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),gs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),gs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),gs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),gs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),gs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),gs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(gs),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}};const gs=[new R,new R,new R,new R,new R,new R,new R,new R],wi=new R,Bc=new mn,yo=new R,_o=new R,vo=new R,Vs=new R,ks=new R,yr=new R,Ba=new R,zc=new R,Vc=new R,_r=new R;function cf(r,t,e,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){_r.fromArray(r,s);const a=i.x*Math.abs(_r.x)+i.y*Math.abs(_r.y)+i.z*Math.abs(_r.z),l=t.dot(_r),c=e.dot(_r),h=n.dot(_r);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const As=xb();function xb(){const r=new ArrayBuffer(4),t=new Float32Array(r),e=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function Gn(r){Math.abs(r)>65504&&pt("DataUtils.toHalfFloat(): Value out of range."),r=Jt(r,-65504,65504),As.floatView[0]=r;const t=As.uint32View[0],e=t>>23&511;return As.baseTable[e]+((t&8388607)>>As.shiftTable[e])}function rl(r){const t=r>>10;return As.uint32View[0]=As.mantissaTable[As.offsetTable[t]+(r&1023)]+As.exponentTable[t],As.floatView[0]}class O_{static toHalfFloat(t){return Gn(t)}static fromHalfFloat(t){return rl(t)}}const Ze=new R,kc=new tt;let yb=0,Te=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:yb++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=jl,this.updateRanges=[],this.gpuType=Tn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)kc.fromBufferAttribute(this,e),kc.applyMatrix3(t),this.setXY(e,kc.x,kc.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.applyMatrix3(t),this.setXYZ(e,Ze.x,Ze.y,Ze.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.applyMatrix4(t),this.setXYZ(e,Ze.x,Ze.y,Ze.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.applyNormalMatrix(t),this.setXYZ(e,Ze.x,Ze.y,Ze.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.transformDirection(t),this.setXYZ(e,Ze.x,Ze.y,Ze.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=On(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=le(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=On(e,this.array)),e}setX(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=On(e,this.array)),e}setY(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=On(e,this.array)),e}setZ(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=On(e,this.array)),e}setW(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array),s=le(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==jl&&(t.usage=this.usage),t}};class _b extends Te{constructor(t,e,n){super(new Int8Array(t),e,n)}}class vb extends Te{constructor(t,e,n){super(new Uint8Array(t),e,n)}}class Mb extends Te{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}}class Sb extends Te{constructor(t,e,n){super(new Int16Array(t),e,n)}}let ld=class extends Te{constructor(t,e,n){super(new Uint16Array(t),e,n)}};class bb extends Te{constructor(t,e,n){super(new Int32Array(t),e,n)}}let um=class extends Te{constructor(t,e,n){super(new Uint32Array(t),e,n)}};class Tb extends Te{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=rl(this.array[t*this.itemSize]);return this.normalized&&(e=On(e,this.array)),e}setX(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize]=Gn(e),this}getY(t){let e=rl(this.array[t*this.itemSize+1]);return this.normalized&&(e=On(e,this.array)),e}setY(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+1]=Gn(e),this}getZ(t){let e=rl(this.array[t*this.itemSize+2]);return this.normalized&&(e=On(e,this.array)),e}setZ(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+2]=Gn(e),this}getW(t){let e=rl(this.array[t*this.itemSize+3]);return this.normalized&&(e=On(e,this.array)),e}setW(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+3]=Gn(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array)),this.array[t+0]=Gn(e),this.array[t+1]=Gn(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array)),this.array[t+0]=Gn(e),this.array[t+1]=Gn(n),this.array[t+2]=Gn(i),this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array),s=le(s,this.array)),this.array[t+0]=Gn(e),this.array[t+1]=Gn(n),this.array[t+2]=Gn(i),this.array[t+3]=Gn(s),this}}let Ct=class extends Te{constructor(t,e,n){super(new Float32Array(t),e,n)}};const wb=new mn,za=new R,hf=new R;let un=class{constructor(t=new R,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 n=this.center;e!==void 0?n.copy(e):wb.setFromPoints(t).getCenter(n);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.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;za.subVectors(t,this.center);const e=za.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(za,i/n),this.radius+=i}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):(hf.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(za.copy(t.center).add(hf)),this.expandByPoint(za.copy(t.center).sub(hf))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},Ab=0;const oi=new Qt,uf=new ve,Mo=new R,Jn=new mn,Va=new mn,an=new R;let se=class B_ extends Bi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ab++}),this.uuid=ei(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(OS(t)?um:ld)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new ae().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return oi.makeRotationFromQuaternion(t),this.applyMatrix4(oi),this}rotateX(t){return oi.makeRotationX(t),this.applyMatrix4(oi),this}rotateY(t){return oi.makeRotationY(t),this.applyMatrix4(oi),this}rotateZ(t){return oi.makeRotationZ(t),this.applyMatrix4(oi),this}translate(t,e,n){return oi.makeTranslation(t,e,n),this.applyMatrix4(oi),this}scale(t,e,n){return oi.makeScale(t,e,n),this.applyMatrix4(oi),this}lookAt(t){return uf.lookAt(t),uf.updateMatrix(),this.applyMatrix4(uf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Mo).negate(),this.translate(Mo.x,Mo.y,Mo.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let i=0,s=t.length;i<s;i++){const o=t[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ct(n,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&pt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Vt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const s=e[n];Jn.setFromBufferAttribute(s),this.morphTargetsRelative?(an.addVectors(this.boundingBox.min,Jn.min),this.boundingBox.expandByPoint(an),an.addVectors(this.boundingBox.max,Jn.max),this.boundingBox.expandByPoint(an)):(this.boundingBox.expandByPoint(Jn.min),this.boundingBox.expandByPoint(Jn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new un);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Vt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(t){const n=this.boundingSphere.center;if(Jn.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];Va.setFromBufferAttribute(a),this.morphTargetsRelative?(an.addVectors(Jn.min,Va.min),Jn.expandByPoint(an),an.addVectors(Jn.max,Va.max),Jn.expandByPoint(an)):(Jn.expandByPoint(Va.min),Jn.expandByPoint(Va.max))}Jn.getCenter(n);let i=0;for(let s=0,o=t.count;s<o;s++)an.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(an));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)an.fromBufferAttribute(a,c),l&&(Mo.fromBufferAttribute(t,c),an.add(Mo)),i=Math.max(i,n.distanceToSquared(an))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Vt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Vt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Te(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let M=0;M<n.count;M++)a[M]=new R,l[M]=new R;const c=new R,h=new R,u=new R,d=new tt,f=new tt,p=new tt,x=new R,g=new R;function m(M,b,P){c.fromBufferAttribute(n,M),h.fromBufferAttribute(n,b),u.fromBufferAttribute(n,P),d.fromBufferAttribute(s,M),f.fromBufferAttribute(s,b),p.fromBufferAttribute(s,P),h.sub(c),u.sub(c),f.sub(d),p.sub(d);const N=1/(f.x*p.y-p.x*f.y);isFinite(N)&&(x.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(N),g.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(N),a[M].add(x),a[b].add(x),a[P].add(x),l[M].add(g),l[b].add(g),l[P].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let M=0,b=y.length;M<b;++M){const P=y[M],N=P.start,L=P.count;for(let U=N,V=N+L;U<V;U+=3)m(t.getX(U+0),t.getX(U+1),t.getX(U+2))}const v=new R,_=new R,w=new R,T=new R;function E(M){w.fromBufferAttribute(i,M),T.copy(w);const b=a[M];v.copy(b),v.sub(w.multiplyScalar(w.dot(b))).normalize(),_.crossVectors(T,b);const N=_.dot(l[M])<0?-1:1;o.setXYZW(M,v.x,v.y,v.z,N)}for(let M=0,b=y.length;M<b;++M){const P=y[M],N=P.start,L=P.count;for(let U=N,V=N+L;U<V;U+=3)E(t.getX(U+0)),E(t.getX(U+1)),E(t.getX(U+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Te(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new R,s=new R,o=new R,a=new R,l=new R,c=new R,h=new R,u=new R;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),x=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,x),o.fromBufferAttribute(e,g),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),a.fromBufferAttribute(n,p),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,g),a.add(h),l.add(h),c.add(h),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)an.fromBufferAttribute(t,e),an.normalize(),t.setXYZ(e,an.x,an.y,an.z)}toNonIndexed(){function t(a,l){const c=a.array,h=a.itemSize,u=a.normalized,d=new c.constructor(l.length*h);let f=0,p=0;for(let x=0,g=l.length;x<g;x++){a.isInterleavedBufferAttribute?f=l[x]*a.data.stride+a.offset:f=l[x]*h;for(let m=0;m<h;m++)d[p++]=c[f++]}return new Te(d,h,u)}if(this.index===null)return pt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new B_,n=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=t(l,n);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);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 n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),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 n=t.index;n!==null&&this.setIndex(n.clone());const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},xc=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=jl,this.updateRanges=[],this.version=0,this.uuid=ei()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ei()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ei()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const In=new R;let ua=class z_{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)In.fromBufferAttribute(this,e),In.applyMatrix4(t),this.setXYZ(e,In.x,In.y,In.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)In.fromBufferAttribute(this,e),In.applyNormalMatrix(t),this.setXYZ(e,In.x,In.y,In.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)In.fromBufferAttribute(this,e),In.transformDirection(t),this.setXYZ(e,In.x,In.y,In.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=On(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=le(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=le(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=le(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=le(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=le(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=On(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=On(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=On(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=On(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=le(e,this.array),n=le(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array),s=le(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){Ql("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Te(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new z_(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Ql("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Eb=0,gn=class extends Bi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Eb++}),this.uuid=ei(),this.name="",this.type="Material",this.blending=nr,this.side=is,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=du,this.blendDst=fu,this.blendEquation=Qs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new wt(0,0,0),this.blendAlpha=0,this.depthFunc=rr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Cu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ks,this.stencilZFail=Ks,this.stencilZPass=Ks,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){pt(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){pt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==nr&&(n.blending=this.blending),this.side!==is&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==du&&(n.blendSrc=this.blendSrc),this.blendDst!==fu&&(n.blendDst=this.blendDst),this.blendEquation!==Qs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==rr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Cu&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ks&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ks&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ks&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};class cd extends gn{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new wt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let So;const ka=new R,bo=new R,To=new R,wo=new tt,Ga=new tt,V_=new Qt,Gc=new R,Ha=new R,Hc=new R,s0=new tt,df=new tt,r0=new tt;class dm extends ve{constructor(t=new cd){if(super(),this.isSprite=!0,this.type="Sprite",So===void 0){So=new se;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new xc(e,5);So.setIndex([0,1,2,0,2,3]),So.setAttribute("position",new ua(n,3,0,!1)),So.setAttribute("uv",new ua(n,2,3,!1))}this.geometry=So,this.material=t,this.center=new tt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Vt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),bo.setFromMatrixScale(this.matrixWorld),V_.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),To.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&bo.multiplyScalar(-To.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const o=this.center;Wc(Gc.set(-.5,-.5,0),To,o,bo,i,s),Wc(Ha.set(.5,-.5,0),To,o,bo,i,s),Wc(Hc.set(.5,.5,0),To,o,bo,i,s),s0.set(0,0),df.set(1,0),r0.set(1,1);let a=t.ray.intersectTriangle(Gc,Ha,Hc,!1,ka);if(a===null&&(Wc(Ha.set(-.5,.5,0),To,o,bo,i,s),df.set(0,1),a=t.ray.intersectTriangle(Gc,Hc,Ha,!1,ka),a===null))return;const l=t.ray.origin.distanceTo(ka);l<t.near||l>t.far||e.push({distance:l,point:ka.clone(),uv:ws.getInterpolation(ka,Gc,Ha,Hc,s0,df,r0,new tt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function Wc(r,t,e,n,i,s){wo.subVectors(r,e).addScalar(.5).multiply(n),i!==void 0?(Ga.x=s*wo.x-i*wo.y,Ga.y=i*wo.x+s*wo.y):Ga.copy(wo),r.copy(t),r.x+=Ga.x,r.y+=Ga.y,r.applyMatrix4(V_)}const Xc=new R,o0=new R;class fm extends ve{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let n=0,i=e.length;n<i;n++){const s=e[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let s;for(s=0;s<i.length&&!(e<i[s].distance);s++);return i.splice(s,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){const i=e.splice(n,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let s=e[n].distance;if(e[n].object.visible&&(s-=s*e[n].hysteresis),t<s)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Xc.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(Xc);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Xc.setFromMatrixPosition(t.matrixWorld),o0.setFromMatrixPosition(this.matrixWorld);const n=Xc.distanceTo(o0)/t.zoom;e[0].object.visible=!0;let i,s;for(i=1,s=e.length;i<s;i++){let o=e[i].distance;if(e[i].object.visible&&(o-=o*e[i].hysteresis),n>=o)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);this.autoUpdate===!1&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const o=n[i];e.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return e}}const xs=new R,ff=new R,$c=new R,Gs=new R,pf=new R,qc=new R,mf=new R;let eo=class{constructor(t=new R,e=new R(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,xs)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=xs.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(xs.copy(this.origin).addScaledVector(this.direction,e),xs.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ff.copy(t).add(e).multiplyScalar(.5),$c.copy(e).sub(t).normalize(),Gs.copy(this.origin).sub(ff);const s=t.distanceTo(e)*.5,o=-this.direction.dot($c),a=Gs.dot(this.direction),l=-Gs.dot($c),c=Gs.lengthSq(),h=Math.abs(1-o*o);let u,d,f,p;if(h>0)if(u=o*l-a,d=o*a-l,p=s*h,u>=0)if(d>=-p)if(d<=p){const x=1/h;u*=x,d*=x,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-p?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=p?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(ff).addScaledVector($c,d),f}intersectSphere(t,e){xs.subVectors(t.center,this.origin);const n=xs.dot(this.direction),i=xs.dot(xs)-n*n,s=t.radius*t.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(s=(t.min.y-d.y)*h,o=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,o=(t.min.y-d.y)*h),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),u>=0?(a=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,xs)!==null}intersectTriangle(t,e,n,i,s){pf.subVectors(e,t),qc.subVectors(n,t),mf.crossVectors(pf,qc);let o=this.direction.dot(mf),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Gs.subVectors(this.origin,t);const l=a*this.direction.dot(qc.crossVectors(Gs,qc));if(l<0)return null;const c=a*this.direction.dot(pf.cross(Gs));if(c<0||l+c>o)return null;const h=-a*Gs.dot(mf);return h<0?null:this.at(h/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ds=class extends gn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new wt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=uc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}};const a0=new Qt,vr=new eo,Yc=new un,l0=new R,Zc=new R,Jc=new R,jc=new R,gf=new R,Kc=new R,c0=new R,Qc=new R;let Ye=class extends ve{constructor(t=new se,e=new Ds){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){Kc.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],u=s[l];h!==0&&(gf.fromBufferAttribute(u,t),o?Kc.addScaledVector(gf,h):Kc.addScaledVector(gf.sub(e),h))}e.add(Kc)}return e}raycast(t,e){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Yc.copy(n.boundingSphere),Yc.applyMatrix4(s),vr.copy(t.ray).recast(t.near),!(Yc.containsPoint(vr.origin)===!1&&(vr.intersectSphere(Yc,l0)===null||vr.origin.distanceToSquared(l0)>(t.far-t.near)**2))&&(a0.copy(s).invert(),vr.copy(t.ray).applyMatrix4(a0),!(n.boundingBox!==null&&vr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,vr)))}_computeIntersections(t,e,n){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,x=d.length;p<x;p++){const g=d[p],m=o[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,w=v;_<w;_+=3){const T=a.getX(_),E=a.getX(_+1),M=a.getX(_+2);i=th(this,m,t,n,c,h,u,T,E,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let g=p,m=x;g<m;g+=3){const y=a.getX(g),v=a.getX(g+1),_=a.getX(g+2);i=th(this,o,t,n,c,h,u,y,v,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let p=0,x=d.length;p<x;p++){const g=d[p],m=o[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,w=v;_<w;_+=3){const T=_,E=_+1,M=_+2;i=th(this,m,t,n,c,h,u,T,E,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),x=Math.min(l.count,f.start+f.count);for(let g=p,m=x;g<m;g+=3){const y=g,v=g+1,_=g+2;i=th(this,o,t,n,c,h,u,y,v,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}}};function Cb(r,t,e,n,i,s,o,a){let l;if(t.side===An?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,t.side===is,a),l===null)return null;Qc.copy(a),Qc.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(Qc);return c<e.near||c>e.far?null:{distance:c,point:Qc.clone(),object:r}}function th(r,t,e,n,i,s,o,a,l,c){r.getVertexPosition(a,Zc),r.getVertexPosition(l,Jc),r.getVertexPosition(c,jc);const h=Cb(r,t,e,n,Zc,Jc,jc,c0);if(h){const u=new R;ws.getBarycoord(c0,Zc,Jc,jc,u),i&&(h.uv=ws.getInterpolatedAttribute(i,a,l,c,u,new tt)),s&&(h.uv1=ws.getInterpolatedAttribute(s,a,l,c,u,new tt)),o&&(h.normal=ws.getInterpolatedAttribute(o,a,l,c,u,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new R,materialIndex:0};ws.getNormal(Zc,Jc,jc,d.normal),h.face=d,h.barycoord=u}return h}const h0=new R,u0=new Le,d0=new Le,Nb=new R,f0=new Qt,eh=new R,xf=new un,p0=new Qt,yf=new eo;class pm extends Ye{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=bp,this.bindMatrix=new Qt,this.bindMatrixInverse=new Qt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new mn),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,eh),this.boundingBox.expandByPoint(eh)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new un),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,eh),this.boundingSphere.expandByPoint(eh)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xf.copy(this.boundingSphere),xf.applyMatrix4(i),t.ray.intersectsSphere(xf)!==!1&&(p0.copy(i).invert(),yf.copy(t.ray).applyMatrix4(p0),!(this.boundingBox!==null&&yf.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,yf)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Le,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===bp?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Jy?this.bindMatrixInverse.copy(this.bindMatrix).invert():pt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;u0.fromBufferAttribute(i.attributes.skinIndex,t),d0.fromBufferAttribute(i.attributes.skinWeight,t),h0.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const o=d0.getComponent(s);if(o!==0){const a=u0.getComponent(s);f0.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),e.addScaledVector(Nb.copy(h0).applyMatrix4(f0),o)}}return e.applyMatrix4(this.bindMatrixInverse)}}class hd extends ve{constructor(){super(),this.isBone=!0,this.type="Bone"}}class fi extends rn{constructor(t=null,e=1,n=1,i,s,o,a,l,c=Xe,h=Xe,u,d){super(null,o,a,l,c,h,i,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const m0=new Qt,Rb=new Qt;class yc{constructor(t=[],e=[]){this.uuid=ei(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){pt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Qt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const n=new Qt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,o=t.length;s<o;s++){const a=t[s]?t[s].matrixWorld:Rb;m0.multiplyMatrices(a,e[s]),m0.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new yc(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new fi(e,t,t,wn,Tn);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const s=t.bones[n];let o=e[s];o===void 0&&(pt("Skeleton: No bone found with UUID:",s),o=new hd),this.bones.push(o),this.boneInverses.push(new Qt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,s=e.length;i<s;i++){const o=e[i];t.bones.push(o.uuid);const a=n[i];t.boneInverses.push(a.toArray())}return t}}let Jr=class extends Te{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};const Ao=new Qt,g0=new Qt,nh=[],x0=new mn,Ib=new Qt,Wa=new Ye,Xa=new un;class mm extends Ye{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Jr(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Ib)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new mn),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Ao),x0.copy(t.boundingBox).applyMatrix4(Ao),this.boundingBox.union(x0)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new un),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Ao),Xa.copy(t.boundingSphere).applyMatrix4(Ao),this.boundingSphere.union(Xa)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=t.previousInstanceMatrix.clone()),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,s=n.length+1,o=t*s+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Wa.geometry=this.geometry,Wa.material=this.material,Wa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Xa.copy(this.boundingSphere),Xa.applyMatrix4(n),t.ray.intersectsSphere(Xa)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Ao),g0.multiplyMatrices(n,Ao),Wa.matrixWorld=g0,Wa.raycast(t,nh);for(let o=0,a=nh.length;o<a;o++){const l=nh[o];l.instanceId=s,l.object=this,e.push(l)}nh.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new Jr(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new fi(new Float32Array(i*this.count),i,this.count,dc,Tn));const s=this.morphTexture.source.data.data;let o=0;for(let c=0;c<n.length;c++)o+=n[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=i*t;s[l]=a,s.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const _f=new R,Pb=new R,Lb=new ae;let Ts=class{constructor(t=new R(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=_f.subVectors(n,e).cross(Pb.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(_f),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Lb.getNormalMatrix(t),i=this.coplanarPoint(_f).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Mr=new un,Fb=new tt(.5,.5),ih=new R;let no=class{constructor(t=new Ts,e=new Ts,n=new Ts,i=new Ts,s=new Ts,o=new Ts){this.planes=[t,e,n,i,s,o]}set(t,e,n,i,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=ti,n=!1){const i=this.planes,s=t.elements,o=s[0],a=s[1],l=s[2],c=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],x=s[9],g=s[10],m=s[11],y=s[12],v=s[13],_=s[14],w=s[15];if(i[0].setComponents(c-o,f-h,m-p,w-y).normalize(),i[1].setComponents(c+o,f+h,m+p,w+y).normalize(),i[2].setComponents(c+a,f+u,m+x,w+v).normalize(),i[3].setComponents(c-a,f-u,m-x,w-v).normalize(),n)i[4].setComponents(l,d,g,_).normalize(),i[5].setComponents(c-l,f-d,m-g,w-_).normalize();else if(i[4].setComponents(c-l,f-d,m-g,w-_).normalize(),e===ti)i[5].setComponents(c+l,f+d,m+g,w+_).normalize();else if(e===Zr)i[5].setComponents(l,d,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Mr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Mr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Mr)}intersectsSprite(t){Mr.center.set(0,0,0);const e=Fb.distanceTo(t.center);return Mr.radius=.7071067811865476+e,Mr.applyMatrix4(t.matrixWorld),this.intersectsSphere(Mr)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(ih.x=i.normal.x>0?t.max.x:t.min.x,ih.y=i.normal.y>0?t.max.y:t.min.y,ih.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ih)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};const Gi=new Qt,Hi=new no;class ud{constructor(){this.coordinateSystem=ti}intersectsObject(t,e){if(!e.isArrayCamera||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.containsPoint(t))return!0}return!1}clone(){return new ud}}function vf(r,t){return r-t}function Db(r,t){return r.z-t.z}function Ub(r,t){return t.z-r.z}class Ob{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){const s=this.pool,o=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const a=s[this.index];o.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const kn=new Qt,Bb=new wt(1,1,1),y0=new no,zb=new ud,sh=new mn,Sr=new un,$a=new R,_0=new R,Vb=new R,Mf=new Ob,Mn=new Ye,rh=[];function kb(r,t,e=0){const n=t.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==t.array.constructor){const i=r.count;for(let s=0;s<i;s++)for(let o=0;o<n;o++)t.setComponent(s+e,o,r.getComponent(s,o))}else t.array.set(r.array,e*n);t.needsUpdate=!0}function br(r,t){if(r.constructor!==t.constructor){const e=Math.min(r.length,t.length);for(let n=0;n<e;n++)t[n]=r[n]}else{const e=Math.min(r.length,t.length);t.set(new r.constructor(r.buffer,0,e))}}class gm extends Ye{constructor(t,e,n=e*2,i){super(new se,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(this._maxInstanceCount*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new fi(e,t,t,wn,Tn);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),n=new fi(e,t,t,Ma,ii);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),n=new fi(e,t,t,wn,Tn);n.colorSpace=fe.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in t.attributes){const o=t.getAttribute(s),{array:a,itemSize:l,normalized:c}=o,h=new a.constructor(n*l),u=new Te(h,l,c);e.setAttribute(s,u)}if(t.getIndex()!==null){const s=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new Te(s,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),s=e.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mn);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;const s=e[n].geometryIndex;this.getMatrixAt(n,kn),this.getBoundingBoxAt(s,sh).applyMatrix4(kn),t.union(sh)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new un);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;const s=e[n].geometryIndex;this.getMatrixAt(n,kn),this.getBoundingSphereAt(s,Sr).applyMatrix4(kn),t.union(Sr)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:t};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(vf),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;kn.identity().toArray(s.image.data,i*16),s.needsUpdate=!0;const o=this._colorsTexture;return o&&(Bb.toArray(o.image.data,i*4),o.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=e===-1?t.getAttribute("position").count:e;const o=t.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?o.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(vf),l=this._availableGeometryIds.shift(),s[l]=i):(l=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(l,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=n.getIndex()!==null,s=n.getIndex(),o=e.getIndex(),a=this._geometryInfo[t];if(i&&o.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const h in n.attributes){const u=e.getAttribute(h),d=n.getAttribute(h);kb(u,d,l);const f=u.itemSize;for(let p=u.count,x=c;p<x;p++){const g=l+p;for(let m=0;m<f;m++)d.setComponent(g,m,0)}d.needsUpdate=!0,d.addUpdateRange(l*f,c*f)}if(i){const h=a.indexStart,u=a.reservedIndexCount;a.indexCount=e.getIndex().count;for(let d=0;d<o.count;d++)s.setX(h+d,l+o.getX(d));for(let d=o.count,f=u;d<f;d++)s.setX(h+d,l);s.needsUpdate=!0,s.addUpdateRange(h,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,e.boundingBox!==null&&(a.boundingBox=e.boundingBox.clone()),a.boundingSphere=null,e.boundingSphere!==null&&(a.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||e[t].active===!1)return this;const n=this._instanceInfo;for(let i=0,s=n.length;i<s;i++)n[i].active&&n[i].geometryIndex===t&&this.deleteInstance(i);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),s=this.geometry;for(let o=0,a=n.length;o<a;o++){const l=i[o],c=n[l];if(c.active!==!1){if(s.index!==null){if(c.indexStart!==e){const{indexStart:h,vertexStart:u,reservedIndexCount:d}=c,f=s.index,p=f.array,x=t-u;for(let g=h;g<h+d;g++)p[g]=p[g]+x;f.array.copyWithin(e,h,h+d),f.addUpdateRange(e,d),f.needsUpdate=!0,c.indexStart=e}e+=c.reservedIndexCount}if(c.vertexStart!==t){const{vertexStart:h,reservedVertexCount:u}=c,d=s.attributes;for(const f in d){const p=d[f],{array:x,itemSize:g}=p;x.copyWithin(t*g,h*g,(h+u)*g),p.addUpdateRange(t*g,u*g),p.needsUpdate=!0}c.vertexStart=t}t+=c.reservedVertexCount,c.start=s.index?c.indexStart:c.vertexStart}}return this._nextIndexStart=e,this._nextVertexStart=t,this._visibilityChanged=!0,this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(i.boundingBox===null){const s=new mn,o=n.index,a=n.attributes.position;for(let l=i.start,c=i.start+i.count;l<c;l++){let h=l;o&&(h=o.getX(h)),s.expandByPoint($a.fromBufferAttribute(a,h))}i.boundingBox=s}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(i.boundingSphere===null){const s=new un;this.getBoundingBoxAt(t,sh),sh.getCenter(s.center);const o=n.index,a=n.attributes.position;let l=0;for(let c=i.start,h=i.start+i.count;c<h;c++){let u=c;o&&(u=o.getX(u)),$a.fromBufferAttribute(a,u),l=Math.max(l,s.center.distanceToSquared($a))}s.radius=Math.sqrt(l),i.boundingSphere=s}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const n=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,t*16),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,t*16)}setColorAt(t,e){return this.validateInstanceId(t),this._colorsTexture===null&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,t*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,t*4)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e?this:(this._instanceInfo[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(vf);e[e.length-1]===n.length-1;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const i=new Int32Array(t),s=new Int32Array(t);br(this._multiDrawCounts,i),br(this._multiDrawStarts,s),this._multiDrawCounts=i,this._multiDrawStarts=s,this._maxInstanceCount=t;const o=this._indirectTexture,a=this._matricesTexture,l=this._colorsTexture;o.dispose(),this._initIndirectTexture(),br(o.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),br(a.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),br(l.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const n=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new se,this._initializeGeometry(s));const o=this.geometry;s.index&&br(s.index.array,o.index.array);for(const a in s.attributes)br(s.attributes[a].array,o.attributes[a].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,s=this.matrixWorld,o=this.geometry;Mn.material=this.material,Mn.geometry.index=o.index,Mn.geometry.attributes=o.attributes,Mn.geometry.boundingBox===null&&(Mn.geometry.boundingBox=new mn),Mn.geometry.boundingSphere===null&&(Mn.geometry.boundingSphere=new un);for(let a=0,l=n.length;a<l;a++){if(!n[a].visible||!n[a].active)continue;const c=n[a].geometryIndex,h=i[c];Mn.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(a,Mn.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,Mn.geometry.boundingBox),this.getBoundingSphereAt(c,Mn.geometry.boundingSphere),Mn.raycast(t,rh);for(let u=0,d=rh.length;u<d;u++){const f=rh[u];f.object=this,f.batchId=a,e.push(f)}rh.length=0}Mn.material=null,Mn.geometry.index=null,Mn.geometry.attributes={},Mn.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex();let a=o===null?1:o.array.BYTES_PER_ELEMENT,l=1;s.wireframe&&(l=2,a=i.attributes.position.count>65535?4:2);const c=this._instanceInfo,h=this._multiDrawStarts,u=this._multiDrawCounts,d=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,x=p.image.data,g=n.isArrayCamera?zb:y0;f&&!n.isArrayCamera&&(kn.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),y0.setFromProjectionMatrix(kn,n.coordinateSystem,n.reversedDepth));let m=0;if(this.sortObjects){kn.copy(this.matrixWorld).invert(),$a.setFromMatrixPosition(n.matrixWorld).applyMatrix4(kn),_0.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(kn);for(let _=0,w=c.length;_<w;_++)if(c[_].visible&&c[_].active){const T=c[_].geometryIndex;this.getMatrixAt(_,kn),this.getBoundingSphereAt(T,Sr).applyMatrix4(kn);let E=!1;if(f&&(E=!g.intersectsSphere(Sr,n)),!E){const M=d[T],b=Vb.subVectors(Sr.center,$a).dot(_0);Mf.push(M.start,M.count,b,_)}}const y=Mf.list,v=this.customSort;v===null?y.sort(s.transparent?Ub:Db):v.call(this,y,n);for(let _=0,w=y.length;_<w;_++){const T=y[_];h[m]=T.start*a*l,u[m]=T.count*l,x[m]=T.index,m++}Mf.reset()}else for(let y=0,v=c.length;y<v;y++)if(c[y].visible&&c[y].active){const _=c[y].geometryIndex;let w=!1;if(f&&(this.getMatrixAt(y,kn),this.getBoundingSphereAt(_,Sr).applyMatrix4(kn),w=!g.intersectsSphere(Sr,n)),!w){const T=d[_];h[m]=T.start*a*l,u[m]=T.count*l,x[m]=y,m++}}p.needsUpdate=!0,this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,s,o){this.onBeforeRender(t,null,i,s,o)}}class Rn extends gn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new wt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Ru=new R,Iu=new R,v0=new Qt,qa=new eo,oh=new un,Sf=new R,M0=new R;class Fs extends ve{constructor(t=new se,e=new Rn){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[0];for(let i=1,s=e.count;i<s;i++)Ru.fromBufferAttribute(e,i-1),Iu.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=Ru.distanceTo(Iu);t.setAttribute("lineDistance",new Ct(n,1))}else pt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),oh.copy(n.boundingSphere),oh.applyMatrix4(i),oh.radius+=s,t.ray.intersectsSphere(oh)===!1)return;v0.copy(i).invert(),qa.copy(t.ray).applyMatrix4(v0);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let x=f,g=p-1;x<g;x+=c){const m=h.getX(x),y=h.getX(x+1),v=ah(this,t,qa,l,m,y,x);v&&e.push(v)}if(this.isLineLoop){const x=h.getX(p-1),g=h.getX(f),m=ah(this,t,qa,l,x,g,p-1);m&&e.push(m)}}else{const f=Math.max(0,o.start),p=Math.min(d.count,o.start+o.count);for(let x=f,g=p-1;x<g;x+=c){const m=ah(this,t,qa,l,x,x+1,x);m&&e.push(m)}if(this.isLineLoop){const x=ah(this,t,qa,l,p-1,f,p-1);x&&e.push(x)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function ah(r,t,e,n,i,s,o){const a=r.geometry.attributes.position;if(Ru.fromBufferAttribute(a,i),Iu.fromBufferAttribute(a,s),e.distanceSqToSegment(Ru,Iu,Sf,M0)>n)return;Sf.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(Sf);if(!(c<t.near||c>t.far))return{distance:c,point:M0.clone().applyMatrix4(r.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:r}}const S0=new R,b0=new R;class zi extends Fs{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,s=e.count;i<s;i+=2)S0.fromBufferAttribute(e,i),b0.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+S0.distanceTo(b0);t.setAttribute("lineDistance",new Ct(n,1))}else pt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class xm extends Fs{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class dd extends gn{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new wt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const T0=new Qt,Ap=new eo,lh=new un,ch=new R;class ym extends ve{constructor(t=new se,e=new dd){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,s=t.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),lh.copy(n.boundingSphere),lh.applyMatrix4(i),lh.radius+=s,t.ray.intersectsSphere(lh)===!1)return;T0.copy(i).invert(),Ap.copy(t.ray).applyMatrix4(T0);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,o.start),f=Math.min(c.count,o.start+o.count);for(let p=d,x=f;p<x;p++){const g=c.getX(p);ch.fromBufferAttribute(u,g),w0(ch,g,l,i,t,e,this)}}else{const d=Math.max(0,o.start),f=Math.min(u.count,o.start+o.count);for(let p=d,x=f;p<x;p++)ch.fromBufferAttribute(u,p),w0(ch,p,l,i,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function w0(r,t,e,n,i,s,o){const a=Ap.distanceSqToPoint(r);if(a<e){const l=new R;Ap.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class _m extends rn{constructor(t,e,n,i,s=Fe,o=Fe,a,l,c){super(t,e,n,i,s,o,a,l,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const h=this;function u(){h.needsUpdate=!0,h._requestVideoFrameCallbackId=t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(u))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class Gb extends _m{constructor(t,e,n,i,s,o,a,l){super({},t,e,n,i,s,o,a,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}}let Hb=class extends rn{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Xe,this.minFilter=Xe,this.generateMipmaps=!1,this.needsUpdate=!0}};class _c extends rn{constructor(t,e,n,i,s,o,a,l,c,h,u,d){super(null,o,a,l,c,h,i,s,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class k_ extends _c{constructor(t,e,n,i,s,o){super(t,e,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Bn,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class G_ extends _c{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,ss),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}let Sa=class extends rn{constructor(t=[],e=ss,n,i,s,o,a,l,c,h){super(t,e,n,i,s,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}};class H_ extends rn{constructor(t,e,n,i,s,o,a,l,c){super(t,e,n,i,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}let jr=class extends rn{constructor(t,e,n=ii,i,s,o,a=Xe,l=Xe,c,h=Oi,u=1){if(h!==Oi&&h!==Cs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,i,s,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ns(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},W_=class extends jr{constructor(t,e=ii,n=ss,i,s,o=Xe,a=Xe,l,c=Oi){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,i,s,o,a,l,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}};class vm extends rn{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class dr extends se{constructor(t=1,e=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,n,e,t,o,s,0),p("z","y","x",1,-1,n,e,-t,o,s,1),p("x","z","y",1,1,t,n,e,i,o,2),p("x","z","y",1,-1,t,n,-e,i,o,3),p("x","y","z",1,-1,t,e,n,i,s,4),p("x","y","z",-1,-1,t,e,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Ct(c,3)),this.setAttribute("normal",new Ct(h,3)),this.setAttribute("uv",new Ct(u,2));function p(x,g,m,y,v,_,w,T,E,M,b){const P=_/E,N=w/M,L=_/2,U=w/2,V=T/2,O=E+1,k=M+1;let G=0,it=0;const nt=new R;for(let mt=0;mt<k;mt++){const xt=mt*N-U;for(let bt=0;bt<O;bt++){const jt=bt*P-L;nt[x]=jt*y,nt[g]=xt*v,nt[m]=V,c.push(nt.x,nt.y,nt.z),nt[x]=0,nt[g]=0,nt[m]=T>0?1:-1,h.push(nt.x,nt.y,nt.z),u.push(bt/E),u.push(1-mt/M),G+=1}}for(let mt=0;mt<M;mt++)for(let xt=0;xt<E;xt++){const bt=d+xt+O*mt,jt=d+xt+O*(mt+1),Me=d+(xt+1)+O*(mt+1),we=d+(xt+1)+O*mt;l.push(bt,jt,we),l.push(jt,Me,we),it+=6}a.addGroup(f,it,b),f+=it,d+=G}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new dr(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class fd extends se{constructor(t=1,e=1,n=4,i=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:n,radialSegments:i,heightSegments:s},e=Math.max(0,e),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),s=Math.max(1,Math.floor(s));const o=[],a=[],l=[],c=[],h=e/2,u=Math.PI/2*t,d=e,f=2*u+d,p=n*2+s,x=i+1,g=new R,m=new R;for(let y=0;y<=p;y++){let v=0,_=0,w=0,T=0;if(y<=n){const b=y/n,P=b*Math.PI/2;_=-h-t*Math.cos(P),w=t*Math.sin(P),T=-t*Math.cos(P),v=b*u}else if(y<=n+s){const b=(y-n)/s;_=-h+b*e,w=t,T=0,v=u+b*d}else{const b=(y-n-s)/n,P=b*Math.PI/2;_=h+t*Math.sin(P),w=t*Math.cos(P),T=t*Math.sin(P),v=u+d+b*u}const E=Math.max(0,Math.min(1,v/f));let M=0;y===0?M=.5/i:y===p&&(M=-.5/i);for(let b=0;b<=i;b++){const P=b/i,N=P*Math.PI*2,L=Math.sin(N),U=Math.cos(N);m.x=-w*U,m.y=_,m.z=w*L,a.push(m.x,m.y,m.z),g.set(-w*U,T,w*L),g.normalize(),l.push(g.x,g.y,g.z),c.push(P+M,E)}if(y>0){const b=(y-1)*x;for(let P=0;P<i;P++){const N=b+P,L=b+P+1,U=y*x+P,V=y*x+P+1;o.push(N,L,U),o.push(L,V,U)}}}this.setIndex(o),this.setAttribute("position",new Ct(a,3)),this.setAttribute("normal",new Ct(l,3)),this.setAttribute("uv",new Ct(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new fd(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}}class pd extends se{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const s=[],o=[],a=[],l=[],c=new R,h=new tt;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*i;c.x=t*Math.cos(f),c.y=t*Math.sin(f),o.push(c.x,c.y,c.z),a.push(0,0,1),h.x=(o[d]/t+1)/2,h.y=(o[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new Ct(o,3)),this.setAttribute("normal",new Ct(a,3)),this.setAttribute("uv",new Ct(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pd(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class ba extends se{constructor(t=1,e=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const h=[],u=[],d=[],f=[];let p=0;const x=[],g=n/2;let m=0;y(),o===!1&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new Ct(u,3)),this.setAttribute("normal",new Ct(d,3)),this.setAttribute("uv",new Ct(f,2));function y(){const _=new R,w=new R;let T=0;const E=(e-t)/n;for(let M=0;M<=s;M++){const b=[],P=M/s,N=P*(e-t)+t;for(let L=0;L<=i;L++){const U=L/i,V=U*l+a,O=Math.sin(V),k=Math.cos(V);w.x=N*O,w.y=-P*n+g,w.z=N*k,u.push(w.x,w.y,w.z),_.set(O,E,k).normalize(),d.push(_.x,_.y,_.z),f.push(U,1-P),b.push(p++)}x.push(b)}for(let M=0;M<i;M++)for(let b=0;b<s;b++){const P=x[b][M],N=x[b+1][M],L=x[b+1][M+1],U=x[b][M+1];(t>0||b!==0)&&(h.push(P,N,U),T+=3),(e>0||b!==s-1)&&(h.push(N,L,U),T+=3)}c.addGroup(m,T,0),m+=T}function v(_){const w=p,T=new tt,E=new R;let M=0;const b=_===!0?t:e,P=_===!0?1:-1;for(let L=1;L<=i;L++)u.push(0,g*P,0),d.push(0,P,0),f.push(.5,.5),p++;const N=p;for(let L=0;L<=i;L++){const V=L/i*l+a,O=Math.cos(V),k=Math.sin(V);E.x=b*k,E.y=g*P,E.z=b*O,u.push(E.x,E.y,E.z),d.push(0,P,0),T.x=O*.5+.5,T.y=k*.5*P+.5,f.push(T.x,T.y),p++}for(let L=0;L<i;L++){const U=w+L,V=N+L;_===!0?h.push(V,V+1,U):h.push(V+1,V,U),M+=3}c.addGroup(m,M,_===!0?1:2),m+=M}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ba(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class vc extends ba{constructor(t=1,e=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new vc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class fr extends se{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const s=[],o=[];a(i),c(n),h(),this.setAttribute("position",new Ct(s,3)),this.setAttribute("normal",new Ct(s.slice(),3)),this.setAttribute("uv",new Ct(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){const v=new R,_=new R,w=new R;for(let T=0;T<e.length;T+=3)f(e[T+0],v),f(e[T+1],_),f(e[T+2],w),l(v,_,w,y)}function l(y,v,_,w){const T=w+1,E=[];for(let M=0;M<=T;M++){E[M]=[];const b=y.clone().lerp(_,M/T),P=v.clone().lerp(_,M/T),N=T-M;for(let L=0;L<=N;L++)L===0&&M===T?E[M][L]=b:E[M][L]=b.clone().lerp(P,L/N)}for(let M=0;M<T;M++)for(let b=0;b<2*(T-M)-1;b++){const P=Math.floor(b/2);b%2===0?(d(E[M][P+1]),d(E[M+1][P]),d(E[M][P])):(d(E[M][P+1]),d(E[M+1][P+1]),d(E[M+1][P]))}}function c(y){const v=new R;for(let _=0;_<s.length;_+=3)v.x=s[_+0],v.y=s[_+1],v.z=s[_+2],v.normalize().multiplyScalar(y),s[_+0]=v.x,s[_+1]=v.y,s[_+2]=v.z}function h(){const y=new R;for(let v=0;v<s.length;v+=3){y.x=s[v+0],y.y=s[v+1],y.z=s[v+2];const _=g(y)/2/Math.PI+.5,w=m(y)/Math.PI+.5;o.push(_,1-w)}p(),u()}function u(){for(let y=0;y<o.length;y+=6){const v=o[y+0],_=o[y+2],w=o[y+4],T=Math.max(v,_,w),E=Math.min(v,_,w);T>.9&&E<.1&&(v<.2&&(o[y+0]+=1),_<.2&&(o[y+2]+=1),w<.2&&(o[y+4]+=1))}}function d(y){s.push(y.x,y.y,y.z)}function f(y,v){const _=y*3;v.x=t[_+0],v.y=t[_+1],v.z=t[_+2]}function p(){const y=new R,v=new R,_=new R,w=new R,T=new tt,E=new tt,M=new tt;for(let b=0,P=0;b<s.length;b+=9,P+=6){y.set(s[b+0],s[b+1],s[b+2]),v.set(s[b+3],s[b+4],s[b+5]),_.set(s[b+6],s[b+7],s[b+8]),T.set(o[P+0],o[P+1]),E.set(o[P+2],o[P+3]),M.set(o[P+4],o[P+5]),w.copy(y).add(v).add(_).divideScalar(3);const N=g(w);x(T,P+0,y,N),x(E,P+2,v,N),x(M,P+4,_,N)}}function x(y,v,_,w){w<0&&y.x===1&&(o[v]=y.x-1),_.x===0&&_.z===0&&(o[v]=w/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new fr(t.vertices,t.indices,t.radius,t.detail)}}class md extends fr{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new md(t.radius,t.detail)}}const hh=new R,uh=new R,bf=new R,dh=new ws;class Mm extends se{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){const i=Math.pow(10,4),s=Math.cos(Xr*e),o=t.getIndex(),a=t.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],h=["a","b","c"],u=new Array(3),d={},f=[];for(let p=0;p<l;p+=3){o?(c[0]=o.getX(p),c[1]=o.getX(p+1),c[2]=o.getX(p+2)):(c[0]=p,c[1]=p+1,c[2]=p+2);const{a:x,b:g,c:m}=dh;if(x.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),m.fromBufferAttribute(a,c[2]),dh.getNormal(bf),u[0]=`${Math.round(x.x*i)},${Math.round(x.y*i)},${Math.round(x.z*i)}`,u[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,u[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let y=0;y<3;y++){const v=(y+1)%3,_=u[y],w=u[v],T=dh[h[y]],E=dh[h[v]],M=`${_}_${w}`,b=`${w}_${_}`;b in d&&d[b]?(bf.dot(d[b].normal)<=s&&(f.push(T.x,T.y,T.z),f.push(E.x,E.y,E.z)),d[b]=null):M in d||(d[M]={index0:c[y],index1:c[v],normal:bf.clone()})}}for(const p in d)if(d[p]){const{index0:x,index1:g}=d[p];hh.fromBufferAttribute(a,x),uh.fromBufferAttribute(a,g),f.push(hh.x,hh.y,hh.z),f.push(uh.x,uh.y,uh.z)}this.setAttribute("position",new Ct(f,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class vi{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){pt("Curve: .getPoint() not implemented.")}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const n=this.getLengths();let i=0;const s=n.length;let o;e?o=e:o=t*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);const h=n[i],d=n[i+1]-h,f=(o-h)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new tt:new R);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e=!1){const n=new R,i=[],s=[],o=[],a=new R,l=new Qt;for(let f=0;f<=t;f++){const p=f/t;i[f]=this.getTangentAt(p,new R)}s[0]=new R,o[0]=new R;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();const p=Math.acos(Jt(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(Jt(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],f*p)),o[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class gd extends vi{constructor(t=0,e=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new tt){const n=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+t*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class X_ extends gd{constructor(t,e,n,i,s,o){super(t,e,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Sm(){let r=0,t=0,e=0,n=0;function i(s,o,a,l){r=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,u){let d=(o-s)/c-(a-s)/(c+h)+(a-o)/h,f=(a-o)/h-(l-o)/(h+u)+(l-a)/u;d*=h,f*=h,i(o,a,d,f)},calc:function(s){const o=s*s,a=o*s;return r+t*s+e*o+n*a}}}const fh=new R,Tf=new Sm,wf=new Sm,Af=new Sm;class bm extends vi{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new R){const n=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(fh.subVectors(i[0],i[1]).add(i[0]),c=fh);const u=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(fh.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=fh),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let p=Math.pow(c.distanceToSquared(u),f),x=Math.pow(u.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(h),f);x<1e-4&&(x=1),p<1e-4&&(p=x),g<1e-4&&(g=x),Tf.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,p,x,g),wf.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,p,x,g),Af.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,p,x,g)}else this.curveType==="catmullrom"&&(Tf.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),wf.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Af.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Tf.calc(l),wf.calc(l),Af.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(new R().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function A0(r,t,e,n,i){const s=(n-t)*.5,o=(i-e)*.5,a=r*r,l=r*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*r+e}function Wb(r,t){const e=1-r;return e*e*t}function Xb(r,t){return 2*(1-r)*r*t}function $b(r,t){return r*r*t}function pl(r,t,e,n){return Wb(r,t)+Xb(r,e)+$b(r,n)}function qb(r,t){const e=1-r;return e*e*e*t}function Yb(r,t){const e=1-r;return 3*e*e*r*t}function Zb(r,t){return 3*(1-r)*r*r*t}function Jb(r,t){return r*r*r*t}function ml(r,t,e,n,i){return qb(r,t)+Yb(r,e)+Zb(r,n)+Jb(r,i)}class Tm extends vi{constructor(t=new tt,e=new tt,n=new tt,i=new tt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new tt){const n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(ml(t,i.x,s.x,o.x,a.x),ml(t,i.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class $_ extends vi{constructor(t=new R,e=new R,n=new R,i=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new R){const n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(ml(t,i.x,s.x,o.x,a.x),ml(t,i.y,s.y,o.y,a.y),ml(t,i.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class wm extends vi{constructor(t=new tt,e=new tt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new tt){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new tt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class q_ extends vi{constructor(t=new R,e=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new R){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new R){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Am extends vi{constructor(t=new tt,e=new tt,n=new tt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new tt){const n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(pl(t,i.x,s.x,o.x),pl(t,i.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Em extends vi{constructor(t=new R,e=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new R){const n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(pl(t,i.x,s.x,o.x),pl(t,i.y,s.y,o.y),pl(t,i.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Cm extends vi{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new tt){const n=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(A0(a,l.x,c.x,h.x,u.x),A0(a,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(new tt().fromArray(i))}return this}}var Pu=Object.freeze({__proto__:null,ArcCurve:X_,CatmullRomCurve3:bm,CubicBezierCurve:Tm,CubicBezierCurve3:$_,EllipseCurve:gd,LineCurve:wm,LineCurve3:q_,QuadraticBezierCurve:Am,QuadraticBezierCurve3:Em,SplineCurve:Cm});class Y_ extends vi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Pu[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const i=t.curves[e];this.curves.push(new Pu[i.type]().fromJSON(i))}return this}}class Lu extends Y_{constructor(t){super(),this.type="Path",this.currentPoint=new tt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new wm(this.currentPoint.clone(),new tt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const s=new Am(this.currentPoint.clone(),new tt(t,e),new tt(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,o){const a=new Tm(this.currentPoint.clone(),new tt(t,e),new tt(n,i),new tt(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new Cm(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,i,s,o),this}absarc(t,e,n,i,s,o){return this.absellipse(t,e,n,n,i,s,o),this}ellipse(t,e,n,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,i,s,o,a,l),this}absellipse(t,e,n,i,s,o,a,l){const c=new gd(t,e,n,i,s,o,a,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class ir extends Lu{constructor(t){super(t),this.uuid=ei(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const i=t.holes[e];this.holes.push(new Lu().fromJSON(i))}return this}}function jb(r,t,e=2){const n=t&&t.length,i=n?t[0]*e:r.length;let s=Z_(r,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(n&&(s=nT(r,t,s,e)),r.length>80*e){a=r[0],l=r[1];let h=a,u=l;for(let d=e;d<i;d+=e){const f=r[d],p=r[d+1];f<a&&(a=f),p<l&&(l=p),f>h&&(h=f),p>u&&(u=p)}c=Math.max(h-a,u-l),c=c!==0?32767/c:0}return ec(s,o,e,a,l,c,0),o}function Z_(r,t,e,n,i){let s;if(i===fT(r,t,e,n)>0)for(let o=t;o<e;o+=n)s=E0(o/n|0,r[o],r[o+1],s);else for(let o=e-n;o>=t;o-=n)s=E0(o/n|0,r[o],r[o+1],s);return s&&da(s,s.next)&&(ic(s),s=s.next),s}function Kr(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(da(e,e.next)||ze(e.prev,e,e.next)===0)){if(ic(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function ec(r,t,e,n,i,s,o){if(!r)return;!o&&s&&aT(r,n,i,s);let a=r;for(;r.prev!==r.next;){const l=r.prev,c=r.next;if(s?Qb(r,n,i,s):Kb(r)){t.push(l.i,r.i,c.i),ic(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=tT(Kr(r),t),ec(r,t,e,n,i,s,2)):o===2&&eT(r,t,e,n,i,s):ec(Kr(r),t,e,n,i,s,1);break}}}function Kb(r){const t=r.prev,e=r,n=r.next;if(ze(t,e,n)>=0)return!1;const i=t.x,s=e.x,o=n.x,a=t.y,l=e.y,c=n.y,h=Math.min(i,s,o),u=Math.min(a,l,c),d=Math.max(i,s,o),f=Math.max(a,l,c);let p=n.next;for(;p!==t;){if(p.x>=h&&p.x<=d&&p.y>=u&&p.y<=f&&ol(i,a,s,l,o,c,p.x,p.y)&&ze(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Qb(r,t,e,n){const i=r.prev,s=r,o=r.next;if(ze(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,h=i.y,u=s.y,d=o.y,f=Math.min(a,l,c),p=Math.min(h,u,d),x=Math.max(a,l,c),g=Math.max(h,u,d),m=Ep(f,p,t,e,n),y=Ep(x,g,t,e,n);let v=r.prevZ,_=r.nextZ;for(;v&&v.z>=m&&_&&_.z<=y;){if(v.x>=f&&v.x<=x&&v.y>=p&&v.y<=g&&v!==i&&v!==o&&ol(a,h,l,u,c,d,v.x,v.y)&&ze(v.prev,v,v.next)>=0||(v=v.prevZ,_.x>=f&&_.x<=x&&_.y>=p&&_.y<=g&&_!==i&&_!==o&&ol(a,h,l,u,c,d,_.x,_.y)&&ze(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;v&&v.z>=m;){if(v.x>=f&&v.x<=x&&v.y>=p&&v.y<=g&&v!==i&&v!==o&&ol(a,h,l,u,c,d,v.x,v.y)&&ze(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;_&&_.z<=y;){if(_.x>=f&&_.x<=x&&_.y>=p&&_.y<=g&&_!==i&&_!==o&&ol(a,h,l,u,c,d,_.x,_.y)&&ze(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function tT(r,t){let e=r;do{const n=e.prev,i=e.next.next;!da(n,i)&&j_(n,e,e.next,i)&&nc(n,i)&&nc(i,n)&&(t.push(n.i,e.i,i.i),ic(e),ic(e.next),e=r=i),e=e.next}while(e!==r);return Kr(e)}function eT(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&hT(o,a)){let l=K_(o,a);o=Kr(o,o.next),l=Kr(l,l.next),ec(o,t,e,n,i,s,0),ec(l,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function nT(r,t,e,n){const i=[];for(let s=0,o=t.length;s<o;s++){const a=t[s]*n,l=s<o-1?t[s+1]*n:r.length,c=Z_(r,a,l,n,!1);c===c.next&&(c.steiner=!0),i.push(cT(c))}i.sort(iT);for(let s=0;s<i.length;s++)e=sT(i[s],e);return e}function iT(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const n=(r.next.y-r.y)/(r.next.x-r.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=n-i}return e}function sT(r,t){const e=rT(r,t);if(!e)return t;const n=K_(e,r);return Kr(n,n.next),Kr(e,e.next)}function rT(r,t){let e=t;const n=r.x,i=r.y;let s=-1/0,o;if(da(r,e))return e;do{if(da(r,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const u=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=n&&u>s&&(s=u,o=e.x<e.next.x?e:e.next,u===n))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;e=o;do{if(n>=e.x&&e.x>=l&&n!==e.x&&J_(i<c?n:s,i,l,c,i<c?s:n,i,e.x,e.y)){const u=Math.abs(i-e.y)/(n-e.x);nc(e,r)&&(u<h||u===h&&(e.x>o.x||e.x===o.x&&oT(o,e)))&&(o=e,h=u)}e=e.next}while(e!==a);return o}function oT(r,t){return ze(r.prev,r,t.prev)<0&&ze(t.next,r,r.next)<0}function aT(r,t,e,n){let i=r;do i.z===0&&(i.z=Ep(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,lT(i)}function lT(r){let t,e=1;do{let n=r,i;r=null;let s=null;for(t=0;n;){t++;let o=n,a=0;for(let c=0;c<e&&(a++,o=o.nextZ,!!o);c++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(i=n,n=n.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;n=o}s.nextZ=null,e*=2}while(t>1);return r}function Ep(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function cT(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function J_(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function ol(r,t,e,n,i,s,o,a){return!(r===o&&t===a)&&J_(r,t,e,n,i,s,o,a)}function hT(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!uT(r,t)&&(nc(r,t)&&nc(t,r)&&dT(r,t)&&(ze(r.prev,r,t.prev)||ze(r,t.prev,t))||da(r,t)&&ze(r.prev,r,r.next)>0&&ze(t.prev,t,t.next)>0)}function ze(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function da(r,t){return r.x===t.x&&r.y===t.y}function j_(r,t,e,n){const i=mh(ze(r,t,e)),s=mh(ze(r,t,n)),o=mh(ze(e,n,r)),a=mh(ze(e,n,t));return!!(i!==s&&o!==a||i===0&&ph(r,e,t)||s===0&&ph(r,n,t)||o===0&&ph(e,r,n)||a===0&&ph(e,t,n))}function ph(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function mh(r){return r>0?1:r<0?-1:0}function uT(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&j_(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function nc(r,t){return ze(r.prev,r,r.next)<0?ze(r,t,r.next)>=0&&ze(r,r.prev,t)>=0:ze(r,t,r.prev)<0||ze(r,r.next,t)<0}function dT(r,t){let e=r,n=!1;const i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function K_(r,t){const e=Cp(r.i,r.x,r.y),n=Cp(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function E0(r,t,e,n){const i=Cp(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ic(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 Cp(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function fT(r,t,e,n){let i=0;for(let s=t,o=e-n;s<e;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}class pT{static triangulate(t,e,n=2){return jb(t,e,n)}}class ui{static area(t){const e=t.length;let n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return n*.5}static isClockWise(t){return ui.area(t)<0}static triangulateShape(t,e){const n=[],i=[],s=[];C0(t),N0(n,t);let o=t.length;e.forEach(C0);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,N0(n,e[l]);const a=pT.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function C0(r){const t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function N0(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}class Mc extends se{constructor(t=new ir([new tt(.5,.5),new tt(-.5,.5),new tt(-.5,-.5),new tt(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],s=[];for(let a=0,l=t.length;a<l;a++){const c=t[a];o(c)}this.setAttribute("position",new Ct(i,3)),this.setAttribute("uv",new Ct(s,2)),this.computeVertexNormals();function o(a){const l=[],c=e.curveSegments!==void 0?e.curveSegments:12,h=e.steps!==void 0?e.steps:1,u=e.depth!==void 0?e.depth:1;let d=e.bevelEnabled!==void 0?e.bevelEnabled:!0,f=e.bevelThickness!==void 0?e.bevelThickness:.2,p=e.bevelSize!==void 0?e.bevelSize:f-.1,x=e.bevelOffset!==void 0?e.bevelOffset:0,g=e.bevelSegments!==void 0?e.bevelSegments:3;const m=e.extrudePath,y=e.UVGenerator!==void 0?e.UVGenerator:mT;let v,_=!1,w,T,E,M;if(m){v=m.getSpacedPoints(h),_=!0,d=!1;const Q=m.isCatmullRomCurve3?m.closed:!1;w=m.computeFrenetFrames(h,Q),T=new R,E=new R,M=new R}d||(g=0,f=0,p=0,x=0);const b=a.extractPoints(c);let P=b.shape;const N=b.holes;if(!ui.isClockWise(P)){P=P.reverse();for(let Q=0,rt=N.length;Q<rt;Q++){const et=N[Q];ui.isClockWise(et)&&(N[Q]=et.reverse())}}function U(Q){const et=10000000000000001e-36;let yt=Q[0];for(let I=1;I<=Q.length;I++){const $t=I%Q.length,Tt=Q[$t],Yt=Tt.x-yt.x,ut=Tt.y-yt.y,C=Yt*Yt+ut*ut,S=Math.max(Math.abs(Tt.x),Math.abs(Tt.y),Math.abs(yt.x),Math.abs(yt.y)),D=et*S*S;if(C<=D){Q.splice($t,1),I--;continue}yt=Tt}}U(P),N.forEach(U);const V=N.length,O=P;for(let Q=0;Q<V;Q++){const rt=N[Q];P=P.concat(rt)}function k(Q,rt,et){return rt||Vt("ExtrudeGeometry: vec does not exist"),Q.clone().addScaledVector(rt,et)}const G=P.length;function it(Q,rt,et){let yt,I,$t;const Tt=Q.x-rt.x,Yt=Q.y-rt.y,ut=et.x-Q.x,C=et.y-Q.y,S=Tt*Tt+Yt*Yt,D=Tt*C-Yt*ut;if(Math.abs(D)>Number.EPSILON){const Y=Math.sqrt(S),K=Math.sqrt(ut*ut+C*C),Z=rt.x-Yt/Y,It=rt.y+Tt/Y,dt=et.x-C/K,Ht=et.y+ut/K,Zt=((dt-Z)*C-(Ht-It)*ut)/(Tt*C-Yt*ut);yt=Z+Tt*Zt-Q.x,I=It+Yt*Zt-Q.y;const st=yt*yt+I*I;if(st<=2)return new tt(yt,I);$t=Math.sqrt(st/2)}else{let Y=!1;Tt>Number.EPSILON?ut>Number.EPSILON&&(Y=!0):Tt<-Number.EPSILON?ut<-Number.EPSILON&&(Y=!0):Math.sign(Yt)===Math.sign(C)&&(Y=!0),Y?(yt=-Yt,I=Tt,$t=Math.sqrt(S)):(yt=Tt,I=Yt,$t=Math.sqrt(S/2))}return new tt(yt/$t,I/$t)}const nt=[];for(let Q=0,rt=O.length,et=rt-1,yt=Q+1;Q<rt;Q++,et++,yt++)et===rt&&(et=0),yt===rt&&(yt=0),nt[Q]=it(O[Q],O[et],O[yt]);const mt=[];let xt,bt=nt.concat();for(let Q=0,rt=V;Q<rt;Q++){const et=N[Q];xt=[];for(let yt=0,I=et.length,$t=I-1,Tt=yt+1;yt<I;yt++,$t++,Tt++)$t===I&&($t=0),Tt===I&&(Tt=0),xt[yt]=it(et[yt],et[$t],et[Tt]);mt.push(xt),bt=bt.concat(xt)}let jt;if(g===0)jt=ui.triangulateShape(O,N);else{const Q=[],rt=[];for(let et=0;et<g;et++){const yt=et/g,I=f*Math.cos(yt*Math.PI/2),$t=p*Math.sin(yt*Math.PI/2)+x;for(let Tt=0,Yt=O.length;Tt<Yt;Tt++){const ut=k(O[Tt],nt[Tt],$t);qt(ut.x,ut.y,-I),yt===0&&Q.push(ut)}for(let Tt=0,Yt=V;Tt<Yt;Tt++){const ut=N[Tt];xt=mt[Tt];const C=[];for(let S=0,D=ut.length;S<D;S++){const Y=k(ut[S],xt[S],$t);qt(Y.x,Y.y,-I),yt===0&&C.push(Y)}yt===0&&rt.push(C)}}jt=ui.triangulateShape(Q,rt)}const Me=jt.length,we=p+x;for(let Q=0;Q<G;Q++){const rt=d?k(P[Q],bt[Q],we):P[Q];_?(E.copy(w.normals[0]).multiplyScalar(rt.x),T.copy(w.binormals[0]).multiplyScalar(rt.y),M.copy(v[0]).add(E).add(T),qt(M.x,M.y,M.z)):qt(rt.x,rt.y,0)}for(let Q=1;Q<=h;Q++)for(let rt=0;rt<G;rt++){const et=d?k(P[rt],bt[rt],we):P[rt];_?(E.copy(w.normals[Q]).multiplyScalar(et.x),T.copy(w.binormals[Q]).multiplyScalar(et.y),M.copy(v[Q]).add(E).add(T),qt(M.x,M.y,M.z)):qt(et.x,et.y,u/h*Q)}for(let Q=g-1;Q>=0;Q--){const rt=Q/g,et=f*Math.cos(rt*Math.PI/2),yt=p*Math.sin(rt*Math.PI/2)+x;for(let I=0,$t=O.length;I<$t;I++){const Tt=k(O[I],nt[I],yt);qt(Tt.x,Tt.y,u+et)}for(let I=0,$t=N.length;I<$t;I++){const Tt=N[I];xt=mt[I];for(let Yt=0,ut=Tt.length;Yt<ut;Yt++){const C=k(Tt[Yt],xt[Yt],yt);_?qt(C.x,C.y+v[h-1].y,v[h-1].x+et):qt(C.x,C.y,u+et)}}}j(),ct();function j(){const Q=i.length/3;if(d){let rt=0,et=G*rt;for(let yt=0;yt<Me;yt++){const I=jt[yt];Xt(I[2]+et,I[1]+et,I[0]+et)}rt=h+g*2,et=G*rt;for(let yt=0;yt<Me;yt++){const I=jt[yt];Xt(I[0]+et,I[1]+et,I[2]+et)}}else{for(let rt=0;rt<Me;rt++){const et=jt[rt];Xt(et[2],et[1],et[0])}for(let rt=0;rt<Me;rt++){const et=jt[rt];Xt(et[0]+G*h,et[1]+G*h,et[2]+G*h)}}n.addGroup(Q,i.length/3-Q,0)}function ct(){const Q=i.length/3;let rt=0;ht(O,rt),rt+=O.length;for(let et=0,yt=N.length;et<yt;et++){const I=N[et];ht(I,rt),rt+=I.length}n.addGroup(Q,i.length/3-Q,1)}function ht(Q,rt){let et=Q.length;for(;--et>=0;){const yt=et;let I=et-1;I<0&&(I=Q.length-1);for(let $t=0,Tt=h+g*2;$t<Tt;$t++){const Yt=G*$t,ut=G*($t+1),C=rt+yt+Yt,S=rt+I+Yt,D=rt+I+ut,Y=rt+yt+ut;Kt(C,S,D,Y)}}}function qt(Q,rt,et){l.push(Q),l.push(rt),l.push(et)}function Xt(Q,rt,et){Ae(Q),Ae(rt),Ae(et);const yt=i.length/3,I=y.generateTopUV(n,i,yt-3,yt-2,yt-1);ie(I[0]),ie(I[1]),ie(I[2])}function Kt(Q,rt,et,yt){Ae(Q),Ae(rt),Ae(yt),Ae(rt),Ae(et),Ae(yt);const I=i.length/3,$t=y.generateSideWallUV(n,i,I-6,I-3,I-2,I-1);ie($t[0]),ie($t[1]),ie($t[3]),ie($t[1]),ie($t[2]),ie($t[3])}function Ae(Q){i.push(l[Q*3+0]),i.push(l[Q*3+1]),i.push(l[Q*3+2])}function ie(Q){s.push(Q.x),s.push(Q.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return gT(e,n,t)}static fromJSON(t,e){const n=[];for(let s=0,o=t.shapes.length;s<o;s++){const a=e[t.shapes[s]];n.push(a)}const i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new Pu[i.type]().fromJSON(i)),new Mc(n,t.options)}}const mT={generateTopUV:function(r,t,e,n,i){const s=t[e*3],o=t[e*3+1],a=t[n*3],l=t[n*3+1],c=t[i*3],h=t[i*3+1];return[new tt(s,o),new tt(a,l),new tt(c,h)]},generateSideWallUV:function(r,t,e,n,i,s){const o=t[e*3],a=t[e*3+1],l=t[e*3+2],c=t[n*3],h=t[n*3+1],u=t[n*3+2],d=t[i*3],f=t[i*3+1],p=t[i*3+2],x=t[s*3],g=t[s*3+1],m=t[s*3+2];return Math.abs(a-h)<Math.abs(o-c)?[new tt(o,1-l),new tt(c,1-u),new tt(d,1-p),new tt(x,1-m)]:[new tt(a,1-l),new tt(h,1-u),new tt(f,1-p),new tt(g,1-m)]}};function gT(r,t,e){if(e.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];e.shapes.push(s.uuid)}else e.shapes.push(r.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class xd extends fr{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new xd(t.radius,t.detail)}}class yd extends se{constructor(t=[new tt(0,-.5),new tt(.5,0),new tt(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=Jt(i,0,Math.PI*2);const s=[],o=[],a=[],l=[],c=[],h=1/e,u=new R,d=new tt,f=new R,p=new R,x=new R;let g=0,m=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:g=t[y+1].x-t[y].x,m=t[y+1].y-t[y].y,f.x=m*1,f.y=-g,f.z=m*0,x.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(x.x,x.y,x.z);break;default:g=t[y+1].x-t[y].x,m=t[y+1].y-t[y].y,f.x=m*1,f.y=-g,f.z=m*0,p.copy(f),f.x+=x.x,f.y+=x.y,f.z+=x.z,f.normalize(),l.push(f.x,f.y,f.z),x.copy(p)}for(let y=0;y<=e;y++){const v=n+y*h*i,_=Math.sin(v),w=Math.cos(v);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*_,u.y=t[T].y,u.z=t[T].x*w,o.push(u.x,u.y,u.z),d.x=y/e,d.y=T/(t.length-1),a.push(d.x,d.y);const E=l[3*T+0]*_,M=l[3*T+1],b=l[3*T+0]*w;c.push(E,M,b)}}for(let y=0;y<e;y++)for(let v=0;v<t.length-1;v++){const _=v+y*t.length,w=_,T=_+t.length,E=_+t.length+1,M=_+1;s.push(w,T,M),s.push(E,M,T)}this.setIndex(s),this.setAttribute("position",new Ct(o,3)),this.setAttribute("uv",new Ct(a,2)),this.setAttribute("normal",new Ct(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new yd(t.points,t.segments,t.phiStart,t.phiLength)}}class Ta extends fr{constructor(t=1,e=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ta(t.radius,t.detail)}}class io extends se{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const s=t/2,o=e/2,a=Math.floor(n),l=Math.floor(i),c=a+1,h=l+1,u=t/a,d=e/l,f=[],p=[],x=[],g=[];for(let m=0;m<h;m++){const y=m*d-o;for(let v=0;v<c;v++){const _=v*u-s;p.push(_,-y,0),x.push(0,0,1),g.push(v/a),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let y=0;y<a;y++){const v=y+c*m,_=y+c*(m+1),w=y+1+c*(m+1),T=y+1+c*m;f.push(v,_,T),f.push(_,w,T)}this.setIndex(f),this.setAttribute("position",new Ct(p,3)),this.setAttribute("normal",new Ct(x,3)),this.setAttribute("uv",new Ct(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new io(t.width,t.height,t.widthSegments,t.heightSegments)}}class Sc extends se{constructor(t=.5,e=1,n=32,i=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],l=[],c=[],h=[];let u=t;const d=(e-t)/i,f=new R,p=new tt;for(let x=0;x<=i;x++){for(let g=0;g<=n;g++){const m=s+g/n*o;f.x=u*Math.cos(m),f.y=u*Math.sin(m),l.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/e+1)/2,p.y=(f.y/e+1)/2,h.push(p.x,p.y)}u+=d}for(let x=0;x<i;x++){const g=x*(n+1);for(let m=0;m<n;m++){const y=m+g,v=y,_=y+n+1,w=y+n+2,T=y+1;a.push(v,_,T),a.push(_,w,T)}}this.setIndex(a),this.setAttribute("position",new Ct(l,3)),this.setAttribute("normal",new Ct(c,3)),this.setAttribute("uv",new Ct(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Sc(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class _d extends se{constructor(t=new ir([new tt(0,.5),new tt(-.5,-.5),new tt(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(n),this.setAttribute("position",new Ct(i,3)),this.setAttribute("normal",new Ct(s,3)),this.setAttribute("uv",new Ct(o,2));function c(h){const u=i.length/3,d=h.extractPoints(e);let f=d.shape;const p=d.holes;ui.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){const y=p[g];ui.isClockWise(y)===!0&&(p[g]=y.reverse())}const x=ui.triangulateShape(f,p);for(let g=0,m=p.length;g<m;g++){const y=p[g];f=f.concat(y)}for(let g=0,m=f.length;g<m;g++){const y=f[g];i.push(y.x,y.y,0),s.push(0,0,1),o.push(y.x,y.y)}for(let g=0,m=x.length;g<m;g++){const y=x[g],v=y[0]+u,_=y[1]+u,w=y[2]+u;n.push(v,_,w),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return xT(e,t)}static fromJSON(t,e){const n=[];for(let i=0,s=t.shapes.length;i<s;i++){const o=e[t.shapes[i]];n.push(o)}return new _d(n,t.curveSegments)}}function xT(r,t){if(t.shapes=[],Array.isArray(r))for(let e=0,n=r.length;e<n;e++){const i=r[e];t.shapes.push(i.uuid)}else t.shapes.push(r.uuid);return t}class wa extends se{constructor(t=1,e=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(o+a,Math.PI);let c=0;const h=[],u=new R,d=new R,f=[],p=[],x=[],g=[];for(let m=0;m<=n;m++){const y=[],v=m/n;let _=0;m===0&&o===0?_=.5/e:m===n&&l===Math.PI&&(_=-.5/e);for(let w=0;w<=e;w++){const T=w/e;u.x=-t*Math.cos(i+T*s)*Math.sin(o+v*a),u.y=t*Math.cos(o+v*a),u.z=t*Math.sin(i+T*s)*Math.sin(o+v*a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),g.push(T+_,1-v),y.push(c++)}h.push(y)}for(let m=0;m<n;m++)for(let y=0;y<e;y++){const v=h[m][y+1],_=h[m][y],w=h[m+1][y],T=h[m+1][y+1];(m!==0||o>0)&&f.push(v,_,T),(m!==n-1||l<Math.PI)&&f.push(_,w,T)}this.setIndex(f),this.setAttribute("position",new Ct(p,3)),this.setAttribute("normal",new Ct(x,3)),this.setAttribute("uv",new Ct(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new wa(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class vd extends fr{constructor(t=1,e=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new vd(t.radius,t.detail)}}class bc extends se{constructor(t=1,e=.4,n=12,i=48,s=Math.PI*2,o=0,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:s,thetaStart:o,thetaLength:a},n=Math.floor(n),i=Math.floor(i);const l=[],c=[],h=[],u=[],d=new R,f=new R,p=new R;for(let x=0;x<=n;x++){const g=o+x/n*a;for(let m=0;m<=i;m++){const y=m/i*s;f.x=(t+e*Math.cos(g))*Math.cos(y),f.y=(t+e*Math.cos(g))*Math.sin(y),f.z=e*Math.sin(g),c.push(f.x,f.y,f.z),d.x=t*Math.cos(y),d.y=t*Math.sin(y),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(m/i),u.push(x/n)}}for(let x=1;x<=n;x++)for(let g=1;g<=i;g++){const m=(i+1)*x+g-1,y=(i+1)*(x-1)+g-1,v=(i+1)*(x-1)+g,_=(i+1)*x+g;l.push(m,y,_),l.push(y,v,_)}this.setIndex(l),this.setAttribute("position",new Ct(c,3)),this.setAttribute("normal",new Ct(h,3)),this.setAttribute("uv",new Ct(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new bc(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Md extends se{constructor(t=1,e=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],l=[],c=[],h=[],u=new R,d=new R,f=new R,p=new R,x=new R,g=new R,m=new R;for(let v=0;v<=n;++v){const _=v/n*s*Math.PI*2;y(_,s,o,t,f),y(_+.01,s,o,t,p),g.subVectors(p,f),m.addVectors(p,f),x.crossVectors(g,m),m.crossVectors(x,g),x.normalize(),m.normalize();for(let w=0;w<=i;++w){const T=w/i*Math.PI*2,E=-e*Math.cos(T),M=e*Math.sin(T);u.x=f.x+(E*m.x+M*x.x),u.y=f.y+(E*m.y+M*x.y),u.z=f.z+(E*m.z+M*x.z),l.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),h.push(v/n),h.push(w/i)}}for(let v=1;v<=n;v++)for(let _=1;_<=i;_++){const w=(i+1)*(v-1)+(_-1),T=(i+1)*v+(_-1),E=(i+1)*v+_,M=(i+1)*(v-1)+_;a.push(w,T,M),a.push(T,E,M)}this.setIndex(a),this.setAttribute("position",new Ct(l,3)),this.setAttribute("normal",new Ct(c,3)),this.setAttribute("uv",new Ct(h,2));function y(v,_,w,T,E){const M=Math.cos(v),b=Math.sin(v),P=w/_*v,N=Math.cos(P);E.x=T*(2+N)*.5*M,E.y=T*(2+N)*b*.5,E.z=T*Math.sin(P)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Md(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class Sd extends se{constructor(t=new Em(new R(-1,-1,0),new R(-1,1,0),new R(1,1,0)),e=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:s};const o=t.computeFrenetFrames(e,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new R,l=new R,c=new tt;let h=new R;const u=[],d=[],f=[],p=[];x(),this.setIndex(p),this.setAttribute("position",new Ct(u,3)),this.setAttribute("normal",new Ct(d,3)),this.setAttribute("uv",new Ct(f,2));function x(){for(let v=0;v<e;v++)g(v);g(s===!1?e:0),y(),m()}function g(v){h=t.getPointAt(v/e,h);const _=o.normals[v],w=o.binormals[v];for(let T=0;T<=i;T++){const E=T/i*Math.PI*2,M=Math.sin(E),b=-Math.cos(E);l.x=b*_.x+M*w.x,l.y=b*_.y+M*w.y,l.z=b*_.z+M*w.z,l.normalize(),d.push(l.x,l.y,l.z),a.x=h.x+n*l.x,a.y=h.y+n*l.y,a.z=h.z+n*l.z,u.push(a.x,a.y,a.z)}}function m(){for(let v=1;v<=e;v++)for(let _=1;_<=i;_++){const w=(i+1)*(v-1)+(_-1),T=(i+1)*v+(_-1),E=(i+1)*v+_,M=(i+1)*(v-1)+_;p.push(w,T,M),p.push(T,E,M)}}function y(){for(let v=0;v<=e;v++)for(let _=0;_<=i;_++)c.x=v/e,c.y=_/i,f.push(c.x,c.y)}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new Sd(new Pu[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class Nm extends se{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},t!==null){const e=[],n=new Set,i=new R,s=new R;if(t.index!==null){const o=t.attributes.position,a=t.index;let l=t.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,h=l.length;c<h;++c){const u=l[c],d=u.start,f=u.count;for(let p=d,x=d+f;p<x;p+=3)for(let g=0;g<3;g++){const m=a.getX(p+g),y=a.getX(p+(g+1)%3);i.fromBufferAttribute(o,m),s.fromBufferAttribute(o,y),R0(i,s,n)===!0&&(e.push(i.x,i.y,i.z),e.push(s.x,s.y,s.z))}}}else{const o=t.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const h=3*a+c,u=3*a+(c+1)%3;i.fromBufferAttribute(o,h),s.fromBufferAttribute(o,u),R0(i,s,n)===!0&&(e.push(i.x,i.y,i.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ct(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function R0(r,t,e){const n=`${r.x},${r.y},${r.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${r.x},${r.y},${r.z}`;return e.has(n)===!0||e.has(i)===!0?!1:(e.add(n),e.add(i),!0)}var I0=Object.freeze({__proto__:null,BoxGeometry:dr,CapsuleGeometry:fd,CircleGeometry:pd,ConeGeometry:vc,CylinderGeometry:ba,DodecahedronGeometry:md,EdgesGeometry:Mm,ExtrudeGeometry:Mc,IcosahedronGeometry:xd,LatheGeometry:yd,OctahedronGeometry:Ta,PlaneGeometry:io,PolyhedronGeometry:fr,RingGeometry:Sc,ShapeGeometry:_d,SphereGeometry:wa,TetrahedronGeometry:vd,TorusGeometry:bc,TorusKnotGeometry:Md,TubeGeometry:Sd,WireframeGeometry:Nm});class Rm extends gn{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new wt(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}function fa(r){const t={};for(const e in r){t[e]={};for(const n in r[e]){const i=r[e][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(pt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}function Ln(r){const t={};for(let e=0;e<r.length;e++){const n=fa(r[e]);for(const i in n)t[i]=n[i]}return t}function yT(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}function Q_(r){const t=r.getRenderTarget();return t===null?r.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:fe.workingColorSpace}const Im={clone:fa,merge:Ln};var _T=`void main() {
|
|
1
|
+
"use strict";var ho=typeof document<"u"?document.currentScript:null;const Wr="183.2",Ey={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Cy={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ny=0,vp=1,Ry=2,pS=3,mS=0,Jo=1,Iy=2,Yo=3,is=0,An=1,Ri=2,Di=0,nr=1,uu=2,Mp=3,Sp=4,Yp=5,gS=6,Qs=100,Py=101,Ly=102,Fy=103,Zp=104,Dy=200,Uy=201,Oy=202,By=203,du=204,fu=205,zy=206,Vy=207,ky=208,Gy=209,Hy=210,Wy=211,Xy=212,$y=213,qy=214,bl=0,Tl=1,wl=2,rr=3,Al=4,El=5,Cl=6,Nl=7,uc=0,Yy=1,Zy=2,di=0,Wu=1,Xu=2,Jp=3,$u=4,jp=5,qu=6,Yu=7,bp="attached",Jy="detached",Zu=300,ss=301,or=302,jo=303,Ko=304,to=306,aa=1e3,Bn=1001,la=1002,Xe=1003,Ju=1004,jy=1004,zr=1005,xS=1005,Fe=1006,Qo=1007,yS=1007,Li=1008,Ky=1008,Un=1009,Kp=1010,Qp=1011,ca=1012,ju=1013,ii=1014,Tn=1015,Ui=1016,Ku=1017,Qu=1018,Yr=1020,td=35902,ed=35899,tm=1021,nd=1022,wn=1023,Oi=1026,Cs=1027,dc=1028,Sa=1029,ar=1030,fc=1031,_S=1032,pc=1033,ta=33776,ea=33777,dl=33778,na=33779,Rl=35840,pu=35841,Il=35842,Pl=35843,Ll=36196,Fl=37492,Dl=37496,Ul=37488,Ol=37489,Bl=37490,zl=37491,Vl=37808,mu=37809,gu=37810,xu=37811,kl=37812,yu=37813,_u=37814,vu=37815,Mu=37816,Su=37817,bu=37818,Tu=37819,wu=37820,Au=37821,Gl=36492,Eu=36494,Hl=36495,Wl=36283,Xl=36284,$l=36285,ql=36286,em=2200,nm=2201,Qy=2202,ha=2300,Yl=2301,su=2302,Tp=2303,Vr=2400,kr=2401,Zl=2402,id=2500,im=2501,t_=0,e_=1,n_=2,sm=3200,i_=3201,vS=3202,MS=3203,ur=0,s_=1,Ki="",Fn="srgb",lr="srgb-linear",Jl="linear",_e="srgb",SS="",bS="rg",TS="ga",r_=0,Ks=7680,o_=7681,a_=7682,l_=7683,c_=34055,h_=34056,u_=5386,d_=512,f_=513,p_=514,m_=515,g_=516,x_=517,y_=518,Cu=519,__=512,v_=513,M_=514,sd=515,S_=516,b_=517,rd=518,T_=519,jl=35044,w_=35048,wS=35040,AS=35045,ES=35049,CS=35041,NS=35046,RS=35050,IS=35042,PS="100",Nu="300 es",ti=2e3,Zr=2001,LS={COMPUTE:"compute",RENDER:"render"},FS={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},DS={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},US={TEXTURE_COMPARE:"depthTextureCompare"};function OS(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}const BS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Zo(r,t){return new BS[r](t)}function A_(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Kl(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function E_(){const r=Kl("canvas");return r.style.display="block",r}const Wg={};let cr=null;function zS(r){cr=r}function VS(){return cr}function Ql(...r){const t="THREE."+r.shift();cr?cr("log",t,...r):console.log(t,...r)}function C_(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function pt(...r){r=C_(r);const t="THREE."+r.shift();if(cr)cr("warn",t,...r);else{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function Vt(...r){r=C_(r);const t="THREE."+r.shift();if(cr)cr("error",t,...r);else{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function tc(...r){const t=r.join(" ");t in Wg||(Wg[t]=!0,pt(...r))}function kS(r,t,e){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}const GS={[bl]:Tl,[wl]:Cl,[Al]:Nl,[rr]:El,[Tl]:bl,[Cl]:wl,[Nl]:Al,[El]:rr};let Bi=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const i=n[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}};const _n=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Xg=1234567;const Xr=Math.PI/180,ua=180/Math.PI;function ei(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(_n[r&255]+_n[r>>8&255]+_n[r>>16&255]+_n[r>>24&255]+"-"+_n[t&255]+_n[t>>8&255]+"-"+_n[t>>16&15|64]+_n[t>>24&255]+"-"+_n[e&63|128]+_n[e>>8&255]+"-"+_n[e>>16&255]+_n[e>>24&255]+_n[n&255]+_n[n>>8&255]+_n[n>>16&255]+_n[n>>24&255]).toLowerCase()}function Jt(r,t,e){return Math.max(t,Math.min(e,r))}function rm(r,t){return(r%t+t)%t}function HS(r,t,e,n,i){return n+(r-t)*(i-n)/(e-t)}function WS(r,t,e){return r!==t?(e-r)/(t-r):0}function fl(r,t,e){return(1-e)*r+e*t}function XS(r,t,e,n){return fl(r,t,1-Math.exp(-e*n))}function $S(r,t=1){return t-Math.abs(rm(r,t*2)-t)}function qS(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function YS(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function ZS(r,t){return r+Math.floor(Math.random()*(t-r+1))}function JS(r,t){return r+Math.random()*(t-r)}function jS(r){return r*(.5-Math.random())}function KS(r){r!==void 0&&(Xg=r);let t=Xg+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function QS(r){return r*Xr}function tb(r){return r*ua}function eb(r){return(r&r-1)===0&&r!==0}function nb(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function ib(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function sb(r,t,e,n,i){const s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),c=s((t+n)/2),h=o((t+n)/2),u=s((t-n)/2),d=o((t-n)/2),f=s((n-t)/2),p=o((n-t)/2);switch(i){case"XYX":r.set(a*h,l*u,l*d,a*c);break;case"YZY":r.set(l*d,a*h,l*u,a*c);break;case"ZXZ":r.set(l*u,l*d,a*h,a*c);break;case"XZX":r.set(a*h,l*p,l*f,a*c);break;case"YXY":r.set(l*f,a*h,l*p,a*c);break;case"ZYZ":r.set(l*p,l*f,a*h,a*c);break;default:pt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function On(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function le(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const N_={DEG2RAD:Xr,RAD2DEG:ua,generateUUID:ei,clamp:Jt,euclideanModulo:rm,mapLinear:HS,inverseLerp:WS,lerp:fl,damp:XS,pingpong:$S,smoothstep:qS,smootherstep:YS,randInt:ZS,randFloat:JS,randFloatSpread:jS,seededRandom:KS,degToRad:QS,radToDeg:tb,isPowerOfTwo:eb,ceilPowerOfTwo:nb,floorPowerOfTwo:ib,setQuaternionFromProperEuler:sb,normalize:le,denormalize:On};let tt=class R_{constructor(t=0,e=0){R_.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,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=Jt(this.x,t.x,e.x),this.y=Jt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Jt(this.x,t,e),this.y=Jt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Jt(n,t,e))}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 n=this.dot(t)/e;return Math.acos(Jt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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 n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*n-o*i+t.x,this.y=s*i+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},En=class{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,o,a){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3],d=s[o+0],f=s[o+1],p=s[o+2],x=s[o+3];if(u!==x||l!==d||c!==f||h!==p){let g=l*d+c*f+h*p+u*x;g<0&&(d=-d,f=-f,p=-p,x=-x,g=-g);let m=1-a;if(g<.9995){const y=Math.acos(g),v=Math.sin(y);m=Math.sin(m*y)/v,a=Math.sin(a*y)/v,l=l*m+d*a,c=c*m+f*a,h=h*m+p*a,u=u*m+x*a}else{l=l*m+d*a,c=c*m+f*a,h=h*m+p*a,u=u*m+x*a;const y=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=y,c*=y,h*=y,u*=y}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+h*u+l*f-c*d,t[e+1]=l*p+h*d+c*u-a*f,t[e+2]=c*p+h*f+a*d-l*u,t[e+3]=h*p-a*u-l*d-c*f,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,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,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 n=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(i/2),u=a(s/2),d=l(n/2),f=l(i/2),p=l(s/2);switch(o){case"XYZ":this._x=d*h*u+c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u+d*f*p;break;case"YZX":this._x=d*h*u+c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u-d*f*p;break;case"XZY":this._x=d*h*u-c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u+d*f*p;break;default:pt("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+a+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(n>a&&n>u){const f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>u){const f=2*Math.sqrt(1+a-n-u);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Jt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),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 n=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-n*c,this._z=s*h+o*c+n*l-i*a,this._w=o*h-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,s=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,i=-i,s=-s,o=-o,a=-a);let l=1-e;if(a<.9995){const c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+i*e,this._z=this._z*l+s*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+i*e,this._z=this._z*l+s*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}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}},R=class I_{constructor(t=0,e=0,n=0){I_.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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($g.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion($g.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*i-a*n),h=2*(a*e-s*i),u=2*(s*n-o*e);return this.x=e+l*c+o*u-a*h,this.y=n+l*h+a*c-s*u,this.z=i+l*u+s*h-o*c,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,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,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=Jt(this.x,t.x,e.x),this.y=Jt(this.y,t.y,e.y),this.z=Jt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Jt(this.x,t,e),this.y=Jt(this.y,t,e),this.z=Jt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Jt(n,t,e))}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Zd.copy(this).projectOnVector(t),this.sub(Zd)}reflect(t){return this.sub(Zd.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 n=this.dot(t)/e;return Math.acos(Jt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,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(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Zd=new R,$g=new En;let ae=class P_{constructor(t,e,n,i,s,o,a,l,c){P_.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,o,a,l,c)}set(t,e,n,i,s,o,a,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=s,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.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 n=t.elements,i=e.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],p=n[8],x=i[0],g=i[3],m=i[6],y=i[1],v=i[4],_=i[7],w=i[2],T=i[5],E=i[8];return s[0]=o*x+a*y+l*w,s[3]=o*g+a*v+l*T,s[6]=o*m+a*_+l*E,s[1]=c*x+h*y+u*w,s[4]=c*g+h*v+u*T,s[7]=c*m+h*_+u*E,s[2]=d*x+f*y+p*w,s[5]=d*g+f*v+p*T,s[8]=d*m+f*_+p*E,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],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*s*h+n*a*l+i*s*c-i*o*l}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*o-a*c,d=a*l-h*s,f=c*s-o*l,p=e*u+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/p;return t[0]=u*x,t[1]=(i*c-h*n)*x,t[2]=(a*n-i*o)*x,t[3]=d*x,t[4]=(h*e-i*l)*x,t[5]=(i*s-a*e)*x,t[6]=f*x,t[7]=(n*l-c*e)*x,t[8]=(o*e-n*s)*x,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,n,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Jd.makeScale(t,e)),this}rotate(t){return this.premultiply(Jd.makeRotation(-t)),this}translate(t,e){return this.premultiply(Jd.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),n=Math.sin(t);return this.set(e,-n,0,n,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,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};const Jd=new ae,qg=new ae().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Yg=new ae().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rb(){const r={enabled:!0,workingColorSpace:lr,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===_e&&(i.r=Is(i.r),i.g=Is(i.g),i.b=Is(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===_e&&(i.r=ia(i.r),i.g=ia(i.g),i.b=ia(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Ki?Jl:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return tc("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return tc("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[lr]:{primaries:t,whitePoint:n,transfer:Jl,toXYZ:qg,fromXYZ:Yg,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Fn},outputColorSpaceConfig:{drawingBufferColorSpace:Fn}},[Fn]:{primaries:t,whitePoint:n,transfer:_e,toXYZ:qg,fromXYZ:Yg,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Fn}}}),r}const fe=rb();function Is(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ia(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let uo,om=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{uo===void 0&&(uo=Kl("canvas")),uo.width=t.width,uo.height=t.height;const i=uo.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=uo}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Kl("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Is(s[o]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Is(e[n]/255)*255):e[n]=Is(e[n]);return{data:e,width:t.width,height:t.height}}else return pt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},ob=0,Ns=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ob++}),this.uuid=ei(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(jd(i[o].image)):s.push(jd(i[o]))}else s=jd(i);n.url=s}return e||(t.images[this.uuid]=n),n}};function jd(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?om.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(pt("Texture: Unable to serialize Texture."),{})}let ab=0;const Kd=new R;let rn=class ru extends Bi{constructor(t=ru.DEFAULT_IMAGE,e=ru.DEFAULT_MAPPING,n=Bn,i=Bn,s=Fe,o=Li,a=wn,l=Un,c=ru.DEFAULT_ANISOTROPY,h=Ki){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ab++}),this.uuid=ei(),this.name="",this.source=new Ns(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new tt(0,0),this.repeat=new tt(1,1),this.center=new tt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ae,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Kd).x}get height(){return this.source.getSize(Kd).y}get depth(){return this.source.getSize(Kd).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){pt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){pt(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Zu)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case aa:t.x=t.x-Math.floor(t.x);break;case Bn:t.x=t.x<0?0:1;break;case la: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 aa:t.y=t.y-Math.floor(t.y);break;case Bn:t.y=t.y<0?0:1;break;case la: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)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};rn.DEFAULT_IMAGE=null;rn.DEFAULT_MAPPING=Zu;rn.DEFAULT_ANISOTROPY=4;let Le=class L_{constructor(t=0,e=0,n=0,i=1){L_.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=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;case 3:this.w=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;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}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!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=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.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=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.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,s;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],p=l[9],x=l[2],g=l[6],m=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(p+g)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const v=(c+1)/2,_=(f+1)/2,w=(m+1)/2,T=(h+d)/4,E=(u+x)/4,M=(p+g)/4;return v>_&&v>w?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=T/n,s=E/n):_>w?_<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(_),n=T/i,s=M/i):w<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),n=E/s,i=M/s),this.set(n,i,s,e),this}let y=Math.sqrt((g-p)*(g-p)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-x)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}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.w=Math.min(this.w,t.w),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.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Jt(this.x,t.x,e.x),this.y=Jt(this.y,t.y,e.y),this.z=Jt(this.z,t.z,e.z),this.w=Jt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Jt(this.x,t,e),this.y=Jt(this.y,t,e),this.z=Jt(this.z,t,e),this.w=Jt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Jt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},am=class extends Bi{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fe,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Le(0,0,t,e),this.scissorTest=!1,this.viewport=new Le(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},s=new rn(i),o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){const e={minFilter:Fe,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new Ns(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}};class qn extends am{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}let od=class extends rn{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Xe,this.minFilter=Xe,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}};class lb extends qn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new od(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class mc extends rn{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Xe,this.minFilter=Xe,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class cb extends qn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new mc(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}let Qt=class wp{constructor(t,e,n,i,s,o,a,l,c,h,u,d,f,p,x,g){wp.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,n,i,s,o,a,l,c,h,u,d,f,p,x,g)}set(t,e,n,i,s,o,a,l,c,h,u,d,f,p,x,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=p,m[11]=x,m[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 wp().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[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,n){return this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();const e=this.elements,n=t.elements,i=1/fo.setFromMatrixColumn(t,0).length(),s=1/fo.setFromMatrixColumn(t,1).length(),o=1/fo.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,s=t.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=o*h,f=o*u,p=a*h,x=a*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+p*c,e[5]=d-x*c,e[9]=-a*l,e[2]=x-d*c,e[6]=p+f*c,e[10]=o*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,p=c*h,x=c*u;e[0]=d+x*a,e[4]=p*a-f,e[8]=o*c,e[1]=o*u,e[5]=o*h,e[9]=-a,e[2]=f*a-p,e[6]=x+d*a,e[10]=o*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,p=c*h,x=c*u;e[0]=d-x*a,e[4]=-o*u,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*h,e[9]=x-d*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const d=o*h,f=o*u,p=a*h,x=a*u;e[0]=l*h,e[4]=p*c-f,e[8]=d*c+x,e[1]=l*u,e[5]=x*c+d,e[9]=f*c-p,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const d=o*l,f=o*c,p=a*l,x=a*c;e[0]=l*h,e[4]=x-d*u,e[8]=p*u+f,e[1]=u,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=f*u+p,e[10]=d-x*u}else if(t.order==="XZY"){const d=o*l,f=o*c,p=a*l,x=a*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+x,e[5]=o*h,e[9]=f*u-p,e[2]=p*u-f,e[6]=a*h,e[10]=x*u+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(hb,t,ub)}lookAt(t,e,n){const i=this.elements;return Zn.subVectors(t,e),Zn.lengthSq()===0&&(Zn.z=1),Zn.normalize(),Bs.crossVectors(n,Zn),Bs.lengthSq()===0&&(Math.abs(n.z)===1?Zn.x+=1e-4:Zn.z+=1e-4,Zn.normalize(),Bs.crossVectors(n,Zn)),Bs.normalize(),Dc.crossVectors(Zn,Bs),i[0]=Bs.x,i[4]=Dc.x,i[8]=Zn.x,i[1]=Bs.y,i[5]=Dc.y,i[9]=Zn.y,i[2]=Bs.z,i[6]=Dc.z,i[10]=Zn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],p=n[2],x=n[6],g=n[10],m=n[14],y=n[3],v=n[7],_=n[11],w=n[15],T=i[0],E=i[4],M=i[8],b=i[12],P=i[1],N=i[5],L=i[9],U=i[13],V=i[2],O=i[6],k=i[10],G=i[14],it=i[3],nt=i[7],mt=i[11],xt=i[15];return s[0]=o*T+a*P+l*V+c*it,s[4]=o*E+a*N+l*O+c*nt,s[8]=o*M+a*L+l*k+c*mt,s[12]=o*b+a*U+l*G+c*xt,s[1]=h*T+u*P+d*V+f*it,s[5]=h*E+u*N+d*O+f*nt,s[9]=h*M+u*L+d*k+f*mt,s[13]=h*b+u*U+d*G+f*xt,s[2]=p*T+x*P+g*V+m*it,s[6]=p*E+x*N+g*O+m*nt,s[10]=p*M+x*L+g*k+m*mt,s[14]=p*b+x*U+g*G+m*xt,s[3]=y*T+v*P+_*V+w*it,s[7]=y*E+v*N+_*O+w*nt,s[11]=y*M+v*L+_*k+w*mt,s[15]=y*b+v*U+_*G+w*xt,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],n=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],p=t[3],x=t[7],g=t[11],m=t[15],y=l*f-c*d,v=a*f-c*u,_=a*d-l*u,w=o*f-c*h,T=o*d-l*h,E=o*u-a*h;return e*(x*y-g*v+m*_)-n*(p*y-g*w+m*T)+i*(p*v-x*w+m*E)-s*(p*_-x*T+g*E)}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,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],p=t[12],x=t[13],g=t[14],m=t[15],y=e*a-n*o,v=e*l-i*o,_=e*c-s*o,w=n*l-i*a,T=n*c-s*a,E=i*c-s*l,M=h*x-u*p,b=h*g-d*p,P=h*m-f*p,N=u*g-d*x,L=u*m-f*x,U=d*m-f*g,V=y*U-v*L+_*N+w*P-T*b+E*M;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/V;return t[0]=(a*U-l*L+c*N)*O,t[1]=(i*L-n*U-s*N)*O,t[2]=(x*E-g*T+m*w)*O,t[3]=(d*T-u*E-f*w)*O,t[4]=(l*P-o*U-c*b)*O,t[5]=(e*U-i*P+s*b)*O,t[6]=(g*_-p*E-m*v)*O,t[7]=(h*E-d*_+f*v)*O,t[8]=(o*L-a*P+c*M)*O,t[9]=(n*P-e*L-s*M)*O,t[10]=(p*T-x*_+m*y)*O,t[11]=(u*_-h*T-f*y)*O,t[12]=(a*b-o*N-l*M)*O,t[13]=(e*N-n*b+i*M)*O,t[14]=(x*v-p*w-g*y)*O,t[15]=(h*w-u*v+d*y)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),s=1-n,o=t.x,a=t.y,l=t.z,c=s*o,h=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+n,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,o){return this.set(1,n,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,h=o+o,u=a+a,d=s*c,f=s*h,p=s*u,x=o*h,g=o*u,m=a*u,y=l*c,v=l*h,_=l*u,w=n.x,T=n.y,E=n.z;return i[0]=(1-(x+m))*w,i[1]=(f+_)*w,i[2]=(p-v)*w,i[3]=0,i[4]=(f-_)*T,i[5]=(1-(d+m))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+v)*E,i[9]=(g-y)*E,i[10]=(1-(d+x))*E,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const s=this.determinant();if(s===0)return n.set(1,1,1),e.identity(),this;let o=fo.set(i[0],i[1],i[2]).length();const a=fo.set(i[4],i[5],i[6]).length(),l=fo.set(i[8],i[9],i[10]).length();s<0&&(o=-o),bi.copy(this);const c=1/o,h=1/a,u=1/l;return bi.elements[0]*=c,bi.elements[1]*=c,bi.elements[2]*=c,bi.elements[4]*=h,bi.elements[5]*=h,bi.elements[6]*=h,bi.elements[8]*=u,bi.elements[9]*=u,bi.elements[10]*=u,e.setFromRotationMatrix(bi),n.x=o,n.y=a,n.z=l,this}makePerspective(t,e,n,i,s,o,a=ti,l=!1){const c=this.elements,h=2*s/(e-t),u=2*s/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i);let p,x;if(l)p=s/(o-s),x=o*s/(o-s);else if(a===ti)p=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(a===Zr)p=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,s,o,a=ti,l=!1){const c=this.elements,h=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),f=-(n+i)/(n-i);let p,x;if(l)p=1/(o-s),x=o/(o-s);else if(a===ti)p=-2/(o-s),x=-(o+s)/(o-s);else if(a===Zr)p=-1/(o-s),x=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}};const fo=new R,bi=new Qt,hb=new R(0,0,0),ub=new R(1,1,1),Bs=new R,Dc=new R,Zn=new R,Zg=new Qt,Jg=new En;let mi=class F_{constructor(t=0,e=0,n=0,i=F_.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,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,n=!0){const i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(Jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Jt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Jt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Jt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:pt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Zg.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Zg,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Jg.setFromEuler(this),this.setFromQuaternion(Jg,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}};mi.DEFAULT_ORDER="XYZ";let gc=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},db=0;const jg=new R,po=new En,fs=new Qt,Uc=new R,Ba=new R,fb=new R,pb=new En,Kg=new R(1,0,0),Qg=new R(0,1,0),t0=new R(0,0,1),e0={type:"added"},mb={type:"removed"},mo={type:"childadded",child:null},Qd={type:"childremoved",child:null};let ve=class ou extends Bi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:db++}),this.uuid=ei(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ou.DEFAULT_UP.clone();const t=new R,e=new mi,n=new En,i=new R(1,1,1);function s(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Qt},normalMatrix:{value:new ae}}),this.matrix=new Qt,this.matrixWorld=new Qt,this.matrixAutoUpdate=ou.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ou.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return po.setFromAxisAngle(t,e),this.quaternion.multiply(po),this}rotateOnWorldAxis(t,e){return po.setFromAxisAngle(t,e),this.quaternion.premultiply(po),this}rotateX(t){return this.rotateOnAxis(Kg,t)}rotateY(t){return this.rotateOnAxis(Qg,t)}rotateZ(t){return this.rotateOnAxis(t0,t)}translateOnAxis(t,e){return jg.copy(t).applyQuaternion(this.quaternion),this.position.add(jg.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Kg,t)}translateY(t){return this.translateOnAxis(Qg,t)}translateZ(t){return this.translateOnAxis(t0,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(fs.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Uc.copy(t):Uc.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Ba.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?fs.lookAt(Ba,Uc,this.up):fs.lookAt(Uc,Ba,this.up),this.quaternion.setFromRotationMatrix(fs),i&&(fs.extractRotation(i.matrixWorld),po.setFromRotationMatrix(fs),this.quaternion.premultiply(po.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Vt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(e0),mo.child=t,this.dispatchEvent(mo),mo.child=null):Vt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(mb),Qd.child=t,this.dispatchEvent(Qd),Qd.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),fs.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),fs.multiply(t.parent.matrixWorld)),t.applyMatrix4(fs),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(e0),mo.child=t,this.dispatchEvent(mo),mo.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ba,t,fb),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ba,pb,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,i=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*i,s[13]+=n-s[1]*e-s[5]*n-s[9]*i,s[14]+=i-s[2]*e-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(t.shapes,u)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),h=o(t.images),u=o(t.shapes),d=o(t.skeletons),f=o(t.animations),p=o(t.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}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),t.pivot!==null&&(this.pivot=t.pivot.clone()),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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}};ve.DEFAULT_UP=new R(0,1,0);ve.DEFAULT_MATRIX_AUTO_UPDATE=!0;ve.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Gr extends ve{constructor(){super(),this.isGroup=!0,this.type="Group"}}const gb={type:"move"};class au{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Gr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(const x of t.hand.values()){const g=e.getJointPose(x,n),m=this._getHandJoint(c,x);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,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));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(gb)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Gr;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const D_={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},zs={h:0,s:0,l:0},Oc={h:0,s:0,l:0};function tf(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}let wt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Fn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,fe.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=fe.workingColorSpace){return this.r=t,this.g=e,this.b=n,fe.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=fe.workingColorSpace){if(t=rm(t,1),e=Jt(e,0,1),n=Jt(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,o=2*n-s;this.r=tf(o,s,t+1/3),this.g=tf(o,s,t),this.b=tf(o,s,t-1/3)}return fe.colorSpaceToWorking(this,i),this}setStyle(t,e=Fn){function n(s){s!==void 0&&parseFloat(s)<1&&pt("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:pt("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);pt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Fn){const n=D_[t.toLowerCase()];return n!==void 0?this.setHex(n,e):pt("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=Is(t.r),this.g=Is(t.g),this.b=Is(t.b),this}copyLinearToSRGB(t){return this.r=ia(t.r),this.g=ia(t.g),this.b=ia(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Fn){return fe.workingToColorSpace(vn.copy(this),t),Math.round(Jt(vn.r*255,0,255))*65536+Math.round(Jt(vn.g*255,0,255))*256+Math.round(Jt(vn.b*255,0,255))}getHexString(t=Fn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=fe.workingColorSpace){fe.workingToColorSpace(vn.copy(this),e);const n=vn.r,i=vn.g,s=vn.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=fe.workingColorSpace){return fe.workingToColorSpace(vn.copy(this),e),t.r=vn.r,t.g=vn.g,t.b=vn.b,t}getStyle(t=Fn){fe.workingToColorSpace(vn.copy(this),t);const e=vn.r,n=vn.g,i=vn.b;return t!==Fn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(zs),this.setHSL(zs.h+t,zs.s+e,zs.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(zs),t.getHSL(Oc);const n=fl(zs.h,Oc.h,e),i=fl(zs.s,Oc.s,e),s=fl(zs.l,Oc.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const vn=new wt;wt.NAMES=D_;class ad{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new wt(t),this.density=e}clone(){return new ad(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let lm=class U_{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new wt(t),this.near=e,this.far=n}clone(){return new U_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class cm extends ve{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new mi,this.environmentIntensity=1,this.environmentRotation=new mi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const Ti=new R,ps=new R,ef=new R,ms=new R,go=new R,xo=new R,n0=new R,nf=new R,sf=new R,rf=new R,of=new Le,af=new Le,lf=new Le;let ws=class $o{constructor(t=new R,e=new R,n=new R){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Ti.subVectors(t,e),i.cross(Ti);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){Ti.subVectors(i,e),ps.subVectors(n,e),ef.subVectors(t,e);const o=Ti.dot(Ti),a=Ti.dot(ps),l=Ti.dot(ef),c=ps.dot(ps),h=ps.dot(ef),u=o*c-a*a;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(c*l-a*h)*d,p=(o*h-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,ms)===null?!1:ms.x>=0&&ms.y>=0&&ms.x+ms.y<=1}static getInterpolation(t,e,n,i,s,o,a,l){return this.getBarycoord(t,e,n,i,ms)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,ms.x),l.addScaledVector(o,ms.y),l.addScaledVector(a,ms.z),l)}static getInterpolatedAttribute(t,e,n,i,s,o){return of.setScalar(0),af.setScalar(0),lf.setScalar(0),of.fromBufferAttribute(t,e),af.fromBufferAttribute(t,n),lf.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(of,s.x),o.addScaledVector(af,s.y),o.addScaledVector(lf,s.z),o}static isFrontFacing(t,e,n,i){return Ti.subVectors(n,e),ps.subVectors(t,e),Ti.cross(ps).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ti.subVectors(this.c,this.b),ps.subVectors(this.a,this.b),Ti.cross(ps).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return $o.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return $o.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return $o.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return $o.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return $o.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,s=this.c;let o,a;go.subVectors(i,n),xo.subVectors(s,n),nf.subVectors(t,n);const l=go.dot(nf),c=xo.dot(nf);if(l<=0&&c<=0)return e.copy(n);sf.subVectors(t,i);const h=go.dot(sf),u=xo.dot(sf);if(h>=0&&u<=h)return e.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(n).addScaledVector(go,o);rf.subVectors(t,s);const f=go.dot(rf),p=xo.dot(rf);if(p>=0&&f<=p)return e.copy(s);const x=f*c-l*p;if(x<=0&&c>=0&&p<=0)return a=c/(c-p),e.copy(n).addScaledVector(xo,a);const g=h*p-f*u;if(g<=0&&u-h>=0&&f-p>=0)return n0.subVectors(s,i),a=(u-h)/(u-h+(f-p)),e.copy(i).addScaledVector(n0,a);const m=1/(g+x+d);return o=x*m,a=d*m,e.copy(n).addScaledVector(go,o).addScaledVector(xo,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},mn=class{constructor(t=new R(1/0,1/0,1/0),e=new R(-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,n=t.length;e<n;e+=3)this.expandByPoint(wi.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(wi.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=wi.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,wi):wi.fromBufferAttribute(s,o),wi.applyMatrix4(t.matrixWorld),this.expandByPoint(wi);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Bc.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Bc.copy(n.boundingBox)),Bc.applyMatrix4(t.matrixWorld),this.union(Bc)}const i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.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.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,wi),wi.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(za),zc.subVectors(this.max,za),yo.subVectors(t.a,za),_o.subVectors(t.b,za),vo.subVectors(t.c,za),Vs.subVectors(_o,yo),ks.subVectors(vo,_o),yr.subVectors(yo,vo);let e=[0,-Vs.z,Vs.y,0,-ks.z,ks.y,0,-yr.z,yr.y,Vs.z,0,-Vs.x,ks.z,0,-ks.x,yr.z,0,-yr.x,-Vs.y,Vs.x,0,-ks.y,ks.x,0,-yr.y,yr.x,0];return!cf(e,yo,_o,vo,zc)||(e=[1,0,0,0,1,0,0,0,1],!cf(e,yo,_o,vo,zc))?!1:(Vc.crossVectors(Vs,ks),e=[Vc.x,Vc.y,Vc.z],cf(e,yo,_o,vo,zc))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,wi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(wi).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:(gs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),gs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),gs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),gs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),gs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),gs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),gs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),gs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(gs),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}};const gs=[new R,new R,new R,new R,new R,new R,new R,new R],wi=new R,Bc=new mn,yo=new R,_o=new R,vo=new R,Vs=new R,ks=new R,yr=new R,za=new R,zc=new R,Vc=new R,_r=new R;function cf(r,t,e,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){_r.fromArray(r,s);const a=i.x*Math.abs(_r.x)+i.y*Math.abs(_r.y)+i.z*Math.abs(_r.z),l=t.dot(_r),c=e.dot(_r),h=n.dot(_r);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const As=xb();function xb(){const r=new ArrayBuffer(4),t=new Float32Array(r),e=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function Gn(r){Math.abs(r)>65504&&pt("DataUtils.toHalfFloat(): Value out of range."),r=Jt(r,-65504,65504),As.floatView[0]=r;const t=As.uint32View[0],e=t>>23&511;return As.baseTable[e]+((t&8388607)>>As.shiftTable[e])}function ol(r){const t=r>>10;return As.uint32View[0]=As.mantissaTable[As.offsetTable[t]+(r&1023)]+As.exponentTable[t],As.floatView[0]}class O_{static toHalfFloat(t){return Gn(t)}static fromHalfFloat(t){return ol(t)}}const Ze=new R,kc=new tt;let yb=0,Te=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:yb++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=jl,this.updateRanges=[],this.gpuType=Tn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)kc.fromBufferAttribute(this,e),kc.applyMatrix3(t),this.setXY(e,kc.x,kc.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.applyMatrix3(t),this.setXYZ(e,Ze.x,Ze.y,Ze.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.applyMatrix4(t),this.setXYZ(e,Ze.x,Ze.y,Ze.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.applyNormalMatrix(t),this.setXYZ(e,Ze.x,Ze.y,Ze.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ze.fromBufferAttribute(this,e),Ze.transformDirection(t),this.setXYZ(e,Ze.x,Ze.y,Ze.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=On(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=le(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=On(e,this.array)),e}setX(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=On(e,this.array)),e}setY(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=On(e,this.array)),e}setZ(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=On(e,this.array)),e}setW(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array),s=le(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==jl&&(t.usage=this.usage),t}};class _b extends Te{constructor(t,e,n){super(new Int8Array(t),e,n)}}class vb extends Te{constructor(t,e,n){super(new Uint8Array(t),e,n)}}class Mb extends Te{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}}class Sb extends Te{constructor(t,e,n){super(new Int16Array(t),e,n)}}let ld=class extends Te{constructor(t,e,n){super(new Uint16Array(t),e,n)}};class bb extends Te{constructor(t,e,n){super(new Int32Array(t),e,n)}}let hm=class extends Te{constructor(t,e,n){super(new Uint32Array(t),e,n)}};class Tb extends Te{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=ol(this.array[t*this.itemSize]);return this.normalized&&(e=On(e,this.array)),e}setX(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize]=Gn(e),this}getY(t){let e=ol(this.array[t*this.itemSize+1]);return this.normalized&&(e=On(e,this.array)),e}setY(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+1]=Gn(e),this}getZ(t){let e=ol(this.array[t*this.itemSize+2]);return this.normalized&&(e=On(e,this.array)),e}setZ(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+2]=Gn(e),this}getW(t){let e=ol(this.array[t*this.itemSize+3]);return this.normalized&&(e=On(e,this.array)),e}setW(t,e){return this.normalized&&(e=le(e,this.array)),this.array[t*this.itemSize+3]=Gn(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array)),this.array[t+0]=Gn(e),this.array[t+1]=Gn(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array)),this.array[t+0]=Gn(e),this.array[t+1]=Gn(n),this.array[t+2]=Gn(i),this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array),s=le(s,this.array)),this.array[t+0]=Gn(e),this.array[t+1]=Gn(n),this.array[t+2]=Gn(i),this.array[t+3]=Gn(s),this}}let Ct=class extends Te{constructor(t,e,n){super(new Float32Array(t),e,n)}};const wb=new mn,Va=new R,hf=new R;let un=class{constructor(t=new R,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 n=this.center;e!==void 0?n.copy(e):wb.setFromPoints(t).getCenter(n);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.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;Va.subVectors(t,this.center);const e=Va.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Va,i/n),this.radius+=i}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):(hf.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Va.copy(t.center).add(hf)),this.expandByPoint(Va.copy(t.center).sub(hf))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},Ab=0;const oi=new Qt,uf=new ve,Mo=new R,Jn=new mn,ka=new mn,an=new R;let se=class B_ extends Bi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ab++}),this.uuid=ei(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(OS(t)?hm:ld)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new ae().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return oi.makeRotationFromQuaternion(t),this.applyMatrix4(oi),this}rotateX(t){return oi.makeRotationX(t),this.applyMatrix4(oi),this}rotateY(t){return oi.makeRotationY(t),this.applyMatrix4(oi),this}rotateZ(t){return oi.makeRotationZ(t),this.applyMatrix4(oi),this}translate(t,e,n){return oi.makeTranslation(t,e,n),this.applyMatrix4(oi),this}scale(t,e,n){return oi.makeScale(t,e,n),this.applyMatrix4(oi),this}lookAt(t){return uf.lookAt(t),uf.updateMatrix(),this.applyMatrix4(uf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Mo).negate(),this.translate(Mo.x,Mo.y,Mo.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let i=0,s=t.length;i<s;i++){const o=t[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ct(n,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&pt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Vt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const s=e[n];Jn.setFromBufferAttribute(s),this.morphTargetsRelative?(an.addVectors(this.boundingBox.min,Jn.min),this.boundingBox.expandByPoint(an),an.addVectors(this.boundingBox.max,Jn.max),this.boundingBox.expandByPoint(an)):(this.boundingBox.expandByPoint(Jn.min),this.boundingBox.expandByPoint(Jn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new un);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Vt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(t){const n=this.boundingSphere.center;if(Jn.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];ka.setFromBufferAttribute(a),this.morphTargetsRelative?(an.addVectors(Jn.min,ka.min),Jn.expandByPoint(an),an.addVectors(Jn.max,ka.max),Jn.expandByPoint(an)):(Jn.expandByPoint(ka.min),Jn.expandByPoint(ka.max))}Jn.getCenter(n);let i=0;for(let s=0,o=t.count;s<o;s++)an.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(an));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)an.fromBufferAttribute(a,c),l&&(Mo.fromBufferAttribute(t,c),an.add(Mo)),i=Math.max(i,n.distanceToSquared(an))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Vt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Vt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Te(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let M=0;M<n.count;M++)a[M]=new R,l[M]=new R;const c=new R,h=new R,u=new R,d=new tt,f=new tt,p=new tt,x=new R,g=new R;function m(M,b,P){c.fromBufferAttribute(n,M),h.fromBufferAttribute(n,b),u.fromBufferAttribute(n,P),d.fromBufferAttribute(s,M),f.fromBufferAttribute(s,b),p.fromBufferAttribute(s,P),h.sub(c),u.sub(c),f.sub(d),p.sub(d);const N=1/(f.x*p.y-p.x*f.y);isFinite(N)&&(x.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(N),g.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(N),a[M].add(x),a[b].add(x),a[P].add(x),l[M].add(g),l[b].add(g),l[P].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let M=0,b=y.length;M<b;++M){const P=y[M],N=P.start,L=P.count;for(let U=N,V=N+L;U<V;U+=3)m(t.getX(U+0),t.getX(U+1),t.getX(U+2))}const v=new R,_=new R,w=new R,T=new R;function E(M){w.fromBufferAttribute(i,M),T.copy(w);const b=a[M];v.copy(b),v.sub(w.multiplyScalar(w.dot(b))).normalize(),_.crossVectors(T,b);const N=_.dot(l[M])<0?-1:1;o.setXYZW(M,v.x,v.y,v.z,N)}for(let M=0,b=y.length;M<b;++M){const P=y[M],N=P.start,L=P.count;for(let U=N,V=N+L;U<V;U+=3)E(t.getX(U+0)),E(t.getX(U+1)),E(t.getX(U+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Te(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new R,s=new R,o=new R,a=new R,l=new R,c=new R,h=new R,u=new R;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),x=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,x),o.fromBufferAttribute(e,g),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),a.fromBufferAttribute(n,p),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,g),a.add(h),l.add(h),c.add(h),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)an.fromBufferAttribute(t,e),an.normalize(),t.setXYZ(e,an.x,an.y,an.z)}toNonIndexed(){function t(a,l){const c=a.array,h=a.itemSize,u=a.normalized,d=new c.constructor(l.length*h);let f=0,p=0;for(let x=0,g=l.length;x<g;x++){a.isInterleavedBufferAttribute?f=l[x]*a.data.stride+a.offset:f=l[x]*h;for(let m=0;m<h;m++)d[p++]=c[f++]}return new Te(d,h,u)}if(this.index===null)return pt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new B_,n=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=t(l,n);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);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 n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),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 n=t.index;n!==null&&this.setIndex(n.clone());const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},xc=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=jl,this.updateRanges=[],this.version=0,this.uuid=ei()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ei()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ei()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const In=new R;let da=class z_{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)In.fromBufferAttribute(this,e),In.applyMatrix4(t),this.setXYZ(e,In.x,In.y,In.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)In.fromBufferAttribute(this,e),In.applyNormalMatrix(t),this.setXYZ(e,In.x,In.y,In.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)In.fromBufferAttribute(this,e),In.transformDirection(t),this.setXYZ(e,In.x,In.y,In.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=On(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=le(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=le(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=le(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=le(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=le(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=On(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=On(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=On(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=On(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=le(e,this.array),n=le(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=le(e,this.array),n=le(n,this.array),i=le(i,this.array),s=le(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){Ql("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Te(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new z_(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Ql("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Eb=0,gn=class extends Bi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Eb++}),this.uuid=ei(),this.name="",this.type="Material",this.blending=nr,this.side=is,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=du,this.blendDst=fu,this.blendEquation=Qs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new wt(0,0,0),this.blendAlpha=0,this.depthFunc=rr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Cu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ks,this.stencilZFail=Ks,this.stencilZPass=Ks,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){pt(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){pt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==nr&&(n.blending=this.blending),this.side!==is&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==du&&(n.blendSrc=this.blendSrc),this.blendDst!==fu&&(n.blendDst=this.blendDst),this.blendEquation!==Qs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==rr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Cu&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ks&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ks&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ks&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};class cd extends gn{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new wt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let So;const Ga=new R,bo=new R,To=new R,wo=new tt,Ha=new tt,V_=new Qt,Gc=new R,Wa=new R,Hc=new R,i0=new tt,df=new tt,s0=new tt;class um extends ve{constructor(t=new cd){if(super(),this.isSprite=!0,this.type="Sprite",So===void 0){So=new se;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new xc(e,5);So.setIndex([0,1,2,0,2,3]),So.setAttribute("position",new da(n,3,0,!1)),So.setAttribute("uv",new da(n,2,3,!1))}this.geometry=So,this.material=t,this.center=new tt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Vt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),bo.setFromMatrixScale(this.matrixWorld),V_.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),To.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&bo.multiplyScalar(-To.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const o=this.center;Wc(Gc.set(-.5,-.5,0),To,o,bo,i,s),Wc(Wa.set(.5,-.5,0),To,o,bo,i,s),Wc(Hc.set(.5,.5,0),To,o,bo,i,s),i0.set(0,0),df.set(1,0),s0.set(1,1);let a=t.ray.intersectTriangle(Gc,Wa,Hc,!1,Ga);if(a===null&&(Wc(Wa.set(-.5,.5,0),To,o,bo,i,s),df.set(0,1),a=t.ray.intersectTriangle(Gc,Hc,Wa,!1,Ga),a===null))return;const l=t.ray.origin.distanceTo(Ga);l<t.near||l>t.far||e.push({distance:l,point:Ga.clone(),uv:ws.getInterpolation(Ga,Gc,Wa,Hc,i0,df,s0,new tt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function Wc(r,t,e,n,i,s){wo.subVectors(r,e).addScalar(.5).multiply(n),i!==void 0?(Ha.x=s*wo.x-i*wo.y,Ha.y=i*wo.x+s*wo.y):Ha.copy(wo),r.copy(t),r.x+=Ha.x,r.y+=Ha.y,r.applyMatrix4(V_)}const Xc=new R,r0=new R;class dm extends ve{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let n=0,i=e.length;n<i;n++){const s=e[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let s;for(s=0;s<i.length&&!(e<i[s].distance);s++);return i.splice(s,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){const i=e.splice(n,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let s=e[n].distance;if(e[n].object.visible&&(s-=s*e[n].hysteresis),t<s)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Xc.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(Xc);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Xc.setFromMatrixPosition(t.matrixWorld),r0.setFromMatrixPosition(this.matrixWorld);const n=Xc.distanceTo(r0)/t.zoom;e[0].object.visible=!0;let i,s;for(i=1,s=e.length;i<s;i++){let o=e[i].distance;if(e[i].object.visible&&(o-=o*e[i].hysteresis),n>=o)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);this.autoUpdate===!1&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const o=n[i];e.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return e}}const xs=new R,ff=new R,$c=new R,Gs=new R,pf=new R,qc=new R,mf=new R;let eo=class{constructor(t=new R,e=new R(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,xs)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=xs.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(xs.copy(this.origin).addScaledVector(this.direction,e),xs.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ff.copy(t).add(e).multiplyScalar(.5),$c.copy(e).sub(t).normalize(),Gs.copy(this.origin).sub(ff);const s=t.distanceTo(e)*.5,o=-this.direction.dot($c),a=Gs.dot(this.direction),l=-Gs.dot($c),c=Gs.lengthSq(),h=Math.abs(1-o*o);let u,d,f,p;if(h>0)if(u=o*l-a,d=o*a-l,p=s*h,u>=0)if(d>=-p)if(d<=p){const x=1/h;u*=x,d*=x,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-p?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=p?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(ff).addScaledVector($c,d),f}intersectSphere(t,e){xs.subVectors(t.center,this.origin);const n=xs.dot(this.direction),i=xs.dot(xs)-n*n,s=t.radius*t.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(s=(t.min.y-d.y)*h,o=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,o=(t.min.y-d.y)*h),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),u>=0?(a=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,xs)!==null}intersectTriangle(t,e,n,i,s){pf.subVectors(e,t),qc.subVectors(n,t),mf.crossVectors(pf,qc);let o=this.direction.dot(mf),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Gs.subVectors(this.origin,t);const l=a*this.direction.dot(qc.crossVectors(Gs,qc));if(l<0)return null;const c=a*this.direction.dot(pf.cross(Gs));if(c<0||l+c>o)return null;const h=-a*Gs.dot(mf);return h<0?null:this.at(h/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ds=class extends gn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new wt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=uc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}};const o0=new Qt,vr=new eo,Yc=new un,a0=new R,Zc=new R,Jc=new R,jc=new R,gf=new R,Kc=new R,l0=new R,Qc=new R;let Ye=class extends ve{constructor(t=new se,e=new Ds){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){Kc.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],u=s[l];h!==0&&(gf.fromBufferAttribute(u,t),o?Kc.addScaledVector(gf,h):Kc.addScaledVector(gf.sub(e),h))}e.add(Kc)}return e}raycast(t,e){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Yc.copy(n.boundingSphere),Yc.applyMatrix4(s),vr.copy(t.ray).recast(t.near),!(Yc.containsPoint(vr.origin)===!1&&(vr.intersectSphere(Yc,a0)===null||vr.origin.distanceToSquared(a0)>(t.far-t.near)**2))&&(o0.copy(s).invert(),vr.copy(t.ray).applyMatrix4(o0),!(n.boundingBox!==null&&vr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,vr)))}_computeIntersections(t,e,n){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,x=d.length;p<x;p++){const g=d[p],m=o[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,w=v;_<w;_+=3){const T=a.getX(_),E=a.getX(_+1),M=a.getX(_+2);i=th(this,m,t,n,c,h,u,T,E,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let g=p,m=x;g<m;g+=3){const y=a.getX(g),v=a.getX(g+1),_=a.getX(g+2);i=th(this,o,t,n,c,h,u,y,v,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let p=0,x=d.length;p<x;p++){const g=d[p],m=o[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,w=v;_<w;_+=3){const T=_,E=_+1,M=_+2;i=th(this,m,t,n,c,h,u,T,E,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),x=Math.min(l.count,f.start+f.count);for(let g=p,m=x;g<m;g+=3){const y=g,v=g+1,_=g+2;i=th(this,o,t,n,c,h,u,y,v,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}}};function Cb(r,t,e,n,i,s,o,a){let l;if(t.side===An?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,t.side===is,a),l===null)return null;Qc.copy(a),Qc.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(Qc);return c<e.near||c>e.far?null:{distance:c,point:Qc.clone(),object:r}}function th(r,t,e,n,i,s,o,a,l,c){r.getVertexPosition(a,Zc),r.getVertexPosition(l,Jc),r.getVertexPosition(c,jc);const h=Cb(r,t,e,n,Zc,Jc,jc,l0);if(h){const u=new R;ws.getBarycoord(l0,Zc,Jc,jc,u),i&&(h.uv=ws.getInterpolatedAttribute(i,a,l,c,u,new tt)),s&&(h.uv1=ws.getInterpolatedAttribute(s,a,l,c,u,new tt)),o&&(h.normal=ws.getInterpolatedAttribute(o,a,l,c,u,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new R,materialIndex:0};ws.getNormal(Zc,Jc,jc,d.normal),h.face=d,h.barycoord=u}return h}const c0=new R,h0=new Le,u0=new Le,Nb=new R,d0=new Qt,eh=new R,xf=new un,f0=new Qt,yf=new eo;class fm extends Ye{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=bp,this.bindMatrix=new Qt,this.bindMatrixInverse=new Qt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new mn),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,eh),this.boundingBox.expandByPoint(eh)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new un),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,eh),this.boundingSphere.expandByPoint(eh)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xf.copy(this.boundingSphere),xf.applyMatrix4(i),t.ray.intersectsSphere(xf)!==!1&&(f0.copy(i).invert(),yf.copy(t.ray).applyMatrix4(f0),!(this.boundingBox!==null&&yf.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,yf)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Le,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===bp?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Jy?this.bindMatrixInverse.copy(this.bindMatrix).invert():pt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;h0.fromBufferAttribute(i.attributes.skinIndex,t),u0.fromBufferAttribute(i.attributes.skinWeight,t),c0.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const o=u0.getComponent(s);if(o!==0){const a=h0.getComponent(s);d0.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),e.addScaledVector(Nb.copy(c0).applyMatrix4(d0),o)}}return e.applyMatrix4(this.bindMatrixInverse)}}class hd extends ve{constructor(){super(),this.isBone=!0,this.type="Bone"}}class fi extends rn{constructor(t=null,e=1,n=1,i,s,o,a,l,c=Xe,h=Xe,u,d){super(null,o,a,l,c,h,i,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const p0=new Qt,Rb=new Qt;class yc{constructor(t=[],e=[]){this.uuid=ei(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){pt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Qt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const n=new Qt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,o=t.length;s<o;s++){const a=t[s]?t[s].matrixWorld:Rb;p0.multiplyMatrices(a,e[s]),p0.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new yc(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new fi(e,t,t,wn,Tn);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const s=t.bones[n];let o=e[s];o===void 0&&(pt("Skeleton: No bone found with UUID:",s),o=new hd),this.bones.push(o),this.boneInverses.push(new Qt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,s=e.length;i<s;i++){const o=e[i];t.bones.push(o.uuid);const a=n[i];t.boneInverses.push(a.toArray())}return t}}let Jr=class extends Te{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};const Ao=new Qt,m0=new Qt,nh=[],g0=new mn,Ib=new Qt,Xa=new Ye,$a=new un;class pm extends Ye{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Jr(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Ib)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new mn),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Ao),g0.copy(t.boundingBox).applyMatrix4(Ao),this.boundingBox.union(g0)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new un),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Ao),$a.copy(t.boundingSphere).applyMatrix4(Ao),this.boundingSphere.union($a)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=t.previousInstanceMatrix.clone()),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,s=n.length+1,o=t*s+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Xa.geometry=this.geometry,Xa.material=this.material,Xa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),$a.copy(this.boundingSphere),$a.applyMatrix4(n),t.ray.intersectsSphere($a)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Ao),m0.multiplyMatrices(n,Ao),Xa.matrixWorld=m0,Xa.raycast(t,nh);for(let o=0,a=nh.length;o<a;o++){const l=nh[o];l.instanceId=s,l.object=this,e.push(l)}nh.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new Jr(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new fi(new Float32Array(i*this.count),i,this.count,dc,Tn));const s=this.morphTexture.source.data.data;let o=0;for(let c=0;c<n.length;c++)o+=n[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=i*t;s[l]=a,s.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const _f=new R,Pb=new R,Lb=new ae;let Ts=class{constructor(t=new R(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=_f.subVectors(n,e).cross(Pb.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(_f),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Lb.getNormalMatrix(t),i=this.coplanarPoint(_f).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Mr=new un,Fb=new tt(.5,.5),ih=new R;let no=class{constructor(t=new Ts,e=new Ts,n=new Ts,i=new Ts,s=new Ts,o=new Ts){this.planes=[t,e,n,i,s,o]}set(t,e,n,i,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=ti,n=!1){const i=this.planes,s=t.elements,o=s[0],a=s[1],l=s[2],c=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],x=s[9],g=s[10],m=s[11],y=s[12],v=s[13],_=s[14],w=s[15];if(i[0].setComponents(c-o,f-h,m-p,w-y).normalize(),i[1].setComponents(c+o,f+h,m+p,w+y).normalize(),i[2].setComponents(c+a,f+u,m+x,w+v).normalize(),i[3].setComponents(c-a,f-u,m-x,w-v).normalize(),n)i[4].setComponents(l,d,g,_).normalize(),i[5].setComponents(c-l,f-d,m-g,w-_).normalize();else if(i[4].setComponents(c-l,f-d,m-g,w-_).normalize(),e===ti)i[5].setComponents(c+l,f+d,m+g,w+_).normalize();else if(e===Zr)i[5].setComponents(l,d,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Mr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Mr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Mr)}intersectsSprite(t){Mr.center.set(0,0,0);const e=Fb.distanceTo(t.center);return Mr.radius=.7071067811865476+e,Mr.applyMatrix4(t.matrixWorld),this.intersectsSphere(Mr)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(ih.x=i.normal.x>0?t.max.x:t.min.x,ih.y=i.normal.y>0?t.max.y:t.min.y,ih.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ih)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};const Gi=new Qt,Hi=new no;class ud{constructor(){this.coordinateSystem=ti}intersectsObject(t,e){if(!e.isArrayCamera||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(Gi.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Hi.setFromProjectionMatrix(Gi,i.coordinateSystem,i.reversedDepth),Hi.containsPoint(t))return!0}return!1}clone(){return new ud}}function vf(r,t){return r-t}function Db(r,t){return r.z-t.z}function Ub(r,t){return t.z-r.z}class Ob{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){const s=this.pool,o=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const a=s[this.index];o.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const kn=new Qt,Bb=new wt(1,1,1),x0=new no,zb=new ud,sh=new mn,Sr=new un,qa=new R,y0=new R,Vb=new R,Mf=new Ob,Mn=new Ye,rh=[];function kb(r,t,e=0){const n=t.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==t.array.constructor){const i=r.count;for(let s=0;s<i;s++)for(let o=0;o<n;o++)t.setComponent(s+e,o,r.getComponent(s,o))}else t.array.set(r.array,e*n);t.needsUpdate=!0}function br(r,t){if(r.constructor!==t.constructor){const e=Math.min(r.length,t.length);for(let n=0;n<e;n++)t[n]=r[n]}else{const e=Math.min(r.length,t.length);t.set(new r.constructor(r.buffer,0,e))}}class mm extends Ye{constructor(t,e,n=e*2,i){super(new se,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(this._maxInstanceCount*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new fi(e,t,t,wn,Tn);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),n=new fi(e,t,t,Sa,ii);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),n=new fi(e,t,t,wn,Tn);n.colorSpace=fe.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in t.attributes){const o=t.getAttribute(s),{array:a,itemSize:l,normalized:c}=o,h=new a.constructor(n*l),u=new Te(h,l,c);e.setAttribute(s,u)}if(t.getIndex()!==null){const s=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new Te(s,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),s=e.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mn);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;const s=e[n].geometryIndex;this.getMatrixAt(n,kn),this.getBoundingBoxAt(s,sh).applyMatrix4(kn),t.union(sh)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new un);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;const s=e[n].geometryIndex;this.getMatrixAt(n,kn),this.getBoundingSphereAt(s,Sr).applyMatrix4(kn),t.union(Sr)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:t};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(vf),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;kn.identity().toArray(s.image.data,i*16),s.needsUpdate=!0;const o=this._colorsTexture;return o&&(Bb.toArray(o.image.data,i*4),o.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=e===-1?t.getAttribute("position").count:e;const o=t.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?o.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(vf),l=this._availableGeometryIds.shift(),s[l]=i):(l=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(l,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=n.getIndex()!==null,s=n.getIndex(),o=e.getIndex(),a=this._geometryInfo[t];if(i&&o.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const h in n.attributes){const u=e.getAttribute(h),d=n.getAttribute(h);kb(u,d,l);const f=u.itemSize;for(let p=u.count,x=c;p<x;p++){const g=l+p;for(let m=0;m<f;m++)d.setComponent(g,m,0)}d.needsUpdate=!0,d.addUpdateRange(l*f,c*f)}if(i){const h=a.indexStart,u=a.reservedIndexCount;a.indexCount=e.getIndex().count;for(let d=0;d<o.count;d++)s.setX(h+d,l+o.getX(d));for(let d=o.count,f=u;d<f;d++)s.setX(h+d,l);s.needsUpdate=!0,s.addUpdateRange(h,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,e.boundingBox!==null&&(a.boundingBox=e.boundingBox.clone()),a.boundingSphere=null,e.boundingSphere!==null&&(a.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||e[t].active===!1)return this;const n=this._instanceInfo;for(let i=0,s=n.length;i<s;i++)n[i].active&&n[i].geometryIndex===t&&this.deleteInstance(i);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),s=this.geometry;for(let o=0,a=n.length;o<a;o++){const l=i[o],c=n[l];if(c.active!==!1){if(s.index!==null){if(c.indexStart!==e){const{indexStart:h,vertexStart:u,reservedIndexCount:d}=c,f=s.index,p=f.array,x=t-u;for(let g=h;g<h+d;g++)p[g]=p[g]+x;f.array.copyWithin(e,h,h+d),f.addUpdateRange(e,d),f.needsUpdate=!0,c.indexStart=e}e+=c.reservedIndexCount}if(c.vertexStart!==t){const{vertexStart:h,reservedVertexCount:u}=c,d=s.attributes;for(const f in d){const p=d[f],{array:x,itemSize:g}=p;x.copyWithin(t*g,h*g,(h+u)*g),p.addUpdateRange(t*g,u*g),p.needsUpdate=!0}c.vertexStart=t}t+=c.reservedVertexCount,c.start=s.index?c.indexStart:c.vertexStart}}return this._nextIndexStart=e,this._nextVertexStart=t,this._visibilityChanged=!0,this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(i.boundingBox===null){const s=new mn,o=n.index,a=n.attributes.position;for(let l=i.start,c=i.start+i.count;l<c;l++){let h=l;o&&(h=o.getX(h)),s.expandByPoint(qa.fromBufferAttribute(a,h))}i.boundingBox=s}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(i.boundingSphere===null){const s=new un;this.getBoundingBoxAt(t,sh),sh.getCenter(s.center);const o=n.index,a=n.attributes.position;let l=0;for(let c=i.start,h=i.start+i.count;c<h;c++){let u=c;o&&(u=o.getX(u)),qa.fromBufferAttribute(a,u),l=Math.max(l,s.center.distanceToSquared(qa))}s.radius=Math.sqrt(l),i.boundingSphere=s}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const n=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,t*16),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,t*16)}setColorAt(t,e){return this.validateInstanceId(t),this._colorsTexture===null&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,t*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,t*4)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e?this:(this._instanceInfo[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(vf);e[e.length-1]===n.length-1;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const i=new Int32Array(t),s=new Int32Array(t);br(this._multiDrawCounts,i),br(this._multiDrawStarts,s),this._multiDrawCounts=i,this._multiDrawStarts=s,this._maxInstanceCount=t;const o=this._indirectTexture,a=this._matricesTexture,l=this._colorsTexture;o.dispose(),this._initIndirectTexture(),br(o.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),br(a.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),br(l.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const n=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new se,this._initializeGeometry(s));const o=this.geometry;s.index&&br(s.index.array,o.index.array);for(const a in s.attributes)br(s.attributes[a].array,o.attributes[a].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,s=this.matrixWorld,o=this.geometry;Mn.material=this.material,Mn.geometry.index=o.index,Mn.geometry.attributes=o.attributes,Mn.geometry.boundingBox===null&&(Mn.geometry.boundingBox=new mn),Mn.geometry.boundingSphere===null&&(Mn.geometry.boundingSphere=new un);for(let a=0,l=n.length;a<l;a++){if(!n[a].visible||!n[a].active)continue;const c=n[a].geometryIndex,h=i[c];Mn.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(a,Mn.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,Mn.geometry.boundingBox),this.getBoundingSphereAt(c,Mn.geometry.boundingSphere),Mn.raycast(t,rh);for(let u=0,d=rh.length;u<d;u++){const f=rh[u];f.object=this,f.batchId=a,e.push(f)}rh.length=0}Mn.material=null,Mn.geometry.index=null,Mn.geometry.attributes={},Mn.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex();let a=o===null?1:o.array.BYTES_PER_ELEMENT,l=1;s.wireframe&&(l=2,a=i.attributes.position.count>65535?4:2);const c=this._instanceInfo,h=this._multiDrawStarts,u=this._multiDrawCounts,d=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,x=p.image.data,g=n.isArrayCamera?zb:x0;f&&!n.isArrayCamera&&(kn.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),x0.setFromProjectionMatrix(kn,n.coordinateSystem,n.reversedDepth));let m=0;if(this.sortObjects){kn.copy(this.matrixWorld).invert(),qa.setFromMatrixPosition(n.matrixWorld).applyMatrix4(kn),y0.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(kn);for(let _=0,w=c.length;_<w;_++)if(c[_].visible&&c[_].active){const T=c[_].geometryIndex;this.getMatrixAt(_,kn),this.getBoundingSphereAt(T,Sr).applyMatrix4(kn);let E=!1;if(f&&(E=!g.intersectsSphere(Sr,n)),!E){const M=d[T],b=Vb.subVectors(Sr.center,qa).dot(y0);Mf.push(M.start,M.count,b,_)}}const y=Mf.list,v=this.customSort;v===null?y.sort(s.transparent?Ub:Db):v.call(this,y,n);for(let _=0,w=y.length;_<w;_++){const T=y[_];h[m]=T.start*a*l,u[m]=T.count*l,x[m]=T.index,m++}Mf.reset()}else for(let y=0,v=c.length;y<v;y++)if(c[y].visible&&c[y].active){const _=c[y].geometryIndex;let w=!1;if(f&&(this.getMatrixAt(y,kn),this.getBoundingSphereAt(_,Sr).applyMatrix4(kn),w=!g.intersectsSphere(Sr,n)),!w){const T=d[_];h[m]=T.start*a*l,u[m]=T.count*l,x[m]=y,m++}}p.needsUpdate=!0,this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,s,o){this.onBeforeRender(t,null,i,s,o)}}class Rn extends gn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new wt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Ru=new R,Iu=new R,_0=new Qt,Ya=new eo,oh=new un,Sf=new R,v0=new R;class Fs extends ve{constructor(t=new se,e=new Rn){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[0];for(let i=1,s=e.count;i<s;i++)Ru.fromBufferAttribute(e,i-1),Iu.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=Ru.distanceTo(Iu);t.setAttribute("lineDistance",new Ct(n,1))}else pt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),oh.copy(n.boundingSphere),oh.applyMatrix4(i),oh.radius+=s,t.ray.intersectsSphere(oh)===!1)return;_0.copy(i).invert(),Ya.copy(t.ray).applyMatrix4(_0);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let x=f,g=p-1;x<g;x+=c){const m=h.getX(x),y=h.getX(x+1),v=ah(this,t,Ya,l,m,y,x);v&&e.push(v)}if(this.isLineLoop){const x=h.getX(p-1),g=h.getX(f),m=ah(this,t,Ya,l,x,g,p-1);m&&e.push(m)}}else{const f=Math.max(0,o.start),p=Math.min(d.count,o.start+o.count);for(let x=f,g=p-1;x<g;x+=c){const m=ah(this,t,Ya,l,x,x+1,x);m&&e.push(m)}if(this.isLineLoop){const x=ah(this,t,Ya,l,p-1,f,p-1);x&&e.push(x)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function ah(r,t,e,n,i,s,o){const a=r.geometry.attributes.position;if(Ru.fromBufferAttribute(a,i),Iu.fromBufferAttribute(a,s),e.distanceSqToSegment(Ru,Iu,Sf,v0)>n)return;Sf.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(Sf);if(!(c<t.near||c>t.far))return{distance:c,point:v0.clone().applyMatrix4(r.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:r}}const M0=new R,S0=new R;class zi extends Fs{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,s=e.count;i<s;i+=2)M0.fromBufferAttribute(e,i),S0.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+M0.distanceTo(S0);t.setAttribute("lineDistance",new Ct(n,1))}else pt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class gm extends Fs{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class dd extends gn{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new wt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const b0=new Qt,Ap=new eo,lh=new un,ch=new R;class xm extends ve{constructor(t=new se,e=new dd){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,s=t.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),lh.copy(n.boundingSphere),lh.applyMatrix4(i),lh.radius+=s,t.ray.intersectsSphere(lh)===!1)return;b0.copy(i).invert(),Ap.copy(t.ray).applyMatrix4(b0);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,o.start),f=Math.min(c.count,o.start+o.count);for(let p=d,x=f;p<x;p++){const g=c.getX(p);ch.fromBufferAttribute(u,g),T0(ch,g,l,i,t,e,this)}}else{const d=Math.max(0,o.start),f=Math.min(u.count,o.start+o.count);for(let p=d,x=f;p<x;p++)ch.fromBufferAttribute(u,p),T0(ch,p,l,i,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function T0(r,t,e,n,i,s,o){const a=Ap.distanceSqToPoint(r);if(a<e){const l=new R;Ap.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class ym extends rn{constructor(t,e,n,i,s=Fe,o=Fe,a,l,c){super(t,e,n,i,s,o,a,l,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const h=this;function u(){h.needsUpdate=!0,h._requestVideoFrameCallbackId=t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(u))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class Gb extends ym{constructor(t,e,n,i,s,o,a,l){super({},t,e,n,i,s,o,a,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}}let Hb=class extends rn{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Xe,this.minFilter=Xe,this.generateMipmaps=!1,this.needsUpdate=!0}};class _c extends rn{constructor(t,e,n,i,s,o,a,l,c,h,u,d){super(null,o,a,l,c,h,i,s,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class k_ extends _c{constructor(t,e,n,i,s,o){super(t,e,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Bn,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class G_ extends _c{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,ss),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}let ba=class extends rn{constructor(t=[],e=ss,n,i,s,o,a,l,c,h){super(t,e,n,i,s,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}};class H_ extends rn{constructor(t,e,n,i,s,o,a,l,c){super(t,e,n,i,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}let jr=class extends rn{constructor(t,e,n=ii,i,s,o,a=Xe,l=Xe,c,h=Oi,u=1){if(h!==Oi&&h!==Cs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,i,s,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ns(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},W_=class extends jr{constructor(t,e=ii,n=ss,i,s,o=Xe,a=Xe,l,c=Oi){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,i,s,o,a,l,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}};class _m extends rn{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class dr extends se{constructor(t=1,e=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,n,e,t,o,s,0),p("z","y","x",1,-1,n,e,-t,o,s,1),p("x","z","y",1,1,t,n,e,i,o,2),p("x","z","y",1,-1,t,n,-e,i,o,3),p("x","y","z",1,-1,t,e,n,i,s,4),p("x","y","z",-1,-1,t,e,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Ct(c,3)),this.setAttribute("normal",new Ct(h,3)),this.setAttribute("uv",new Ct(u,2));function p(x,g,m,y,v,_,w,T,E,M,b){const P=_/E,N=w/M,L=_/2,U=w/2,V=T/2,O=E+1,k=M+1;let G=0,it=0;const nt=new R;for(let mt=0;mt<k;mt++){const xt=mt*N-U;for(let bt=0;bt<O;bt++){const jt=bt*P-L;nt[x]=jt*y,nt[g]=xt*v,nt[m]=V,c.push(nt.x,nt.y,nt.z),nt[x]=0,nt[g]=0,nt[m]=T>0?1:-1,h.push(nt.x,nt.y,nt.z),u.push(bt/E),u.push(1-mt/M),G+=1}}for(let mt=0;mt<M;mt++)for(let xt=0;xt<E;xt++){const bt=d+xt+O*mt,jt=d+xt+O*(mt+1),Me=d+(xt+1)+O*(mt+1),we=d+(xt+1)+O*mt;l.push(bt,jt,we),l.push(jt,Me,we),it+=6}a.addGroup(f,it,b),f+=it,d+=G}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new dr(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class fd extends se{constructor(t=1,e=1,n=4,i=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:n,radialSegments:i,heightSegments:s},e=Math.max(0,e),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),s=Math.max(1,Math.floor(s));const o=[],a=[],l=[],c=[],h=e/2,u=Math.PI/2*t,d=e,f=2*u+d,p=n*2+s,x=i+1,g=new R,m=new R;for(let y=0;y<=p;y++){let v=0,_=0,w=0,T=0;if(y<=n){const b=y/n,P=b*Math.PI/2;_=-h-t*Math.cos(P),w=t*Math.sin(P),T=-t*Math.cos(P),v=b*u}else if(y<=n+s){const b=(y-n)/s;_=-h+b*e,w=t,T=0,v=u+b*d}else{const b=(y-n-s)/n,P=b*Math.PI/2;_=h+t*Math.sin(P),w=t*Math.cos(P),T=t*Math.sin(P),v=u+d+b*u}const E=Math.max(0,Math.min(1,v/f));let M=0;y===0?M=.5/i:y===p&&(M=-.5/i);for(let b=0;b<=i;b++){const P=b/i,N=P*Math.PI*2,L=Math.sin(N),U=Math.cos(N);m.x=-w*U,m.y=_,m.z=w*L,a.push(m.x,m.y,m.z),g.set(-w*U,T,w*L),g.normalize(),l.push(g.x,g.y,g.z),c.push(P+M,E)}if(y>0){const b=(y-1)*x;for(let P=0;P<i;P++){const N=b+P,L=b+P+1,U=y*x+P,V=y*x+P+1;o.push(N,L,U),o.push(L,V,U)}}}this.setIndex(o),this.setAttribute("position",new Ct(a,3)),this.setAttribute("normal",new Ct(l,3)),this.setAttribute("uv",new Ct(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new fd(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}}class pd extends se{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const s=[],o=[],a=[],l=[],c=new R,h=new tt;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*i;c.x=t*Math.cos(f),c.y=t*Math.sin(f),o.push(c.x,c.y,c.z),a.push(0,0,1),h.x=(o[d]/t+1)/2,h.y=(o[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new Ct(o,3)),this.setAttribute("normal",new Ct(a,3)),this.setAttribute("uv",new Ct(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pd(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Ta extends se{constructor(t=1,e=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const h=[],u=[],d=[],f=[];let p=0;const x=[],g=n/2;let m=0;y(),o===!1&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new Ct(u,3)),this.setAttribute("normal",new Ct(d,3)),this.setAttribute("uv",new Ct(f,2));function y(){const _=new R,w=new R;let T=0;const E=(e-t)/n;for(let M=0;M<=s;M++){const b=[],P=M/s,N=P*(e-t)+t;for(let L=0;L<=i;L++){const U=L/i,V=U*l+a,O=Math.sin(V),k=Math.cos(V);w.x=N*O,w.y=-P*n+g,w.z=N*k,u.push(w.x,w.y,w.z),_.set(O,E,k).normalize(),d.push(_.x,_.y,_.z),f.push(U,1-P),b.push(p++)}x.push(b)}for(let M=0;M<i;M++)for(let b=0;b<s;b++){const P=x[b][M],N=x[b+1][M],L=x[b+1][M+1],U=x[b][M+1];(t>0||b!==0)&&(h.push(P,N,U),T+=3),(e>0||b!==s-1)&&(h.push(N,L,U),T+=3)}c.addGroup(m,T,0),m+=T}function v(_){const w=p,T=new tt,E=new R;let M=0;const b=_===!0?t:e,P=_===!0?1:-1;for(let L=1;L<=i;L++)u.push(0,g*P,0),d.push(0,P,0),f.push(.5,.5),p++;const N=p;for(let L=0;L<=i;L++){const V=L/i*l+a,O=Math.cos(V),k=Math.sin(V);E.x=b*k,E.y=g*P,E.z=b*O,u.push(E.x,E.y,E.z),d.push(0,P,0),T.x=O*.5+.5,T.y=k*.5*P+.5,f.push(T.x,T.y),p++}for(let L=0;L<i;L++){const U=w+L,V=N+L;_===!0?h.push(V,V+1,U):h.push(V+1,V,U),M+=3}c.addGroup(m,M,_===!0?1:2),m+=M}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ta(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class vc extends Ta{constructor(t=1,e=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new vc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class fr extends se{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const s=[],o=[];a(i),c(n),h(),this.setAttribute("position",new Ct(s,3)),this.setAttribute("normal",new Ct(s.slice(),3)),this.setAttribute("uv",new Ct(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){const v=new R,_=new R,w=new R;for(let T=0;T<e.length;T+=3)f(e[T+0],v),f(e[T+1],_),f(e[T+2],w),l(v,_,w,y)}function l(y,v,_,w){const T=w+1,E=[];for(let M=0;M<=T;M++){E[M]=[];const b=y.clone().lerp(_,M/T),P=v.clone().lerp(_,M/T),N=T-M;for(let L=0;L<=N;L++)L===0&&M===T?E[M][L]=b:E[M][L]=b.clone().lerp(P,L/N)}for(let M=0;M<T;M++)for(let b=0;b<2*(T-M)-1;b++){const P=Math.floor(b/2);b%2===0?(d(E[M][P+1]),d(E[M+1][P]),d(E[M][P])):(d(E[M][P+1]),d(E[M+1][P+1]),d(E[M+1][P]))}}function c(y){const v=new R;for(let _=0;_<s.length;_+=3)v.x=s[_+0],v.y=s[_+1],v.z=s[_+2],v.normalize().multiplyScalar(y),s[_+0]=v.x,s[_+1]=v.y,s[_+2]=v.z}function h(){const y=new R;for(let v=0;v<s.length;v+=3){y.x=s[v+0],y.y=s[v+1],y.z=s[v+2];const _=g(y)/2/Math.PI+.5,w=m(y)/Math.PI+.5;o.push(_,1-w)}p(),u()}function u(){for(let y=0;y<o.length;y+=6){const v=o[y+0],_=o[y+2],w=o[y+4],T=Math.max(v,_,w),E=Math.min(v,_,w);T>.9&&E<.1&&(v<.2&&(o[y+0]+=1),_<.2&&(o[y+2]+=1),w<.2&&(o[y+4]+=1))}}function d(y){s.push(y.x,y.y,y.z)}function f(y,v){const _=y*3;v.x=t[_+0],v.y=t[_+1],v.z=t[_+2]}function p(){const y=new R,v=new R,_=new R,w=new R,T=new tt,E=new tt,M=new tt;for(let b=0,P=0;b<s.length;b+=9,P+=6){y.set(s[b+0],s[b+1],s[b+2]),v.set(s[b+3],s[b+4],s[b+5]),_.set(s[b+6],s[b+7],s[b+8]),T.set(o[P+0],o[P+1]),E.set(o[P+2],o[P+3]),M.set(o[P+4],o[P+5]),w.copy(y).add(v).add(_).divideScalar(3);const N=g(w);x(T,P+0,y,N),x(E,P+2,v,N),x(M,P+4,_,N)}}function x(y,v,_,w){w<0&&y.x===1&&(o[v]=y.x-1),_.x===0&&_.z===0&&(o[v]=w/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new fr(t.vertices,t.indices,t.radius,t.detail)}}class md extends fr{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new md(t.radius,t.detail)}}const hh=new R,uh=new R,bf=new R,dh=new ws;class vm extends se{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){const i=Math.pow(10,4),s=Math.cos(Xr*e),o=t.getIndex(),a=t.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],h=["a","b","c"],u=new Array(3),d={},f=[];for(let p=0;p<l;p+=3){o?(c[0]=o.getX(p),c[1]=o.getX(p+1),c[2]=o.getX(p+2)):(c[0]=p,c[1]=p+1,c[2]=p+2);const{a:x,b:g,c:m}=dh;if(x.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),m.fromBufferAttribute(a,c[2]),dh.getNormal(bf),u[0]=`${Math.round(x.x*i)},${Math.round(x.y*i)},${Math.round(x.z*i)}`,u[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,u[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let y=0;y<3;y++){const v=(y+1)%3,_=u[y],w=u[v],T=dh[h[y]],E=dh[h[v]],M=`${_}_${w}`,b=`${w}_${_}`;b in d&&d[b]?(bf.dot(d[b].normal)<=s&&(f.push(T.x,T.y,T.z),f.push(E.x,E.y,E.z)),d[b]=null):M in d||(d[M]={index0:c[y],index1:c[v],normal:bf.clone()})}}for(const p in d)if(d[p]){const{index0:x,index1:g}=d[p];hh.fromBufferAttribute(a,x),uh.fromBufferAttribute(a,g),f.push(hh.x,hh.y,hh.z),f.push(uh.x,uh.y,uh.z)}this.setAttribute("position",new Ct(f,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class vi{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){pt("Curve: .getPoint() not implemented.")}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const n=this.getLengths();let i=0;const s=n.length;let o;e?o=e:o=t*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);const h=n[i],d=n[i+1]-h,f=(o-h)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new tt:new R);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e=!1){const n=new R,i=[],s=[],o=[],a=new R,l=new Qt;for(let f=0;f<=t;f++){const p=f/t;i[f]=this.getTangentAt(p,new R)}s[0]=new R,o[0]=new R;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();const p=Math.acos(Jt(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(Jt(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],f*p)),o[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class gd extends vi{constructor(t=0,e=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new tt){const n=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+t*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class X_ extends gd{constructor(t,e,n,i,s,o){super(t,e,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Mm(){let r=0,t=0,e=0,n=0;function i(s,o,a,l){r=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,u){let d=(o-s)/c-(a-s)/(c+h)+(a-o)/h,f=(a-o)/h-(l-o)/(h+u)+(l-a)/u;d*=h,f*=h,i(o,a,d,f)},calc:function(s){const o=s*s,a=o*s;return r+t*s+e*o+n*a}}}const fh=new R,Tf=new Mm,wf=new Mm,Af=new Mm;class Sm extends vi{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new R){const n=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(fh.subVectors(i[0],i[1]).add(i[0]),c=fh);const u=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(fh.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=fh),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let p=Math.pow(c.distanceToSquared(u),f),x=Math.pow(u.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(h),f);x<1e-4&&(x=1),p<1e-4&&(p=x),g<1e-4&&(g=x),Tf.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,p,x,g),wf.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,p,x,g),Af.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,p,x,g)}else this.curveType==="catmullrom"&&(Tf.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),wf.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Af.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Tf.calc(l),wf.calc(l),Af.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(new R().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function w0(r,t,e,n,i){const s=(n-t)*.5,o=(i-e)*.5,a=r*r,l=r*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*r+e}function Wb(r,t){const e=1-r;return e*e*t}function Xb(r,t){return 2*(1-r)*r*t}function $b(r,t){return r*r*t}function pl(r,t,e,n){return Wb(r,t)+Xb(r,e)+$b(r,n)}function qb(r,t){const e=1-r;return e*e*e*t}function Yb(r,t){const e=1-r;return 3*e*e*r*t}function Zb(r,t){return 3*(1-r)*r*r*t}function Jb(r,t){return r*r*r*t}function ml(r,t,e,n,i){return qb(r,t)+Yb(r,e)+Zb(r,n)+Jb(r,i)}class bm extends vi{constructor(t=new tt,e=new tt,n=new tt,i=new tt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new tt){const n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(ml(t,i.x,s.x,o.x,a.x),ml(t,i.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class $_ extends vi{constructor(t=new R,e=new R,n=new R,i=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new R){const n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(ml(t,i.x,s.x,o.x,a.x),ml(t,i.y,s.y,o.y,a.y),ml(t,i.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Tm extends vi{constructor(t=new tt,e=new tt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new tt){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new tt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class q_ extends vi{constructor(t=new R,e=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new R){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new R){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class wm extends vi{constructor(t=new tt,e=new tt,n=new tt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new tt){const n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(pl(t,i.x,s.x,o.x),pl(t,i.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Am extends vi{constructor(t=new R,e=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new R){const n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(pl(t,i.x,s.x,o.x),pl(t,i.y,s.y,o.y),pl(t,i.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Em extends vi{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new tt){const n=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(w0(a,l.x,c.x,h.x,u.x),w0(a,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(new tt().fromArray(i))}return this}}var Pu=Object.freeze({__proto__:null,ArcCurve:X_,CatmullRomCurve3:Sm,CubicBezierCurve:bm,CubicBezierCurve3:$_,EllipseCurve:gd,LineCurve:Tm,LineCurve3:q_,QuadraticBezierCurve:wm,QuadraticBezierCurve3:Am,SplineCurve:Em});class Y_ extends vi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Pu[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const i=t.curves[e];this.curves.push(new Pu[i.type]().fromJSON(i))}return this}}class Lu extends Y_{constructor(t){super(),this.type="Path",this.currentPoint=new tt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new Tm(this.currentPoint.clone(),new tt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const s=new wm(this.currentPoint.clone(),new tt(t,e),new tt(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,o){const a=new bm(this.currentPoint.clone(),new tt(t,e),new tt(n,i),new tt(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new Em(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,i,s,o),this}absarc(t,e,n,i,s,o){return this.absellipse(t,e,n,n,i,s,o),this}ellipse(t,e,n,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,i,s,o,a,l),this}absellipse(t,e,n,i,s,o,a,l){const c=new gd(t,e,n,i,s,o,a,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class ir extends Lu{constructor(t){super(t),this.uuid=ei(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const i=t.holes[e];this.holes.push(new Lu().fromJSON(i))}return this}}function jb(r,t,e=2){const n=t&&t.length,i=n?t[0]*e:r.length;let s=Z_(r,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(n&&(s=nT(r,t,s,e)),r.length>80*e){a=r[0],l=r[1];let h=a,u=l;for(let d=e;d<i;d+=e){const f=r[d],p=r[d+1];f<a&&(a=f),p<l&&(l=p),f>h&&(h=f),p>u&&(u=p)}c=Math.max(h-a,u-l),c=c!==0?32767/c:0}return ec(s,o,e,a,l,c,0),o}function Z_(r,t,e,n,i){let s;if(i===fT(r,t,e,n)>0)for(let o=t;o<e;o+=n)s=A0(o/n|0,r[o],r[o+1],s);else for(let o=e-n;o>=t;o-=n)s=A0(o/n|0,r[o],r[o+1],s);return s&&fa(s,s.next)&&(ic(s),s=s.next),s}function Kr(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(fa(e,e.next)||ze(e.prev,e,e.next)===0)){if(ic(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function ec(r,t,e,n,i,s,o){if(!r)return;!o&&s&&aT(r,n,i,s);let a=r;for(;r.prev!==r.next;){const l=r.prev,c=r.next;if(s?Qb(r,n,i,s):Kb(r)){t.push(l.i,r.i,c.i),ic(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=tT(Kr(r),t),ec(r,t,e,n,i,s,2)):o===2&&eT(r,t,e,n,i,s):ec(Kr(r),t,e,n,i,s,1);break}}}function Kb(r){const t=r.prev,e=r,n=r.next;if(ze(t,e,n)>=0)return!1;const i=t.x,s=e.x,o=n.x,a=t.y,l=e.y,c=n.y,h=Math.min(i,s,o),u=Math.min(a,l,c),d=Math.max(i,s,o),f=Math.max(a,l,c);let p=n.next;for(;p!==t;){if(p.x>=h&&p.x<=d&&p.y>=u&&p.y<=f&&al(i,a,s,l,o,c,p.x,p.y)&&ze(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Qb(r,t,e,n){const i=r.prev,s=r,o=r.next;if(ze(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,h=i.y,u=s.y,d=o.y,f=Math.min(a,l,c),p=Math.min(h,u,d),x=Math.max(a,l,c),g=Math.max(h,u,d),m=Ep(f,p,t,e,n),y=Ep(x,g,t,e,n);let v=r.prevZ,_=r.nextZ;for(;v&&v.z>=m&&_&&_.z<=y;){if(v.x>=f&&v.x<=x&&v.y>=p&&v.y<=g&&v!==i&&v!==o&&al(a,h,l,u,c,d,v.x,v.y)&&ze(v.prev,v,v.next)>=0||(v=v.prevZ,_.x>=f&&_.x<=x&&_.y>=p&&_.y<=g&&_!==i&&_!==o&&al(a,h,l,u,c,d,_.x,_.y)&&ze(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;v&&v.z>=m;){if(v.x>=f&&v.x<=x&&v.y>=p&&v.y<=g&&v!==i&&v!==o&&al(a,h,l,u,c,d,v.x,v.y)&&ze(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;_&&_.z<=y;){if(_.x>=f&&_.x<=x&&_.y>=p&&_.y<=g&&_!==i&&_!==o&&al(a,h,l,u,c,d,_.x,_.y)&&ze(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function tT(r,t){let e=r;do{const n=e.prev,i=e.next.next;!fa(n,i)&&j_(n,e,e.next,i)&&nc(n,i)&&nc(i,n)&&(t.push(n.i,e.i,i.i),ic(e),ic(e.next),e=r=i),e=e.next}while(e!==r);return Kr(e)}function eT(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&hT(o,a)){let l=K_(o,a);o=Kr(o,o.next),l=Kr(l,l.next),ec(o,t,e,n,i,s,0),ec(l,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function nT(r,t,e,n){const i=[];for(let s=0,o=t.length;s<o;s++){const a=t[s]*n,l=s<o-1?t[s+1]*n:r.length,c=Z_(r,a,l,n,!1);c===c.next&&(c.steiner=!0),i.push(cT(c))}i.sort(iT);for(let s=0;s<i.length;s++)e=sT(i[s],e);return e}function iT(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const n=(r.next.y-r.y)/(r.next.x-r.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=n-i}return e}function sT(r,t){const e=rT(r,t);if(!e)return t;const n=K_(e,r);return Kr(n,n.next),Kr(e,e.next)}function rT(r,t){let e=t;const n=r.x,i=r.y;let s=-1/0,o;if(fa(r,e))return e;do{if(fa(r,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const u=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=n&&u>s&&(s=u,o=e.x<e.next.x?e:e.next,u===n))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;e=o;do{if(n>=e.x&&e.x>=l&&n!==e.x&&J_(i<c?n:s,i,l,c,i<c?s:n,i,e.x,e.y)){const u=Math.abs(i-e.y)/(n-e.x);nc(e,r)&&(u<h||u===h&&(e.x>o.x||e.x===o.x&&oT(o,e)))&&(o=e,h=u)}e=e.next}while(e!==a);return o}function oT(r,t){return ze(r.prev,r,t.prev)<0&&ze(t.next,r,r.next)<0}function aT(r,t,e,n){let i=r;do i.z===0&&(i.z=Ep(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,lT(i)}function lT(r){let t,e=1;do{let n=r,i;r=null;let s=null;for(t=0;n;){t++;let o=n,a=0;for(let c=0;c<e&&(a++,o=o.nextZ,!!o);c++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(i=n,n=n.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;n=o}s.nextZ=null,e*=2}while(t>1);return r}function Ep(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function cT(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function J_(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function al(r,t,e,n,i,s,o,a){return!(r===o&&t===a)&&J_(r,t,e,n,i,s,o,a)}function hT(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!uT(r,t)&&(nc(r,t)&&nc(t,r)&&dT(r,t)&&(ze(r.prev,r,t.prev)||ze(r,t.prev,t))||fa(r,t)&&ze(r.prev,r,r.next)>0&&ze(t.prev,t,t.next)>0)}function ze(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function fa(r,t){return r.x===t.x&&r.y===t.y}function j_(r,t,e,n){const i=mh(ze(r,t,e)),s=mh(ze(r,t,n)),o=mh(ze(e,n,r)),a=mh(ze(e,n,t));return!!(i!==s&&o!==a||i===0&&ph(r,e,t)||s===0&&ph(r,n,t)||o===0&&ph(e,r,n)||a===0&&ph(e,t,n))}function ph(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function mh(r){return r>0?1:r<0?-1:0}function uT(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&j_(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function nc(r,t){return ze(r.prev,r,r.next)<0?ze(r,t,r.next)>=0&&ze(r,r.prev,t)>=0:ze(r,t,r.prev)<0||ze(r,r.next,t)<0}function dT(r,t){let e=r,n=!1;const i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function K_(r,t){const e=Cp(r.i,r.x,r.y),n=Cp(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function A0(r,t,e,n){const i=Cp(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ic(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 Cp(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function fT(r,t,e,n){let i=0;for(let s=t,o=e-n;s<e;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}class pT{static triangulate(t,e,n=2){return jb(t,e,n)}}class ui{static area(t){const e=t.length;let n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return n*.5}static isClockWise(t){return ui.area(t)<0}static triangulateShape(t,e){const n=[],i=[],s=[];E0(t),C0(n,t);let o=t.length;e.forEach(E0);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,C0(n,e[l]);const a=pT.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function E0(r){const t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function C0(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}class Mc extends se{constructor(t=new ir([new tt(.5,.5),new tt(-.5,.5),new tt(-.5,-.5),new tt(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],s=[];for(let a=0,l=t.length;a<l;a++){const c=t[a];o(c)}this.setAttribute("position",new Ct(i,3)),this.setAttribute("uv",new Ct(s,2)),this.computeVertexNormals();function o(a){const l=[],c=e.curveSegments!==void 0?e.curveSegments:12,h=e.steps!==void 0?e.steps:1,u=e.depth!==void 0?e.depth:1;let d=e.bevelEnabled!==void 0?e.bevelEnabled:!0,f=e.bevelThickness!==void 0?e.bevelThickness:.2,p=e.bevelSize!==void 0?e.bevelSize:f-.1,x=e.bevelOffset!==void 0?e.bevelOffset:0,g=e.bevelSegments!==void 0?e.bevelSegments:3;const m=e.extrudePath,y=e.UVGenerator!==void 0?e.UVGenerator:mT;let v,_=!1,w,T,E,M;if(m){v=m.getSpacedPoints(h),_=!0,d=!1;const Q=m.isCatmullRomCurve3?m.closed:!1;w=m.computeFrenetFrames(h,Q),T=new R,E=new R,M=new R}d||(g=0,f=0,p=0,x=0);const b=a.extractPoints(c);let P=b.shape;const N=b.holes;if(!ui.isClockWise(P)){P=P.reverse();for(let Q=0,rt=N.length;Q<rt;Q++){const et=N[Q];ui.isClockWise(et)&&(N[Q]=et.reverse())}}function U(Q){const et=10000000000000001e-36;let yt=Q[0];for(let I=1;I<=Q.length;I++){const $t=I%Q.length,Tt=Q[$t],Yt=Tt.x-yt.x,ut=Tt.y-yt.y,C=Yt*Yt+ut*ut,S=Math.max(Math.abs(Tt.x),Math.abs(Tt.y),Math.abs(yt.x),Math.abs(yt.y)),D=et*S*S;if(C<=D){Q.splice($t,1),I--;continue}yt=Tt}}U(P),N.forEach(U);const V=N.length,O=P;for(let Q=0;Q<V;Q++){const rt=N[Q];P=P.concat(rt)}function k(Q,rt,et){return rt||Vt("ExtrudeGeometry: vec does not exist"),Q.clone().addScaledVector(rt,et)}const G=P.length;function it(Q,rt,et){let yt,I,$t;const Tt=Q.x-rt.x,Yt=Q.y-rt.y,ut=et.x-Q.x,C=et.y-Q.y,S=Tt*Tt+Yt*Yt,D=Tt*C-Yt*ut;if(Math.abs(D)>Number.EPSILON){const Y=Math.sqrt(S),K=Math.sqrt(ut*ut+C*C),Z=rt.x-Yt/Y,It=rt.y+Tt/Y,dt=et.x-C/K,Ht=et.y+ut/K,Zt=((dt-Z)*C-(Ht-It)*ut)/(Tt*C-Yt*ut);yt=Z+Tt*Zt-Q.x,I=It+Yt*Zt-Q.y;const st=yt*yt+I*I;if(st<=2)return new tt(yt,I);$t=Math.sqrt(st/2)}else{let Y=!1;Tt>Number.EPSILON?ut>Number.EPSILON&&(Y=!0):Tt<-Number.EPSILON?ut<-Number.EPSILON&&(Y=!0):Math.sign(Yt)===Math.sign(C)&&(Y=!0),Y?(yt=-Yt,I=Tt,$t=Math.sqrt(S)):(yt=Tt,I=Yt,$t=Math.sqrt(S/2))}return new tt(yt/$t,I/$t)}const nt=[];for(let Q=0,rt=O.length,et=rt-1,yt=Q+1;Q<rt;Q++,et++,yt++)et===rt&&(et=0),yt===rt&&(yt=0),nt[Q]=it(O[Q],O[et],O[yt]);const mt=[];let xt,bt=nt.concat();for(let Q=0,rt=V;Q<rt;Q++){const et=N[Q];xt=[];for(let yt=0,I=et.length,$t=I-1,Tt=yt+1;yt<I;yt++,$t++,Tt++)$t===I&&($t=0),Tt===I&&(Tt=0),xt[yt]=it(et[yt],et[$t],et[Tt]);mt.push(xt),bt=bt.concat(xt)}let jt;if(g===0)jt=ui.triangulateShape(O,N);else{const Q=[],rt=[];for(let et=0;et<g;et++){const yt=et/g,I=f*Math.cos(yt*Math.PI/2),$t=p*Math.sin(yt*Math.PI/2)+x;for(let Tt=0,Yt=O.length;Tt<Yt;Tt++){const ut=k(O[Tt],nt[Tt],$t);qt(ut.x,ut.y,-I),yt===0&&Q.push(ut)}for(let Tt=0,Yt=V;Tt<Yt;Tt++){const ut=N[Tt];xt=mt[Tt];const C=[];for(let S=0,D=ut.length;S<D;S++){const Y=k(ut[S],xt[S],$t);qt(Y.x,Y.y,-I),yt===0&&C.push(Y)}yt===0&&rt.push(C)}}jt=ui.triangulateShape(Q,rt)}const Me=jt.length,we=p+x;for(let Q=0;Q<G;Q++){const rt=d?k(P[Q],bt[Q],we):P[Q];_?(E.copy(w.normals[0]).multiplyScalar(rt.x),T.copy(w.binormals[0]).multiplyScalar(rt.y),M.copy(v[0]).add(E).add(T),qt(M.x,M.y,M.z)):qt(rt.x,rt.y,0)}for(let Q=1;Q<=h;Q++)for(let rt=0;rt<G;rt++){const et=d?k(P[rt],bt[rt],we):P[rt];_?(E.copy(w.normals[Q]).multiplyScalar(et.x),T.copy(w.binormals[Q]).multiplyScalar(et.y),M.copy(v[Q]).add(E).add(T),qt(M.x,M.y,M.z)):qt(et.x,et.y,u/h*Q)}for(let Q=g-1;Q>=0;Q--){const rt=Q/g,et=f*Math.cos(rt*Math.PI/2),yt=p*Math.sin(rt*Math.PI/2)+x;for(let I=0,$t=O.length;I<$t;I++){const Tt=k(O[I],nt[I],yt);qt(Tt.x,Tt.y,u+et)}for(let I=0,$t=N.length;I<$t;I++){const Tt=N[I];xt=mt[I];for(let Yt=0,ut=Tt.length;Yt<ut;Yt++){const C=k(Tt[Yt],xt[Yt],yt);_?qt(C.x,C.y+v[h-1].y,v[h-1].x+et):qt(C.x,C.y,u+et)}}}j(),ct();function j(){const Q=i.length/3;if(d){let rt=0,et=G*rt;for(let yt=0;yt<Me;yt++){const I=jt[yt];Xt(I[2]+et,I[1]+et,I[0]+et)}rt=h+g*2,et=G*rt;for(let yt=0;yt<Me;yt++){const I=jt[yt];Xt(I[0]+et,I[1]+et,I[2]+et)}}else{for(let rt=0;rt<Me;rt++){const et=jt[rt];Xt(et[2],et[1],et[0])}for(let rt=0;rt<Me;rt++){const et=jt[rt];Xt(et[0]+G*h,et[1]+G*h,et[2]+G*h)}}n.addGroup(Q,i.length/3-Q,0)}function ct(){const Q=i.length/3;let rt=0;ht(O,rt),rt+=O.length;for(let et=0,yt=N.length;et<yt;et++){const I=N[et];ht(I,rt),rt+=I.length}n.addGroup(Q,i.length/3-Q,1)}function ht(Q,rt){let et=Q.length;for(;--et>=0;){const yt=et;let I=et-1;I<0&&(I=Q.length-1);for(let $t=0,Tt=h+g*2;$t<Tt;$t++){const Yt=G*$t,ut=G*($t+1),C=rt+yt+Yt,S=rt+I+Yt,D=rt+I+ut,Y=rt+yt+ut;Kt(C,S,D,Y)}}}function qt(Q,rt,et){l.push(Q),l.push(rt),l.push(et)}function Xt(Q,rt,et){Ae(Q),Ae(rt),Ae(et);const yt=i.length/3,I=y.generateTopUV(n,i,yt-3,yt-2,yt-1);ie(I[0]),ie(I[1]),ie(I[2])}function Kt(Q,rt,et,yt){Ae(Q),Ae(rt),Ae(yt),Ae(rt),Ae(et),Ae(yt);const I=i.length/3,$t=y.generateSideWallUV(n,i,I-6,I-3,I-2,I-1);ie($t[0]),ie($t[1]),ie($t[3]),ie($t[1]),ie($t[2]),ie($t[3])}function Ae(Q){i.push(l[Q*3+0]),i.push(l[Q*3+1]),i.push(l[Q*3+2])}function ie(Q){s.push(Q.x),s.push(Q.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return gT(e,n,t)}static fromJSON(t,e){const n=[];for(let s=0,o=t.shapes.length;s<o;s++){const a=e[t.shapes[s]];n.push(a)}const i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new Pu[i.type]().fromJSON(i)),new Mc(n,t.options)}}const mT={generateTopUV:function(r,t,e,n,i){const s=t[e*3],o=t[e*3+1],a=t[n*3],l=t[n*3+1],c=t[i*3],h=t[i*3+1];return[new tt(s,o),new tt(a,l),new tt(c,h)]},generateSideWallUV:function(r,t,e,n,i,s){const o=t[e*3],a=t[e*3+1],l=t[e*3+2],c=t[n*3],h=t[n*3+1],u=t[n*3+2],d=t[i*3],f=t[i*3+1],p=t[i*3+2],x=t[s*3],g=t[s*3+1],m=t[s*3+2];return Math.abs(a-h)<Math.abs(o-c)?[new tt(o,1-l),new tt(c,1-u),new tt(d,1-p),new tt(x,1-m)]:[new tt(a,1-l),new tt(h,1-u),new tt(f,1-p),new tt(g,1-m)]}};function gT(r,t,e){if(e.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];e.shapes.push(s.uuid)}else e.shapes.push(r.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class xd extends fr{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new xd(t.radius,t.detail)}}class yd extends se{constructor(t=[new tt(0,-.5),new tt(.5,0),new tt(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=Jt(i,0,Math.PI*2);const s=[],o=[],a=[],l=[],c=[],h=1/e,u=new R,d=new tt,f=new R,p=new R,x=new R;let g=0,m=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:g=t[y+1].x-t[y].x,m=t[y+1].y-t[y].y,f.x=m*1,f.y=-g,f.z=m*0,x.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(x.x,x.y,x.z);break;default:g=t[y+1].x-t[y].x,m=t[y+1].y-t[y].y,f.x=m*1,f.y=-g,f.z=m*0,p.copy(f),f.x+=x.x,f.y+=x.y,f.z+=x.z,f.normalize(),l.push(f.x,f.y,f.z),x.copy(p)}for(let y=0;y<=e;y++){const v=n+y*h*i,_=Math.sin(v),w=Math.cos(v);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*_,u.y=t[T].y,u.z=t[T].x*w,o.push(u.x,u.y,u.z),d.x=y/e,d.y=T/(t.length-1),a.push(d.x,d.y);const E=l[3*T+0]*_,M=l[3*T+1],b=l[3*T+0]*w;c.push(E,M,b)}}for(let y=0;y<e;y++)for(let v=0;v<t.length-1;v++){const _=v+y*t.length,w=_,T=_+t.length,E=_+t.length+1,M=_+1;s.push(w,T,M),s.push(E,M,T)}this.setIndex(s),this.setAttribute("position",new Ct(o,3)),this.setAttribute("uv",new Ct(a,2)),this.setAttribute("normal",new Ct(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new yd(t.points,t.segments,t.phiStart,t.phiLength)}}class wa extends fr{constructor(t=1,e=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new wa(t.radius,t.detail)}}class io extends se{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const s=t/2,o=e/2,a=Math.floor(n),l=Math.floor(i),c=a+1,h=l+1,u=t/a,d=e/l,f=[],p=[],x=[],g=[];for(let m=0;m<h;m++){const y=m*d-o;for(let v=0;v<c;v++){const _=v*u-s;p.push(_,-y,0),x.push(0,0,1),g.push(v/a),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let y=0;y<a;y++){const v=y+c*m,_=y+c*(m+1),w=y+1+c*(m+1),T=y+1+c*m;f.push(v,_,T),f.push(_,w,T)}this.setIndex(f),this.setAttribute("position",new Ct(p,3)),this.setAttribute("normal",new Ct(x,3)),this.setAttribute("uv",new Ct(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new io(t.width,t.height,t.widthSegments,t.heightSegments)}}class Sc extends se{constructor(t=.5,e=1,n=32,i=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],l=[],c=[],h=[];let u=t;const d=(e-t)/i,f=new R,p=new tt;for(let x=0;x<=i;x++){for(let g=0;g<=n;g++){const m=s+g/n*o;f.x=u*Math.cos(m),f.y=u*Math.sin(m),l.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/e+1)/2,p.y=(f.y/e+1)/2,h.push(p.x,p.y)}u+=d}for(let x=0;x<i;x++){const g=x*(n+1);for(let m=0;m<n;m++){const y=m+g,v=y,_=y+n+1,w=y+n+2,T=y+1;a.push(v,_,T),a.push(_,w,T)}}this.setIndex(a),this.setAttribute("position",new Ct(l,3)),this.setAttribute("normal",new Ct(c,3)),this.setAttribute("uv",new Ct(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Sc(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class _d extends se{constructor(t=new ir([new tt(0,.5),new tt(-.5,-.5),new tt(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(n),this.setAttribute("position",new Ct(i,3)),this.setAttribute("normal",new Ct(s,3)),this.setAttribute("uv",new Ct(o,2));function c(h){const u=i.length/3,d=h.extractPoints(e);let f=d.shape;const p=d.holes;ui.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){const y=p[g];ui.isClockWise(y)===!0&&(p[g]=y.reverse())}const x=ui.triangulateShape(f,p);for(let g=0,m=p.length;g<m;g++){const y=p[g];f=f.concat(y)}for(let g=0,m=f.length;g<m;g++){const y=f[g];i.push(y.x,y.y,0),s.push(0,0,1),o.push(y.x,y.y)}for(let g=0,m=x.length;g<m;g++){const y=x[g],v=y[0]+u,_=y[1]+u,w=y[2]+u;n.push(v,_,w),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return xT(e,t)}static fromJSON(t,e){const n=[];for(let i=0,s=t.shapes.length;i<s;i++){const o=e[t.shapes[i]];n.push(o)}return new _d(n,t.curveSegments)}}function xT(r,t){if(t.shapes=[],Array.isArray(r))for(let e=0,n=r.length;e<n;e++){const i=r[e];t.shapes.push(i.uuid)}else t.shapes.push(r.uuid);return t}class Aa extends se{constructor(t=1,e=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(o+a,Math.PI);let c=0;const h=[],u=new R,d=new R,f=[],p=[],x=[],g=[];for(let m=0;m<=n;m++){const y=[],v=m/n;let _=0;m===0&&o===0?_=.5/e:m===n&&l===Math.PI&&(_=-.5/e);for(let w=0;w<=e;w++){const T=w/e;u.x=-t*Math.cos(i+T*s)*Math.sin(o+v*a),u.y=t*Math.cos(o+v*a),u.z=t*Math.sin(i+T*s)*Math.sin(o+v*a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),g.push(T+_,1-v),y.push(c++)}h.push(y)}for(let m=0;m<n;m++)for(let y=0;y<e;y++){const v=h[m][y+1],_=h[m][y],w=h[m+1][y],T=h[m+1][y+1];(m!==0||o>0)&&f.push(v,_,T),(m!==n-1||l<Math.PI)&&f.push(_,w,T)}this.setIndex(f),this.setAttribute("position",new Ct(p,3)),this.setAttribute("normal",new Ct(x,3)),this.setAttribute("uv",new Ct(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Aa(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class vd extends fr{constructor(t=1,e=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new vd(t.radius,t.detail)}}class bc extends se{constructor(t=1,e=.4,n=12,i=48,s=Math.PI*2,o=0,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:s,thetaStart:o,thetaLength:a},n=Math.floor(n),i=Math.floor(i);const l=[],c=[],h=[],u=[],d=new R,f=new R,p=new R;for(let x=0;x<=n;x++){const g=o+x/n*a;for(let m=0;m<=i;m++){const y=m/i*s;f.x=(t+e*Math.cos(g))*Math.cos(y),f.y=(t+e*Math.cos(g))*Math.sin(y),f.z=e*Math.sin(g),c.push(f.x,f.y,f.z),d.x=t*Math.cos(y),d.y=t*Math.sin(y),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(m/i),u.push(x/n)}}for(let x=1;x<=n;x++)for(let g=1;g<=i;g++){const m=(i+1)*x+g-1,y=(i+1)*(x-1)+g-1,v=(i+1)*(x-1)+g,_=(i+1)*x+g;l.push(m,y,_),l.push(y,v,_)}this.setIndex(l),this.setAttribute("position",new Ct(c,3)),this.setAttribute("normal",new Ct(h,3)),this.setAttribute("uv",new Ct(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new bc(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Md extends se{constructor(t=1,e=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],l=[],c=[],h=[],u=new R,d=new R,f=new R,p=new R,x=new R,g=new R,m=new R;for(let v=0;v<=n;++v){const _=v/n*s*Math.PI*2;y(_,s,o,t,f),y(_+.01,s,o,t,p),g.subVectors(p,f),m.addVectors(p,f),x.crossVectors(g,m),m.crossVectors(x,g),x.normalize(),m.normalize();for(let w=0;w<=i;++w){const T=w/i*Math.PI*2,E=-e*Math.cos(T),M=e*Math.sin(T);u.x=f.x+(E*m.x+M*x.x),u.y=f.y+(E*m.y+M*x.y),u.z=f.z+(E*m.z+M*x.z),l.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),h.push(v/n),h.push(w/i)}}for(let v=1;v<=n;v++)for(let _=1;_<=i;_++){const w=(i+1)*(v-1)+(_-1),T=(i+1)*v+(_-1),E=(i+1)*v+_,M=(i+1)*(v-1)+_;a.push(w,T,M),a.push(T,E,M)}this.setIndex(a),this.setAttribute("position",new Ct(l,3)),this.setAttribute("normal",new Ct(c,3)),this.setAttribute("uv",new Ct(h,2));function y(v,_,w,T,E){const M=Math.cos(v),b=Math.sin(v),P=w/_*v,N=Math.cos(P);E.x=T*(2+N)*.5*M,E.y=T*(2+N)*b*.5,E.z=T*Math.sin(P)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Md(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class Sd extends se{constructor(t=new Am(new R(-1,-1,0),new R(-1,1,0),new R(1,1,0)),e=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:s};const o=t.computeFrenetFrames(e,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new R,l=new R,c=new tt;let h=new R;const u=[],d=[],f=[],p=[];x(),this.setIndex(p),this.setAttribute("position",new Ct(u,3)),this.setAttribute("normal",new Ct(d,3)),this.setAttribute("uv",new Ct(f,2));function x(){for(let v=0;v<e;v++)g(v);g(s===!1?e:0),y(),m()}function g(v){h=t.getPointAt(v/e,h);const _=o.normals[v],w=o.binormals[v];for(let T=0;T<=i;T++){const E=T/i*Math.PI*2,M=Math.sin(E),b=-Math.cos(E);l.x=b*_.x+M*w.x,l.y=b*_.y+M*w.y,l.z=b*_.z+M*w.z,l.normalize(),d.push(l.x,l.y,l.z),a.x=h.x+n*l.x,a.y=h.y+n*l.y,a.z=h.z+n*l.z,u.push(a.x,a.y,a.z)}}function m(){for(let v=1;v<=e;v++)for(let _=1;_<=i;_++){const w=(i+1)*(v-1)+(_-1),T=(i+1)*v+(_-1),E=(i+1)*v+_,M=(i+1)*(v-1)+_;p.push(w,T,M),p.push(T,E,M)}}function y(){for(let v=0;v<=e;v++)for(let _=0;_<=i;_++)c.x=v/e,c.y=_/i,f.push(c.x,c.y)}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new Sd(new Pu[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class Cm extends se{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},t!==null){const e=[],n=new Set,i=new R,s=new R;if(t.index!==null){const o=t.attributes.position,a=t.index;let l=t.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,h=l.length;c<h;++c){const u=l[c],d=u.start,f=u.count;for(let p=d,x=d+f;p<x;p+=3)for(let g=0;g<3;g++){const m=a.getX(p+g),y=a.getX(p+(g+1)%3);i.fromBufferAttribute(o,m),s.fromBufferAttribute(o,y),N0(i,s,n)===!0&&(e.push(i.x,i.y,i.z),e.push(s.x,s.y,s.z))}}}else{const o=t.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const h=3*a+c,u=3*a+(c+1)%3;i.fromBufferAttribute(o,h),s.fromBufferAttribute(o,u),N0(i,s,n)===!0&&(e.push(i.x,i.y,i.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ct(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function N0(r,t,e){const n=`${r.x},${r.y},${r.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${r.x},${r.y},${r.z}`;return e.has(n)===!0||e.has(i)===!0?!1:(e.add(n),e.add(i),!0)}var R0=Object.freeze({__proto__:null,BoxGeometry:dr,CapsuleGeometry:fd,CircleGeometry:pd,ConeGeometry:vc,CylinderGeometry:Ta,DodecahedronGeometry:md,EdgesGeometry:vm,ExtrudeGeometry:Mc,IcosahedronGeometry:xd,LatheGeometry:yd,OctahedronGeometry:wa,PlaneGeometry:io,PolyhedronGeometry:fr,RingGeometry:Sc,ShapeGeometry:_d,SphereGeometry:Aa,TetrahedronGeometry:vd,TorusGeometry:bc,TorusKnotGeometry:Md,TubeGeometry:Sd,WireframeGeometry:Cm});class Nm extends gn{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new wt(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}function pa(r){const t={};for(const e in r){t[e]={};for(const n in r[e]){const i=r[e][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(pt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}function Ln(r){const t={};for(let e=0;e<r.length;e++){const n=pa(r[e]);for(const i in n)t[i]=n[i]}return t}function yT(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}function Q_(r){const t=r.getRenderTarget();return t===null?r.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:fe.workingColorSpace}const Rm={clone:pa,merge:Ln};var _T=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,vT=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`;class si extends gn{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_T,this.fragmentShader=vT,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=fa(t.uniforms),this.uniformsGroups=yT(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?e.uniforms[i]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[i]={type:"m4",value:o.toArray()}:e.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class bd extends si{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Td extends gn{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new wt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Pm extends Td{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new tt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new wt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new wt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new wt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Lm extends gn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new wt(16777215),this.specular=new wt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=uc,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class tv extends gn{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new wt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Fm extends gn{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Dm extends gn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new wt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=uc,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class wd extends gn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rm,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Um extends gn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class ev extends gn{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new wt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this.fog=t.fog,this}}class nv extends Rn{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Hr(r,t){return!r||r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function iv(r){function t(i,s){return r[i]-r[s]}const e=r.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function Np(r,t,e){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=e[s]*t;for(let l=0;l!==t;++l)i[o++]=r[a+l]}return i}function Om(r,t,e,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(t.push(s.time),e.push(...o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(t.push(s.time),e.push(o)),s=r[i++];while(s!==void 0)}function MT(r,t,e,n,i=30){const s=r.clone();s.name=t;const o=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],h=c.getValueSize(),u=[],d=[];for(let f=0;f<c.times.length;++f){const p=c.times[f]*i;if(!(p<e||p>=n)){u.push(c.times[f]);for(let x=0;x<h;++x)d.push(c.values[f*h+x])}}u.length!==0&&(c.times=Hr(u,c.times.constructor),c.values=Hr(d,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s}function ST(r,t=0,e=r,n=30){n<=0&&(n=30);const i=e.tracks.length,s=t/n;for(let o=0;o<i;++o){const a=e.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===l});if(c===void 0)continue;let h=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0;const f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);const p=a.times.length-1;let x;if(s<=a.times[0]){const m=h,y=u-h;x=a.values.slice(m,y)}else if(s>=a.times[p]){const m=p*u+h,y=m+u-h;x=a.values.slice(m,y)}else{const m=a.createInterpolant(),y=h,v=u-h;m.evaluate(s),x=m.resultBuffer.slice(y,v)}l==="quaternion"&&new En().fromArray(x).normalize().conjugate().toArray(x);const g=c.times.length;for(let m=0;m<g;++m){const y=m*f+d;if(l==="quaternion")En.multiplyQuaternionsFlat(c.values,y,x,0,c.values,y);else{const v=f-d*2;for(let _=0;_<v;++_)c.values[y+_]-=x[_]}}}return r.blendMode=sm,r}class bT{static convertArray(t,e){return Hr(t,e)}static isTypedArray(t){return A_(t)}static getKeyframeOrder(t){return iv(t)}static sortedArray(t,e,n){return Np(t,e,n)}static flattenJSON(t,e,n,i){Om(t,e,n,i)}static subclip(t,e,n,i,s=30){return MT(t,e,n,i,s)}static makeClipAdditive(t,e=0,n=t,i=30){return ST(t,e,n,i)}}class so{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],s=e[n-1];t:{e:{let o;n:{i:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break e}o=e.length;break n}if(!(t>=s)){const a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=e[--n-1],t>=s)break e}o=n,n=0;break n}break t}for(;n<o;){const a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class sv extends so{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Vr,endingEnd:Vr}}intervalChanged_(t,e,n){const i=this.parameterPositions;let s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case kr:s=t,a=2*e-n;break;case Zl:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case kr:o=t,l=2*n-e;break;case Zl:o=1,l=n+i[1]-i[0];break;default:o=t-1,l=e}const c=(n-e)*.5,h=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=o*h}interpolate_(t,e,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-e)/(i-e),x=p*p,g=x*p,m=-d*g+2*d*x-d*p,y=(1+d)*g+(-1.5-2*d)*x+(-.5+d)*p+1,v=(-1-f)*g+(1.5+f)*x+.5*p,_=f*g-f*x;for(let w=0;w!==a;++w)s[w]=m*o[h+w]+y*o[c+w]+v*o[l+w]+_*o[u+w];return s}}class Bm extends so{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,h=(n-e)/(i-e),u=1-h;for(let d=0;d!==a;++d)s[d]=o[c+d]*u+o[l+d]*h;return s}}class rv extends so{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class ov extends so{interpolate_(t,e,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,h=this.settings||this.DefaultSettings_,u=h.inTangents,d=h.outTangents;if(!u||!d){const x=(n-e)/(i-e),g=1-x;for(let m=0;m!==a;++m)s[m]=o[c+m]*g+o[l+m]*x;return s}const f=a*2,p=t-1;for(let x=0;x!==a;++x){const g=o[c+x],m=o[l+x],y=p*f+x*2,v=d[y],_=d[y+1],w=t*f+x*2,T=u[w],E=u[w+1];let M=(n-e)/(i-e),b,P,N,L,U;for(let V=0;V<8;V++){b=M*M,P=b*M,N=1-M,L=N*N,U=L*N;const k=U*e+3*L*M*v+3*N*b*T+P*i-n;if(Math.abs(k)<1e-10)break;const G=3*L*(v-e)+6*N*M*(T-v)+3*b*(i-T);if(Math.abs(G)<1e-10)break;M=M-k/G,M=Math.max(0,Math.min(1,M))}s[x]=U*g+3*L*M*_+3*N*b*E+P*m}return s}}class ri{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Hr(e,this.TimeBufferType),this.values=Hr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Hr(t.times,Array),values:Hr(t.values,Array)};const i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new rv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Bm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new sv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new ov(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.settings=this.settings),e}setInterpolation(t){let e;switch(t){case ca:e=this.InterpolantFactoryMethodDiscrete;break;case Yl:e=this.InterpolantFactoryMethodLinear;break;case su:e=this.InterpolantFactoryMethodSmooth;break;case Tp:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return pt("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ca;case this.InterpolantFactoryMethodLinear:return Yl;case this.InterpolantFactoryMethodSmooth:return su;case this.InterpolantFactoryMethodBezier:return Tp}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let s=0,o=i-1;for(;s!==i&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(Vt("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,s=n.length;s===0&&(Vt("KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){Vt("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){Vt("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&A_(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){Vt("KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===su,s=t.length-1;let o=1;for(let a=1;a<s;++a){let l=!1;const c=t[a],h=t[a+1];if(c!==h&&(a!==1||c!==t[0]))if(i)l=!0;else{const u=a*n,d=u-n,f=u+n;for(let p=0;p!==n;++p){const x=e[u+p];if(x!==e[d+p]||x!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];const u=a*n,d=o*n;for(let f=0;f!==n;++f)e[d+f]=e[u+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}ri.prototype.ValueTypeName="";ri.prototype.TimeBufferType=Float32Array;ri.prototype.ValueBufferType=Float32Array;ri.prototype.DefaultInterpolation=Yl;class pr extends ri{constructor(t,e,n){super(t,e,n)}}pr.prototype.ValueTypeName="bool";pr.prototype.ValueBufferType=Array;pr.prototype.DefaultInterpolation=ca;pr.prototype.InterpolantFactoryMethodLinear=void 0;pr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ad extends ri{constructor(t,e,n,i){super(t,e,n,i)}}Ad.prototype.ValueTypeName="color";class pa extends ri{constructor(t,e,n,i){super(t,e,n,i)}}pa.prototype.ValueTypeName="number";class av extends so{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(i-e);let c=t*a;for(let h=c+a;c!==h;c+=4)En.slerpFlat(s,0,o,c-a,o,c,l);return s}}class Aa extends ri{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new av(this.times,this.values,this.getValueSize(),t)}}Aa.prototype.ValueTypeName="quaternion";Aa.prototype.InterpolantFactoryMethodSmooth=void 0;class ro extends ri{constructor(t,e,n){super(t,e,n)}}ro.prototype.ValueTypeName="string";ro.prototype.ValueBufferType=Array;ro.prototype.DefaultInterpolation=ca;ro.prototype.InterpolantFactoryMethodLinear=void 0;ro.prototype.InterpolantFactoryMethodSmooth=void 0;class ma extends ri{constructor(t,e,n,i){super(t,e,n,i)}}ma.prototype.ValueTypeName="vector";class ga{constructor(t="",e=-1,n=[],i=id){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=ei(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(wT(n[o]).scale(i));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s.userData=JSON.parse(t.userData||"{}"),s}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let s=0,o=n.length;s!==o;++s)e.push(ri.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const s=e.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);const h=iv(l);l=Np(l,1,h),c=Np(c,1,h),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new pa(".morphTargetInfluences["+e[a].name+"]",l,c).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){const c=t[a],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,n));return o}static parseAnimation(t,e){if(pt("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return Vt("AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,p,x){if(f.length!==0){const g=[],m=[];Om(f,g,m,p),g.length!==0&&x.push(new u(d,g,m))}},i=[],s=t.name||"default",o=t.fps||30,a=t.blendMode;let l=t.length||-1;const c=t.hierarchy||[];for(let u=0;u<c.length;u++){const d=c[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let x=0;x<d[p].morphTargets.length;x++)f[d[p].morphTargets[x]]=-1;for(const x in f){const g=[],m=[];for(let y=0;y!==d[p].morphTargets.length;++y){const v=d[p];g.push(v.time),m.push(v.morphTarget===x?1:0)}i.push(new pa(".morphTargetInfluence["+x+"]",g,m))}l=f.length*o}else{const f=".bones["+e[u].name+"]";n(ma,f+".position",d,"pos",i),n(Aa,f+".quaternion",d,"rot",i),n(ma,f+".scale",d,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){const t=this.tracks;let e=0;for(let n=0,i=t.length;n!==i;++n){const s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function TT(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return pa;case"vector":case"vector2":case"vector3":case"vector4":return ma;case"color":return Ad;case"quaternion":return Aa;case"bool":case"boolean":return pr;case"string":return ro}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function wT(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=TT(r.type);if(r.times===void 0){const e=[],n=[];Om(r.keys,e,n,"value"),r.times=e,r.values=n}return t.parse!==void 0?t.parse(r):new t(r.name,r.times,r.values,r.interpolation)}const Fi={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(P0(r)||(this.files[r]=t))},get:function(r){if(this.enabled!==!1&&!P0(r))return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};function P0(r){try{const t=r.slice(r.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class Ed{constructor(t,e,n){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){const f=c[u],p=c[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const zm=new Ed;class Vn{constructor(t){this.manager=t!==void 0?t:zm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}Vn.DEFAULT_MATERIAL_NAME="__DEFAULT";const ys={};class AT extends Error{constructor(t,e){super(t),this.response=e}}class rs extends Vn{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=Fi.get(`file:${t}`);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(ys[t]!==void 0){ys[t].push({onLoad:e,onProgress:n,onError:i});return}ys[t]=[],ys[t].push({onLoad:e,onProgress:n,onError:i});const o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&pt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=ys[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let x=0;const g=new ReadableStream({start(m){y();function y(){u.read().then(({done:v,value:_})=>{if(v)m.close();else{x+=_.byteLength;const w=new ProgressEvent("progress",{lengthComputable:p,loaded:x,total:f});for(let T=0,E=h.length;T<E;T++){const M=h[T];M.onProgress&&M.onProgress(w)}m.enqueue(_),y()}},v=>{m.error(v)})}}});return new Response(g)}else throw new AT(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a==="")return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{Fi.add(`file:${t}`,c);const h=ys[t];delete ys[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(c)}}).catch(c=>{const h=ys[t];if(h===void 0)throw this.manager.itemError(t),c;delete ys[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class ET extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=new rs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):Vt(l),s.manager.itemError(t)}},n,i)}parse(t){const e=[];for(let n=0;n<t.length;n++){const i=ga.parse(t[n]);e.push(i)}return e}}class CT extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=[],a=new _c,l=new rs(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function h(u){l.load(t[u],function(d){const f=s.parse(d,!0);o[u]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},c+=1,c===6&&(f.mipmapCount===1&&(a.minFilter=Fe),a.image=o,a.format=f.format,a.needsUpdate=!0,e&&e(a))},n,i)}if(Array.isArray(t))for(let u=0,d=t.length;u<d;++u)h(u);else l.load(t,function(u){const d=s.parse(u,!0);if(d.isCubemap){const f=d.mipmaps.length/d.mipmapCount;for(let p=0;p<f;p++){o[p]={mipmaps:[]};for(let x=0;x<d.mipmapCount;x++)o[p].mipmaps.push(d.mipmaps[p*d.mipmapCount+x]),o[p].format=d.format,o[p].width=d.width,o[p].height=d.height}a.image=o}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=Fe),a.format=d.format,a.needsUpdate=!0,e&&e(a)},n,i);return a}}const Eo=new WeakMap;class sc extends Vn{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=Fi.get(`image:${t}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0);else{let u=Eo.get(o);u===void 0&&(u=[],Eo.set(o,u)),u.push({onLoad:e,onError:i})}return o}const a=Kl("img");function l(){h(),e&&e(this);const u=Eo.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}Eo.delete(this),s.manager.itemEnd(t)}function c(u){h(),i&&i(u),Fi.remove(`image:${t}`);const d=Eo.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}Eo.delete(this),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),Fi.add(`image:${t}`,a),s.manager.itemStart(t),a.src=t,a}}class NT extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=new Sa;s.colorSpace=Fn;const o=new sc(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(t[c],function(h){s.images[c]=h,a++,a===6&&(s.needsUpdate=!0,e&&e(s))},void 0,i)}for(let c=0;c<t.length;++c)l(c);return s}}class lv extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=new fi,a=new rs(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(t,function(l){let c;try{c=s.parse(l)}catch(h){if(i!==void 0)i(h);else{h(h);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:Bn,o.wrapT=c.wrapT!==void 0?c.wrapT:Bn,o.magFilter=c.magFilter!==void 0?c.magFilter:Fe,o.minFilter=c.minFilter!==void 0?c.minFilter:Fe,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=Li),c.mipmapCount===1&&(o.minFilter=Fe),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,e&&e(o,c)},n,i),o}}class cv extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=new rn,o=new sc(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},n,i),s}}let mr=class extends ve{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new wt(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}},Vm=class extends mr{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.groundColor=new wt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}};const Ef=new Qt,L0=new R,F0=new R;let km=class{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new tt(512,512),this.mapType=Un,this.map=null,this.mapPass=null,this.matrix=new Qt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new no,this._frameExtents=new tt(1,1),this._viewportCount=1,this._viewports=[new Le(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;L0.setFromMatrixPosition(t.matrixWorld),e.position.copy(L0),F0.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(F0),e.updateMatrixWorld(),Ef.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ef,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Zr||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ef)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}};const gh=new R,xh=new En,Wi=new R;let Tc=class extends ve{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Qt,this.projectionMatrix=new Qt,this.projectionMatrixInverse=new Qt,this.coordinateSystem=ti,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(gh,xh,Wi),Wi.x===1&&Wi.y===1&&Wi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gh,xh,Wi.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose(gh,xh,Wi),Wi.x===1&&Wi.y===1&&Wi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gh,xh,Wi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};const Hs=new R,D0=new tt,U0=new tt;let cn=class extends Tc{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=ha*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Xr*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return ha*2*Math.atan(Math.tan(Xr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Hs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Hs.x,Hs.y).multiplyScalar(-t/Hs.z),Hs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Hs.x,Hs.y).multiplyScalar(-t/Hs.z)}getViewSize(t,e){return this.getViewBounds(t,D0,U0),e.subVectors(U0,D0)}setViewOffset(t,e,n,i,s,o){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Xr*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,e-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},RT=class extends km{constructor(){super(new cn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=ha*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Gm=class extends mr{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.target=new ve,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new RT}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}},IT=class extends km{constructor(){super(new cn(90,1,.5,500)),this.isPointLightShadow=!0}},Hm=class extends mr{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new IT}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}},Ea=class extends Tc{constructor(t=-1,e=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-t,o=n+t,a=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},PT=class extends km{constructor(){super(new Ea(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Wm=class extends mr{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.target=new ve,this.shadow=new PT}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}},Xm=class extends mr{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}},hv=class extends mr{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}},$m=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new R)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*i),e.addScaledVector(o[2],.488603*s),e.addScaledVector(o[3],.488603*n),e.addScaledVector(o[4],1.092548*(n*i)),e.addScaledVector(o[5],1.092548*(i*s)),e.addScaledVector(o[6],.315392*(3*s*s-1)),e.addScaledVector(o[7],1.092548*(n*s)),e.addScaledVector(o[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],2*.511664*i),e.addScaledVector(o[2],2*.511664*s),e.addScaledVector(o[3],2*.511664*n),e.addScaledVector(o[4],2*.429043*n*i),e.addScaledVector(o[5],2*.429043*i*s),e.addScaledVector(o[6],.743125*s*s-.247708),e.addScaledVector(o[7],2*.429043*n*s),e.addScaledVector(o[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+i*3);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+i*3);return t}static getBasisAt(t,e){const n=t.x,i=t.y,s=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*s,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*n*s,e[8]=.546274*(n*n-i*i)}},uv=class extends mr{constructor(t=new $m,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}};class Cd extends Vn{constructor(t){super(t),this.textures={}}load(t,e,n,i){const s=this,o=new rs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):Vt(l),s.manager.itemError(t)}},n,i)}parse(t){const e=this.textures;function n(s){return e[s]===void 0&&pt("MaterialLoader: Undefined texture",s),e[s]}const i=this.createMaterialFromType(t.type);if(t.uuid!==void 0&&(i.uuid=t.uuid),t.name!==void 0&&(i.name=t.name),t.color!==void 0&&i.color!==void 0&&i.color.setHex(t.color),t.roughness!==void 0&&(i.roughness=t.roughness),t.metalness!==void 0&&(i.metalness=t.metalness),t.sheen!==void 0&&(i.sheen=t.sheen),t.sheenColor!==void 0&&(i.sheenColor=new wt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(i.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(t.emissive),t.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(t.specular),t.specularIntensity!==void 0&&(i.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(i.shininess=t.shininess),t.clearcoat!==void 0&&(i.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(i.dispersion=t.dispersion),t.iridescence!==void 0&&(i.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(i.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(i.transmission=t.transmission),t.thickness!==void 0&&(i.thickness=t.thickness),t.attenuationDistance!==void 0&&(i.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(i.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(i.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(i.fog=t.fog),t.flatShading!==void 0&&(i.flatShading=t.flatShading),t.blending!==void 0&&(i.blending=t.blending),t.combine!==void 0&&(i.combine=t.combine),t.side!==void 0&&(i.side=t.side),t.shadowSide!==void 0&&(i.shadowSide=t.shadowSide),t.opacity!==void 0&&(i.opacity=t.opacity),t.transparent!==void 0&&(i.transparent=t.transparent),t.alphaTest!==void 0&&(i.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(i.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(i.depthFunc=t.depthFunc),t.depthTest!==void 0&&(i.depthTest=t.depthTest),t.depthWrite!==void 0&&(i.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(i.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(i.blendSrc=t.blendSrc),t.blendDst!==void 0&&(i.blendDst=t.blendDst),t.blendEquation!==void 0&&(i.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(i.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(i.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(i.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(i.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(i.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(i.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(i.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(i.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(i.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(i.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(i.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(i.rotation=t.rotation),t.linewidth!==void 0&&(i.linewidth=t.linewidth),t.dashSize!==void 0&&(i.dashSize=t.dashSize),t.gapSize!==void 0&&(i.gapSize=t.gapSize),t.scale!==void 0&&(i.scale=t.scale),t.polygonOffset!==void 0&&(i.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(i.dithering=t.dithering),t.alphaToCoverage!==void 0&&(i.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(i.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(i.allowOverride=t.allowOverride),t.visible!==void 0&&(i.visible=t.visible),t.toneMapped!==void 0&&(i.toneMapped=t.toneMapped),t.userData!==void 0&&(i.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const s in t.uniforms){const o=t.uniforms[s];switch(i.uniforms[s]={},o.type){case"t":i.uniforms[s].value=n(o.value);break;case"c":i.uniforms[s].value=new wt().setHex(o.value);break;case"v2":i.uniforms[s].value=new tt().fromArray(o.value);break;case"v3":i.uniforms[s].value=new R().fromArray(o.value);break;case"v4":i.uniforms[s].value=new Le().fromArray(o.value);break;case"m3":i.uniforms[s].value=new ae().fromArray(o.value);break;case"m4":i.uniforms[s].value=new Qt().fromArray(o.value);break;default:i.uniforms[s].value=o.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(const s in t.extensions)i.extensions[s]=t.extensions[s];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let s=t.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new tt().fromArray(s)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new tt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Cd.createMaterialFromType(t)}static createMaterialFromType(t){const e={ShadowMaterial:Rm,SpriteMaterial:cd,RawShaderMaterial:bd,ShaderMaterial:si,PointsMaterial:dd,MeshPhysicalMaterial:Pm,MeshStandardMaterial:Td,MeshPhongMaterial:Lm,MeshToonMaterial:tv,MeshNormalMaterial:Fm,MeshLambertMaterial:Dm,MeshDepthMaterial:wd,MeshDistanceMaterial:Um,MeshBasicMaterial:Ds,MeshMatcapMaterial:ev,LineDashedMaterial:nv,LineBasicMaterial:Rn,Material:gn};return new e[t]}}class Fu{static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class qm extends se{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class dv extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=new rs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):Vt(l),s.manager.itemError(t)}},n,i)}parse(t){const e={},n={};function i(f,p){if(e[p]!==void 0)return e[p];const g=f.interleavedBuffers[p],m=s(f,g.buffer),y=Zo(g.type,m),v=new xc(y,g.stride);return v.uuid=g.uuid,e[p]=v,v}function s(f,p){if(n[p]!==void 0)return n[p];const g=f.arrayBuffers[p],m=new Uint32Array(g).buffer;return n[p]=m,m}const o=t.isInstancedBufferGeometry?new qm:new se,a=t.data.index;if(a!==void 0){const f=Zo(a.type,a.array);o.setIndex(new Te(f,1))}const l=t.data.attributes;for(const f in l){const p=l[f];let x;if(p.isInterleavedBufferAttribute){const g=i(t.data,p.data);x=new ua(g,p.itemSize,p.offset,p.normalized)}else{const g=Zo(p.type,p.array),m=p.isInstancedBufferAttribute?Jr:Te;x=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(x.name=p.name),p.usage!==void 0&&x.setUsage(p.usage),o.setAttribute(f,x)}const c=t.data.morphAttributes;if(c)for(const f in c){const p=c[f],x=[];for(let g=0,m=p.length;g<m;g++){const y=p[g];let v;if(y.isInterleavedBufferAttribute){const _=i(t.data,y.data);v=new ua(_,y.itemSize,y.offset,y.normalized)}else{const _=Zo(y.type,y.array);v=new Te(_,y.itemSize,y.normalized)}y.name!==void 0&&(v.name=y.name),x.push(v)}o.morphAttributes[f]=x}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const u=t.data.groups||t.data.drawcalls||t.data.offsets;if(u!==void 0)for(let f=0,p=u.length;f!==p;++f){const x=u[f];o.addGroup(x.start,x.count,x.materialIndex)}const d=t.data.boundingSphere;return d!==void 0&&(o.boundingSphere=new un().fromJSON(d)),t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}}class LT extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=this.path===""?Fu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||o;const a=new rs(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(l){let c=null;try{c=JSON.parse(l)}catch(u){i!==void 0&&i(u),u("ObjectLoader: Can't parse "+t+".",u.message);return}const h=c.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+t)),Vt("ObjectLoader: Can't load "+t);return}s.parse(c,e)},n,i)}async loadAsync(t,e){const n=this,i=this.path===""?Fu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const s=new rs(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const o=await s.loadAsync(t,e);let a;try{a=JSON.parse(o)}catch(c){throw new Error("ObjectLoader: Can't parse "+t+". "+c.message)}const l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+t);return await n.parseAsync(a)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,i),o=this.parseImages(t.images,function(){e!==void 0&&e(c)}),a=this.parseTextures(t.textures,o),l=this.parseMaterials(t.materials,a),c=this.parseObject(t.object,s,l,a,n),h=this.parseSkeletons(t.skeletons,c);if(this.bindSkeletons(c,h),this.bindLightTargets(c),e!==void 0){let u=!1;for(const d in o)if(o[d].data instanceof HTMLImageElement){u=!0;break}u===!1&&e(c)}return c}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),s=await this.parseImagesAsync(t.images),o=this.parseTextures(t.textures,s),a=this.parseMaterials(t.materials,o),l=this.parseObject(t.object,i,a,o,e),c=this.parseSkeletons(t.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(t){const e={};if(t!==void 0)for(let n=0,i=t.length;n<i;n++){const s=new ir().fromJSON(t[n]);e[s.uuid]=s}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse(function(s){s.isBone&&(i[s.uuid]=s)}),t!==void 0)for(let s=0,o=t.length;s<o;s++){const a=new yc().fromJSON(t[s],i);n[a.uuid]=a}return n}parseGeometries(t,e){const n={};if(t!==void 0){const i=new dv;for(let s=0,o=t.length;s<o;s++){let a;const l=t[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(l);break;default:l.type in I0?a=I0[l.type].fromJSON(l,e):pt(`ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),n[l.uuid]=a}}return n}parseMaterials(t,e){const n={},i={};if(t!==void 0){const s=new Cd;s.setTextures(e);for(let o=0,a=t.length;o<a;o++){const l=t[o];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),i[l.uuid]=n[l.uuid]}}return i}parseAnimations(t){const e={};if(t!==void 0)for(let n=0;n<t.length;n++){const i=t[n],s=ga.parse(i);e[s.uuid]=s}return e}parseImages(t,e){const n=this,i={};let s;function o(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){const c=l,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return o(h)}else return l.data?{data:Zo(l.type,l.data),width:l.width,height:l.height}:null}if(t!==void 0&&t.length>0){const l=new Ed(e);s=new sc(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=t.length;c<h;c++){const u=t[c],d=u.url;if(Array.isArray(d)){const f=[];for(let p=0,x=d.length;p<x;p++){const g=d[p],m=a(g);m!==null&&(m instanceof HTMLImageElement?f.push(m):f.push(new fi(m.data,m.width,m.height)))}i[u.uuid]=new Ns(f)}else{const f=a(u.url);i[u.uuid]=new Ns(f)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function s(o){if(typeof o=="string"){const a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:e.resourcePath+a;return await i.loadAsync(l)}else return o.data?{data:Zo(o.type,o.data),width:o.width,height:o.height}:null}if(t!==void 0&&t.length>0){i=new sc(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=t.length;o<a;o++){const l=t[o],c=l.url;if(Array.isArray(c)){const h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u],p=await s(f);p!==null&&(p instanceof HTMLImageElement?h.push(p):h.push(new fi(p.data,p.width,p.height)))}n[l.uuid]=new Ns(h)}else{const h=await s(l.url);n[l.uuid]=new Ns(h)}}}return n}parseTextures(t,e){function n(s,o){return typeof s=="number"?s:(pt("ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}const i={};if(t!==void 0)for(let s=0,o=t.length;s<o;s++){const a=t[s];a.image===void 0&&pt('ObjectLoader: No "image" specified for',a.uuid),e[a.image]===void 0&&pt("ObjectLoader: Undefined image",a.image);const l=e[a.image],c=l.data;let h;Array.isArray(c)?(h=new Sa,c.length===6&&(h.needsUpdate=!0)):(c&&c.data?h=new fi:h=new rn,c&&(h.needsUpdate=!0)),h.source=l,h.uuid=a.uuid,a.name!==void 0&&(h.name=a.name),a.mapping!==void 0&&(h.mapping=n(a.mapping,FT)),a.channel!==void 0&&(h.channel=a.channel),a.offset!==void 0&&h.offset.fromArray(a.offset),a.repeat!==void 0&&h.repeat.fromArray(a.repeat),a.center!==void 0&&h.center.fromArray(a.center),a.rotation!==void 0&&(h.rotation=a.rotation),a.wrap!==void 0&&(h.wrapS=n(a.wrap[0],O0),h.wrapT=n(a.wrap[1],O0)),a.format!==void 0&&(h.format=a.format),a.internalFormat!==void 0&&(h.internalFormat=a.internalFormat),a.type!==void 0&&(h.type=a.type),a.colorSpace!==void 0&&(h.colorSpace=a.colorSpace),a.minFilter!==void 0&&(h.minFilter=n(a.minFilter,B0)),a.magFilter!==void 0&&(h.magFilter=n(a.magFilter,B0)),a.anisotropy!==void 0&&(h.anisotropy=a.anisotropy),a.flipY!==void 0&&(h.flipY=a.flipY),a.generateMipmaps!==void 0&&(h.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(h.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(h.compareFunction=a.compareFunction),a.userData!==void 0&&(h.userData=a.userData),i[a.uuid]=h}return i}parseObject(t,e,n,i,s){let o;function a(d){return e[d]===void 0&&pt("ObjectLoader: Undefined geometry",d),e[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const f=[];for(let p=0,x=d.length;p<x;p++){const g=d[p];n[g]===void 0&&pt("ObjectLoader: Undefined material",g),f.push(n[g])}return f}return n[d]===void 0&&pt("ObjectLoader: Undefined material",d),n[d]}}function c(d){return i[d]===void 0&&pt("ObjectLoader: Undefined texture",d),i[d]}let h,u;switch(t.type){case"Scene":o=new hm,t.background!==void 0&&(Number.isInteger(t.background)?o.background=new wt(t.background):o.background=c(t.background)),t.environment!==void 0&&(o.environment=c(t.environment)),t.fog!==void 0&&(t.fog.type==="Fog"?o.fog=new cm(t.fog.color,t.fog.near,t.fog.far):t.fog.type==="FogExp2"&&(o.fog=new ad(t.fog.color,t.fog.density)),t.fog.name!==""&&(o.fog.name=t.fog.name)),t.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=t.backgroundBlurriness),t.backgroundIntensity!==void 0&&(o.backgroundIntensity=t.backgroundIntensity),t.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(t.backgroundRotation),t.environmentIntensity!==void 0&&(o.environmentIntensity=t.environmentIntensity),t.environmentRotation!==void 0&&o.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":o=new cn(t.fov,t.aspect,t.near,t.far),t.focus!==void 0&&(o.focus=t.focus),t.zoom!==void 0&&(o.zoom=t.zoom),t.filmGauge!==void 0&&(o.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(o.filmOffset=t.filmOffset),t.view!==void 0&&(o.view=Object.assign({},t.view));break;case"OrthographicCamera":o=new Ea(t.left,t.right,t.top,t.bottom,t.near,t.far),t.zoom!==void 0&&(o.zoom=t.zoom),t.view!==void 0&&(o.view=Object.assign({},t.view));break;case"AmbientLight":o=new Xm(t.color,t.intensity);break;case"DirectionalLight":o=new Wm(t.color,t.intensity),o.target=t.target||"";break;case"PointLight":o=new Hm(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":o=new hv(t.color,t.intensity,t.width,t.height);break;case"SpotLight":o=new Gm(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),o.target=t.target||"";break;case"HemisphereLight":o=new Vm(t.color,t.groundColor,t.intensity);break;case"LightProbe":const d=new $m().fromArray(t.sh);o=new uv(d,t.intensity);break;case"SkinnedMesh":h=a(t.geometry),u=l(t.material),o=new pm(h,u),t.bindMode!==void 0&&(o.bindMode=t.bindMode),t.bindMatrix!==void 0&&o.bindMatrix.fromArray(t.bindMatrix),t.skeleton!==void 0&&(o.skeleton=t.skeleton);break;case"Mesh":h=a(t.geometry),u=l(t.material),o=new Ye(h,u);break;case"InstancedMesh":h=a(t.geometry),u=l(t.material);const f=t.count,p=t.instanceMatrix,x=t.instanceColor;o=new mm(h,u,f),o.instanceMatrix=new Jr(new Float32Array(p.array),16),x!==void 0&&(o.instanceColor=new Jr(new Float32Array(x.array),x.itemSize));break;case"BatchedMesh":h=a(t.geometry),u=l(t.material),o=new gm(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,u),o.geometry=h,o.perObjectFrustumCulled=t.perObjectFrustumCulled,o.sortObjects=t.sortObjects,o._drawRanges=t.drawRanges,o._reservedRanges=t.reservedRanges,o._geometryInfo=t.geometryInfo.map(g=>{let m=null,y=null;return g.boundingBox!==void 0&&(m=new mn().fromJSON(g.boundingBox)),g.boundingSphere!==void 0&&(y=new un().fromJSON(g.boundingSphere)),{...g,boundingBox:m,boundingSphere:y}}),o._instanceInfo=t.instanceInfo,o._availableInstanceIds=t._availableInstanceIds,o._availableGeometryIds=t._availableGeometryIds,o._nextIndexStart=t.nextIndexStart,o._nextVertexStart=t.nextVertexStart,o._geometryCount=t.geometryCount,o._maxInstanceCount=t.maxInstanceCount,o._maxVertexCount=t.maxVertexCount,o._maxIndexCount=t.maxIndexCount,o._geometryInitialized=t.geometryInitialized,o._matricesTexture=c(t.matricesTexture.uuid),o._indirectTexture=c(t.indirectTexture.uuid),t.colorsTexture!==void 0&&(o._colorsTexture=c(t.colorsTexture.uuid)),t.boundingSphere!==void 0&&(o.boundingSphere=new un().fromJSON(t.boundingSphere)),t.boundingBox!==void 0&&(o.boundingBox=new mn().fromJSON(t.boundingBox));break;case"LOD":o=new fm;break;case"Line":o=new Fs(a(t.geometry),l(t.material));break;case"LineLoop":o=new xm(a(t.geometry),l(t.material));break;case"LineSegments":o=new zi(a(t.geometry),l(t.material));break;case"PointCloud":case"Points":o=new ym(a(t.geometry),l(t.material));break;case"Sprite":o=new dm(l(t.material));break;case"Group":o=new Gr;break;case"Bone":o=new hd;break;default:o=new ve}if(o.uuid=t.uuid,t.name!==void 0&&(o.name=t.name),t.matrix!==void 0?(o.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=t.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(t.position!==void 0&&o.position.fromArray(t.position),t.rotation!==void 0&&o.rotation.fromArray(t.rotation),t.quaternion!==void 0&&o.quaternion.fromArray(t.quaternion),t.scale!==void 0&&o.scale.fromArray(t.scale)),t.up!==void 0&&o.up.fromArray(t.up),t.pivot!==void 0&&(o.pivot=new R().fromArray(t.pivot)),t.morphTargetDictionary!==void 0&&(o.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),t.morphTargetInfluences!==void 0&&(o.morphTargetInfluences=t.morphTargetInfluences.slice()),t.castShadow!==void 0&&(o.castShadow=t.castShadow),t.receiveShadow!==void 0&&(o.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(o.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(o.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(o.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(o.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(o.visible=t.visible),t.frustumCulled!==void 0&&(o.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(o.renderOrder=t.renderOrder),t.static!==void 0&&(o.static=t.static),t.userData!==void 0&&(o.userData=t.userData),t.layers!==void 0&&(o.layers.mask=t.layers),t.children!==void 0){const d=t.children;for(let f=0;f<d.length;f++)o.add(this.parseObject(d[f],e,n,i,s))}if(t.animations!==void 0){const d=t.animations;for(let f=0;f<d.length;f++){const p=d[f];o.animations.push(s[p])}}if(t.type==="LOD"){t.autoUpdate!==void 0&&(o.autoUpdate=t.autoUpdate);const d=t.levels;for(let f=0;f<d.length;f++){const p=d[f],x=o.getObjectByProperty("uuid",p.object);x!==void 0&&o.addLevel(x,p.distance,p.hysteresis)}}return o}bindSkeletons(t,e){Object.keys(e).length!==0&&t.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=e[n.skeleton];i===void 0?pt("ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const n=e.target,i=t.getObjectByProperty("uuid",n);i!==void 0?e.target=i:e.target=new ve}})}}const FT={UVMapping:Zu,CubeReflectionMapping:ss,CubeRefractionMapping:or,EquirectangularReflectionMapping:Jo,EquirectangularRefractionMapping:jo,CubeUVReflectionMapping:to},O0={RepeatWrapping:oa,ClampToEdgeWrapping:Bn,MirroredRepeatWrapping:aa},B0={NearestFilter:Xe,NearestMipmapNearestFilter:Ju,NearestMipmapLinearFilter:zr,LinearFilter:Fe,LinearMipmapNearestFilter:Ko,LinearMipmapLinearFilter:Li},Cf=new WeakMap;class fv extends Vn{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&pt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&pt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=Fi.get(`image-bitmap:${t}`);if(o!==void 0){if(s.manager.itemStart(t),o.then){o.then(c=>{if(Cf.has(o)===!0)i&&i(Cf.get(o)),s.manager.itemError(t),s.manager.itemEnd(t);else return e&&e(c),s.manager.itemEnd(t),c});return}return setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(t,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Fi.add(`image-bitmap:${t}`,c),e&&e(c),s.manager.itemEnd(t),c}).catch(function(c){i&&i(c),Cf.set(l,c),Fi.remove(`image-bitmap:${t}`),s.manager.itemError(t),s.manager.itemEnd(t)});Fi.add(`image-bitmap:${t}`,l),s.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let yh;class Nd{static getContext(){return yh===void 0&&(yh=new(window.AudioContext||window.webkitAudioContext)),yh}static setContext(t){yh=t}}class pv extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=new rs(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(l){try{const c=l.slice(0);Nd.getContext().decodeAudioData(c,function(u){e(u)}).catch(a)}catch(c){a(c)}},n,i);function a(l){i?i(l):Vt(l),s.manager.itemError(t)}}}const z0=new Qt,V0=new Qt,Tr=new Qt;class DT{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new cn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new cn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Tr.copy(t.projectionMatrix);const i=e.eyeSep/2,s=i*e.near/e.focus,o=e.near*Math.tan(Xr*e.fov*.5)/e.zoom;let a,l;V0.elements[12]=-i,z0.elements[12]=i,a=-o*e.aspect+s,l=o*e.aspect+s,Tr.elements[0]=2*e.near/(l-a),Tr.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Tr),a=-o*e.aspect-s,l=o*e.aspect-s,Tr.elements[0]=2*e.near/(l-a),Tr.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Tr)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(V0),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(z0)}}const Co=-90,No=1;class Ym extends ve{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new cn(Co,No,t,e);i.layers=this.layers,this.add(i);const s=new cn(Co,No,t,e);s.layers=this.layers,this.add(s);const o=new cn(Co,No,t,e);o.layers=this.layers,this.add(o);const a=new cn(Co,No,t,e);a.layers=this.layers,this.add(a);const l=new cn(Co,No,t,e);l.layers=this.layers,this.add(l);const c=new cn(Co,No,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,s,o,a,l]=e;for(const c of e)this.remove(c);if(t===ti)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Zr)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;t.isWebGLRenderer===!0?g=t.state.buffers.depth.getReversed():g=t.reversedDepthBuffer,t.setRenderTarget(n,0,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,s),t.setRenderTarget(n,1,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,2,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,3,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),t.setRenderTarget(n,4,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Zm extends cn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class Jm{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,t.hidden!==void 0&&(this._pageVisibilityHandler=UT.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(t!==void 0?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function UT(){this._document.hidden===!1&&this.reset()}const Xi=new R,Nf=new En,OT=new R,wr=new R,Ar=new R;let mv=class extends ve{constructor(){super(),this.type="AudioListener",this.context=Nd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new Jm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t),this._timer.update();const e=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(Xi,Nf,OT),!(!Number.isFinite(Xi.x)||!Number.isFinite(Xi.y)||!Number.isFinite(Xi.z)))if(wr.set(0,0,-1).applyQuaternion(Nf),Ar.set(0,1,0).applyQuaternion(Nf),e.positionX){const n=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Xi.x,n),e.positionY.linearRampToValueAtTime(Xi.y,n),e.positionZ.linearRampToValueAtTime(Xi.z,n),e.forwardX.linearRampToValueAtTime(wr.x,n),e.forwardY.linearRampToValueAtTime(wr.y,n),e.forwardZ.linearRampToValueAtTime(wr.z,n),e.upX.linearRampToValueAtTime(Ar.x,n),e.upY.linearRampToValueAtTime(Ar.y,n),e.upZ.linearRampToValueAtTime(Ar.z,n)}else e.setPosition(Xi.x,Xi.y,Xi.z),e.setOrientation(wr.x,wr.y,wr.z,Ar.x,Ar.y,Ar.z)}};class jm extends ve{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.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(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){pt("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(t=0){if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),this._connected===!0?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}return this.playbackRate=t,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(pt("Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}return this.loop=t,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),t.sourceType!=="buffer"?(pt("Audio: Audio source type cannot be copied."),this):(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice(),this)}clone(t){return new this.constructor(this.listener).copy(this,t)}}const Er=new R,k0=new En,BT=new R,Cr=new R;class gv extends jm{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Er,k0,BT),Cr.set(0,0,1).applyQuaternion(k0);const e=this.panner;if(e.positionX){const n=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(Er.x,n),e.positionY.linearRampToValueAtTime(Er.y,n),e.positionZ.linearRampToValueAtTime(Er.z,n),e.orientationX.linearRampToValueAtTime(Cr.x,n),e.orientationY.linearRampToValueAtTime(Cr.y,n),e.orientationZ.linearRampToValueAtTime(Cr.z,n)}else e.setPosition(Er.x,Er.y,Er.z),e.setOrientation(Cr.x,Cr.y,Cr.z)}}class zT{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}}class xv{constructor(t,e,n){this.binding=t,this.valueSize=n;let i,s,o;switch(e){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,s=t*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[s+a]=n[a];o=e}else{o+=e;const a=e/o;this._mixBufferRegion(n,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=e*this._origIndex;this._mixBufferRegion(n,i,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(n[l]!==n[l+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let s=n,o=i;s!==o;++s)e[s]=e[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,s){if(i>=.5)for(let o=0;o!==s;++o)t[e+o]=t[n+o]}_slerp(t,e,n,i){En.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,s){const o=this._workIndex*s;En.multiplyQuaternionsFlat(t,o,t,e,t,n),En.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,n,i,s){const o=1-i;for(let a=0;a!==s;++a){const l=e+a;t[l]=t[l]*o+t[n+a]*i}}_lerpAdditive(t,e,n,i,s){for(let o=0;o!==s;++o){const a=e+o;t[a]=t[a]+t[n+o]*i}}}const Km="\\[\\]\\.:\\/",VT=new RegExp("["+Km+"]","g"),Qm="[^"+Km+"]",kT="[^"+Km.replace("\\.","")+"]",GT=/((?:WC+[\/:])*)/.source.replace("WC",Qm),HT=/(WCOD+)?/.source.replace("WCOD",kT),WT=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qm),XT=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qm),$T=new RegExp("^"+GT+HT+WT+XT+"$"),qT=["material","materials","bones","map"];class YT{constructor(t,e,n){const i=n||me.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class me{constructor(t,e,n){this.path=e,this.parsedPath=n||me.parseTrackName(e),this.node=me.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new me.Composite(t,e,n):new me(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(VT,"")}static parseTrackName(t){const e=$T.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);qT.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(s,o){for(let a=0;a<s.length;a++){const l=s[a];if(!o&&(l.name===e||l.uuid===e))return l;if(o&&l.userData&&l.userData.name===e)return l;const c=n(l.children,o);if(c)return c}return null},i=n(t.children);if(i)return i;{const s=n(t.children,!0);if(s)return s}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let s=e.propertyIndex;if(t||(t=me.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){pt("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=e.objectIndex;switch(n){case"materials":if(!t.material){Vt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Vt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){Vt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===c){c=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){Vt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Vt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){Vt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(c!==void 0){if(t[c]===void 0){Vt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}const o=t[i];if(o===void 0){const c=e.nodeName;Vt("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?a=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){Vt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Vt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}me.Composite=YT;me.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};me.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};me.prototype.GetterByBindingType=[me.prototype._getValue_direct,me.prototype._getValue_array,me.prototype._getValue_arrayElement,me.prototype._getValue_toArray];me.prototype.SetterByBindingTypeAndVersioning=[[me.prototype._setValue_direct,me.prototype._setValue_direct_setNeedsUpdate,me.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[me.prototype._setValue_array,me.prototype._setValue_array_setNeedsUpdate,me.prototype._setValue_array_setMatrixWorldNeedsUpdate],[me.prototype._setValue_arrayElement,me.prototype._setValue_arrayElement_setNeedsUpdate,me.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[me.prototype._setValue_fromArray,me.prototype._setValue_fromArray_setNeedsUpdate,me.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ZT{constructor(){this.isAnimationObjectGroup=!0,this.uuid=ei(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let n=0,i=arguments.length;n!==i;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,o=s.length;let a,l=t.length,c=this.nCachedObjects_;for(let h=0,u=arguments.length;h!==u;++h){const d=arguments[h],f=d.uuid;let p=e[f];if(p===void 0){p=l++,e[f]=p,t.push(d);for(let x=0,g=o;x!==g;++x)s[x].push(new me(d,n[x],i[x]))}else if(p<c){a=t[p];const x=--c,g=t[x];e[g.uuid]=p,t[p]=g,e[f]=x,t[x]=d;for(let m=0,y=o;m!==y;++m){const v=s[m],_=v[x];let w=v[p];v[p]=_,w===void 0&&(w=new me(d,n[m],i[m])),v[x]=w}}else t[p]!==a&&Vt("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const l=arguments[o],c=l.uuid,h=e[c];if(h!==void 0&&h>=s){const u=s++,d=t[u];e[d.uuid]=h,t[h]=d,e[c]=u,t[u]=l;for(let f=0,p=i;f!==p;++f){const x=n[f],g=x[u],m=x[h];x[h]=g,x[u]=m}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,o=t.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],h=c.uuid,u=e[h];if(u!==void 0)if(delete e[h],u<s){const d=--s,f=t[d],p=--o,x=t[p];e[f.uuid]=u,t[u]=f,e[x.uuid]=d,t[d]=x,t.pop();for(let g=0,m=i;g!==m;++g){const y=n[g],v=y[d],_=y[p];y[u]=v,y[d]=_,y.pop()}}else{const d=--o,f=t[d];d>0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let p=0,x=i;p!==x;++p){const g=n[p];g[u]=g[d],g.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const s=this._bindings;if(i!==void 0)return s[i];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=s.length,n[t]=i,o.push(t),a.push(e),s.push(u);for(let d=h,f=l.length;d!==f;++d){const p=l[d];u[d]=new me(p,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){const i=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=t[a];e[c]=n,o[n]=l,o.pop(),s[n]=s[a],s.pop(),i[n]=i[a],i.pop()}}}class yv{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Vr,endingEnd:Vr};for(let c=0;c!==o;++c){const h=s[c].createInterpolant(null);a[c]=h,h.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=im,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n=!1){if(t.fadeOut(e),this.fadeIn(e),n===!0){const i=this._clip.duration,s=t._clip.duration,o=s/i,a=i/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n=!1){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,s=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+n,c[0]=t/o,c[1]=e/o,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);const o=this._updateTime(e),a=this._updateWeight(t);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case sm:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(o),c[h].accumulateAdditive(a);break;case id:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(o),c[h].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,s=this._loopCount;const o=n===Qy;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(n===nm){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){const a=Math.floor(i/e);i-=e*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){const c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=kr,i.endingEnd=kr):(t?i.endingStart=this.zeroSlopeAtStart?kr:Vr:i.endingStart=Zl,e?i.endingEnd=this.zeroSlopeAtEnd?kr:Vr:i.endingEnd=Zl)}_scheduleFading(t,e,n){const i=this._mixer,s=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=n,this}}const JT=new Float32Array(1);class _v extends Bi{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,s=i.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=i[u],f=d.name;let p=h[f];if(p!==void 0)++p.referenceCount,o[u]=p;else{if(p=o[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}const x=e&&e._propertyBindings[u].binding.parsedPath;p=new xv(me.create(n,f,x),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[u]=p}a[u].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const n=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,n)}const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,s=this._actionsByClip;let o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{const a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],h=t._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),t._byClipCacheIndex=null;const u=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete u[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,s=this._bindings;let o=i[e];o===void 0&&(o={},i[e]=o),o[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[i],l=e[e.length-1],c=t._cacheIndex;l._cacheIndex=c,e[c]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return n===void 0&&(n=new Bm(new Float32Array(2),new Float32Array(2),1,JT),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,s=e[i];t.__cacheIndex=i,e[i]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){const i=e||this._root,s=i.uuid;let o=typeof t=="string"?ga.findByName(i,t):t;const a=o!==null?o.uuid:t,l=this._actionsByClip[a];let c=null;if(n===void 0&&(o!==null?n=o.blendMode:n=id),l!==void 0){const u=l.actionByRoot[s];if(u!==void 0&&u.blendMode===n)return u;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const h=new yv(this,o,e,n);return this._bindAction(h,c),this._addInactiveAction(h,a,s),h}existingAction(t,e){const n=e||this._root,i=n.uuid,s=typeof t=="string"?ga.findByName(n,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==n;++c)e[c]._update(i,t,s,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const h=c._cacheIndex,u=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,e[h]=u,e.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,s=i[e];if(s!==void 0)for(const o in s){const a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){const n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class jT extends lm{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new mc(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class Rd{constructor(t){this.value=t}clone(){return new Rd(this.value.clone===void 0?this.value:this.value.clone())}}let KT=0;class QT extends Bi{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:KT++}),this.name="",this.usage=jl,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return e!==-1&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let n=0,i=e.length;n<i;n++){const s=Array.isArray(e[n])?e[n]:[e[n]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}}let vv=class extends xc{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}};class t1{constructor(t,e,n,i,s,o=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=s,this.normalized=o,this.version=0}set needsUpdate(t){t===!0&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}}const G0=new Qt;class Mv{constructor(t,e,n=0,i=1/0){this.ray=new eo(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new gc,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Vt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return G0.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(G0),this}intersectObject(t,e=!0,n=[]){return Rp(t,this,n,e),n.sort(H0),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)Rp(t[i],this,n,e);return n.sort(H0),n}}function H0(r,t){return r.distance-t.distance}function Rp(r,t,e,n){let i=!0;if(r.layers.test(t.layers)&&r.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){const s=r.children;for(let o=0,a=s.length;o<a;o++)Rp(s[o],t,e,!0)}}class e1{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,pt("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.")}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}class Sv{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Jt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Jt(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class n1{constructor(t=1,e=0,n=0){this.radius=t,this.theta=e,this.y=n}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return new this.constructor().copy(this)}}let i1=class bv{constructor(t,e,n,i){bv.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}};const W0=new tt;class s1{constructor(t=new tt(1/0,1/0),e=new tt(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=W0.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}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}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))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,W0).distanceTo(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}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 X0=new R,_h=new R,Ro=new R,Io=new R,Rf=new R,r1=new R,o1=new R;class Tv{constructor(t=new R,e=new R){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){X0.subVectors(t,this.start),_h.subVectors(this.end,this.start);const n=_h.dot(_h);let s=_h.dot(X0)/n;return e&&(s=Jt(s,0,1)),s}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(t,e=r1,n=o1){const i=10000000000000001e-32;let s,o;const a=this.start,l=t.start,c=this.end,h=t.end;Ro.subVectors(c,a),Io.subVectors(h,l),Rf.subVectors(a,l);const u=Ro.dot(Ro),d=Io.dot(Io),f=Io.dot(Rf);if(u<=i&&d<=i)return e.copy(a),n.copy(l),e.sub(n),e.dot(e);if(u<=i)s=0,o=f/d,o=Jt(o,0,1);else{const p=Ro.dot(Rf);if(d<=i)o=0,s=Jt(-p/u,0,1);else{const x=Ro.dot(Io),g=u*d-x*x;g!==0?s=Jt((x*f-p*d)/g,0,1):s=0,o=(x*s+f)/d,o<0?(o=0,s=Jt(-p/u,0,1)):o>1&&(o=1,s=Jt((x-p)/u,0,1))}}return e.copy(a).addScaledVector(Ro,s),n.copy(l).addScaledVector(Io,o),e.distanceToSquared(n)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const $0=new R;class a1 extends ve{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new se,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){const c=o/l*Math.PI*2,h=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new Ct(i,3));const s=new Rn({fog:!1,toneMapped:!1});this.cone=new zi(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),$0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt($0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Ws=new R,vh=new Qt,If=new Qt;class l1 extends zi{constructor(t){const e=wv(t),n=new se,i=[],s=[];for(let c=0;c<e.length;c++){const h=e[c];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(0,0,0),s.push(0,0,0))}n.setAttribute("position",new Ct(i,3)),n.setAttribute("color",new Ct(s,3));const o=new Rn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,o),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const a=new wt(255),l=new wt(65280);this.setColors(a,l)}updateMatrixWorld(t){const e=this.bones,n=this.geometry,i=n.getAttribute("position");If.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<e.length;s++){const a=e[s];a.parent&&a.parent.isBone&&(vh.multiplyMatrices(If,a.matrixWorld),Ws.setFromMatrixPosition(vh),i.setXYZ(o,Ws.x,Ws.y,Ws.z),vh.multiplyMatrices(If,a.parent.matrixWorld),Ws.setFromMatrixPosition(vh),i.setXYZ(o+1,Ws.x,Ws.y,Ws.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const i=this.geometry.getAttribute("color");for(let s=0;s<i.count;s+=2)i.setXYZ(s,t.r,t.g,t.b),i.setXYZ(s+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function wv(r){const t=[];r.isBone===!0&&t.push(r);for(let e=0;e<r.children.length;e++)t.push(...wv(r.children[e]));return t}class c1 extends Ye{constructor(t,e,n){const i=new wa(e,4,2),s=new Ds({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const h1=new R,q0=new wt,Y0=new wt;class u1 extends ve{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new Ta(e);i.rotateY(Math.PI*.5),this.material=new Ds({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),o=new Float32Array(s.count*3);i.setAttribute("color",new Te(o,3)),this.add(new Ye(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");q0.copy(this.light.color),Y0.copy(this.light.groundColor);for(let n=0,i=e.count;n<i;n++){const s=n<i/2?q0:Y0;e.setXYZ(n,s.r,s.g,s.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(h1.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Av=class extends zi{constructor(t=10,e=10,n=4473924,i=8947848){n=new wt(n),i=new wt(i);const s=e/2,o=t/e,a=t/2,l=[],c=[];for(let d=0,f=0,p=-a;d<=e;d++,p+=o){l.push(-a,0,p,a,0,p),l.push(p,0,-a,p,0,a);const x=d===s?n:i;x.toArray(c,f),f+=3,x.toArray(c,f),f+=3,x.toArray(c,f),f+=3,x.toArray(c,f),f+=3}const h=new se;h.setAttribute("position",new Ct(l,3)),h.setAttribute("color",new Ct(c,3));const u=new Rn({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class d1 extends zi{constructor(t=10,e=16,n=8,i=64,s=4473924,o=8947848){s=new wt(s),o=new wt(o);const a=[],l=[];if(e>1)for(let u=0;u<e;u++){const d=u/e*(Math.PI*2),f=Math.sin(d)*t,p=Math.cos(d)*t;a.push(0,0,0),a.push(f,0,p);const x=u&1?s:o;l.push(x.r,x.g,x.b),l.push(x.r,x.g,x.b)}for(let u=0;u<n;u++){const d=u&1?s:o,f=t-t/n*u;for(let p=0;p<i;p++){let x=p/i*(Math.PI*2),g=Math.sin(x)*f,m=Math.cos(x)*f;a.push(g,0,m),l.push(d.r,d.g,d.b),x=(p+1)/i*(Math.PI*2),g=Math.sin(x)*f,m=Math.cos(x)*f,a.push(g,0,m),l.push(d.r,d.g,d.b)}}const c=new se;c.setAttribute("position",new Ct(a,3)),c.setAttribute("color",new Ct(l,3));const h=new Rn({vertexColors:!0,toneMapped:!1});super(c,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Z0=new R,Mh=new R,J0=new R;class Ev extends ve{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new se;i.setAttribute("position",new Ct([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new Rn({fog:!1,toneMapped:!1});this.lightPlane=new Fs(i,s),this.add(this.lightPlane),i=new se,i.setAttribute("position",new Ct([0,0,0,0,0,1],3)),this.targetLine=new Fs(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Z0.setFromMatrixPosition(this.light.matrixWorld),Mh.setFromMatrixPosition(this.light.target.matrixWorld),J0.subVectors(Mh,Z0),this.lightPlane.lookAt(Mh),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Mh),this.targetLine.scale.z=J0.length()}}const Sh=new R,We=new Tc;class Cv extends zi{constructor(t){const e=new se,n=new Rn({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,x){l(p),l(x)}function l(p){i.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(i.length/3-1)}e.setAttribute("position",new Ct(i,3)),e.setAttribute("color",new Ct(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const c=new wt(16755200),h=new wt(16711680),u=new wt(43775),d=new wt(16777215),f=new wt(3355443);this.setColors(c,h,u,d,f)}setColors(t,e,n,i,s){const a=this.geometry.getAttribute("color");return a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap,n=1,i=1;let s,o;if(We.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)s=1,o=0;else if(this.camera.coordinateSystem===ti)s=-1,o=1;else if(this.camera.coordinateSystem===Zr)s=0,o=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);qe("c",e,t,We,0,0,s),qe("t",e,t,We,0,0,o),qe("n1",e,t,We,-n,-i,s),qe("n2",e,t,We,n,-i,s),qe("n3",e,t,We,-n,i,s),qe("n4",e,t,We,n,i,s),qe("f1",e,t,We,-n,-i,o),qe("f2",e,t,We,n,-i,o),qe("f3",e,t,We,-n,i,o),qe("f4",e,t,We,n,i,o),qe("u1",e,t,We,n*.7,i*1.1,s),qe("u2",e,t,We,-n*.7,i*1.1,s),qe("u3",e,t,We,0,i*2,s),qe("cf1",e,t,We,-n,0,o),qe("cf2",e,t,We,n,0,o),qe("cf3",e,t,We,0,-i,o),qe("cf4",e,t,We,0,i,o),qe("cn1",e,t,We,-n,0,s),qe("cn2",e,t,We,n,0,s),qe("cn3",e,t,We,0,-i,s),qe("cn4",e,t,We,0,i,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function qe(r,t,e,n,i,s,o){Sh.set(i,s,o).unproject(n);const a=t[r];if(a!==void 0){const l=e.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Sh.x,Sh.y,Sh.z)}}const bh=new mn;class Nv extends zi{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),s=new se;s.setIndex(new Te(n,1)),s.setAttribute("position",new Te(i,3)),super(s,new Rn({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&bh.setFromObject(this.object),bh.isEmpty())return;const t=bh.min,e=bh.max,n=this.geometry.attributes.position,i=n.array;i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=t.x,i[4]=e.y,i[5]=e.z,i[6]=t.x,i[7]=t.y,i[8]=e.z,i[9]=e.x,i[10]=t.y,i[11]=e.z,i[12]=e.x,i[13]=e.y,i[14]=t.z,i[15]=t.x,i[16]=e.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=e.x,i[22]=t.y,i[23]=t.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Rv extends zi{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new se;s.setIndex(new Te(n,1)),s.setAttribute("position",new Ct(i,3)),super(s,new Rn({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class f1 extends Fs{constructor(t,e=1,n=16776960){const i=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new se;o.setAttribute("position",new Ct(s,3)),o.computeBoundingSphere(),super(o,new Rn({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new se;l.setAttribute("position",new Ct(a,3)),l.computeBoundingSphere(),this.add(new Ye(l,new Ds({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const j0=new R;let Th,Pf;class p1 extends ve{constructor(t=new R(0,0,1),e=new R(0,0,0),n=1,i=16776960,s=n*.2,o=s*.2){super(),this.type="ArrowHelper",Th===void 0&&(Th=new se,Th.setAttribute("position",new Ct([0,0,0,0,1,0],3)),Pf=new vc(.5,1,5,1),Pf.translate(0,-.5,0)),this.position.copy(e),this.line=new Fs(Th,new Rn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ye(Pf,new Ds({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,s,o)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{j0.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(j0,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Iv=class extends zi{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new se;i.setAttribute("position",new Ct(e,3)),i.setAttribute("color",new Ct(n,3));const s=new Rn({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){const i=new wt,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class Pv{constructor(){this.type="ShapePath",this.color=new wt,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Lu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,s,o){return this.currentPath.bezierCurveTo(t,e,n,i,s,o),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(m){const y=[];for(let v=0,_=m.length;v<_;v++){const w=m[v],T=new ir;T.curves=w.curves,y.push(T)}return y}function n(m,y){const v=y.length;let _=!1;for(let w=v-1,T=0;T<v;w=T++){let E=y[w],M=y[T],b=M.x-E.x,P=M.y-E.y;if(Math.abs(P)>Number.EPSILON){if(P<0&&(E=y[T],b=-b,M=y[w],P=-P),m.y<E.y||m.y>M.y)continue;if(m.y===E.y){if(m.x===E.x)return!0}else{const N=P*(m.x-E.x)-b*(m.y-E.y);if(N===0)return!0;if(N<0)continue;_=!_}}else{if(m.y!==E.y)continue;if(M.x<=m.x&&m.x<=E.x||E.x<=m.x&&m.x<=M.x)return!0}}return _}const i=ui.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new ir,l.curves=a.curves,c.push(l),c;let h=!i(s[0].getPoints());h=t?!h:h;const u=[],d=[];let f=[],p=0,x;d[p]=void 0,f[p]=[];for(let m=0,y=s.length;m<y;m++)a=s[m],x=a.getPoints(),o=i(x),o=t?!o:o,o?(!h&&d[p]&&p++,d[p]={s:new ir,p:x},d[p].s.curves=a.curves,h&&p++,f[p]=[]):f[p].push({h:a,p:x[0]});if(!d[0])return e(s);if(d.length>1){let m=!1,y=0;for(let v=0,_=d.length;v<_;v++)u[v]=[];for(let v=0,_=d.length;v<_;v++){const w=f[v];for(let T=0;T<w.length;T++){const E=w[T];let M=!0;for(let b=0;b<d.length;b++)n(E.p,d[b].p)&&(v!==b&&y++,M?(M=!1,u[b].push(E)):m=!0);M&&u[v].push(E)}}y>0&&m===!1&&(f=u)}let g;for(let m=0,y=d.length;m<y;m++){l=d[m].s,c.push(l),g=f[m];for(let v=0,_=g.length;v<_;v++)l.holes.push(g[v].h)}return c}}class Lv extends Bi{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){pt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}}function m1(r,t){const e=r.image&&r.image.width?r.image.width/r.image.height:1;return e>t?(r.repeat.x=1,r.repeat.y=e/t,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=t/e,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function g1(r,t){const e=r.image&&r.image.width?r.image.width/r.image.height:1;return e>t?(r.repeat.x=t/e,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=e/t,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function x1(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function Ip(r,t,e,n){const i=y1(n);switch(e){case em:return r*t;case dc:return r*t/i.components*i.byteLength;case Ma:return r*t/i.components*i.byteLength;case ar:return r*t*2/i.components*i.byteLength;case fc:return r*t*2/i.components*i.byteLength;case nd:return r*t*3/i.components*i.byteLength;case wn:return r*t*4/i.components*i.byteLength;case pc:return r*t*4/i.components*i.byteLength;case Qo:case ta:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case dl:case ea:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case pu:case Pl:return Math.max(r,16)*Math.max(t,8)/4;case Rl:case Il:return Math.max(r,8)*Math.max(t,8)/2;case Ll:case Fl:case Ul:case Ol:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case Dl:case Bl:case zl:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Vl:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case mu:return Math.floor((r+4)/5)*Math.floor((t+3)/4)*16;case gu:return Math.floor((r+4)/5)*Math.floor((t+4)/5)*16;case xu:return Math.floor((r+5)/6)*Math.floor((t+4)/5)*16;case kl:return Math.floor((r+5)/6)*Math.floor((t+5)/6)*16;case yu:return Math.floor((r+7)/8)*Math.floor((t+4)/5)*16;case _u:return Math.floor((r+7)/8)*Math.floor((t+5)/6)*16;case vu:return Math.floor((r+7)/8)*Math.floor((t+7)/8)*16;case Mu:return Math.floor((r+9)/10)*Math.floor((t+4)/5)*16;case Su:return Math.floor((r+9)/10)*Math.floor((t+5)/6)*16;case bu:return Math.floor((r+9)/10)*Math.floor((t+7)/8)*16;case Tu:return Math.floor((r+9)/10)*Math.floor((t+9)/10)*16;case wu:return Math.floor((r+11)/12)*Math.floor((t+9)/10)*16;case Au:return Math.floor((r+11)/12)*Math.floor((t+11)/12)*16;case Gl:case Eu:case Hl:return Math.ceil(r/4)*Math.ceil(t/4)*16;case Wl:case Xl:return Math.ceil(r/4)*Math.ceil(t/4)*8;case $l:case ql:return Math.ceil(r/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function y1(r){switch(r){case Un:case Qp:return{byteLength:1,components:1};case la:case tm:case Ui:return{byteLength:2,components:1};case Ku:case Qu:return{byteLength:2,components:4};case ii:case ju:case Tn:return{byteLength:4,components:1};case td:case ed:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}class _1{static contain(t,e){return m1(t,e)}static cover(t,e){return g1(t,e)}static fill(t){return x1(t)}static getByteLength(t,e,n,i){return Ip(t,e,n,i)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Wr}}));if(typeof window<"u"){try{typeof document>"u"?require("url").pathToFileURL(__filename).href:ho&&ho.tagName.toUpperCase()==="SCRIPT"&&ho.src||new URL("three.umd.cjs",document.baseURI).href,window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ho&&ho.tagName.toUpperCase()==="SCRIPT"&&ho.src||new URL("three.umd.cjs",document.baseURI).href,revision:Wr})}catch{}window.__THREE__?(pt("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+Wr),console.warn("THREE imports:",window.__THREE__IMPORTS__)):window.__THREE__=Wr}function Fv(){let r=null,t=!1,e=null,n=null;function i(s,o){e(s,o),n=r.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=r.requestAnimationFrame(i),t=!0)},stop:function(){r.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){r=s}}}function v1(r){const t=new WeakMap;function e(a,l){const c=a.array,h=a.usage,u=c.byteLength,d=r.createBuffer();r.bindBuffer(l,d),r.bufferData(l,c,h),a.onUploadCallback();let f;if(c instanceof Float32Array)f=r.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=r.HALF_FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=r.HALF_FLOAT:f=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=r.SHORT;else if(c instanceof Uint32Array)f=r.UNSIGNED_INT;else if(c instanceof Int32Array)f=r.INT;else if(c instanceof Int8Array)f=r.BYTE;else if(c instanceof Uint8Array)f=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,l,c){const h=l.array,u=l.updateRanges;if(r.bindBuffer(c,a),u.length===0)r.bufferSubData(c,0,h);else{u.sort((f,p)=>f.start-p.start);let d=0;for(let f=1;f<u.length;f++){const p=u[d],x=u[f];x.start<=p.start+p.count+1?p.count=Math.max(p.count,x.start+x.count-p.start):(++d,u[d]=x)}u.length=d+1;for(let f=0,p=u.length;f<p;f++){const x=u[f];r.bufferSubData(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),t.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=t.get(a);l&&(r.deleteBuffer(l.buffer),t.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const h=t.get(a);(!h||h.version<a.version)&&t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const c=t.get(a);if(c===void 0)t.set(a,e(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,a,l),c.version=a.version}}return{get:i,remove:s,update:o}}var M1=`#ifdef USE_ALPHAHASH
|
|
5
|
+
}`;class si extends gn{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_T,this.fragmentShader=vT,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=pa(t.uniforms),this.uniformsGroups=yT(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?e.uniforms[i]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[i]={type:"m4",value:o.toArray()}:e.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class bd extends si{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Td extends gn{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new wt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Im extends Td{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new tt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new wt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new wt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new wt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Pm extends gn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new wt(16777215),this.specular=new wt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=uc,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class tv extends gn{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new wt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Lm extends gn{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Fm extends gn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new wt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=uc,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class wd extends gn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=sm,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Dm extends gn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class ev extends gn{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new wt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ur,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this.fog=t.fog,this}}class nv extends Rn{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Hr(r,t){return!r||r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function iv(r){function t(i,s){return r[i]-r[s]}const e=r.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function Np(r,t,e){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=e[s]*t;for(let l=0;l!==t;++l)i[o++]=r[a+l]}return i}function Um(r,t,e,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(t.push(s.time),e.push(...o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(t.push(s.time),e.push(o)),s=r[i++];while(s!==void 0)}function MT(r,t,e,n,i=30){const s=r.clone();s.name=t;const o=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],h=c.getValueSize(),u=[],d=[];for(let f=0;f<c.times.length;++f){const p=c.times[f]*i;if(!(p<e||p>=n)){u.push(c.times[f]);for(let x=0;x<h;++x)d.push(c.values[f*h+x])}}u.length!==0&&(c.times=Hr(u,c.times.constructor),c.values=Hr(d,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s}function ST(r,t=0,e=r,n=30){n<=0&&(n=30);const i=e.tracks.length,s=t/n;for(let o=0;o<i;++o){const a=e.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===l});if(c===void 0)continue;let h=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0;const f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);const p=a.times.length-1;let x;if(s<=a.times[0]){const m=h,y=u-h;x=a.values.slice(m,y)}else if(s>=a.times[p]){const m=p*u+h,y=m+u-h;x=a.values.slice(m,y)}else{const m=a.createInterpolant(),y=h,v=u-h;m.evaluate(s),x=m.resultBuffer.slice(y,v)}l==="quaternion"&&new En().fromArray(x).normalize().conjugate().toArray(x);const g=c.times.length;for(let m=0;m<g;++m){const y=m*f+d;if(l==="quaternion")En.multiplyQuaternionsFlat(c.values,y,x,0,c.values,y);else{const v=f-d*2;for(let _=0;_<v;++_)c.values[y+_]-=x[_]}}}return r.blendMode=im,r}class bT{static convertArray(t,e){return Hr(t,e)}static isTypedArray(t){return A_(t)}static getKeyframeOrder(t){return iv(t)}static sortedArray(t,e,n){return Np(t,e,n)}static flattenJSON(t,e,n,i){Um(t,e,n,i)}static subclip(t,e,n,i,s=30){return MT(t,e,n,i,s)}static makeClipAdditive(t,e=0,n=t,i=30){return ST(t,e,n,i)}}class so{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],s=e[n-1];t:{e:{let o;n:{i:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break e}o=e.length;break n}if(!(t>=s)){const a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=e[--n-1],t>=s)break e}o=n,n=0;break n}break t}for(;n<o;){const a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class sv extends so{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Vr,endingEnd:Vr}}intervalChanged_(t,e,n){const i=this.parameterPositions;let s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case kr:s=t,a=2*e-n;break;case Zl:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case kr:o=t,l=2*n-e;break;case Zl:o=1,l=n+i[1]-i[0];break;default:o=t-1,l=e}const c=(n-e)*.5,h=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=o*h}interpolate_(t,e,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-e)/(i-e),x=p*p,g=x*p,m=-d*g+2*d*x-d*p,y=(1+d)*g+(-1.5-2*d)*x+(-.5+d)*p+1,v=(-1-f)*g+(1.5+f)*x+.5*p,_=f*g-f*x;for(let w=0;w!==a;++w)s[w]=m*o[h+w]+y*o[c+w]+v*o[l+w]+_*o[u+w];return s}}class Om extends so{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,h=(n-e)/(i-e),u=1-h;for(let d=0;d!==a;++d)s[d]=o[c+d]*u+o[l+d]*h;return s}}class rv extends so{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class ov extends so{interpolate_(t,e,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,h=this.settings||this.DefaultSettings_,u=h.inTangents,d=h.outTangents;if(!u||!d){const x=(n-e)/(i-e),g=1-x;for(let m=0;m!==a;++m)s[m]=o[c+m]*g+o[l+m]*x;return s}const f=a*2,p=t-1;for(let x=0;x!==a;++x){const g=o[c+x],m=o[l+x],y=p*f+x*2,v=d[y],_=d[y+1],w=t*f+x*2,T=u[w],E=u[w+1];let M=(n-e)/(i-e),b,P,N,L,U;for(let V=0;V<8;V++){b=M*M,P=b*M,N=1-M,L=N*N,U=L*N;const k=U*e+3*L*M*v+3*N*b*T+P*i-n;if(Math.abs(k)<1e-10)break;const G=3*L*(v-e)+6*N*M*(T-v)+3*b*(i-T);if(Math.abs(G)<1e-10)break;M=M-k/G,M=Math.max(0,Math.min(1,M))}s[x]=U*g+3*L*M*_+3*N*b*E+P*m}return s}}class ri{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Hr(e,this.TimeBufferType),this.values=Hr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Hr(t.times,Array),values:Hr(t.values,Array)};const i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new rv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Om(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new sv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new ov(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.settings=this.settings),e}setInterpolation(t){let e;switch(t){case ha:e=this.InterpolantFactoryMethodDiscrete;break;case Yl:e=this.InterpolantFactoryMethodLinear;break;case su:e=this.InterpolantFactoryMethodSmooth;break;case Tp:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return pt("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ha;case this.InterpolantFactoryMethodLinear:return Yl;case this.InterpolantFactoryMethodSmooth:return su;case this.InterpolantFactoryMethodBezier:return Tp}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let s=0,o=i-1;for(;s!==i&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(Vt("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,s=n.length;s===0&&(Vt("KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){Vt("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){Vt("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&A_(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){Vt("KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===su,s=t.length-1;let o=1;for(let a=1;a<s;++a){let l=!1;const c=t[a],h=t[a+1];if(c!==h&&(a!==1||c!==t[0]))if(i)l=!0;else{const u=a*n,d=u-n,f=u+n;for(let p=0;p!==n;++p){const x=e[u+p];if(x!==e[d+p]||x!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];const u=a*n,d=o*n;for(let f=0;f!==n;++f)e[d+f]=e[u+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}ri.prototype.ValueTypeName="";ri.prototype.TimeBufferType=Float32Array;ri.prototype.ValueBufferType=Float32Array;ri.prototype.DefaultInterpolation=Yl;class pr extends ri{constructor(t,e,n){super(t,e,n)}}pr.prototype.ValueTypeName="bool";pr.prototype.ValueBufferType=Array;pr.prototype.DefaultInterpolation=ha;pr.prototype.InterpolantFactoryMethodLinear=void 0;pr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ad extends ri{constructor(t,e,n,i){super(t,e,n,i)}}Ad.prototype.ValueTypeName="color";class ma extends ri{constructor(t,e,n,i){super(t,e,n,i)}}ma.prototype.ValueTypeName="number";class av extends so{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(i-e);let c=t*a;for(let h=c+a;c!==h;c+=4)En.slerpFlat(s,0,o,c-a,o,c,l);return s}}class Ea extends ri{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new av(this.times,this.values,this.getValueSize(),t)}}Ea.prototype.ValueTypeName="quaternion";Ea.prototype.InterpolantFactoryMethodSmooth=void 0;class ro extends ri{constructor(t,e,n){super(t,e,n)}}ro.prototype.ValueTypeName="string";ro.prototype.ValueBufferType=Array;ro.prototype.DefaultInterpolation=ha;ro.prototype.InterpolantFactoryMethodLinear=void 0;ro.prototype.InterpolantFactoryMethodSmooth=void 0;class ga extends ri{constructor(t,e,n,i){super(t,e,n,i)}}ga.prototype.ValueTypeName="vector";class xa{constructor(t="",e=-1,n=[],i=id){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=ei(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(wT(n[o]).scale(i));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s.userData=JSON.parse(t.userData||"{}"),s}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let s=0,o=n.length;s!==o;++s)e.push(ri.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const s=e.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);const h=iv(l);l=Np(l,1,h),c=Np(c,1,h),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new ma(".morphTargetInfluences["+e[a].name+"]",l,c).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){const c=t[a],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,n));return o}static parseAnimation(t,e){if(pt("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return Vt("AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,p,x){if(f.length!==0){const g=[],m=[];Um(f,g,m,p),g.length!==0&&x.push(new u(d,g,m))}},i=[],s=t.name||"default",o=t.fps||30,a=t.blendMode;let l=t.length||-1;const c=t.hierarchy||[];for(let u=0;u<c.length;u++){const d=c[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let x=0;x<d[p].morphTargets.length;x++)f[d[p].morphTargets[x]]=-1;for(const x in f){const g=[],m=[];for(let y=0;y!==d[p].morphTargets.length;++y){const v=d[p];g.push(v.time),m.push(v.morphTarget===x?1:0)}i.push(new ma(".morphTargetInfluence["+x+"]",g,m))}l=f.length*o}else{const f=".bones["+e[u].name+"]";n(ga,f+".position",d,"pos",i),n(Ea,f+".quaternion",d,"rot",i),n(ga,f+".scale",d,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){const t=this.tracks;let e=0;for(let n=0,i=t.length;n!==i;++n){const s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function TT(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ma;case"vector":case"vector2":case"vector3":case"vector4":return ga;case"color":return Ad;case"quaternion":return Ea;case"bool":case"boolean":return pr;case"string":return ro}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function wT(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=TT(r.type);if(r.times===void 0){const e=[],n=[];Um(r.keys,e,n,"value"),r.times=e,r.values=n}return t.parse!==void 0?t.parse(r):new t(r.name,r.times,r.values,r.interpolation)}const Fi={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(I0(r)||(this.files[r]=t))},get:function(r){if(this.enabled!==!1&&!I0(r))return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};function I0(r){try{const t=r.slice(r.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class Ed{constructor(t,e,n){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){const f=c[u],p=c[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const Bm=new Ed;class Vn{constructor(t){this.manager=t!==void 0?t:Bm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}Vn.DEFAULT_MATERIAL_NAME="__DEFAULT";const ys={};class AT extends Error{constructor(t,e){super(t),this.response=e}}class rs extends Vn{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=Fi.get(`file:${t}`);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(ys[t]!==void 0){ys[t].push({onLoad:e,onProgress:n,onError:i});return}ys[t]=[],ys[t].push({onLoad:e,onProgress:n,onError:i});const o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&pt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=ys[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let x=0;const g=new ReadableStream({start(m){y();function y(){u.read().then(({done:v,value:_})=>{if(v)m.close();else{x+=_.byteLength;const w=new ProgressEvent("progress",{lengthComputable:p,loaded:x,total:f});for(let T=0,E=h.length;T<E;T++){const M=h[T];M.onProgress&&M.onProgress(w)}m.enqueue(_),y()}},v=>{m.error(v)})}}});return new Response(g)}else throw new AT(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a==="")return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{Fi.add(`file:${t}`,c);const h=ys[t];delete ys[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(c)}}).catch(c=>{const h=ys[t];if(h===void 0)throw this.manager.itemError(t),c;delete ys[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class ET extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=new rs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):Vt(l),s.manager.itemError(t)}},n,i)}parse(t){const e=[];for(let n=0;n<t.length;n++){const i=xa.parse(t[n]);e.push(i)}return e}}class CT extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=[],a=new _c,l=new rs(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function h(u){l.load(t[u],function(d){const f=s.parse(d,!0);o[u]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},c+=1,c===6&&(f.mipmapCount===1&&(a.minFilter=Fe),a.image=o,a.format=f.format,a.needsUpdate=!0,e&&e(a))},n,i)}if(Array.isArray(t))for(let u=0,d=t.length;u<d;++u)h(u);else l.load(t,function(u){const d=s.parse(u,!0);if(d.isCubemap){const f=d.mipmaps.length/d.mipmapCount;for(let p=0;p<f;p++){o[p]={mipmaps:[]};for(let x=0;x<d.mipmapCount;x++)o[p].mipmaps.push(d.mipmaps[p*d.mipmapCount+x]),o[p].format=d.format,o[p].width=d.width,o[p].height=d.height}a.image=o}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=Fe),a.format=d.format,a.needsUpdate=!0,e&&e(a)},n,i);return a}}const Eo=new WeakMap;class sc extends Vn{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=Fi.get(`image:${t}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0);else{let u=Eo.get(o);u===void 0&&(u=[],Eo.set(o,u)),u.push({onLoad:e,onError:i})}return o}const a=Kl("img");function l(){h(),e&&e(this);const u=Eo.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}Eo.delete(this),s.manager.itemEnd(t)}function c(u){h(),i&&i(u),Fi.remove(`image:${t}`);const d=Eo.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}Eo.delete(this),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),Fi.add(`image:${t}`,a),s.manager.itemStart(t),a.src=t,a}}class NT extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=new ba;s.colorSpace=Fn;const o=new sc(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(t[c],function(h){s.images[c]=h,a++,a===6&&(s.needsUpdate=!0,e&&e(s))},void 0,i)}for(let c=0;c<t.length;++c)l(c);return s}}class lv extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=new fi,a=new rs(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(t,function(l){let c;try{c=s.parse(l)}catch(h){if(i!==void 0)i(h);else{h(h);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:Bn,o.wrapT=c.wrapT!==void 0?c.wrapT:Bn,o.magFilter=c.magFilter!==void 0?c.magFilter:Fe,o.minFilter=c.minFilter!==void 0?c.minFilter:Fe,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=Li),c.mipmapCount===1&&(o.minFilter=Fe),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,e&&e(o,c)},n,i),o}}class cv extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=new rn,o=new sc(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},n,i),s}}let mr=class extends ve{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new wt(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}},zm=class extends mr{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.groundColor=new wt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}};const Ef=new Qt,P0=new R,L0=new R;let Vm=class{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new tt(512,512),this.mapType=Un,this.map=null,this.mapPass=null,this.matrix=new Qt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new no,this._frameExtents=new tt(1,1),this._viewportCount=1,this._viewports=[new Le(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;P0.setFromMatrixPosition(t.matrixWorld),e.position.copy(P0),L0.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(L0),e.updateMatrixWorld(),Ef.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ef,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Zr||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ef)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}};const gh=new R,xh=new En,Wi=new R;let Tc=class extends ve{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Qt,this.projectionMatrix=new Qt,this.projectionMatrixInverse=new Qt,this.coordinateSystem=ti,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(gh,xh,Wi),Wi.x===1&&Wi.y===1&&Wi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gh,xh,Wi.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose(gh,xh,Wi),Wi.x===1&&Wi.y===1&&Wi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gh,xh,Wi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};const Hs=new R,F0=new tt,D0=new tt;let cn=class extends Tc{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=ua*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Xr*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return ua*2*Math.atan(Math.tan(Xr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Hs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Hs.x,Hs.y).multiplyScalar(-t/Hs.z),Hs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Hs.x,Hs.y).multiplyScalar(-t/Hs.z)}getViewSize(t,e){return this.getViewBounds(t,F0,D0),e.subVectors(D0,F0)}setViewOffset(t,e,n,i,s,o){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Xr*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,e-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},RT=class extends Vm{constructor(){super(new cn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=ua*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},km=class extends mr{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.target=new ve,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new RT}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}},IT=class extends Vm{constructor(){super(new cn(90,1,.5,500)),this.isPointLightShadow=!0}},Gm=class extends mr{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new IT}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}},Ca=class extends Tc{constructor(t=-1,e=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-t,o=n+t,a=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},PT=class extends Vm{constructor(){super(new Ca(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Hm=class extends mr{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.target=new ve,this.shadow=new PT}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}},Wm=class extends mr{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}},hv=class extends mr{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}},Xm=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new R)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*i),e.addScaledVector(o[2],.488603*s),e.addScaledVector(o[3],.488603*n),e.addScaledVector(o[4],1.092548*(n*i)),e.addScaledVector(o[5],1.092548*(i*s)),e.addScaledVector(o[6],.315392*(3*s*s-1)),e.addScaledVector(o[7],1.092548*(n*s)),e.addScaledVector(o[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],2*.511664*i),e.addScaledVector(o[2],2*.511664*s),e.addScaledVector(o[3],2*.511664*n),e.addScaledVector(o[4],2*.429043*n*i),e.addScaledVector(o[5],2*.429043*i*s),e.addScaledVector(o[6],.743125*s*s-.247708),e.addScaledVector(o[7],2*.429043*n*s),e.addScaledVector(o[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+i*3);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+i*3);return t}static getBasisAt(t,e){const n=t.x,i=t.y,s=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*s,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*n*s,e[8]=.546274*(n*n-i*i)}},uv=class extends mr{constructor(t=new Xm,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}};class Cd extends Vn{constructor(t){super(t),this.textures={}}load(t,e,n,i){const s=this,o=new rs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):Vt(l),s.manager.itemError(t)}},n,i)}parse(t){const e=this.textures;function n(s){return e[s]===void 0&&pt("MaterialLoader: Undefined texture",s),e[s]}const i=this.createMaterialFromType(t.type);if(t.uuid!==void 0&&(i.uuid=t.uuid),t.name!==void 0&&(i.name=t.name),t.color!==void 0&&i.color!==void 0&&i.color.setHex(t.color),t.roughness!==void 0&&(i.roughness=t.roughness),t.metalness!==void 0&&(i.metalness=t.metalness),t.sheen!==void 0&&(i.sheen=t.sheen),t.sheenColor!==void 0&&(i.sheenColor=new wt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(i.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(t.emissive),t.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(t.specular),t.specularIntensity!==void 0&&(i.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(i.shininess=t.shininess),t.clearcoat!==void 0&&(i.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(i.dispersion=t.dispersion),t.iridescence!==void 0&&(i.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(i.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(i.transmission=t.transmission),t.thickness!==void 0&&(i.thickness=t.thickness),t.attenuationDistance!==void 0&&(i.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(i.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(i.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(i.fog=t.fog),t.flatShading!==void 0&&(i.flatShading=t.flatShading),t.blending!==void 0&&(i.blending=t.blending),t.combine!==void 0&&(i.combine=t.combine),t.side!==void 0&&(i.side=t.side),t.shadowSide!==void 0&&(i.shadowSide=t.shadowSide),t.opacity!==void 0&&(i.opacity=t.opacity),t.transparent!==void 0&&(i.transparent=t.transparent),t.alphaTest!==void 0&&(i.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(i.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(i.depthFunc=t.depthFunc),t.depthTest!==void 0&&(i.depthTest=t.depthTest),t.depthWrite!==void 0&&(i.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(i.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(i.blendSrc=t.blendSrc),t.blendDst!==void 0&&(i.blendDst=t.blendDst),t.blendEquation!==void 0&&(i.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(i.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(i.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(i.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(i.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(i.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(i.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(i.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(i.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(i.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(i.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(i.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(i.rotation=t.rotation),t.linewidth!==void 0&&(i.linewidth=t.linewidth),t.dashSize!==void 0&&(i.dashSize=t.dashSize),t.gapSize!==void 0&&(i.gapSize=t.gapSize),t.scale!==void 0&&(i.scale=t.scale),t.polygonOffset!==void 0&&(i.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(i.dithering=t.dithering),t.alphaToCoverage!==void 0&&(i.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(i.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(i.allowOverride=t.allowOverride),t.visible!==void 0&&(i.visible=t.visible),t.toneMapped!==void 0&&(i.toneMapped=t.toneMapped),t.userData!==void 0&&(i.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const s in t.uniforms){const o=t.uniforms[s];switch(i.uniforms[s]={},o.type){case"t":i.uniforms[s].value=n(o.value);break;case"c":i.uniforms[s].value=new wt().setHex(o.value);break;case"v2":i.uniforms[s].value=new tt().fromArray(o.value);break;case"v3":i.uniforms[s].value=new R().fromArray(o.value);break;case"v4":i.uniforms[s].value=new Le().fromArray(o.value);break;case"m3":i.uniforms[s].value=new ae().fromArray(o.value);break;case"m4":i.uniforms[s].value=new Qt().fromArray(o.value);break;default:i.uniforms[s].value=o.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(const s in t.extensions)i.extensions[s]=t.extensions[s];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let s=t.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new tt().fromArray(s)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new tt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Cd.createMaterialFromType(t)}static createMaterialFromType(t){const e={ShadowMaterial:Nm,SpriteMaterial:cd,RawShaderMaterial:bd,ShaderMaterial:si,PointsMaterial:dd,MeshPhysicalMaterial:Im,MeshStandardMaterial:Td,MeshPhongMaterial:Pm,MeshToonMaterial:tv,MeshNormalMaterial:Lm,MeshLambertMaterial:Fm,MeshDepthMaterial:wd,MeshDistanceMaterial:Dm,MeshBasicMaterial:Ds,MeshMatcapMaterial:ev,LineDashedMaterial:nv,LineBasicMaterial:Rn,Material:gn};return new e[t]}}class Fu{static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class $m extends se{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class dv extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=new rs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):Vt(l),s.manager.itemError(t)}},n,i)}parse(t){const e={},n={};function i(f,p){if(e[p]!==void 0)return e[p];const g=f.interleavedBuffers[p],m=s(f,g.buffer),y=Zo(g.type,m),v=new xc(y,g.stride);return v.uuid=g.uuid,e[p]=v,v}function s(f,p){if(n[p]!==void 0)return n[p];const g=f.arrayBuffers[p],m=new Uint32Array(g).buffer;return n[p]=m,m}const o=t.isInstancedBufferGeometry?new $m:new se,a=t.data.index;if(a!==void 0){const f=Zo(a.type,a.array);o.setIndex(new Te(f,1))}const l=t.data.attributes;for(const f in l){const p=l[f];let x;if(p.isInterleavedBufferAttribute){const g=i(t.data,p.data);x=new da(g,p.itemSize,p.offset,p.normalized)}else{const g=Zo(p.type,p.array),m=p.isInstancedBufferAttribute?Jr:Te;x=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(x.name=p.name),p.usage!==void 0&&x.setUsage(p.usage),o.setAttribute(f,x)}const c=t.data.morphAttributes;if(c)for(const f in c){const p=c[f],x=[];for(let g=0,m=p.length;g<m;g++){const y=p[g];let v;if(y.isInterleavedBufferAttribute){const _=i(t.data,y.data);v=new da(_,y.itemSize,y.offset,y.normalized)}else{const _=Zo(y.type,y.array);v=new Te(_,y.itemSize,y.normalized)}y.name!==void 0&&(v.name=y.name),x.push(v)}o.morphAttributes[f]=x}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const u=t.data.groups||t.data.drawcalls||t.data.offsets;if(u!==void 0)for(let f=0,p=u.length;f!==p;++f){const x=u[f];o.addGroup(x.start,x.count,x.materialIndex)}const d=t.data.boundingSphere;return d!==void 0&&(o.boundingSphere=new un().fromJSON(d)),t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}}class LT extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=this.path===""?Fu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||o;const a=new rs(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(l){let c=null;try{c=JSON.parse(l)}catch(u){i!==void 0&&i(u),u("ObjectLoader: Can't parse "+t+".",u.message);return}const h=c.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+t)),Vt("ObjectLoader: Can't load "+t);return}s.parse(c,e)},n,i)}async loadAsync(t,e){const n=this,i=this.path===""?Fu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const s=new rs(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const o=await s.loadAsync(t,e);let a;try{a=JSON.parse(o)}catch(c){throw new Error("ObjectLoader: Can't parse "+t+". "+c.message)}const l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+t);return await n.parseAsync(a)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,i),o=this.parseImages(t.images,function(){e!==void 0&&e(c)}),a=this.parseTextures(t.textures,o),l=this.parseMaterials(t.materials,a),c=this.parseObject(t.object,s,l,a,n),h=this.parseSkeletons(t.skeletons,c);if(this.bindSkeletons(c,h),this.bindLightTargets(c),e!==void 0){let u=!1;for(const d in o)if(o[d].data instanceof HTMLImageElement){u=!0;break}u===!1&&e(c)}return c}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),s=await this.parseImagesAsync(t.images),o=this.parseTextures(t.textures,s),a=this.parseMaterials(t.materials,o),l=this.parseObject(t.object,i,a,o,e),c=this.parseSkeletons(t.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(t){const e={};if(t!==void 0)for(let n=0,i=t.length;n<i;n++){const s=new ir().fromJSON(t[n]);e[s.uuid]=s}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse(function(s){s.isBone&&(i[s.uuid]=s)}),t!==void 0)for(let s=0,o=t.length;s<o;s++){const a=new yc().fromJSON(t[s],i);n[a.uuid]=a}return n}parseGeometries(t,e){const n={};if(t!==void 0){const i=new dv;for(let s=0,o=t.length;s<o;s++){let a;const l=t[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(l);break;default:l.type in R0?a=R0[l.type].fromJSON(l,e):pt(`ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),n[l.uuid]=a}}return n}parseMaterials(t,e){const n={},i={};if(t!==void 0){const s=new Cd;s.setTextures(e);for(let o=0,a=t.length;o<a;o++){const l=t[o];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),i[l.uuid]=n[l.uuid]}}return i}parseAnimations(t){const e={};if(t!==void 0)for(let n=0;n<t.length;n++){const i=t[n],s=xa.parse(i);e[s.uuid]=s}return e}parseImages(t,e){const n=this,i={};let s;function o(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){const c=l,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return o(h)}else return l.data?{data:Zo(l.type,l.data),width:l.width,height:l.height}:null}if(t!==void 0&&t.length>0){const l=new Ed(e);s=new sc(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=t.length;c<h;c++){const u=t[c],d=u.url;if(Array.isArray(d)){const f=[];for(let p=0,x=d.length;p<x;p++){const g=d[p],m=a(g);m!==null&&(m instanceof HTMLImageElement?f.push(m):f.push(new fi(m.data,m.width,m.height)))}i[u.uuid]=new Ns(f)}else{const f=a(u.url);i[u.uuid]=new Ns(f)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function s(o){if(typeof o=="string"){const a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:e.resourcePath+a;return await i.loadAsync(l)}else return o.data?{data:Zo(o.type,o.data),width:o.width,height:o.height}:null}if(t!==void 0&&t.length>0){i=new sc(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=t.length;o<a;o++){const l=t[o],c=l.url;if(Array.isArray(c)){const h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u],p=await s(f);p!==null&&(p instanceof HTMLImageElement?h.push(p):h.push(new fi(p.data,p.width,p.height)))}n[l.uuid]=new Ns(h)}else{const h=await s(l.url);n[l.uuid]=new Ns(h)}}}return n}parseTextures(t,e){function n(s,o){return typeof s=="number"?s:(pt("ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}const i={};if(t!==void 0)for(let s=0,o=t.length;s<o;s++){const a=t[s];a.image===void 0&&pt('ObjectLoader: No "image" specified for',a.uuid),e[a.image]===void 0&&pt("ObjectLoader: Undefined image",a.image);const l=e[a.image],c=l.data;let h;Array.isArray(c)?(h=new ba,c.length===6&&(h.needsUpdate=!0)):(c&&c.data?h=new fi:h=new rn,c&&(h.needsUpdate=!0)),h.source=l,h.uuid=a.uuid,a.name!==void 0&&(h.name=a.name),a.mapping!==void 0&&(h.mapping=n(a.mapping,FT)),a.channel!==void 0&&(h.channel=a.channel),a.offset!==void 0&&h.offset.fromArray(a.offset),a.repeat!==void 0&&h.repeat.fromArray(a.repeat),a.center!==void 0&&h.center.fromArray(a.center),a.rotation!==void 0&&(h.rotation=a.rotation),a.wrap!==void 0&&(h.wrapS=n(a.wrap[0],U0),h.wrapT=n(a.wrap[1],U0)),a.format!==void 0&&(h.format=a.format),a.internalFormat!==void 0&&(h.internalFormat=a.internalFormat),a.type!==void 0&&(h.type=a.type),a.colorSpace!==void 0&&(h.colorSpace=a.colorSpace),a.minFilter!==void 0&&(h.minFilter=n(a.minFilter,O0)),a.magFilter!==void 0&&(h.magFilter=n(a.magFilter,O0)),a.anisotropy!==void 0&&(h.anisotropy=a.anisotropy),a.flipY!==void 0&&(h.flipY=a.flipY),a.generateMipmaps!==void 0&&(h.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(h.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(h.compareFunction=a.compareFunction),a.userData!==void 0&&(h.userData=a.userData),i[a.uuid]=h}return i}parseObject(t,e,n,i,s){let o;function a(d){return e[d]===void 0&&pt("ObjectLoader: Undefined geometry",d),e[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const f=[];for(let p=0,x=d.length;p<x;p++){const g=d[p];n[g]===void 0&&pt("ObjectLoader: Undefined material",g),f.push(n[g])}return f}return n[d]===void 0&&pt("ObjectLoader: Undefined material",d),n[d]}}function c(d){return i[d]===void 0&&pt("ObjectLoader: Undefined texture",d),i[d]}let h,u;switch(t.type){case"Scene":o=new cm,t.background!==void 0&&(Number.isInteger(t.background)?o.background=new wt(t.background):o.background=c(t.background)),t.environment!==void 0&&(o.environment=c(t.environment)),t.fog!==void 0&&(t.fog.type==="Fog"?o.fog=new lm(t.fog.color,t.fog.near,t.fog.far):t.fog.type==="FogExp2"&&(o.fog=new ad(t.fog.color,t.fog.density)),t.fog.name!==""&&(o.fog.name=t.fog.name)),t.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=t.backgroundBlurriness),t.backgroundIntensity!==void 0&&(o.backgroundIntensity=t.backgroundIntensity),t.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(t.backgroundRotation),t.environmentIntensity!==void 0&&(o.environmentIntensity=t.environmentIntensity),t.environmentRotation!==void 0&&o.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":o=new cn(t.fov,t.aspect,t.near,t.far),t.focus!==void 0&&(o.focus=t.focus),t.zoom!==void 0&&(o.zoom=t.zoom),t.filmGauge!==void 0&&(o.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(o.filmOffset=t.filmOffset),t.view!==void 0&&(o.view=Object.assign({},t.view));break;case"OrthographicCamera":o=new Ca(t.left,t.right,t.top,t.bottom,t.near,t.far),t.zoom!==void 0&&(o.zoom=t.zoom),t.view!==void 0&&(o.view=Object.assign({},t.view));break;case"AmbientLight":o=new Wm(t.color,t.intensity);break;case"DirectionalLight":o=new Hm(t.color,t.intensity),o.target=t.target||"";break;case"PointLight":o=new Gm(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":o=new hv(t.color,t.intensity,t.width,t.height);break;case"SpotLight":o=new km(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),o.target=t.target||"";break;case"HemisphereLight":o=new zm(t.color,t.groundColor,t.intensity);break;case"LightProbe":const d=new Xm().fromArray(t.sh);o=new uv(d,t.intensity);break;case"SkinnedMesh":h=a(t.geometry),u=l(t.material),o=new fm(h,u),t.bindMode!==void 0&&(o.bindMode=t.bindMode),t.bindMatrix!==void 0&&o.bindMatrix.fromArray(t.bindMatrix),t.skeleton!==void 0&&(o.skeleton=t.skeleton);break;case"Mesh":h=a(t.geometry),u=l(t.material),o=new Ye(h,u);break;case"InstancedMesh":h=a(t.geometry),u=l(t.material);const f=t.count,p=t.instanceMatrix,x=t.instanceColor;o=new pm(h,u,f),o.instanceMatrix=new Jr(new Float32Array(p.array),16),x!==void 0&&(o.instanceColor=new Jr(new Float32Array(x.array),x.itemSize));break;case"BatchedMesh":h=a(t.geometry),u=l(t.material),o=new mm(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,u),o.geometry=h,o.perObjectFrustumCulled=t.perObjectFrustumCulled,o.sortObjects=t.sortObjects,o._drawRanges=t.drawRanges,o._reservedRanges=t.reservedRanges,o._geometryInfo=t.geometryInfo.map(g=>{let m=null,y=null;return g.boundingBox!==void 0&&(m=new mn().fromJSON(g.boundingBox)),g.boundingSphere!==void 0&&(y=new un().fromJSON(g.boundingSphere)),{...g,boundingBox:m,boundingSphere:y}}),o._instanceInfo=t.instanceInfo,o._availableInstanceIds=t._availableInstanceIds,o._availableGeometryIds=t._availableGeometryIds,o._nextIndexStart=t.nextIndexStart,o._nextVertexStart=t.nextVertexStart,o._geometryCount=t.geometryCount,o._maxInstanceCount=t.maxInstanceCount,o._maxVertexCount=t.maxVertexCount,o._maxIndexCount=t.maxIndexCount,o._geometryInitialized=t.geometryInitialized,o._matricesTexture=c(t.matricesTexture.uuid),o._indirectTexture=c(t.indirectTexture.uuid),t.colorsTexture!==void 0&&(o._colorsTexture=c(t.colorsTexture.uuid)),t.boundingSphere!==void 0&&(o.boundingSphere=new un().fromJSON(t.boundingSphere)),t.boundingBox!==void 0&&(o.boundingBox=new mn().fromJSON(t.boundingBox));break;case"LOD":o=new dm;break;case"Line":o=new Fs(a(t.geometry),l(t.material));break;case"LineLoop":o=new gm(a(t.geometry),l(t.material));break;case"LineSegments":o=new zi(a(t.geometry),l(t.material));break;case"PointCloud":case"Points":o=new xm(a(t.geometry),l(t.material));break;case"Sprite":o=new um(l(t.material));break;case"Group":o=new Gr;break;case"Bone":o=new hd;break;default:o=new ve}if(o.uuid=t.uuid,t.name!==void 0&&(o.name=t.name),t.matrix!==void 0?(o.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=t.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(t.position!==void 0&&o.position.fromArray(t.position),t.rotation!==void 0&&o.rotation.fromArray(t.rotation),t.quaternion!==void 0&&o.quaternion.fromArray(t.quaternion),t.scale!==void 0&&o.scale.fromArray(t.scale)),t.up!==void 0&&o.up.fromArray(t.up),t.pivot!==void 0&&(o.pivot=new R().fromArray(t.pivot)),t.morphTargetDictionary!==void 0&&(o.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),t.morphTargetInfluences!==void 0&&(o.morphTargetInfluences=t.morphTargetInfluences.slice()),t.castShadow!==void 0&&(o.castShadow=t.castShadow),t.receiveShadow!==void 0&&(o.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(o.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(o.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(o.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(o.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(o.visible=t.visible),t.frustumCulled!==void 0&&(o.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(o.renderOrder=t.renderOrder),t.static!==void 0&&(o.static=t.static),t.userData!==void 0&&(o.userData=t.userData),t.layers!==void 0&&(o.layers.mask=t.layers),t.children!==void 0){const d=t.children;for(let f=0;f<d.length;f++)o.add(this.parseObject(d[f],e,n,i,s))}if(t.animations!==void 0){const d=t.animations;for(let f=0;f<d.length;f++){const p=d[f];o.animations.push(s[p])}}if(t.type==="LOD"){t.autoUpdate!==void 0&&(o.autoUpdate=t.autoUpdate);const d=t.levels;for(let f=0;f<d.length;f++){const p=d[f],x=o.getObjectByProperty("uuid",p.object);x!==void 0&&o.addLevel(x,p.distance,p.hysteresis)}}return o}bindSkeletons(t,e){Object.keys(e).length!==0&&t.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=e[n.skeleton];i===void 0?pt("ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const n=e.target,i=t.getObjectByProperty("uuid",n);i!==void 0?e.target=i:e.target=new ve}})}}const FT={UVMapping:Zu,CubeReflectionMapping:ss,CubeRefractionMapping:or,EquirectangularReflectionMapping:jo,EquirectangularRefractionMapping:Ko,CubeUVReflectionMapping:to},U0={RepeatWrapping:aa,ClampToEdgeWrapping:Bn,MirroredRepeatWrapping:la},O0={NearestFilter:Xe,NearestMipmapNearestFilter:Ju,NearestMipmapLinearFilter:zr,LinearFilter:Fe,LinearMipmapNearestFilter:Qo,LinearMipmapLinearFilter:Li},Cf=new WeakMap;class fv extends Vn{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&pt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&pt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=Fi.get(`image-bitmap:${t}`);if(o!==void 0){if(s.manager.itemStart(t),o.then){o.then(c=>{if(Cf.has(o)===!0)i&&i(Cf.get(o)),s.manager.itemError(t),s.manager.itemEnd(t);else return e&&e(c),s.manager.itemEnd(t),c});return}return setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(t,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Fi.add(`image-bitmap:${t}`,c),e&&e(c),s.manager.itemEnd(t),c}).catch(function(c){i&&i(c),Cf.set(l,c),Fi.remove(`image-bitmap:${t}`),s.manager.itemError(t),s.manager.itemEnd(t)});Fi.add(`image-bitmap:${t}`,l),s.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let yh;class Nd{static getContext(){return yh===void 0&&(yh=new(window.AudioContext||window.webkitAudioContext)),yh}static setContext(t){yh=t}}class pv extends Vn{constructor(t){super(t)}load(t,e,n,i){const s=this,o=new rs(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(l){try{const c=l.slice(0);Nd.getContext().decodeAudioData(c,function(u){e(u)}).catch(a)}catch(c){a(c)}},n,i);function a(l){i?i(l):Vt(l),s.manager.itemError(t)}}}const B0=new Qt,z0=new Qt,Tr=new Qt;class DT{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new cn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new cn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Tr.copy(t.projectionMatrix);const i=e.eyeSep/2,s=i*e.near/e.focus,o=e.near*Math.tan(Xr*e.fov*.5)/e.zoom;let a,l;z0.elements[12]=-i,B0.elements[12]=i,a=-o*e.aspect+s,l=o*e.aspect+s,Tr.elements[0]=2*e.near/(l-a),Tr.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Tr),a=-o*e.aspect-s,l=o*e.aspect-s,Tr.elements[0]=2*e.near/(l-a),Tr.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Tr)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(z0),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(B0)}}const Co=-90,No=1;class qm extends ve{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new cn(Co,No,t,e);i.layers=this.layers,this.add(i);const s=new cn(Co,No,t,e);s.layers=this.layers,this.add(s);const o=new cn(Co,No,t,e);o.layers=this.layers,this.add(o);const a=new cn(Co,No,t,e);a.layers=this.layers,this.add(a);const l=new cn(Co,No,t,e);l.layers=this.layers,this.add(l);const c=new cn(Co,No,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,s,o,a,l]=e;for(const c of e)this.remove(c);if(t===ti)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Zr)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;t.isWebGLRenderer===!0?g=t.state.buffers.depth.getReversed():g=t.reversedDepthBuffer,t.setRenderTarget(n,0,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,s),t.setRenderTarget(n,1,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,2,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,3,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),t.setRenderTarget(n,4,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Ym extends cn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class Zm{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,t.hidden!==void 0&&(this._pageVisibilityHandler=UT.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(t!==void 0?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function UT(){this._document.hidden===!1&&this.reset()}const Xi=new R,Nf=new En,OT=new R,wr=new R,Ar=new R;let mv=class extends ve{constructor(){super(),this.type="AudioListener",this.context=Nd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new Zm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t),this._timer.update();const e=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(Xi,Nf,OT),!(!Number.isFinite(Xi.x)||!Number.isFinite(Xi.y)||!Number.isFinite(Xi.z)))if(wr.set(0,0,-1).applyQuaternion(Nf),Ar.set(0,1,0).applyQuaternion(Nf),e.positionX){const n=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Xi.x,n),e.positionY.linearRampToValueAtTime(Xi.y,n),e.positionZ.linearRampToValueAtTime(Xi.z,n),e.forwardX.linearRampToValueAtTime(wr.x,n),e.forwardY.linearRampToValueAtTime(wr.y,n),e.forwardZ.linearRampToValueAtTime(wr.z,n),e.upX.linearRampToValueAtTime(Ar.x,n),e.upY.linearRampToValueAtTime(Ar.y,n),e.upZ.linearRampToValueAtTime(Ar.z,n)}else e.setPosition(Xi.x,Xi.y,Xi.z),e.setOrientation(wr.x,wr.y,wr.z,Ar.x,Ar.y,Ar.z)}};class Jm extends ve{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.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(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){pt("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(t=0){if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),this._connected===!0?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}return this.playbackRate=t,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(pt("Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(this.hasPlaybackControl===!1){pt("Audio: this Audio has no playback control.");return}return this.loop=t,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),t.sourceType!=="buffer"?(pt("Audio: Audio source type cannot be copied."),this):(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice(),this)}clone(t){return new this.constructor(this.listener).copy(this,t)}}const Er=new R,V0=new En,BT=new R,Cr=new R;class gv extends Jm{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Er,V0,BT),Cr.set(0,0,1).applyQuaternion(V0);const e=this.panner;if(e.positionX){const n=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(Er.x,n),e.positionY.linearRampToValueAtTime(Er.y,n),e.positionZ.linearRampToValueAtTime(Er.z,n),e.orientationX.linearRampToValueAtTime(Cr.x,n),e.orientationY.linearRampToValueAtTime(Cr.y,n),e.orientationZ.linearRampToValueAtTime(Cr.z,n)}else e.setPosition(Er.x,Er.y,Er.z),e.setOrientation(Cr.x,Cr.y,Cr.z)}}class zT{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}}class xv{constructor(t,e,n){this.binding=t,this.valueSize=n;let i,s,o;switch(e){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,s=t*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[s+a]=n[a];o=e}else{o+=e;const a=e/o;this._mixBufferRegion(n,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=e*this._origIndex;this._mixBufferRegion(n,i,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(n[l]!==n[l+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let s=n,o=i;s!==o;++s)e[s]=e[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,s){if(i>=.5)for(let o=0;o!==s;++o)t[e+o]=t[n+o]}_slerp(t,e,n,i){En.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,s){const o=this._workIndex*s;En.multiplyQuaternionsFlat(t,o,t,e,t,n),En.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,n,i,s){const o=1-i;for(let a=0;a!==s;++a){const l=e+a;t[l]=t[l]*o+t[n+a]*i}}_lerpAdditive(t,e,n,i,s){for(let o=0;o!==s;++o){const a=e+o;t[a]=t[a]+t[n+o]*i}}}const jm="\\[\\]\\.:\\/",VT=new RegExp("["+jm+"]","g"),Km="[^"+jm+"]",kT="[^"+jm.replace("\\.","")+"]",GT=/((?:WC+[\/:])*)/.source.replace("WC",Km),HT=/(WCOD+)?/.source.replace("WCOD",kT),WT=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Km),XT=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Km),$T=new RegExp("^"+GT+HT+WT+XT+"$"),qT=["material","materials","bones","map"];class YT{constructor(t,e,n){const i=n||me.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class me{constructor(t,e,n){this.path=e,this.parsedPath=n||me.parseTrackName(e),this.node=me.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new me.Composite(t,e,n):new me(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(VT,"")}static parseTrackName(t){const e=$T.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);qT.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(s,o){for(let a=0;a<s.length;a++){const l=s[a];if(!o&&(l.name===e||l.uuid===e))return l;if(o&&l.userData&&l.userData.name===e)return l;const c=n(l.children,o);if(c)return c}return null},i=n(t.children);if(i)return i;{const s=n(t.children,!0);if(s)return s}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let s=e.propertyIndex;if(t||(t=me.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){pt("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=e.objectIndex;switch(n){case"materials":if(!t.material){Vt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Vt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){Vt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===c){c=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){Vt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Vt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){Vt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(c!==void 0){if(t[c]===void 0){Vt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}const o=t[i];if(o===void 0){const c=e.nodeName;Vt("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?a=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){Vt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Vt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}me.Composite=YT;me.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};me.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};me.prototype.GetterByBindingType=[me.prototype._getValue_direct,me.prototype._getValue_array,me.prototype._getValue_arrayElement,me.prototype._getValue_toArray];me.prototype.SetterByBindingTypeAndVersioning=[[me.prototype._setValue_direct,me.prototype._setValue_direct_setNeedsUpdate,me.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[me.prototype._setValue_array,me.prototype._setValue_array_setNeedsUpdate,me.prototype._setValue_array_setMatrixWorldNeedsUpdate],[me.prototype._setValue_arrayElement,me.prototype._setValue_arrayElement_setNeedsUpdate,me.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[me.prototype._setValue_fromArray,me.prototype._setValue_fromArray_setNeedsUpdate,me.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ZT{constructor(){this.isAnimationObjectGroup=!0,this.uuid=ei(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let n=0,i=arguments.length;n!==i;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,o=s.length;let a,l=t.length,c=this.nCachedObjects_;for(let h=0,u=arguments.length;h!==u;++h){const d=arguments[h],f=d.uuid;let p=e[f];if(p===void 0){p=l++,e[f]=p,t.push(d);for(let x=0,g=o;x!==g;++x)s[x].push(new me(d,n[x],i[x]))}else if(p<c){a=t[p];const x=--c,g=t[x];e[g.uuid]=p,t[p]=g,e[f]=x,t[x]=d;for(let m=0,y=o;m!==y;++m){const v=s[m],_=v[x];let w=v[p];v[p]=_,w===void 0&&(w=new me(d,n[m],i[m])),v[x]=w}}else t[p]!==a&&Vt("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const l=arguments[o],c=l.uuid,h=e[c];if(h!==void 0&&h>=s){const u=s++,d=t[u];e[d.uuid]=h,t[h]=d,e[c]=u,t[u]=l;for(let f=0,p=i;f!==p;++f){const x=n[f],g=x[u],m=x[h];x[h]=g,x[u]=m}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,o=t.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],h=c.uuid,u=e[h];if(u!==void 0)if(delete e[h],u<s){const d=--s,f=t[d],p=--o,x=t[p];e[f.uuid]=u,t[u]=f,e[x.uuid]=d,t[d]=x,t.pop();for(let g=0,m=i;g!==m;++g){const y=n[g],v=y[d],_=y[p];y[u]=v,y[d]=_,y.pop()}}else{const d=--o,f=t[d];d>0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let p=0,x=i;p!==x;++p){const g=n[p];g[u]=g[d],g.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const s=this._bindings;if(i!==void 0)return s[i];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=s.length,n[t]=i,o.push(t),a.push(e),s.push(u);for(let d=h,f=l.length;d!==f;++d){const p=l[d];u[d]=new me(p,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){const i=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=t[a];e[c]=n,o[n]=l,o.pop(),s[n]=s[a],s.pop(),i[n]=i[a],i.pop()}}}class yv{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Vr,endingEnd:Vr};for(let c=0;c!==o;++c){const h=s[c].createInterpolant(null);a[c]=h,h.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=nm,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n=!1){if(t.fadeOut(e),this.fadeIn(e),n===!0){const i=this._clip.duration,s=t._clip.duration,o=s/i,a=i/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n=!1){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,s=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+n,c[0]=t/o,c[1]=e/o,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);const o=this._updateTime(e),a=this._updateWeight(t);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case im:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(o),c[h].accumulateAdditive(a);break;case id:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(o),c[h].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,s=this._loopCount;const o=n===Qy;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(n===em){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){const a=Math.floor(i/e);i-=e*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){const c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=kr,i.endingEnd=kr):(t?i.endingStart=this.zeroSlopeAtStart?kr:Vr:i.endingStart=Zl,e?i.endingEnd=this.zeroSlopeAtEnd?kr:Vr:i.endingEnd=Zl)}_scheduleFading(t,e,n){const i=this._mixer,s=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=n,this}}const JT=new Float32Array(1);class _v extends Bi{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,s=i.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=i[u],f=d.name;let p=h[f];if(p!==void 0)++p.referenceCount,o[u]=p;else{if(p=o[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}const x=e&&e._propertyBindings[u].binding.parsedPath;p=new xv(me.create(n,f,x),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[u]=p}a[u].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const n=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,n)}const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,s=this._actionsByClip;let o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{const a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],h=t._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),t._byClipCacheIndex=null;const u=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete u[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,s=this._bindings;let o=i[e];o===void 0&&(o={},i[e]=o),o[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[i],l=e[e.length-1],c=t._cacheIndex;l._cacheIndex=c,e[c]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return n===void 0&&(n=new Om(new Float32Array(2),new Float32Array(2),1,JT),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,s=e[i];t.__cacheIndex=i,e[i]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){const i=e||this._root,s=i.uuid;let o=typeof t=="string"?xa.findByName(i,t):t;const a=o!==null?o.uuid:t,l=this._actionsByClip[a];let c=null;if(n===void 0&&(o!==null?n=o.blendMode:n=id),l!==void 0){const u=l.actionByRoot[s];if(u!==void 0&&u.blendMode===n)return u;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const h=new yv(this,o,e,n);return this._bindAction(h,c),this._addInactiveAction(h,a,s),h}existingAction(t,e){const n=e||this._root,i=n.uuid,s=typeof t=="string"?xa.findByName(n,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==n;++c)e[c]._update(i,t,s,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const h=c._cacheIndex,u=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,e[h]=u,e.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,s=i[e];if(s!==void 0)for(const o in s){const a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){const n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class jT extends am{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new mc(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class Rd{constructor(t){this.value=t}clone(){return new Rd(this.value.clone===void 0?this.value:this.value.clone())}}let KT=0;class QT extends Bi{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:KT++}),this.name="",this.usage=jl,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return e!==-1&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let n=0,i=e.length;n<i;n++){const s=Array.isArray(e[n])?e[n]:[e[n]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}}let vv=class extends xc{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}};class t1{constructor(t,e,n,i,s,o=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=s,this.normalized=o,this.version=0}set needsUpdate(t){t===!0&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}}const k0=new Qt;class Mv{constructor(t,e,n=0,i=1/0){this.ray=new eo(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new gc,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Vt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return k0.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(k0),this}intersectObject(t,e=!0,n=[]){return Rp(t,this,n,e),n.sort(G0),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)Rp(t[i],this,n,e);return n.sort(G0),n}}function G0(r,t){return r.distance-t.distance}function Rp(r,t,e,n){let i=!0;if(r.layers.test(t.layers)&&r.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){const s=r.children;for(let o=0,a=s.length;o<a;o++)Rp(s[o],t,e,!0)}}class e1{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,pt("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.")}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}class Sv{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Jt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Jt(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class n1{constructor(t=1,e=0,n=0){this.radius=t,this.theta=e,this.y=n}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return new this.constructor().copy(this)}}let i1=class bv{constructor(t,e,n,i){bv.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}};const H0=new tt;class s1{constructor(t=new tt(1/0,1/0),e=new tt(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=H0.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}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}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))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,H0).distanceTo(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}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 W0=new R,_h=new R,Ro=new R,Io=new R,Rf=new R,r1=new R,o1=new R;class Tv{constructor(t=new R,e=new R){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){W0.subVectors(t,this.start),_h.subVectors(this.end,this.start);const n=_h.dot(_h);let s=_h.dot(W0)/n;return e&&(s=Jt(s,0,1)),s}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(t,e=r1,n=o1){const i=10000000000000001e-32;let s,o;const a=this.start,l=t.start,c=this.end,h=t.end;Ro.subVectors(c,a),Io.subVectors(h,l),Rf.subVectors(a,l);const u=Ro.dot(Ro),d=Io.dot(Io),f=Io.dot(Rf);if(u<=i&&d<=i)return e.copy(a),n.copy(l),e.sub(n),e.dot(e);if(u<=i)s=0,o=f/d,o=Jt(o,0,1);else{const p=Ro.dot(Rf);if(d<=i)o=0,s=Jt(-p/u,0,1);else{const x=Ro.dot(Io),g=u*d-x*x;g!==0?s=Jt((x*f-p*d)/g,0,1):s=0,o=(x*s+f)/d,o<0?(o=0,s=Jt(-p/u,0,1)):o>1&&(o=1,s=Jt((x-p)/u,0,1))}}return e.copy(a).addScaledVector(Ro,s),n.copy(l).addScaledVector(Io,o),e.distanceToSquared(n)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const X0=new R;class a1 extends ve{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new se,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){const c=o/l*Math.PI*2,h=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new Ct(i,3));const s=new Rn({fog:!1,toneMapped:!1});this.cone=new zi(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),X0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(X0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Ws=new R,vh=new Qt,If=new Qt;class l1 extends zi{constructor(t){const e=wv(t),n=new se,i=[],s=[];for(let c=0;c<e.length;c++){const h=e[c];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(0,0,0),s.push(0,0,0))}n.setAttribute("position",new Ct(i,3)),n.setAttribute("color",new Ct(s,3));const o=new Rn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,o),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const a=new wt(255),l=new wt(65280);this.setColors(a,l)}updateMatrixWorld(t){const e=this.bones,n=this.geometry,i=n.getAttribute("position");If.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<e.length;s++){const a=e[s];a.parent&&a.parent.isBone&&(vh.multiplyMatrices(If,a.matrixWorld),Ws.setFromMatrixPosition(vh),i.setXYZ(o,Ws.x,Ws.y,Ws.z),vh.multiplyMatrices(If,a.parent.matrixWorld),Ws.setFromMatrixPosition(vh),i.setXYZ(o+1,Ws.x,Ws.y,Ws.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const i=this.geometry.getAttribute("color");for(let s=0;s<i.count;s+=2)i.setXYZ(s,t.r,t.g,t.b),i.setXYZ(s+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function wv(r){const t=[];r.isBone===!0&&t.push(r);for(let e=0;e<r.children.length;e++)t.push(...wv(r.children[e]));return t}class c1 extends Ye{constructor(t,e,n){const i=new Aa(e,4,2),s=new Ds({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const h1=new R,$0=new wt,q0=new wt;class u1 extends ve{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new wa(e);i.rotateY(Math.PI*.5),this.material=new Ds({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),o=new Float32Array(s.count*3);i.setAttribute("color",new Te(o,3)),this.add(new Ye(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");$0.copy(this.light.color),q0.copy(this.light.groundColor);for(let n=0,i=e.count;n<i;n++){const s=n<i/2?$0:q0;e.setXYZ(n,s.r,s.g,s.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(h1.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Av=class extends zi{constructor(t=10,e=10,n=4473924,i=8947848){n=new wt(n),i=new wt(i);const s=e/2,o=t/e,a=t/2,l=[],c=[];for(let d=0,f=0,p=-a;d<=e;d++,p+=o){l.push(-a,0,p,a,0,p),l.push(p,0,-a,p,0,a);const x=d===s?n:i;x.toArray(c,f),f+=3,x.toArray(c,f),f+=3,x.toArray(c,f),f+=3,x.toArray(c,f),f+=3}const h=new se;h.setAttribute("position",new Ct(l,3)),h.setAttribute("color",new Ct(c,3));const u=new Rn({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class d1 extends zi{constructor(t=10,e=16,n=8,i=64,s=4473924,o=8947848){s=new wt(s),o=new wt(o);const a=[],l=[];if(e>1)for(let u=0;u<e;u++){const d=u/e*(Math.PI*2),f=Math.sin(d)*t,p=Math.cos(d)*t;a.push(0,0,0),a.push(f,0,p);const x=u&1?s:o;l.push(x.r,x.g,x.b),l.push(x.r,x.g,x.b)}for(let u=0;u<n;u++){const d=u&1?s:o,f=t-t/n*u;for(let p=0;p<i;p++){let x=p/i*(Math.PI*2),g=Math.sin(x)*f,m=Math.cos(x)*f;a.push(g,0,m),l.push(d.r,d.g,d.b),x=(p+1)/i*(Math.PI*2),g=Math.sin(x)*f,m=Math.cos(x)*f,a.push(g,0,m),l.push(d.r,d.g,d.b)}}const c=new se;c.setAttribute("position",new Ct(a,3)),c.setAttribute("color",new Ct(l,3));const h=new Rn({vertexColors:!0,toneMapped:!1});super(c,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Y0=new R,Mh=new R,Z0=new R;class Ev extends ve{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new se;i.setAttribute("position",new Ct([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new Rn({fog:!1,toneMapped:!1});this.lightPlane=new Fs(i,s),this.add(this.lightPlane),i=new se,i.setAttribute("position",new Ct([0,0,0,0,0,1],3)),this.targetLine=new Fs(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Y0.setFromMatrixPosition(this.light.matrixWorld),Mh.setFromMatrixPosition(this.light.target.matrixWorld),Z0.subVectors(Mh,Y0),this.lightPlane.lookAt(Mh),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Mh),this.targetLine.scale.z=Z0.length()}}const Sh=new R,We=new Tc;class Cv extends zi{constructor(t){const e=new se,n=new Rn({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,x){l(p),l(x)}function l(p){i.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(i.length/3-1)}e.setAttribute("position",new Ct(i,3)),e.setAttribute("color",new Ct(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const c=new wt(16755200),h=new wt(16711680),u=new wt(43775),d=new wt(16777215),f=new wt(3355443);this.setColors(c,h,u,d,f)}setColors(t,e,n,i,s){const a=this.geometry.getAttribute("color");return a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap,n=1,i=1;let s,o;if(We.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)s=1,o=0;else if(this.camera.coordinateSystem===ti)s=-1,o=1;else if(this.camera.coordinateSystem===Zr)s=0,o=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);qe("c",e,t,We,0,0,s),qe("t",e,t,We,0,0,o),qe("n1",e,t,We,-n,-i,s),qe("n2",e,t,We,n,-i,s),qe("n3",e,t,We,-n,i,s),qe("n4",e,t,We,n,i,s),qe("f1",e,t,We,-n,-i,o),qe("f2",e,t,We,n,-i,o),qe("f3",e,t,We,-n,i,o),qe("f4",e,t,We,n,i,o),qe("u1",e,t,We,n*.7,i*1.1,s),qe("u2",e,t,We,-n*.7,i*1.1,s),qe("u3",e,t,We,0,i*2,s),qe("cf1",e,t,We,-n,0,o),qe("cf2",e,t,We,n,0,o),qe("cf3",e,t,We,0,-i,o),qe("cf4",e,t,We,0,i,o),qe("cn1",e,t,We,-n,0,s),qe("cn2",e,t,We,n,0,s),qe("cn3",e,t,We,0,-i,s),qe("cn4",e,t,We,0,i,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function qe(r,t,e,n,i,s,o){Sh.set(i,s,o).unproject(n);const a=t[r];if(a!==void 0){const l=e.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Sh.x,Sh.y,Sh.z)}}const bh=new mn;class Nv extends zi{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),s=new se;s.setIndex(new Te(n,1)),s.setAttribute("position",new Te(i,3)),super(s,new Rn({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&bh.setFromObject(this.object),bh.isEmpty())return;const t=bh.min,e=bh.max,n=this.geometry.attributes.position,i=n.array;i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=t.x,i[4]=e.y,i[5]=e.z,i[6]=t.x,i[7]=t.y,i[8]=e.z,i[9]=e.x,i[10]=t.y,i[11]=e.z,i[12]=e.x,i[13]=e.y,i[14]=t.z,i[15]=t.x,i[16]=e.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=e.x,i[22]=t.y,i[23]=t.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Rv extends zi{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new se;s.setIndex(new Te(n,1)),s.setAttribute("position",new Ct(i,3)),super(s,new Rn({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class f1 extends Fs{constructor(t,e=1,n=16776960){const i=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new se;o.setAttribute("position",new Ct(s,3)),o.computeBoundingSphere(),super(o,new Rn({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new se;l.setAttribute("position",new Ct(a,3)),l.computeBoundingSphere(),this.add(new Ye(l,new Ds({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const J0=new R;let Th,Pf;class p1 extends ve{constructor(t=new R(0,0,1),e=new R(0,0,0),n=1,i=16776960,s=n*.2,o=s*.2){super(),this.type="ArrowHelper",Th===void 0&&(Th=new se,Th.setAttribute("position",new Ct([0,0,0,0,1,0],3)),Pf=new vc(.5,1,5,1),Pf.translate(0,-.5,0)),this.position.copy(e),this.line=new Fs(Th,new Rn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ye(Pf,new Ds({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,s,o)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{J0.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(J0,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Iv=class extends zi{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new se;i.setAttribute("position",new Ct(e,3)),i.setAttribute("color",new Ct(n,3));const s=new Rn({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){const i=new wt,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class Pv{constructor(){this.type="ShapePath",this.color=new wt,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Lu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,s,o){return this.currentPath.bezierCurveTo(t,e,n,i,s,o),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(m){const y=[];for(let v=0,_=m.length;v<_;v++){const w=m[v],T=new ir;T.curves=w.curves,y.push(T)}return y}function n(m,y){const v=y.length;let _=!1;for(let w=v-1,T=0;T<v;w=T++){let E=y[w],M=y[T],b=M.x-E.x,P=M.y-E.y;if(Math.abs(P)>Number.EPSILON){if(P<0&&(E=y[T],b=-b,M=y[w],P=-P),m.y<E.y||m.y>M.y)continue;if(m.y===E.y){if(m.x===E.x)return!0}else{const N=P*(m.x-E.x)-b*(m.y-E.y);if(N===0)return!0;if(N<0)continue;_=!_}}else{if(m.y!==E.y)continue;if(M.x<=m.x&&m.x<=E.x||E.x<=m.x&&m.x<=M.x)return!0}}return _}const i=ui.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new ir,l.curves=a.curves,c.push(l),c;let h=!i(s[0].getPoints());h=t?!h:h;const u=[],d=[];let f=[],p=0,x;d[p]=void 0,f[p]=[];for(let m=0,y=s.length;m<y;m++)a=s[m],x=a.getPoints(),o=i(x),o=t?!o:o,o?(!h&&d[p]&&p++,d[p]={s:new ir,p:x},d[p].s.curves=a.curves,h&&p++,f[p]=[]):f[p].push({h:a,p:x[0]});if(!d[0])return e(s);if(d.length>1){let m=!1,y=0;for(let v=0,_=d.length;v<_;v++)u[v]=[];for(let v=0,_=d.length;v<_;v++){const w=f[v];for(let T=0;T<w.length;T++){const E=w[T];let M=!0;for(let b=0;b<d.length;b++)n(E.p,d[b].p)&&(v!==b&&y++,M?(M=!1,u[b].push(E)):m=!0);M&&u[v].push(E)}}y>0&&m===!1&&(f=u)}let g;for(let m=0,y=d.length;m<y;m++){l=d[m].s,c.push(l),g=f[m];for(let v=0,_=g.length;v<_;v++)l.holes.push(g[v].h)}return c}}class Lv extends Bi{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){pt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}}function m1(r,t){const e=r.image&&r.image.width?r.image.width/r.image.height:1;return e>t?(r.repeat.x=1,r.repeat.y=e/t,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=t/e,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function g1(r,t){const e=r.image&&r.image.width?r.image.width/r.image.height:1;return e>t?(r.repeat.x=t/e,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=e/t,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function x1(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function Ip(r,t,e,n){const i=y1(n);switch(e){case tm:return r*t;case dc:return r*t/i.components*i.byteLength;case Sa:return r*t/i.components*i.byteLength;case ar:return r*t*2/i.components*i.byteLength;case fc:return r*t*2/i.components*i.byteLength;case nd:return r*t*3/i.components*i.byteLength;case wn:return r*t*4/i.components*i.byteLength;case pc:return r*t*4/i.components*i.byteLength;case ta:case ea:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case dl:case na:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case pu:case Pl:return Math.max(r,16)*Math.max(t,8)/4;case Rl:case Il:return Math.max(r,8)*Math.max(t,8)/2;case Ll:case Fl:case Ul:case Ol:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case Dl:case Bl:case zl:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Vl:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case mu:return Math.floor((r+4)/5)*Math.floor((t+3)/4)*16;case gu:return Math.floor((r+4)/5)*Math.floor((t+4)/5)*16;case xu:return Math.floor((r+5)/6)*Math.floor((t+4)/5)*16;case kl:return Math.floor((r+5)/6)*Math.floor((t+5)/6)*16;case yu:return Math.floor((r+7)/8)*Math.floor((t+4)/5)*16;case _u:return Math.floor((r+7)/8)*Math.floor((t+5)/6)*16;case vu:return Math.floor((r+7)/8)*Math.floor((t+7)/8)*16;case Mu:return Math.floor((r+9)/10)*Math.floor((t+4)/5)*16;case Su:return Math.floor((r+9)/10)*Math.floor((t+5)/6)*16;case bu:return Math.floor((r+9)/10)*Math.floor((t+7)/8)*16;case Tu:return Math.floor((r+9)/10)*Math.floor((t+9)/10)*16;case wu:return Math.floor((r+11)/12)*Math.floor((t+9)/10)*16;case Au:return Math.floor((r+11)/12)*Math.floor((t+11)/12)*16;case Gl:case Eu:case Hl:return Math.ceil(r/4)*Math.ceil(t/4)*16;case Wl:case Xl:return Math.ceil(r/4)*Math.ceil(t/4)*8;case $l:case ql:return Math.ceil(r/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function y1(r){switch(r){case Un:case Kp:return{byteLength:1,components:1};case ca:case Qp:case Ui:return{byteLength:2,components:1};case Ku:case Qu:return{byteLength:2,components:4};case ii:case ju:case Tn:return{byteLength:4,components:1};case td:case ed:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}class _1{static contain(t,e){return m1(t,e)}static cover(t,e){return g1(t,e)}static fill(t){return x1(t)}static getByteLength(t,e,n,i){return Ip(t,e,n,i)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Wr}}));if(typeof window<"u"){try{typeof document>"u"?require("url").pathToFileURL(__filename).href:ho&&ho.tagName.toUpperCase()==="SCRIPT"&&ho.src||new URL("three.umd.cjs",document.baseURI).href,window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ho&&ho.tagName.toUpperCase()==="SCRIPT"&&ho.src||new URL("three.umd.cjs",document.baseURI).href,revision:Wr})}catch{}window.__THREE__?(pt("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+Wr),console.warn("THREE imports:",window.__THREE__IMPORTS__)):window.__THREE__=Wr}function Fv(){let r=null,t=!1,e=null,n=null;function i(s,o){e(s,o),n=r.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=r.requestAnimationFrame(i),t=!0)},stop:function(){r.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){r=s}}}function v1(r){const t=new WeakMap;function e(a,l){const c=a.array,h=a.usage,u=c.byteLength,d=r.createBuffer();r.bindBuffer(l,d),r.bufferData(l,c,h),a.onUploadCallback();let f;if(c instanceof Float32Array)f=r.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=r.HALF_FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=r.HALF_FLOAT:f=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=r.SHORT;else if(c instanceof Uint32Array)f=r.UNSIGNED_INT;else if(c instanceof Int32Array)f=r.INT;else if(c instanceof Int8Array)f=r.BYTE;else if(c instanceof Uint8Array)f=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,l,c){const h=l.array,u=l.updateRanges;if(r.bindBuffer(c,a),u.length===0)r.bufferSubData(c,0,h);else{u.sort((f,p)=>f.start-p.start);let d=0;for(let f=1;f<u.length;f++){const p=u[d],x=u[f];x.start<=p.start+p.count+1?p.count=Math.max(p.count,x.start+x.count-p.start):(++d,u[d]=x)}u.length=d+1;for(let f=0,p=u.length;f<p;f++){const x=u[f];r.bufferSubData(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),t.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=t.get(a);l&&(r.deleteBuffer(l.buffer),t.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const h=t.get(a);(!h||h.version<a.version)&&t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const c=t.get(a);if(c===void 0)t.set(a,e(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,a,l),c.version=a.version}}return{get:i,remove:s,update:o}}var M1=`#ifdef USE_ALPHAHASH
|
|
6
6
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
7
7
|
#endif`,S1=`#ifdef USE_ALPHAHASH
|
|
8
8
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
@@ -3617,7 +3617,7 @@ void main() {
|
|
|
3617
3617
|
#include <tonemapping_fragment>
|
|
3618
3618
|
#include <colorspace_fragment>
|
|
3619
3619
|
#include <fog_fragment>
|
|
3620
|
-
}`,oe={alphahash_fragment:M1,alphahash_pars_fragment:S1,alphamap_fragment:b1,alphamap_pars_fragment:T1,alphatest_fragment:w1,alphatest_pars_fragment:A1,aomap_fragment:E1,aomap_pars_fragment:C1,batching_pars_vertex:N1,batching_vertex:R1,begin_vertex:I1,beginnormal_vertex:P1,bsdfs:L1,iridescence_fragment:F1,bumpmap_pars_fragment:D1,clipping_planes_fragment:U1,clipping_planes_pars_fragment:O1,clipping_planes_pars_vertex:B1,clipping_planes_vertex:z1,color_fragment:V1,color_pars_fragment:k1,color_pars_vertex:G1,color_vertex:H1,common:W1,cube_uv_reflection_fragment:X1,defaultnormal_vertex:$1,displacementmap_pars_vertex:q1,displacementmap_vertex:Y1,emissivemap_fragment:Z1,emissivemap_pars_fragment:J1,colorspace_fragment:j1,colorspace_pars_fragment:K1,envmap_fragment:Q1,envmap_common_pars_fragment:tw,envmap_pars_fragment:ew,envmap_pars_vertex:nw,envmap_physical_pars_fragment:fw,envmap_vertex:iw,fog_vertex:sw,fog_pars_vertex:rw,fog_fragment:ow,fog_pars_fragment:aw,gradientmap_pars_fragment:lw,lightmap_pars_fragment:cw,lights_lambert_fragment:hw,lights_lambert_pars_fragment:uw,lights_pars_begin:dw,lights_toon_fragment:pw,lights_toon_pars_fragment:mw,lights_phong_fragment:gw,lights_phong_pars_fragment:xw,lights_physical_fragment:yw,lights_physical_pars_fragment:_w,lights_fragment_begin:vw,lights_fragment_maps:Mw,lights_fragment_end:Sw,logdepthbuf_fragment:bw,logdepthbuf_pars_fragment:Tw,logdepthbuf_pars_vertex:ww,logdepthbuf_vertex:Aw,map_fragment:Ew,map_pars_fragment:Cw,map_particle_fragment:Nw,map_particle_pars_fragment:Rw,metalnessmap_fragment:Iw,metalnessmap_pars_fragment:Pw,morphinstance_vertex:Lw,morphcolor_vertex:Fw,morphnormal_vertex:Dw,morphtarget_pars_vertex:Uw,morphtarget_vertex:Ow,normal_fragment_begin:Bw,normal_fragment_maps:zw,normal_pars_fragment:Vw,normal_pars_vertex:kw,normal_vertex:Gw,normalmap_pars_fragment:Hw,clearcoat_normal_fragment_begin:Ww,clearcoat_normal_fragment_maps:Xw,clearcoat_pars_fragment:$w,iridescence_pars_fragment:qw,opaque_fragment:Yw,packing:Zw,premultiplied_alpha_fragment:Jw,project_vertex:jw,dithering_fragment:Kw,dithering_pars_fragment:Qw,roughnessmap_fragment:tA,roughnessmap_pars_fragment:eA,shadowmap_pars_fragment:nA,shadowmap_pars_vertex:iA,shadowmap_vertex:sA,shadowmask_pars_fragment:rA,skinbase_vertex:oA,skinning_pars_vertex:aA,skinning_vertex:lA,skinnormal_vertex:cA,specularmap_fragment:hA,specularmap_pars_fragment:uA,tonemapping_fragment:dA,tonemapping_pars_fragment:fA,transmission_fragment:pA,transmission_pars_fragment:mA,uv_pars_fragment:gA,uv_pars_vertex:xA,uv_vertex:yA,worldpos_vertex:_A,background_vert:vA,background_frag:MA,backgroundCube_vert:SA,backgroundCube_frag:bA,cube_vert:TA,cube_frag:wA,depth_vert:AA,depth_frag:EA,distance_vert:CA,distance_frag:NA,equirect_vert:RA,equirect_frag:IA,linedashed_vert:PA,linedashed_frag:LA,meshbasic_vert:FA,meshbasic_frag:DA,meshlambert_vert:UA,meshlambert_frag:OA,meshmatcap_vert:BA,meshmatcap_frag:zA,meshnormal_vert:VA,meshnormal_frag:kA,meshphong_vert:GA,meshphong_frag:HA,meshphysical_vert:WA,meshphysical_frag:XA,meshtoon_vert:$A,meshtoon_frag:qA,points_vert:YA,points_frag:ZA,shadow_vert:JA,shadow_frag:jA,sprite_vert:KA,sprite_frag:QA},gt={common:{diffuse:{value:new wt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ae},alphaMap:{value:null},alphaMapTransform:{value:new ae},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ae}},envmap:{envMap:{value:null},envMapRotation:{value:new ae},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ae}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ae}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ae},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ae},normalScale:{value:new tt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ae},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ae}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ae}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ae}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new wt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},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 wt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ae},alphaTest:{value:0},uvTransform:{value:new ae}},sprite:{diffuse:{value:new wt(16777215)},opacity:{value:1},center:{value:new tt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ae},alphaMap:{value:null},alphaMapTransform:{value:new ae},alphaTest:{value:0}}},ci={basic:{uniforms:Ln([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.fog]),vertexShader:oe.meshbasic_vert,fragmentShader:oe.meshbasic_frag},lambert:{uniforms:Ln([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new wt(0)},envMapIntensity:{value:1}}]),vertexShader:oe.meshlambert_vert,fragmentShader:oe.meshlambert_frag},phong:{uniforms:Ln([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new wt(0)},specular:{value:new wt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:oe.meshphong_vert,fragmentShader:oe.meshphong_frag},standard:{uniforms:Ln([gt.common,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.roughnessmap,gt.metalnessmap,gt.fog,gt.lights,{emissive:{value:new wt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:oe.meshphysical_vert,fragmentShader:oe.meshphysical_frag},toon:{uniforms:Ln([gt.common,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.gradientmap,gt.fog,gt.lights,{emissive:{value:new wt(0)}}]),vertexShader:oe.meshtoon_vert,fragmentShader:oe.meshtoon_frag},matcap:{uniforms:Ln([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,{matcap:{value:null}}]),vertexShader:oe.meshmatcap_vert,fragmentShader:oe.meshmatcap_frag},points:{uniforms:Ln([gt.points,gt.fog]),vertexShader:oe.points_vert,fragmentShader:oe.points_frag},dashed:{uniforms:Ln([gt.common,gt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:oe.linedashed_vert,fragmentShader:oe.linedashed_frag},depth:{uniforms:Ln([gt.common,gt.displacementmap]),vertexShader:oe.depth_vert,fragmentShader:oe.depth_frag},normal:{uniforms:Ln([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,{opacity:{value:1}}]),vertexShader:oe.meshnormal_vert,fragmentShader:oe.meshnormal_frag},sprite:{uniforms:Ln([gt.sprite,gt.fog]),vertexShader:oe.sprite_vert,fragmentShader:oe.sprite_frag},background:{uniforms:{uvTransform:{value:new ae},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:oe.background_vert,fragmentShader:oe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ae}},vertexShader:oe.backgroundCube_vert,fragmentShader:oe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:oe.cube_vert,fragmentShader:oe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:oe.equirect_vert,fragmentShader:oe.equirect_frag},distance:{uniforms:Ln([gt.common,gt.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:oe.distance_vert,fragmentShader:oe.distance_frag},shadow:{uniforms:Ln([gt.lights,gt.fog,{color:{value:new wt(0)},opacity:{value:1}}]),vertexShader:oe.shadow_vert,fragmentShader:oe.shadow_frag}};ci.physical={uniforms:Ln([ci.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ae},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ae},clearcoatNormalScale:{value:new tt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ae},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ae},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ae},sheen:{value:0},sheenColor:{value:new wt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ae},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ae},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ae},transmissionSamplerSize:{value:new tt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ae},attenuationDistance:{value:0},attenuationColor:{value:new wt(0)},specularColor:{value:new wt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ae},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ae},anisotropyVector:{value:new tt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ae}}]),vertexShader:oe.meshphysical_vert,fragmentShader:oe.meshphysical_frag};const wh={r:0,b:0,g:0},Nr=new mi,tE=new Qt;function eE(r,t,e,n,i,s){const o=new wt(0);let a=i===!0?0:1,l,c,h=null,u=0,d=null;function f(y){let v=y.isScene===!0?y.background:null;if(v&&v.isTexture){const _=y.backgroundBlurriness>0;v=t.get(v,_)}return v}function p(y){let v=!1;const _=f(y);_===null?g(o,a):_&&_.isColor&&(g(_,1),v=!0);const w=r.xr.getEnvironmentBlendMode();w==="additive"?e.buffers.color.setClear(0,0,0,1,s):w==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(r.autoClear||v)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function x(y,v){const _=f(v);_&&(_.isCubeTexture||_.mapping===to)?(c===void 0&&(c=new Ye(new dr(1,1,1),new si({name:"BackgroundCubeMaterial",uniforms:fa(ci.backgroundCube.uniforms),vertexShader:ci.backgroundCube.vertexShader,fragmentShader:ci.backgroundCube.fragmentShader,side:An,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(w,T,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),Nr.copy(v.backgroundRotation),Nr.x*=-1,Nr.y*=-1,Nr.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Nr.y*=-1,Nr.z*=-1),c.material.uniforms.envMap.value=_,c.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(tE.makeRotationFromEuler(Nr)),c.material.toneMapped=fe.getTransfer(_.colorSpace)!==_e,(h!==_||u!==_.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,h=_,u=_.version,d=r.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new Ye(new io(2,2),new si({name:"BackgroundMaterial",uniforms:fa(ci.background.uniforms),vertexShader:ci.background.vertexShader,fragmentShader:ci.background.fragmentShader,side:is,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=fe.getTransfer(_.colorSpace)!==_e,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||u!==_.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,h=_,u=_.version,d=r.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function g(y,v){y.getRGB(wh,Q_(r)),e.buffers.color.setClear(wh.r,wh.g,wh.b,v,s)}function m(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,v=1){o.set(y),a=v,g(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,g(o,a)},render:p,addToRenderList:x,dispose:m}}function nE(r,t){const e=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=d(null);let s=i,o=!1;function a(N,L,U,V,O){let k=!1;const G=u(N,V,U,L);s!==G&&(s=G,c(s.object)),k=f(N,V,U,O),k&&p(N,V,U,O),O!==null&&t.update(O,r.ELEMENT_ARRAY_BUFFER),(k||o)&&(o=!1,_(N,L,U,V),O!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(O).buffer))}function l(){return r.createVertexArray()}function c(N){return r.bindVertexArray(N)}function h(N){return r.deleteVertexArray(N)}function u(N,L,U,V){const O=V.wireframe===!0;let k=n[L.id];k===void 0&&(k={},n[L.id]=k);const G=N.isInstancedMesh===!0?N.id:0;let it=k[G];it===void 0&&(it={},k[G]=it);let nt=it[U.id];nt===void 0&&(nt={},it[U.id]=nt);let mt=nt[O];return mt===void 0&&(mt=d(l()),nt[O]=mt),mt}function d(N){const L=[],U=[],V=[];for(let O=0;O<e;O++)L[O]=0,U[O]=0,V[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:U,attributeDivisors:V,object:N,attributes:{},index:null}}function f(N,L,U,V){const O=s.attributes,k=L.attributes;let G=0;const it=U.getAttributes();for(const nt in it)if(it[nt].location>=0){const xt=O[nt];let bt=k[nt];if(bt===void 0&&(nt==="instanceMatrix"&&N.instanceMatrix&&(bt=N.instanceMatrix),nt==="instanceColor"&&N.instanceColor&&(bt=N.instanceColor)),xt===void 0||xt.attribute!==bt||bt&&xt.data!==bt.data)return!0;G++}return s.attributesNum!==G||s.index!==V}function p(N,L,U,V){const O={},k=L.attributes;let G=0;const it=U.getAttributes();for(const nt in it)if(it[nt].location>=0){let xt=k[nt];xt===void 0&&(nt==="instanceMatrix"&&N.instanceMatrix&&(xt=N.instanceMatrix),nt==="instanceColor"&&N.instanceColor&&(xt=N.instanceColor));const bt={};bt.attribute=xt,xt&&xt.data&&(bt.data=xt.data),O[nt]=bt,G++}s.attributes=O,s.attributesNum=G,s.index=V}function x(){const N=s.newAttributes;for(let L=0,U=N.length;L<U;L++)N[L]=0}function g(N){m(N,0)}function m(N,L){const U=s.newAttributes,V=s.enabledAttributes,O=s.attributeDivisors;U[N]=1,V[N]===0&&(r.enableVertexAttribArray(N),V[N]=1),O[N]!==L&&(r.vertexAttribDivisor(N,L),O[N]=L)}function y(){const N=s.newAttributes,L=s.enabledAttributes;for(let U=0,V=L.length;U<V;U++)L[U]!==N[U]&&(r.disableVertexAttribArray(U),L[U]=0)}function v(N,L,U,V,O,k,G){G===!0?r.vertexAttribIPointer(N,L,U,O,k):r.vertexAttribPointer(N,L,U,V,O,k)}function _(N,L,U,V){x();const O=V.attributes,k=U.getAttributes(),G=L.defaultAttributeValues;for(const it in k){const nt=k[it];if(nt.location>=0){let mt=O[it];if(mt===void 0&&(it==="instanceMatrix"&&N.instanceMatrix&&(mt=N.instanceMatrix),it==="instanceColor"&&N.instanceColor&&(mt=N.instanceColor)),mt!==void 0){const xt=mt.normalized,bt=mt.itemSize,jt=t.get(mt);if(jt===void 0)continue;const Me=jt.buffer,we=jt.type,j=jt.bytesPerElement,ct=we===r.INT||we===r.UNSIGNED_INT||mt.gpuType===ju;if(mt.isInterleavedBufferAttribute){const ht=mt.data,qt=ht.stride,Xt=mt.offset;if(ht.isInstancedInterleavedBuffer){for(let Kt=0;Kt<nt.locationSize;Kt++)m(nt.location+Kt,ht.meshPerAttribute);N.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ht.meshPerAttribute*ht.count)}else for(let Kt=0;Kt<nt.locationSize;Kt++)g(nt.location+Kt);r.bindBuffer(r.ARRAY_BUFFER,Me);for(let Kt=0;Kt<nt.locationSize;Kt++)v(nt.location+Kt,bt/nt.locationSize,we,xt,qt*j,(Xt+bt/nt.locationSize*Kt)*j,ct)}else{if(mt.isInstancedBufferAttribute){for(let ht=0;ht<nt.locationSize;ht++)m(nt.location+ht,mt.meshPerAttribute);N.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=mt.meshPerAttribute*mt.count)}else for(let ht=0;ht<nt.locationSize;ht++)g(nt.location+ht);r.bindBuffer(r.ARRAY_BUFFER,Me);for(let ht=0;ht<nt.locationSize;ht++)v(nt.location+ht,bt/nt.locationSize,we,xt,bt*j,bt/nt.locationSize*ht*j,ct)}}else if(G!==void 0){const xt=G[it];if(xt!==void 0)switch(xt.length){case 2:r.vertexAttrib2fv(nt.location,xt);break;case 3:r.vertexAttrib3fv(nt.location,xt);break;case 4:r.vertexAttrib4fv(nt.location,xt);break;default:r.vertexAttrib1fv(nt.location,xt)}}}}y()}function w(){b();for(const N in n){const L=n[N];for(const U in L){const V=L[U];for(const O in V){const k=V[O];for(const G in k)h(k[G].object),delete k[G];delete V[O]}}delete n[N]}}function T(N){if(n[N.id]===void 0)return;const L=n[N.id];for(const U in L){const V=L[U];for(const O in V){const k=V[O];for(const G in k)h(k[G].object),delete k[G];delete V[O]}}delete n[N.id]}function E(N){for(const L in n){const U=n[L];for(const V in U){const O=U[V];if(O[N.id]===void 0)continue;const k=O[N.id];for(const G in k)h(k[G].object),delete k[G];delete O[N.id]}}}function M(N){for(const L in n){const U=n[L],V=N.isInstancedMesh===!0?N.id:0,O=U[V];if(O!==void 0){for(const k in O){const G=O[k];for(const it in G)h(G[it].object),delete G[it];delete O[k]}delete U[V],Object.keys(U).length===0&&delete n[L]}}}function b(){P(),o=!0,s!==i&&(s=i,c(s.object))}function P(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:b,resetDefaultState:P,dispose:w,releaseStatesOfGeometry:T,releaseStatesOfObject:M,releaseStatesOfProgram:E,initAttributes:x,enableAttribute:g,disableUnusedAttributes:y}}function iE(r,t,e){let n;function i(c){n=c}function s(c,h){r.drawArrays(n,c,h),e.update(h,n,1)}function o(c,h,u){u!==0&&(r.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function a(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let f=0;for(let p=0;p<u;p++)f+=h[p];e.update(f,n,1)}function l(c,h,u,d){if(u===0)return;const f=t.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<c.length;p++)o(c[p],h[p],d[p]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let p=0;for(let x=0;x<u;x++)p+=h[x]*d[x];e.update(p,n,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function sE(r,t,e,n){let i;function s(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){const E=t.get("EXT_texture_filter_anisotropic");i=r.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(E){return!(E!==wn&&n.convert(E)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(E){const M=E===Ui&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(E!==Un&&n.convert(E)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==Tn&&!M)}function l(E){if(E==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(pt("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control"),f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=r.getParameter(r.MAX_TEXTURE_SIZE),g=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),m=r.getParameter(r.MAX_VERTEX_ATTRIBS),y=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),v=r.getParameter(r.MAX_VARYING_VECTORS),_=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),w=r.getParameter(r.MAX_SAMPLES),T=r.getParameter(r.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:x,maxCubemapSize:g,maxAttributes:m,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:_,maxSamples:w,samples:T}}function rE(r){const t=this;let e=null,n=0,i=!1,s=!1;const o=new Ts,a=new ae,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,x=u.clipIntersection,g=u.clipShadows,m=r.get(u);if(!i||p===null||p.length===0||s&&!g)s?h(null):c();else{const y=s?0:n,v=y*4;let _=m.clippingState||null;l.value=_,_=h(p,d,v,f);for(let w=0;w!==v;++w)_[w]=e[w];m.clippingState=_,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,p){const x=u!==null?u.length:0;let g=null;if(x!==0){if(g=l.value,p!==!0||g===null){const m=f+x*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(g===null||g.length<m)&&(g=new Float32Array(m));for(let v=0,_=f;v!==x;++v,_+=4)o.copy(u[v]).applyMatrix4(y,a),o.normal.toArray(g,_),g[_+3]=o.constant}l.value=g,l.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,g}}const er=4,K0=[.125,.215,.35,.446,.526,.582],Ur=20,oE=256,Ya=new Ea,Q0=new wt;let Lf=null,Ff=0,Df=0,Uf=!1;const aE=new R;class Du{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,s={}){const{size:o=256,position:a=aE}=s;Lf=this._renderer.getRenderTarget(),Ff=this._renderer.getActiveCubeFace(),Df=this._renderer.getActiveMipmapLevel(),Uf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(t,n,i,l,a),e>0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ix(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=nx(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Lf,Ff,Df),this._renderer.xr.enabled=Uf,t.scissorTest=!1,Po(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ss||t.mapping===or?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Lf=this._renderer.getRenderTarget(),Ff=this._renderer.getActiveCubeFace(),Df=this._renderer.getActiveMipmapLevel(),Uf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Fe,minFilter:Fe,generateMipmaps:!1,type:Ui,format:wn,colorSpace:lr,depthBuffer:!1},i=ex(t,e,n),{_lodMax:s}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=tx(s),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=ex(t,e,n);const{_lodMax:o}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=tx(o)),this._blurMaterial=cE(o,t,e),this._ggxMaterial=lE(o,t,e)}return i}_compileMaterial(t){const e=new Ye(new se,t);this._renderer.compile(e,Ya)}_sceneToCubeUV(t,e,n,i,s){const l=new cn(90,1,e,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Q0),u.toneMapping=di,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ye(new dr,new Ds({name:"PMREM.Background",side:An,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,g=x.material;let m=!1;const y=t.background;y?y.isColor&&(g.color.copy(y),t.background=null,m=!0):(g.color.copy(Q0),m=!0);for(let v=0;v<6;v++){const _=v%3;_===0?(l.up.set(0,c[v],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[v],s.y,s.z)):_===1?(l.up.set(0,0,c[v]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[v],s.z)):(l.up.set(0,c[v],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[v]));const w=this._cubeSize;Po(i,_*w,v>2?w:0,w,w),u.setRenderTarget(i),m&&u.render(x,l),u.render(t,l)}u.toneMapping=f,u.autoClear=d,t.background=y}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===ss||t.mapping===or;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=ix()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=nx());const s=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;const a=s.uniforms;a.envMap.value=t;const l=this._cubeSize;Po(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Ya)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,s=this._pingPongRenderTarget,o=this._ggxMaterial,a=this._lodMeshes[n];a.material=o;const l=o.uniforms,c=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(c*c-h*h),d=0+c*1.25,f=u*d,{_lodMax:p}=this,x=this._sizeLods[n],g=3*x*(n>p-er?n-p+er:0),m=4*(this._cubeSize-x);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=p-e,Po(s,g,m,3*x,2*x),i.setRenderTarget(s),i.render(a,Ya),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=p-n,Po(t,g,m,3*x,2*x),i.setRenderTarget(t),i.render(a,Ya)}_blur(t,e,n,i,s){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,i,"latitudinal",s),this._halfBlur(o,t,n,n,i,"longitudinal",s)}_halfBlur(t,e,n,i,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Vt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[i];u.material=c;const d=c.uniforms,f=this._sizeLods[n]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Ur-1),x=s/p,g=isFinite(s)?1+Math.floor(h*x):Ur;g>Ur&&pt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Ur}`);const m=[];let y=0;for(let E=0;E<Ur;++E){const M=E/x,b=Math.exp(-M*M/2);m.push(b),E===0?y+=b:E<g&&(y+=2*b)}for(let E=0;E<m.length;E++)m[E]=m[E]/y;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=m,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:v}=this;d.dTheta.value=p,d.mipInt.value=v-n;const _=this._sizeLods[i],w=3*_*(i>v-er?i-v+er:0),T=4*(this._cubeSize-_);Po(e,w,T,3*_,2*_),l.setRenderTarget(e),l.render(u,Ya)}}function tx(r){const t=[],e=[],n=[];let i=r;const s=r-er+1+K0.length;for(let o=0;o<s;o++){const a=Math.pow(2,i);t.push(a);let l=1/a;o>r-er?l=K0[o-r+er-1]:o===0&&(l=0),e.push(l);const c=1/(a-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,x=3,g=2,m=1,y=new Float32Array(x*p*f),v=new Float32Array(g*p*f),_=new Float32Array(m*p*f);for(let T=0;T<f;T++){const E=T%3*2/3-1,M=T>2?0:-1,b=[E,M,0,E+2/3,M,0,E+2/3,M+1,0,E,M,0,E+2/3,M+1,0,E,M+1,0];y.set(b,x*p*T),v.set(d,g*p*T);const P=[T,T,T,T,T,T];_.set(P,m*p*T)}const w=new se;w.setAttribute("position",new Te(y,x)),w.setAttribute("uv",new Te(v,g)),w.setAttribute("faceIndex",new Te(_,m)),n.push(new Ye(w,null)),i>er&&i--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function ex(r,t,e){const n=new qn(r,t,e);return n.texture.mapping=to,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Po(r,t,e,n,i){r.viewport.set(t,e,n,i),r.scissor.set(t,e,n,i)}function lE(r,t,e){return new si({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:oE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Id(),fragmentShader:`
|
|
3620
|
+
}`,oe={alphahash_fragment:M1,alphahash_pars_fragment:S1,alphamap_fragment:b1,alphamap_pars_fragment:T1,alphatest_fragment:w1,alphatest_pars_fragment:A1,aomap_fragment:E1,aomap_pars_fragment:C1,batching_pars_vertex:N1,batching_vertex:R1,begin_vertex:I1,beginnormal_vertex:P1,bsdfs:L1,iridescence_fragment:F1,bumpmap_pars_fragment:D1,clipping_planes_fragment:U1,clipping_planes_pars_fragment:O1,clipping_planes_pars_vertex:B1,clipping_planes_vertex:z1,color_fragment:V1,color_pars_fragment:k1,color_pars_vertex:G1,color_vertex:H1,common:W1,cube_uv_reflection_fragment:X1,defaultnormal_vertex:$1,displacementmap_pars_vertex:q1,displacementmap_vertex:Y1,emissivemap_fragment:Z1,emissivemap_pars_fragment:J1,colorspace_fragment:j1,colorspace_pars_fragment:K1,envmap_fragment:Q1,envmap_common_pars_fragment:tw,envmap_pars_fragment:ew,envmap_pars_vertex:nw,envmap_physical_pars_fragment:fw,envmap_vertex:iw,fog_vertex:sw,fog_pars_vertex:rw,fog_fragment:ow,fog_pars_fragment:aw,gradientmap_pars_fragment:lw,lightmap_pars_fragment:cw,lights_lambert_fragment:hw,lights_lambert_pars_fragment:uw,lights_pars_begin:dw,lights_toon_fragment:pw,lights_toon_pars_fragment:mw,lights_phong_fragment:gw,lights_phong_pars_fragment:xw,lights_physical_fragment:yw,lights_physical_pars_fragment:_w,lights_fragment_begin:vw,lights_fragment_maps:Mw,lights_fragment_end:Sw,logdepthbuf_fragment:bw,logdepthbuf_pars_fragment:Tw,logdepthbuf_pars_vertex:ww,logdepthbuf_vertex:Aw,map_fragment:Ew,map_pars_fragment:Cw,map_particle_fragment:Nw,map_particle_pars_fragment:Rw,metalnessmap_fragment:Iw,metalnessmap_pars_fragment:Pw,morphinstance_vertex:Lw,morphcolor_vertex:Fw,morphnormal_vertex:Dw,morphtarget_pars_vertex:Uw,morphtarget_vertex:Ow,normal_fragment_begin:Bw,normal_fragment_maps:zw,normal_pars_fragment:Vw,normal_pars_vertex:kw,normal_vertex:Gw,normalmap_pars_fragment:Hw,clearcoat_normal_fragment_begin:Ww,clearcoat_normal_fragment_maps:Xw,clearcoat_pars_fragment:$w,iridescence_pars_fragment:qw,opaque_fragment:Yw,packing:Zw,premultiplied_alpha_fragment:Jw,project_vertex:jw,dithering_fragment:Kw,dithering_pars_fragment:Qw,roughnessmap_fragment:tA,roughnessmap_pars_fragment:eA,shadowmap_pars_fragment:nA,shadowmap_pars_vertex:iA,shadowmap_vertex:sA,shadowmask_pars_fragment:rA,skinbase_vertex:oA,skinning_pars_vertex:aA,skinning_vertex:lA,skinnormal_vertex:cA,specularmap_fragment:hA,specularmap_pars_fragment:uA,tonemapping_fragment:dA,tonemapping_pars_fragment:fA,transmission_fragment:pA,transmission_pars_fragment:mA,uv_pars_fragment:gA,uv_pars_vertex:xA,uv_vertex:yA,worldpos_vertex:_A,background_vert:vA,background_frag:MA,backgroundCube_vert:SA,backgroundCube_frag:bA,cube_vert:TA,cube_frag:wA,depth_vert:AA,depth_frag:EA,distance_vert:CA,distance_frag:NA,equirect_vert:RA,equirect_frag:IA,linedashed_vert:PA,linedashed_frag:LA,meshbasic_vert:FA,meshbasic_frag:DA,meshlambert_vert:UA,meshlambert_frag:OA,meshmatcap_vert:BA,meshmatcap_frag:zA,meshnormal_vert:VA,meshnormal_frag:kA,meshphong_vert:GA,meshphong_frag:HA,meshphysical_vert:WA,meshphysical_frag:XA,meshtoon_vert:$A,meshtoon_frag:qA,points_vert:YA,points_frag:ZA,shadow_vert:JA,shadow_frag:jA,sprite_vert:KA,sprite_frag:QA},gt={common:{diffuse:{value:new wt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ae},alphaMap:{value:null},alphaMapTransform:{value:new ae},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ae}},envmap:{envMap:{value:null},envMapRotation:{value:new ae},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ae}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ae}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ae},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ae},normalScale:{value:new tt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ae},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ae}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ae}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ae}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new wt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},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 wt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ae},alphaTest:{value:0},uvTransform:{value:new ae}},sprite:{diffuse:{value:new wt(16777215)},opacity:{value:1},center:{value:new tt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ae},alphaMap:{value:null},alphaMapTransform:{value:new ae},alphaTest:{value:0}}},ci={basic:{uniforms:Ln([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.fog]),vertexShader:oe.meshbasic_vert,fragmentShader:oe.meshbasic_frag},lambert:{uniforms:Ln([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new wt(0)},envMapIntensity:{value:1}}]),vertexShader:oe.meshlambert_vert,fragmentShader:oe.meshlambert_frag},phong:{uniforms:Ln([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new wt(0)},specular:{value:new wt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:oe.meshphong_vert,fragmentShader:oe.meshphong_frag},standard:{uniforms:Ln([gt.common,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.roughnessmap,gt.metalnessmap,gt.fog,gt.lights,{emissive:{value:new wt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:oe.meshphysical_vert,fragmentShader:oe.meshphysical_frag},toon:{uniforms:Ln([gt.common,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.gradientmap,gt.fog,gt.lights,{emissive:{value:new wt(0)}}]),vertexShader:oe.meshtoon_vert,fragmentShader:oe.meshtoon_frag},matcap:{uniforms:Ln([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,{matcap:{value:null}}]),vertexShader:oe.meshmatcap_vert,fragmentShader:oe.meshmatcap_frag},points:{uniforms:Ln([gt.points,gt.fog]),vertexShader:oe.points_vert,fragmentShader:oe.points_frag},dashed:{uniforms:Ln([gt.common,gt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:oe.linedashed_vert,fragmentShader:oe.linedashed_frag},depth:{uniforms:Ln([gt.common,gt.displacementmap]),vertexShader:oe.depth_vert,fragmentShader:oe.depth_frag},normal:{uniforms:Ln([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,{opacity:{value:1}}]),vertexShader:oe.meshnormal_vert,fragmentShader:oe.meshnormal_frag},sprite:{uniforms:Ln([gt.sprite,gt.fog]),vertexShader:oe.sprite_vert,fragmentShader:oe.sprite_frag},background:{uniforms:{uvTransform:{value:new ae},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:oe.background_vert,fragmentShader:oe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ae}},vertexShader:oe.backgroundCube_vert,fragmentShader:oe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:oe.cube_vert,fragmentShader:oe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:oe.equirect_vert,fragmentShader:oe.equirect_frag},distance:{uniforms:Ln([gt.common,gt.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:oe.distance_vert,fragmentShader:oe.distance_frag},shadow:{uniforms:Ln([gt.lights,gt.fog,{color:{value:new wt(0)},opacity:{value:1}}]),vertexShader:oe.shadow_vert,fragmentShader:oe.shadow_frag}};ci.physical={uniforms:Ln([ci.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ae},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ae},clearcoatNormalScale:{value:new tt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ae},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ae},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ae},sheen:{value:0},sheenColor:{value:new wt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ae},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ae},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ae},transmissionSamplerSize:{value:new tt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ae},attenuationDistance:{value:0},attenuationColor:{value:new wt(0)},specularColor:{value:new wt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ae},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ae},anisotropyVector:{value:new tt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ae}}]),vertexShader:oe.meshphysical_vert,fragmentShader:oe.meshphysical_frag};const wh={r:0,b:0,g:0},Nr=new mi,tE=new Qt;function eE(r,t,e,n,i,s){const o=new wt(0);let a=i===!0?0:1,l,c,h=null,u=0,d=null;function f(y){let v=y.isScene===!0?y.background:null;if(v&&v.isTexture){const _=y.backgroundBlurriness>0;v=t.get(v,_)}return v}function p(y){let v=!1;const _=f(y);_===null?g(o,a):_&&_.isColor&&(g(_,1),v=!0);const w=r.xr.getEnvironmentBlendMode();w==="additive"?e.buffers.color.setClear(0,0,0,1,s):w==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(r.autoClear||v)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function x(y,v){const _=f(v);_&&(_.isCubeTexture||_.mapping===to)?(c===void 0&&(c=new Ye(new dr(1,1,1),new si({name:"BackgroundCubeMaterial",uniforms:pa(ci.backgroundCube.uniforms),vertexShader:ci.backgroundCube.vertexShader,fragmentShader:ci.backgroundCube.fragmentShader,side:An,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(w,T,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),Nr.copy(v.backgroundRotation),Nr.x*=-1,Nr.y*=-1,Nr.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Nr.y*=-1,Nr.z*=-1),c.material.uniforms.envMap.value=_,c.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(tE.makeRotationFromEuler(Nr)),c.material.toneMapped=fe.getTransfer(_.colorSpace)!==_e,(h!==_||u!==_.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,h=_,u=_.version,d=r.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new Ye(new io(2,2),new si({name:"BackgroundMaterial",uniforms:pa(ci.background.uniforms),vertexShader:ci.background.vertexShader,fragmentShader:ci.background.fragmentShader,side:is,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=fe.getTransfer(_.colorSpace)!==_e,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||u!==_.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,h=_,u=_.version,d=r.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function g(y,v){y.getRGB(wh,Q_(r)),e.buffers.color.setClear(wh.r,wh.g,wh.b,v,s)}function m(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,v=1){o.set(y),a=v,g(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,g(o,a)},render:p,addToRenderList:x,dispose:m}}function nE(r,t){const e=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=d(null);let s=i,o=!1;function a(N,L,U,V,O){let k=!1;const G=u(N,V,U,L);s!==G&&(s=G,c(s.object)),k=f(N,V,U,O),k&&p(N,V,U,O),O!==null&&t.update(O,r.ELEMENT_ARRAY_BUFFER),(k||o)&&(o=!1,_(N,L,U,V),O!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(O).buffer))}function l(){return r.createVertexArray()}function c(N){return r.bindVertexArray(N)}function h(N){return r.deleteVertexArray(N)}function u(N,L,U,V){const O=V.wireframe===!0;let k=n[L.id];k===void 0&&(k={},n[L.id]=k);const G=N.isInstancedMesh===!0?N.id:0;let it=k[G];it===void 0&&(it={},k[G]=it);let nt=it[U.id];nt===void 0&&(nt={},it[U.id]=nt);let mt=nt[O];return mt===void 0&&(mt=d(l()),nt[O]=mt),mt}function d(N){const L=[],U=[],V=[];for(let O=0;O<e;O++)L[O]=0,U[O]=0,V[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:U,attributeDivisors:V,object:N,attributes:{},index:null}}function f(N,L,U,V){const O=s.attributes,k=L.attributes;let G=0;const it=U.getAttributes();for(const nt in it)if(it[nt].location>=0){const xt=O[nt];let bt=k[nt];if(bt===void 0&&(nt==="instanceMatrix"&&N.instanceMatrix&&(bt=N.instanceMatrix),nt==="instanceColor"&&N.instanceColor&&(bt=N.instanceColor)),xt===void 0||xt.attribute!==bt||bt&&xt.data!==bt.data)return!0;G++}return s.attributesNum!==G||s.index!==V}function p(N,L,U,V){const O={},k=L.attributes;let G=0;const it=U.getAttributes();for(const nt in it)if(it[nt].location>=0){let xt=k[nt];xt===void 0&&(nt==="instanceMatrix"&&N.instanceMatrix&&(xt=N.instanceMatrix),nt==="instanceColor"&&N.instanceColor&&(xt=N.instanceColor));const bt={};bt.attribute=xt,xt&&xt.data&&(bt.data=xt.data),O[nt]=bt,G++}s.attributes=O,s.attributesNum=G,s.index=V}function x(){const N=s.newAttributes;for(let L=0,U=N.length;L<U;L++)N[L]=0}function g(N){m(N,0)}function m(N,L){const U=s.newAttributes,V=s.enabledAttributes,O=s.attributeDivisors;U[N]=1,V[N]===0&&(r.enableVertexAttribArray(N),V[N]=1),O[N]!==L&&(r.vertexAttribDivisor(N,L),O[N]=L)}function y(){const N=s.newAttributes,L=s.enabledAttributes;for(let U=0,V=L.length;U<V;U++)L[U]!==N[U]&&(r.disableVertexAttribArray(U),L[U]=0)}function v(N,L,U,V,O,k,G){G===!0?r.vertexAttribIPointer(N,L,U,O,k):r.vertexAttribPointer(N,L,U,V,O,k)}function _(N,L,U,V){x();const O=V.attributes,k=U.getAttributes(),G=L.defaultAttributeValues;for(const it in k){const nt=k[it];if(nt.location>=0){let mt=O[it];if(mt===void 0&&(it==="instanceMatrix"&&N.instanceMatrix&&(mt=N.instanceMatrix),it==="instanceColor"&&N.instanceColor&&(mt=N.instanceColor)),mt!==void 0){const xt=mt.normalized,bt=mt.itemSize,jt=t.get(mt);if(jt===void 0)continue;const Me=jt.buffer,we=jt.type,j=jt.bytesPerElement,ct=we===r.INT||we===r.UNSIGNED_INT||mt.gpuType===ju;if(mt.isInterleavedBufferAttribute){const ht=mt.data,qt=ht.stride,Xt=mt.offset;if(ht.isInstancedInterleavedBuffer){for(let Kt=0;Kt<nt.locationSize;Kt++)m(nt.location+Kt,ht.meshPerAttribute);N.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ht.meshPerAttribute*ht.count)}else for(let Kt=0;Kt<nt.locationSize;Kt++)g(nt.location+Kt);r.bindBuffer(r.ARRAY_BUFFER,Me);for(let Kt=0;Kt<nt.locationSize;Kt++)v(nt.location+Kt,bt/nt.locationSize,we,xt,qt*j,(Xt+bt/nt.locationSize*Kt)*j,ct)}else{if(mt.isInstancedBufferAttribute){for(let ht=0;ht<nt.locationSize;ht++)m(nt.location+ht,mt.meshPerAttribute);N.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=mt.meshPerAttribute*mt.count)}else for(let ht=0;ht<nt.locationSize;ht++)g(nt.location+ht);r.bindBuffer(r.ARRAY_BUFFER,Me);for(let ht=0;ht<nt.locationSize;ht++)v(nt.location+ht,bt/nt.locationSize,we,xt,bt*j,bt/nt.locationSize*ht*j,ct)}}else if(G!==void 0){const xt=G[it];if(xt!==void 0)switch(xt.length){case 2:r.vertexAttrib2fv(nt.location,xt);break;case 3:r.vertexAttrib3fv(nt.location,xt);break;case 4:r.vertexAttrib4fv(nt.location,xt);break;default:r.vertexAttrib1fv(nt.location,xt)}}}}y()}function w(){b();for(const N in n){const L=n[N];for(const U in L){const V=L[U];for(const O in V){const k=V[O];for(const G in k)h(k[G].object),delete k[G];delete V[O]}}delete n[N]}}function T(N){if(n[N.id]===void 0)return;const L=n[N.id];for(const U in L){const V=L[U];for(const O in V){const k=V[O];for(const G in k)h(k[G].object),delete k[G];delete V[O]}}delete n[N.id]}function E(N){for(const L in n){const U=n[L];for(const V in U){const O=U[V];if(O[N.id]===void 0)continue;const k=O[N.id];for(const G in k)h(k[G].object),delete k[G];delete O[N.id]}}}function M(N){for(const L in n){const U=n[L],V=N.isInstancedMesh===!0?N.id:0,O=U[V];if(O!==void 0){for(const k in O){const G=O[k];for(const it in G)h(G[it].object),delete G[it];delete O[k]}delete U[V],Object.keys(U).length===0&&delete n[L]}}}function b(){P(),o=!0,s!==i&&(s=i,c(s.object))}function P(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:b,resetDefaultState:P,dispose:w,releaseStatesOfGeometry:T,releaseStatesOfObject:M,releaseStatesOfProgram:E,initAttributes:x,enableAttribute:g,disableUnusedAttributes:y}}function iE(r,t,e){let n;function i(c){n=c}function s(c,h){r.drawArrays(n,c,h),e.update(h,n,1)}function o(c,h,u){u!==0&&(r.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function a(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let f=0;for(let p=0;p<u;p++)f+=h[p];e.update(f,n,1)}function l(c,h,u,d){if(u===0)return;const f=t.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<c.length;p++)o(c[p],h[p],d[p]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let p=0;for(let x=0;x<u;x++)p+=h[x]*d[x];e.update(p,n,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function sE(r,t,e,n){let i;function s(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){const E=t.get("EXT_texture_filter_anisotropic");i=r.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(E){return!(E!==wn&&n.convert(E)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(E){const M=E===Ui&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(E!==Un&&n.convert(E)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==Tn&&!M)}function l(E){if(E==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(pt("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control"),f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=r.getParameter(r.MAX_TEXTURE_SIZE),g=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),m=r.getParameter(r.MAX_VERTEX_ATTRIBS),y=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),v=r.getParameter(r.MAX_VARYING_VECTORS),_=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),w=r.getParameter(r.MAX_SAMPLES),T=r.getParameter(r.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:x,maxCubemapSize:g,maxAttributes:m,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:_,maxSamples:w,samples:T}}function rE(r){const t=this;let e=null,n=0,i=!1,s=!1;const o=new Ts,a=new ae,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,x=u.clipIntersection,g=u.clipShadows,m=r.get(u);if(!i||p===null||p.length===0||s&&!g)s?h(null):c();else{const y=s?0:n,v=y*4;let _=m.clippingState||null;l.value=_,_=h(p,d,v,f);for(let w=0;w!==v;++w)_[w]=e[w];m.clippingState=_,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,p){const x=u!==null?u.length:0;let g=null;if(x!==0){if(g=l.value,p!==!0||g===null){const m=f+x*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(g===null||g.length<m)&&(g=new Float32Array(m));for(let v=0,_=f;v!==x;++v,_+=4)o.copy(u[v]).applyMatrix4(y,a),o.normal.toArray(g,_),g[_+3]=o.constant}l.value=g,l.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,g}}const er=4,j0=[.125,.215,.35,.446,.526,.582],Ur=20,oE=256,Za=new Ca,K0=new wt;let Lf=null,Ff=0,Df=0,Uf=!1;const aE=new R;class Du{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,s={}){const{size:o=256,position:a=aE}=s;Lf=this._renderer.getRenderTarget(),Ff=this._renderer.getActiveCubeFace(),Df=this._renderer.getActiveMipmapLevel(),Uf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(t,n,i,l,a),e>0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=nx(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ex(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Lf,Ff,Df),this._renderer.xr.enabled=Uf,t.scissorTest=!1,Po(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ss||t.mapping===or?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Lf=this._renderer.getRenderTarget(),Ff=this._renderer.getActiveCubeFace(),Df=this._renderer.getActiveMipmapLevel(),Uf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Fe,minFilter:Fe,generateMipmaps:!1,type:Ui,format:wn,colorSpace:lr,depthBuffer:!1},i=tx(t,e,n),{_lodMax:s}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Q0(s),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=tx(t,e,n);const{_lodMax:o}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Q0(o)),this._blurMaterial=cE(o,t,e),this._ggxMaterial=lE(o,t,e)}return i}_compileMaterial(t){const e=new Ye(new se,t);this._renderer.compile(e,Za)}_sceneToCubeUV(t,e,n,i,s){const l=new cn(90,1,e,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(K0),u.toneMapping=di,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ye(new dr,new Ds({name:"PMREM.Background",side:An,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,g=x.material;let m=!1;const y=t.background;y?y.isColor&&(g.color.copy(y),t.background=null,m=!0):(g.color.copy(K0),m=!0);for(let v=0;v<6;v++){const _=v%3;_===0?(l.up.set(0,c[v],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[v],s.y,s.z)):_===1?(l.up.set(0,0,c[v]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[v],s.z)):(l.up.set(0,c[v],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[v]));const w=this._cubeSize;Po(i,_*w,v>2?w:0,w,w),u.setRenderTarget(i),m&&u.render(x,l),u.render(t,l)}u.toneMapping=f,u.autoClear=d,t.background=y}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===ss||t.mapping===or;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=nx()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ex());const s=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;const a=s.uniforms;a.envMap.value=t;const l=this._cubeSize;Po(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Za)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,s=this._pingPongRenderTarget,o=this._ggxMaterial,a=this._lodMeshes[n];a.material=o;const l=o.uniforms,c=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(c*c-h*h),d=0+c*1.25,f=u*d,{_lodMax:p}=this,x=this._sizeLods[n],g=3*x*(n>p-er?n-p+er:0),m=4*(this._cubeSize-x);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=p-e,Po(s,g,m,3*x,2*x),i.setRenderTarget(s),i.render(a,Za),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=p-n,Po(t,g,m,3*x,2*x),i.setRenderTarget(t),i.render(a,Za)}_blur(t,e,n,i,s){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,i,"latitudinal",s),this._halfBlur(o,t,n,n,i,"longitudinal",s)}_halfBlur(t,e,n,i,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Vt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[i];u.material=c;const d=c.uniforms,f=this._sizeLods[n]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Ur-1),x=s/p,g=isFinite(s)?1+Math.floor(h*x):Ur;g>Ur&&pt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Ur}`);const m=[];let y=0;for(let E=0;E<Ur;++E){const M=E/x,b=Math.exp(-M*M/2);m.push(b),E===0?y+=b:E<g&&(y+=2*b)}for(let E=0;E<m.length;E++)m[E]=m[E]/y;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=m,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:v}=this;d.dTheta.value=p,d.mipInt.value=v-n;const _=this._sizeLods[i],w=3*_*(i>v-er?i-v+er:0),T=4*(this._cubeSize-_);Po(e,w,T,3*_,2*_),l.setRenderTarget(e),l.render(u,Za)}}function Q0(r){const t=[],e=[],n=[];let i=r;const s=r-er+1+j0.length;for(let o=0;o<s;o++){const a=Math.pow(2,i);t.push(a);let l=1/a;o>r-er?l=j0[o-r+er-1]:o===0&&(l=0),e.push(l);const c=1/(a-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,x=3,g=2,m=1,y=new Float32Array(x*p*f),v=new Float32Array(g*p*f),_=new Float32Array(m*p*f);for(let T=0;T<f;T++){const E=T%3*2/3-1,M=T>2?0:-1,b=[E,M,0,E+2/3,M,0,E+2/3,M+1,0,E,M,0,E+2/3,M+1,0,E,M+1,0];y.set(b,x*p*T),v.set(d,g*p*T);const P=[T,T,T,T,T,T];_.set(P,m*p*T)}const w=new se;w.setAttribute("position",new Te(y,x)),w.setAttribute("uv",new Te(v,g)),w.setAttribute("faceIndex",new Te(_,m)),n.push(new Ye(w,null)),i>er&&i--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function tx(r,t,e){const n=new qn(r,t,e);return n.texture.mapping=to,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Po(r,t,e,n,i){r.viewport.set(t,e,n,i),r.scissor.set(t,e,n,i)}function lE(r,t,e){return new si({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:oE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Id(),fragmentShader:`
|
|
3621
3621
|
|
|
3622
3622
|
precision highp float;
|
|
3623
3623
|
precision highp int;
|
|
@@ -3781,7 +3781,7 @@ void main() {
|
|
|
3781
3781
|
}
|
|
3782
3782
|
|
|
3783
3783
|
}
|
|
3784
|
-
`,blending:Di,depthTest:!1,depthWrite:!1})}function
|
|
3784
|
+
`,blending:Di,depthTest:!1,depthWrite:!1})}function ex(){return new si({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Id(),fragmentShader:`
|
|
3785
3785
|
|
|
3786
3786
|
precision mediump float;
|
|
3787
3787
|
precision mediump int;
|
|
@@ -3800,7 +3800,7 @@ void main() {
|
|
|
3800
3800
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3801
3801
|
|
|
3802
3802
|
}
|
|
3803
|
-
`,blending:Di,depthTest:!1,depthWrite:!1})}function
|
|
3803
|
+
`,blending:Di,depthTest:!1,depthWrite:!1})}function nx(){return new si({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Id(),fragmentShader:`
|
|
3804
3804
|
|
|
3805
3805
|
precision mediump float;
|
|
3806
3806
|
precision mediump int;
|
|
@@ -3871,7 +3871,7 @@ void main() {
|
|
|
3871
3871
|
gl_Position = vec4( position, 1.0 );
|
|
3872
3872
|
|
|
3873
3873
|
}
|
|
3874
|
-
`}class Pd extends qn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new
|
|
3874
|
+
`}class Pd extends qn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new ba(i),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
3875
3875
|
|
|
3876
3876
|
varying vec3 vWorldDirection;
|
|
3877
3877
|
|
|
@@ -3906,7 +3906,7 @@ void main() {
|
|
|
3906
3906
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3907
3907
|
|
|
3908
3908
|
}
|
|
3909
|
-
`},i=new dr(5,5,5),s=new si({name:"CubemapFromEquirect",uniforms:
|
|
3909
|
+
`},i=new dr(5,5,5),s=new si({name:"CubemapFromEquirect",uniforms:pa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:An,blending:Di});s.uniforms.tEquirect.value=e;const o=new Ye(i,s),a=e.minFilter;return e.minFilter===Li&&(e.minFilter=Fe),new qm(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){const s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,i);t.setRenderTarget(s)}}function hE(r){let t=new WeakMap,e=new WeakMap,n=null;function i(d,f=!1){return d==null?null:f?o(d):s(d)}function s(d){if(d&&d.isTexture){const f=d.mapping;if(f===jo||f===Ko)if(t.has(d)){const p=t.get(d).texture;return a(p,d.mapping)}else{const p=d.image;if(p&&p.height>0){const x=new Pd(p.height);return x.fromEquirectangularTexture(r,d),t.set(d,x),d.addEventListener("dispose",c),a(x.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture){const f=d.mapping,p=f===jo||f===Ko,x=f===ss||f===or;if(p||x){let g=e.get(d);const m=g!==void 0?g.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==m)return n===null&&(n=new Du(r)),g=p?n.fromEquirectangular(d,g):n.fromCubemap(d,g),g.texture.pmremVersion=d.pmremVersion,e.set(d,g),g.texture;if(g!==void 0)return g.texture;{const y=d.image;return p&&y&&y.height>0||x&&y&&l(y)?(n===null&&(n=new Du(r)),g=p?n.fromEquirectangular(d):n.fromCubemap(d),g.texture.pmremVersion=d.pmremVersion,e.set(d,g),d.addEventListener("dispose",h),g.texture):null}}}return d}function a(d,f){return f===jo?d.mapping=ss:f===Ko&&(d.mapping=or),d}function l(d){let f=0;const p=6;for(let x=0;x<p;x++)d[x]!==void 0&&f++;return f===p}function c(d){const f=d.target;f.removeEventListener("dispose",c);const p=t.get(f);p!==void 0&&(t.delete(f),p.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const p=e.get(f);p!==void 0&&(e.delete(f),p.dispose())}function u(){t=new WeakMap,e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:u}}function uE(r){const t={};function e(n){if(t[n]!==void 0)return t[n];const i=r.getExtension(n);return t[n]=i,i}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const i=e(n);return i===null&&tc("WebGLRenderer: "+n+" extension not supported."),i}}}function dE(r,t,e,n){const i={},s=new WeakMap;function o(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const p in d.attributes)t.remove(d.attributes[p]);d.removeEventListener("dispose",o),delete i[d.id];const f=s.get(d);f&&(t.remove(f),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function a(u,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,e.memory.geometries++),d}function l(u){const d=u.attributes;for(const f in d)t.update(d[f],r.ARRAY_BUFFER)}function c(u){const d=[],f=u.index,p=u.attributes.position;let x=0;if(p===void 0)return;if(f!==null){const y=f.array;x=f.version;for(let v=0,_=y.length;v<_;v+=3){const w=y[v+0],T=y[v+1],E=y[v+2];d.push(w,T,T,E,E,w)}}else{const y=p.array;x=p.version;for(let v=0,_=y.length/3-1;v<_;v+=3){const w=v+0,T=v+1,E=v+2;d.push(w,T,T,E,E,w)}}const g=new(p.count>=65535?hm:ld)(d,1);g.version=x;const m=s.get(u);m&&t.remove(m),s.set(u,g)}function h(u){const d=s.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return s.get(u)}return{get:a,update:l,getWireframeAttribute:h}}function fE(r,t,e){let n;function i(d){n=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function l(d,f){r.drawElements(n,f,s,d*o),e.update(f,n,1)}function c(d,f,p){p!==0&&(r.drawElementsInstanced(n,f,s,d*o,p),e.update(f,n,p))}function h(d,f,p){if(p===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,s,d,0,p);let g=0;for(let m=0;m<p;m++)g+=f[m];e.update(g,n,1)}function u(d,f,p,x){if(p===0)return;const g=t.get("WEBGL_multi_draw");if(g===null)for(let m=0;m<d.length;m++)c(d[m]/o,f[m],x[m]);else{g.multiDrawElementsInstancedWEBGL(n,f,0,s,d,0,x,0,p);let m=0;for(let y=0;y<p;y++)m+=f[y]*x[y];e.update(m,n,1)}}this.setMode=i,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function pE(r){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(e.calls++,o){case r.TRIANGLES:e.triangles+=a*(s/3);break;case r.LINES:e.lines+=a*(s/2);break;case r.LINE_STRIP:e.lines+=a*(s-1);break;case r.LINE_LOOP:e.lines+=a*s;break;case r.POINTS:e.points+=a*s;break;default:Vt("WebGLInfo: Unknown draw mode:",o);break}}function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}function mE(r,t,e){const n=new WeakMap,i=new Le;function s(o,a,l){const c=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(a);if(d===void 0||d.count!==u){let b=function(){E.dispose(),n.delete(a),a.removeEventListener("dispose",b)};d!==void 0&&d.texture.dispose();const f=a.morphAttributes.position!==void 0,p=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,g=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],y=a.morphAttributes.color||[];let v=0;f===!0&&(v=1),p===!0&&(v=2),x===!0&&(v=3);let _=a.attributes.position.count*v,w=1;_>t.maxTextureSize&&(w=Math.ceil(_/t.maxTextureSize),_=t.maxTextureSize);const T=new Float32Array(_*w*4*u),E=new od(T,_,w,u);E.type=Tn,E.needsUpdate=!0;const M=v*4;for(let P=0;P<u;P++){const N=g[P],L=m[P],U=y[P],V=_*w*4*P;for(let O=0;O<N.count;O++){const k=O*M;f===!0&&(i.fromBufferAttribute(N,O),T[V+k+0]=i.x,T[V+k+1]=i.y,T[V+k+2]=i.z,T[V+k+3]=0),p===!0&&(i.fromBufferAttribute(L,O),T[V+k+4]=i.x,T[V+k+5]=i.y,T[V+k+6]=i.z,T[V+k+7]=0),x===!0&&(i.fromBufferAttribute(U,O),T[V+k+8]=i.x,T[V+k+9]=i.y,T[V+k+10]=i.z,T[V+k+11]=U.itemSize===4?i.w:1)}}d={count:u,texture:E,size:new tt(_,w)},n.set(a,d),a.addEventListener("dispose",b)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(r,"morphTexture",o.morphTexture,e);else{let f=0;for(let x=0;x<c.length;x++)f+=c[x];const p=a.morphTargetsRelative?1:1-f;l.getUniforms().setValue(r,"morphTargetBaseInfluence",p),l.getUniforms().setValue(r,"morphTargetInfluences",c)}l.getUniforms().setValue(r,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(r,"morphTargetsTextureSize",d.size)}return{update:s}}function gE(r,t,e,n,i){let s=new WeakMap;function o(c){const h=i.render.frame,u=c.geometry,d=t.get(c,u);if(s.get(d)!==h&&(t.update(d),s.set(d,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),s.get(c)!==h&&(e.update(c.instanceMatrix,r.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,r.ARRAY_BUFFER),s.set(c,h))),c.isSkinnedMesh){const f=c.skeleton;s.get(f)!==h&&(f.update(),s.set(f,h))}return d}function a(){s=new WeakMap}function l(c){const h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),e.remove(h.instanceMatrix),h.instanceColor!==null&&e.remove(h.instanceColor)}return{update:o,dispose:a}}const xE={[Wu]:"LINEAR_TONE_MAPPING",[Xu]:"REINHARD_TONE_MAPPING",[Jp]:"CINEON_TONE_MAPPING",[$u]:"ACES_FILMIC_TONE_MAPPING",[qu]:"AGX_TONE_MAPPING",[Yu]:"NEUTRAL_TONE_MAPPING",[jp]:"CUSTOM_TONE_MAPPING"};function yE(r,t,e,n,i){const s=new qn(t,e,{type:r,depthBuffer:n,stencilBuffer:i}),o=new qn(t,e,{type:Ui,depthBuffer:!1,stencilBuffer:!1}),a=new se;a.setAttribute("position",new Ct([-1,3,0,-1,-1,0,3,-1,0],3)),a.setAttribute("uv",new Ct([0,2,0,0,2,0],2));const l=new bd({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
3910
3910
|
precision highp float;
|
|
3911
3911
|
|
|
3912
3912
|
uniform mat4 modelViewMatrix;
|
|
@@ -3952,17 +3952,17 @@ void main() {
|
|
|
3952
3952
|
#ifdef SRGB_TRANSFER
|
|
3953
3953
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
3954
3954
|
#endif
|
|
3955
|
-
}`,depthTest:!1,depthWrite:!1}),c=new Ye(a,l),h=new
|
|
3955
|
+
}`,depthTest:!1,depthWrite:!1}),c=new Ye(a,l),h=new Ca(-1,1,1,-1,0,1);let u=null,d=null,f=!1,p,x=null,g=[],m=!1;this.setSize=function(y,v){s.setSize(y,v),o.setSize(y,v);for(let _=0;_<g.length;_++){const w=g[_];w.setSize&&w.setSize(y,v)}},this.setEffects=function(y){g=y,m=g.length>0&&g[0].isRenderPass===!0;const v=s.width,_=s.height;for(let w=0;w<g.length;w++){const T=g[w];T.setSize&&T.setSize(v,_)}},this.begin=function(y,v){if(f||y.toneMapping===di&&g.length===0)return!1;if(x=v,v!==null){const _=v.width,w=v.height;(s.width!==_||s.height!==w)&&this.setSize(_,w)}return m===!1&&y.setRenderTarget(s),p=y.toneMapping,y.toneMapping=di,!0},this.hasRenderPass=function(){return m},this.end=function(y,v){y.toneMapping=p,f=!0;let _=s,w=o;for(let T=0;T<g.length;T++){const E=g[T];if(E.enabled!==!1&&(E.render(y,w,_,v),E.needsSwap!==!1)){const M=_;_=w,w=M}}if(u!==y.outputColorSpace||d!==y.toneMapping){u=y.outputColorSpace,d=y.toneMapping,l.defines={},fe.getTransfer(u)===_e&&(l.defines.SRGB_TRANSFER="");const T=xE[d];T&&(l.defines[T]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=_.texture,y.setRenderTarget(x),y.render(c,h),x=null,f=!1},this.isCompositing=function(){return f},this.dispose=function(){s.dispose(),o.dispose(),a.dispose(),l.dispose()}}const Dv=new rn,Pp=new jr(1,1),Uv=new od,Ov=new mc,Bv=new ba,ix=[],sx=[],rx=new Float32Array(16),ox=new Float32Array(9),ax=new Float32Array(4);function Na(r,t,e){const n=r[0];if(n<=0||n>0)return r;const i=t*e;let s=ix[i];if(s===void 0&&(s=new Float32Array(i),ix[i]=s),t!==0){n.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,r[o].toArray(s,a)}return s}function nn(r,t){if(r.length!==t.length)return!1;for(let e=0,n=r.length;e<n;e++)if(r[e]!==t[e])return!1;return!0}function sn(r,t){for(let e=0,n=t.length;e<n;e++)r[e]=t[e]}function Ld(r,t){let e=sx[t];e===void 0&&(e=new Int32Array(t),sx[t]=e);for(let n=0;n!==t;++n)e[n]=r.allocateTextureUnit();return e}function _E(r,t){const e=this.cache;e[0]!==t&&(r.uniform1f(this.addr,t),e[0]=t)}function vE(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(r.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(nn(e,t))return;r.uniform2fv(this.addr,t),sn(e,t)}}function ME(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(r.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(r.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(nn(e,t))return;r.uniform3fv(this.addr,t),sn(e,t)}}function SE(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(r.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(nn(e,t))return;r.uniform4fv(this.addr,t),sn(e,t)}}function bE(r,t){const e=this.cache,n=t.elements;if(n===void 0){if(nn(e,t))return;r.uniformMatrix2fv(this.addr,!1,t),sn(e,t)}else{if(nn(e,n))return;ax.set(n),r.uniformMatrix2fv(this.addr,!1,ax),sn(e,n)}}function TE(r,t){const e=this.cache,n=t.elements;if(n===void 0){if(nn(e,t))return;r.uniformMatrix3fv(this.addr,!1,t),sn(e,t)}else{if(nn(e,n))return;ox.set(n),r.uniformMatrix3fv(this.addr,!1,ox),sn(e,n)}}function wE(r,t){const e=this.cache,n=t.elements;if(n===void 0){if(nn(e,t))return;r.uniformMatrix4fv(this.addr,!1,t),sn(e,t)}else{if(nn(e,n))return;rx.set(n),r.uniformMatrix4fv(this.addr,!1,rx),sn(e,n)}}function AE(r,t){const e=this.cache;e[0]!==t&&(r.uniform1i(this.addr,t),e[0]=t)}function EE(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(r.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(nn(e,t))return;r.uniform2iv(this.addr,t),sn(e,t)}}function CE(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(r.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(nn(e,t))return;r.uniform3iv(this.addr,t),sn(e,t)}}function NE(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(r.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(nn(e,t))return;r.uniform4iv(this.addr,t),sn(e,t)}}function RE(r,t){const e=this.cache;e[0]!==t&&(r.uniform1ui(this.addr,t),e[0]=t)}function IE(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(r.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(nn(e,t))return;r.uniform2uiv(this.addr,t),sn(e,t)}}function PE(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(r.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(nn(e,t))return;r.uniform3uiv(this.addr,t),sn(e,t)}}function LE(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(r.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(nn(e,t))return;r.uniform4uiv(this.addr,t),sn(e,t)}}function FE(r,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i);let s;this.type===r.SAMPLER_2D_SHADOW?(Pp.compareFunction=e.isReversedDepthBuffer()?rd:sd,s=Pp):s=Dv,e.setTexture2D(t||s,i)}function DE(r,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||Ov,i)}function UE(r,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||Bv,i)}function OE(r,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||Uv,i)}function BE(r){switch(r){case 5126:return _E;case 35664:return vE;case 35665:return ME;case 35666:return SE;case 35674:return bE;case 35675:return TE;case 35676:return wE;case 5124:case 35670:return AE;case 35667:case 35671:return EE;case 35668:case 35672:return CE;case 35669:case 35673:return NE;case 5125:return RE;case 36294:return IE;case 36295:return PE;case 36296:return LE;case 35678:case 36198:case 36298:case 36306:case 35682:return FE;case 35679:case 36299:case 36307:return DE;case 35680:case 36300:case 36308:case 36293:return UE;case 36289:case 36303:case 36311:case 36292:return OE}}function zE(r,t){r.uniform1fv(this.addr,t)}function VE(r,t){const e=Na(t,this.size,2);r.uniform2fv(this.addr,e)}function kE(r,t){const e=Na(t,this.size,3);r.uniform3fv(this.addr,e)}function GE(r,t){const e=Na(t,this.size,4);r.uniform4fv(this.addr,e)}function HE(r,t){const e=Na(t,this.size,4);r.uniformMatrix2fv(this.addr,!1,e)}function WE(r,t){const e=Na(t,this.size,9);r.uniformMatrix3fv(this.addr,!1,e)}function XE(r,t){const e=Na(t,this.size,16);r.uniformMatrix4fv(this.addr,!1,e)}function $E(r,t){r.uniform1iv(this.addr,t)}function qE(r,t){r.uniform2iv(this.addr,t)}function YE(r,t){r.uniform3iv(this.addr,t)}function ZE(r,t){r.uniform4iv(this.addr,t)}function JE(r,t){r.uniform1uiv(this.addr,t)}function jE(r,t){r.uniform2uiv(this.addr,t)}function KE(r,t){r.uniform3uiv(this.addr,t)}function QE(r,t){r.uniform4uiv(this.addr,t)}function tC(r,t,e){const n=this.cache,i=t.length,s=Ld(e,i);nn(n,s)||(r.uniform1iv(this.addr,s),sn(n,s));let o;this.type===r.SAMPLER_2D_SHADOW?o=Pp:o=Dv;for(let a=0;a!==i;++a)e.setTexture2D(t[a]||o,s[a])}function eC(r,t,e){const n=this.cache,i=t.length,s=Ld(e,i);nn(n,s)||(r.uniform1iv(this.addr,s),sn(n,s));for(let o=0;o!==i;++o)e.setTexture3D(t[o]||Ov,s[o])}function nC(r,t,e){const n=this.cache,i=t.length,s=Ld(e,i);nn(n,s)||(r.uniform1iv(this.addr,s),sn(n,s));for(let o=0;o!==i;++o)e.setTextureCube(t[o]||Bv,s[o])}function iC(r,t,e){const n=this.cache,i=t.length,s=Ld(e,i);nn(n,s)||(r.uniform1iv(this.addr,s),sn(n,s));for(let o=0;o!==i;++o)e.setTexture2DArray(t[o]||Uv,s[o])}function sC(r){switch(r){case 5126:return zE;case 35664:return VE;case 35665:return kE;case 35666:return GE;case 35674:return HE;case 35675:return WE;case 35676:return XE;case 5124:case 35670:return $E;case 35667:case 35671:return qE;case 35668:case 35672:return YE;case 35669:case 35673:return ZE;case 5125:return JE;case 36294:return jE;case 36295:return KE;case 36296:return QE;case 35678:case 36198:case 36298:case 36306:case 35682:return tC;case 35679:case 36299:case 36307:return eC;case 35680:case 36300:case 36308:case 36293:return nC;case 36289:case 36303:case 36311:case 36292:return iC}}class rC{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=BE(e.type)}}class oC{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=sC(e.type)}}class aC{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const a=i[s];a.setValue(t,e[a.id],n)}}}const Of=/(\w+)(\])?(\[|\.)?/g;function lx(r,t){r.seq.push(t),r.map[t.id]=t}function lC(r,t,e){const n=r.name,i=n.length;for(Of.lastIndex=0;;){const s=Of.exec(n),o=Of.lastIndex;let a=s[1];const l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){lx(e,c===void 0?new rC(a,r,t):new oC(a,r,t));break}else{let u=e.map[a];u===void 0&&(u=new aC(a),lx(e,u)),e=u}}}class lu{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){const a=t.getActiveUniform(e,o),l=t.getUniformLocation(e,a.name);lC(a,l,this)}const i=[],s=[];for(const o of this.seq)o.type===t.SAMPLER_2D_SHADOW||o.type===t.SAMPLER_CUBE_SHADOW||o.type===t.SAMPLER_2D_ARRAY_SHADOW?i.push(o):s.push(o);i.length>0&&(this.seq=i.concat(s))}setValue(t,e,n,i){const s=this.map[e];s!==void 0&&s.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let s=0,o=e.length;s!==o;++s){const a=e[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,s=t.length;i!==s;++i){const o=t[i];o.id in e&&n.push(o)}return n}}function cx(r,t,e){const n=r.createShader(t);return r.shaderSource(n,e),r.compileShader(n),n}const cC=37297;let hC=0;function uC(r,t){const e=r.split(`
|
|
3956
3956
|
`),n=[],i=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let o=i;o<s;o++){const a=o+1;n.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return n.join(`
|
|
3957
|
-
`)}const
|
|
3957
|
+
`)}const hx=new ae;function dC(r){fe._getMatrix(hx,fe.workingColorSpace,r);const t=`mat3( ${hx.elements.map(e=>e.toFixed(4))} )`;switch(fe.getTransfer(r)){case Jl:return[t,"LinearTransferOETF"];case _e:return[t,"sRGBTransferOETF"];default:return pt("WebGLProgram: Unsupported color space: ",r),[t,"LinearTransferOETF"]}}function ux(r,t,e){const n=r.getShaderParameter(t,r.COMPILE_STATUS),s=(r.getShaderInfoLog(t)||"").trim();if(n&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const a=parseInt(o[1]);return e.toUpperCase()+`
|
|
3958
3958
|
|
|
3959
3959
|
`+s+`
|
|
3960
3960
|
|
|
3961
3961
|
`+uC(r.getShaderSource(t),a)}else return s}function fC(r,t){const e=dC(t);return[`vec4 ${r}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
|
|
3962
|
-
`)}const pC={[Wu]:"Linear",[Xu]:"Reinhard",[
|
|
3963
|
-
`)}function xC(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(
|
|
3962
|
+
`)}const pC={[Wu]:"Linear",[Xu]:"Reinhard",[Jp]:"Cineon",[$u]:"ACESFilmic",[qu]:"AgX",[Yu]:"Neutral",[jp]:"Custom"};function mC(r,t){const e=pC[t];return e===void 0?(pt("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+r+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+r+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const Ah=new R;function gC(){fe.getLuminanceCoefficients(Ah);const r=Ah.x.toFixed(4),t=Ah.y.toFixed(4),e=Ah.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
|
|
3963
|
+
`)}function xC(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ll).join(`
|
|
3964
3964
|
`)}function yC(r){const t=[];for(const e in r){const n=r[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
|
|
3965
|
-
`)}function _C(r,t){const e={},n=r.getProgramParameter(t,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(t,i),o=s.name;let a=1;s.type===r.FLOAT_MAT2&&(a=2),s.type===r.FLOAT_MAT3&&(a=3),s.type===r.FLOAT_MAT4&&(a=4),e[o]={type:s.type,location:r.getAttribLocation(t,o),locationSize:a}}return e}function
|
|
3965
|
+
`)}function _C(r,t){const e={},n=r.getProgramParameter(t,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(t,i),o=s.name;let a=1;s.type===r.FLOAT_MAT2&&(a=2),s.type===r.FLOAT_MAT3&&(a=3),s.type===r.FLOAT_MAT4&&(a=4),e[o]={type:s.type,location:r.getAttribLocation(t,o),locationSize:a}}return e}function ll(r){return r!==""}function dx(r,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function fx(r,t){return r.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const vC=/^[ \t]*#include +<([\w\d./]+)>/gm;function Lp(r){return r.replace(vC,SC)}const MC=new Map;function SC(r,t){let e=oe[t];if(e===void 0){const n=MC.get(t);if(n!==void 0)e=oe[n],pt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Lp(e)}const bC=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function px(r){return r.replace(bC,TC)}function TC(r,t,e,n){let i="";for(let s=parseInt(t);s<parseInt(e);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function mx(r){let t=`precision ${r.precision} float;
|
|
3966
3966
|
precision ${r.precision} int;
|
|
3967
3967
|
precision ${r.precision} sampler2D;
|
|
3968
3968
|
precision ${r.precision} samplerCube;
|
|
@@ -3982,28 +3982,28 @@ void main() {
|
|
|
3982
3982
|
`;return r.precision==="highp"?t+=`
|
|
3983
3983
|
#define HIGH_PRECISION`:r.precision==="mediump"?t+=`
|
|
3984
3984
|
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(t+=`
|
|
3985
|
-
#define LOW_PRECISION`),t}const wC={[
|
|
3986
|
-
`:"";e.isRawShaderMaterial?(g=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p].filter(
|
|
3985
|
+
#define LOW_PRECISION`),t}const wC={[Jo]:"SHADOWMAP_TYPE_PCF",[Yo]:"SHADOWMAP_TYPE_VSM"};function AC(r){return wC[r.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const EC={[ss]:"ENVMAP_TYPE_CUBE",[or]:"ENVMAP_TYPE_CUBE",[to]:"ENVMAP_TYPE_CUBE_UV"};function CC(r){return r.envMap===!1?"ENVMAP_TYPE_CUBE":EC[r.envMapMode]||"ENVMAP_TYPE_CUBE"}const NC={[or]:"ENVMAP_MODE_REFRACTION"};function RC(r){return r.envMap===!1?"ENVMAP_MODE_REFLECTION":NC[r.envMapMode]||"ENVMAP_MODE_REFLECTION"}const IC={[uc]:"ENVMAP_BLENDING_MULTIPLY",[Yy]:"ENVMAP_BLENDING_MIX",[Zy]:"ENVMAP_BLENDING_ADD"};function PC(r){return r.envMap===!1?"ENVMAP_BLENDING_NONE":IC[r.combine]||"ENVMAP_BLENDING_NONE"}function LC(r){const t=r.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function FC(r,t,e,n){const i=r.getContext(),s=e.defines;let o=e.vertexShader,a=e.fragmentShader;const l=AC(e),c=CC(e),h=RC(e),u=PC(e),d=LC(e),f=xC(e),p=yC(s),x=i.createProgram();let g,m,y=e.glslVersion?"#version "+e.glslVersion+`
|
|
3986
|
+
`:"";e.isRawShaderMaterial?(g=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p].filter(ll).join(`
|
|
3987
3987
|
`),g.length>0&&(g+=`
|
|
3988
|
-
`),m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p].filter(
|
|
3988
|
+
`),m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p].filter(ll).join(`
|
|
3989
3989
|
`),m.length>0&&(m+=`
|
|
3990
|
-
`)):(g=[
|
|
3991
|
-
`].filter(
|
|
3992
|
-
`),m=[
|
|
3993
|
-
`].filter(
|
|
3994
|
-
`)),o=Lp(o),o=
|
|
3990
|
+
`)):(g=[mx(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
3991
|
+
`].filter(ll).join(`
|
|
3992
|
+
`),m=[mx(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==di?"#define TONE_MAPPING":"",e.toneMapping!==di?oe.tonemapping_pars_fragment:"",e.toneMapping!==di?mC("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",oe.colorspace_pars_fragment,fC("linearToOutputTexel",e.outputColorSpace),gC(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
|
|
3993
|
+
`].filter(ll).join(`
|
|
3994
|
+
`)),o=Lp(o),o=dx(o,e),o=fx(o,e),a=Lp(a),a=dx(a,e),a=fx(a,e),o=px(o),a=px(a),e.isRawShaderMaterial!==!0&&(y=`#version 300 es
|
|
3995
3995
|
`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3996
3996
|
`)+`
|
|
3997
3997
|
`+g,m=["#define varying in",e.glslVersion===Nu?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Nu?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
3998
3998
|
`)+`
|
|
3999
|
-
`+m);const v=y+g+o,_=y+m+a,w=
|
|
3999
|
+
`+m);const v=y+g+o,_=y+m+a,w=cx(i,i.VERTEX_SHADER,v),T=cx(i,i.FRAGMENT_SHADER,_);i.attachShader(x,w),i.attachShader(x,T),e.index0AttributeName!==void 0?i.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(x,0,"position"),i.linkProgram(x);function E(N){if(r.debug.checkShaderErrors){const L=i.getProgramInfoLog(x)||"",U=i.getShaderInfoLog(w)||"",V=i.getShaderInfoLog(T)||"",O=L.trim(),k=U.trim(),G=V.trim();let it=!0,nt=!0;if(i.getProgramParameter(x,i.LINK_STATUS)===!1)if(it=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,x,w,T);else{const mt=ux(i,w,"vertex"),xt=ux(i,T,"fragment");Vt("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(x,i.VALIDATE_STATUS)+`
|
|
4000
4000
|
|
|
4001
4001
|
Material Name: `+N.name+`
|
|
4002
4002
|
Material Type: `+N.type+`
|
|
4003
4003
|
|
|
4004
4004
|
Program Info Log: `+O+`
|
|
4005
4005
|
`+mt+`
|
|
4006
|
-
`+xt)}else O!==""?pt("WebGLProgram: Program Info Log:",O):(k===""||G==="")&&(nt=!1);nt&&(N.diagnostics={runnable:it,programLog:O,vertexShader:{log:k,prefix:g},fragmentShader:{log:G,prefix:m}})}i.deleteShader(w),i.deleteShader(T),M=new lu(i,x),b=_C(i,x)}let M;this.getUniforms=function(){return M===void 0&&E(this),M};let b;this.getAttributes=function(){return b===void 0&&E(this),b};let P=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(x,cC)),P},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=hC++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=w,this.fragmentShader=T,this}let DC=0;class UC{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new OC(t),e.set(t,n)),n}}class OC{constructor(t){this.id=DC++,this.code=t,this.usedTimes=0}}function BC(r,t,e,n,i,s){const o=new gc,a=new UC,l=new Set,c=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(M){return l.add(M),M===0?"uv":`uv${M}`}function x(M,b,P,N,L){const U=N.fog,V=L.geometry,O=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?N.environment:null,k=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap,G=t.get(M.envMap||O,k),it=G&&G.mapping===to?G.image.height:null,nt=f[M.type];M.precision!==null&&(d=n.getMaxPrecision(M.precision),d!==M.precision&&pt("WebGLProgram.getParameters:",M.precision,"not supported, using",d,"instead."));const mt=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,xt=mt!==void 0?mt.length:0;let bt=0;V.morphAttributes.position!==void 0&&(bt=1),V.morphAttributes.normal!==void 0&&(bt=2),V.morphAttributes.color!==void 0&&(bt=3);let jt,Me,we,j;if(nt){const Se=ci[nt];jt=Se.vertexShader,Me=Se.fragmentShader}else jt=M.vertexShader,Me=M.fragmentShader,a.update(M),we=a.getVertexShaderID(M),j=a.getFragmentShaderID(M);const ct=r.getRenderTarget(),ht=r.state.buffers.depth.getReversed(),qt=L.isInstancedMesh===!0,Xt=L.isBatchedMesh===!0,Kt=!!M.map,Ae=!!M.matcap,ie=!!G,Q=!!M.aoMap,rt=!!M.lightMap,et=!!M.bumpMap,yt=!!M.normalMap,I=!!M.displacementMap,$t=!!M.emissiveMap,Tt=!!M.metalnessMap,Yt=!!M.roughnessMap,ut=M.anisotropy>0,C=M.clearcoat>0,S=M.dispersion>0,D=M.iridescence>0,Y=M.sheen>0,K=M.transmission>0,Z=ut&&!!M.anisotropyMap,It=C&&!!M.clearcoatMap,dt=C&&!!M.clearcoatNormalMap,Ht=C&&!!M.clearcoatRoughnessMap,Zt=D&&!!M.iridescenceMap,st=D&&!!M.iridescenceThicknessMap,at=Y&&!!M.sheenColorMap,Lt=Y&&!!M.sheenRoughnessMap,Dt=!!M.specularMap,Et=!!M.specularColorMap,ce=!!M.specularIntensityMap,F=K&&!!M.transmissionMap,ft=K&&!!M.thicknessMap,lt=!!M.gradientMap,Rt=!!M.alphaMap,ot=M.alphaTest>0,J=!!M.alphaHash,Ft=!!M.extensions;let ee=di;M.toneMapped&&(ct===null||ct.isXRRenderTarget===!0)&&(ee=r.toneMapping);const Ie={shaderID:nt,shaderType:M.type,shaderName:M.name,vertexShader:jt,fragmentShader:Me,defines:M.defines,customVertexShaderID:we,customFragmentShaderID:j,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:d,batching:Xt,batchingColor:Xt&&L._colorsTexture!==null,instancing:qt,instancingColor:qt&&L.instanceColor!==null,instancingMorph:qt&&L.morphTexture!==null,outputColorSpace:ct===null?r.outputColorSpace:ct.isXRRenderTarget===!0?ct.texture.colorSpace:lr,alphaToCoverage:!!M.alphaToCoverage,map:Kt,matcap:Ae,envMap:ie,envMapMode:ie&&G.mapping,envMapCubeUVHeight:it,aoMap:Q,lightMap:rt,bumpMap:et,normalMap:yt,displacementMap:I,emissiveMap:$t,normalMapObjectSpace:yt&&M.normalMapType===s_,normalMapTangentSpace:yt&&M.normalMapType===ur,metalnessMap:Tt,roughnessMap:Yt,anisotropy:ut,anisotropyMap:Z,clearcoat:C,clearcoatMap:It,clearcoatNormalMap:dt,clearcoatRoughnessMap:Ht,dispersion:S,iridescence:D,iridescenceMap:Zt,iridescenceThicknessMap:st,sheen:Y,sheenColorMap:at,sheenRoughnessMap:Lt,specularMap:Dt,specularColorMap:Et,specularIntensityMap:ce,transmission:K,transmissionMap:F,thicknessMap:ft,gradientMap:lt,opaque:M.transparent===!1&&M.blending===nr&&M.alphaToCoverage===!1,alphaMap:Rt,alphaTest:ot,alphaHash:J,combine:M.combine,mapUv:Kt&&p(M.map.channel),aoMapUv:Q&&p(M.aoMap.channel),lightMapUv:rt&&p(M.lightMap.channel),bumpMapUv:et&&p(M.bumpMap.channel),normalMapUv:yt&&p(M.normalMap.channel),displacementMapUv:I&&p(M.displacementMap.channel),emissiveMapUv:$t&&p(M.emissiveMap.channel),metalnessMapUv:Tt&&p(M.metalnessMap.channel),roughnessMapUv:Yt&&p(M.roughnessMap.channel),anisotropyMapUv:Z&&p(M.anisotropyMap.channel),clearcoatMapUv:It&&p(M.clearcoatMap.channel),clearcoatNormalMapUv:dt&&p(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ht&&p(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Zt&&p(M.iridescenceMap.channel),iridescenceThicknessMapUv:st&&p(M.iridescenceThicknessMap.channel),sheenColorMapUv:at&&p(M.sheenColorMap.channel),sheenRoughnessMapUv:Lt&&p(M.sheenRoughnessMap.channel),specularMapUv:Dt&&p(M.specularMap.channel),specularColorMapUv:Et&&p(M.specularColorMap.channel),specularIntensityMapUv:ce&&p(M.specularIntensityMap.channel),transmissionMapUv:F&&p(M.transmissionMap.channel),thicknessMapUv:ft&&p(M.thicknessMap.channel),alphaMapUv:Rt&&p(M.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(yt||ut),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!V.attributes.uv&&(Kt||Rt),fog:!!U,useFog:M.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:M.wireframe===!1&&(M.flatShading===!0||V.attributes.normal===void 0&&yt===!1&&(M.isMeshLambertMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isMeshPhysicalMaterial)),sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:ht,skinning:L.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:xt,morphTextureStride:bt,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:M.dithering,shadowMapEnabled:r.shadowMap.enabled&&P.length>0,shadowMapType:r.shadowMap.type,toneMapping:ee,decodeVideoTexture:Kt&&M.map.isVideoTexture===!0&&fe.getTransfer(M.map.colorSpace)===_e,decodeVideoTextureEmissive:$t&&M.emissiveMap.isVideoTexture===!0&&fe.getTransfer(M.emissiveMap.colorSpace)===_e,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Ri,flipSided:M.side===An,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:Ft&&M.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ft&&M.extensions.multiDraw===!0||Xt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return Ie.vertexUv1s=l.has(1),Ie.vertexUv2s=l.has(2),Ie.vertexUv3s=l.has(3),l.clear(),Ie}function g(M){const b=[];if(M.shaderID?b.push(M.shaderID):(b.push(M.customVertexShaderID),b.push(M.customFragmentShaderID)),M.defines!==void 0)for(const P in M.defines)b.push(P),b.push(M.defines[P]);return M.isRawShaderMaterial===!1&&(m(b,M),y(b,M),b.push(r.outputColorSpace)),b.push(M.customProgramCacheKey),b.join()}function m(M,b){M.push(b.precision),M.push(b.outputColorSpace),M.push(b.envMapMode),M.push(b.envMapCubeUVHeight),M.push(b.mapUv),M.push(b.alphaMapUv),M.push(b.lightMapUv),M.push(b.aoMapUv),M.push(b.bumpMapUv),M.push(b.normalMapUv),M.push(b.displacementMapUv),M.push(b.emissiveMapUv),M.push(b.metalnessMapUv),M.push(b.roughnessMapUv),M.push(b.anisotropyMapUv),M.push(b.clearcoatMapUv),M.push(b.clearcoatNormalMapUv),M.push(b.clearcoatRoughnessMapUv),M.push(b.iridescenceMapUv),M.push(b.iridescenceThicknessMapUv),M.push(b.sheenColorMapUv),M.push(b.sheenRoughnessMapUv),M.push(b.specularMapUv),M.push(b.specularColorMapUv),M.push(b.specularIntensityMapUv),M.push(b.transmissionMapUv),M.push(b.thicknessMapUv),M.push(b.combine),M.push(b.fogExp2),M.push(b.sizeAttenuation),M.push(b.morphTargetsCount),M.push(b.morphAttributeCount),M.push(b.numDirLights),M.push(b.numPointLights),M.push(b.numSpotLights),M.push(b.numSpotLightMaps),M.push(b.numHemiLights),M.push(b.numRectAreaLights),M.push(b.numDirLightShadows),M.push(b.numPointLightShadows),M.push(b.numSpotLightShadows),M.push(b.numSpotLightShadowsWithMaps),M.push(b.numLightProbes),M.push(b.shadowMapType),M.push(b.toneMapping),M.push(b.numClippingPlanes),M.push(b.numClipIntersection),M.push(b.depthPacking)}function y(M,b){o.disableAll(),b.instancing&&o.enable(0),b.instancingColor&&o.enable(1),b.instancingMorph&&o.enable(2),b.matcap&&o.enable(3),b.envMap&&o.enable(4),b.normalMapObjectSpace&&o.enable(5),b.normalMapTangentSpace&&o.enable(6),b.clearcoat&&o.enable(7),b.iridescence&&o.enable(8),b.alphaTest&&o.enable(9),b.vertexColors&&o.enable(10),b.vertexAlphas&&o.enable(11),b.vertexUv1s&&o.enable(12),b.vertexUv2s&&o.enable(13),b.vertexUv3s&&o.enable(14),b.vertexTangents&&o.enable(15),b.anisotropy&&o.enable(16),b.alphaHash&&o.enable(17),b.batching&&o.enable(18),b.dispersion&&o.enable(19),b.batchingColor&&o.enable(20),b.gradientMap&&o.enable(21),M.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reversedDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.decodeVideoTextureEmissive&&o.enable(20),b.alphaToCoverage&&o.enable(21),M.push(o.mask)}function v(M){const b=f[M.type];let P;if(b){const N=ci[b];P=Im.clone(N.uniforms)}else P=M.uniforms;return P}function _(M,b){let P=h.get(b);return P!==void 0?++P.usedTimes:(P=new FC(r,b,M,i),c.push(P),h.set(b,P)),P}function w(M){if(--M.usedTimes===0){const b=c.indexOf(M);c[b]=c[c.length-1],c.pop(),h.delete(M.cacheKey),M.destroy()}}function T(M){a.remove(M)}function E(){a.dispose()}return{getParameters:x,getProgramCacheKey:g,getUniforms:v,acquireProgram:_,releaseProgram:w,releaseShaderCache:T,programs:c,dispose:E}}function zC(){let r=new WeakMap;function t(o){return r.has(o)}function e(o){let a=r.get(o);return a===void 0&&(a={},r.set(o,a)),a}function n(o){r.delete(o)}function i(o,a,l){r.get(o)[a]=l}function s(){r=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:s}}function VC(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.material.id!==t.material.id?r.material.id-t.material.id:r.materialVariant!==t.materialVariant?r.materialVariant-t.materialVariant:r.z!==t.z?r.z-t.z:r.id-t.id}function xx(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.z!==t.z?t.z-r.z:r.id-t.id}function yx(){const r=[];let t=0;const e=[],n=[],i=[];function s(){t=0,e.length=0,n.length=0,i.length=0}function o(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function a(d,f,p,x,g,m){let y=r[t];return y===void 0?(y={id:d.id,object:d,geometry:f,material:p,materialVariant:o(d),groupOrder:x,renderOrder:d.renderOrder,z:g,group:m},r[t]=y):(y.id=d.id,y.object=d,y.geometry=f,y.material=p,y.materialVariant=o(d),y.groupOrder=x,y.renderOrder=d.renderOrder,y.z=g,y.group=m),t++,y}function l(d,f,p,x,g,m){const y=a(d,f,p,x,g,m);d.onBeforeRenderListPush?.(d,f,p,m),p.transmission>0?n.push(y):p.transparent===!0?i.push(y):e.push(y),d.onAfterRenderListPush?.(d,f,p,m)}function c(d,f,p,x,g,m){const y=a(d,f,p,x,g,m);p.transmission>0?n.unshift(y):p.transparent===!0?i.unshift(y):e.unshift(y)}function h(d,f){e.length>1&&e.sort(d||VC),n.length>1&&n.sort(f||xx),i.length>1&&i.sort(f||xx)}function u(){for(let d=t,f=r.length;d<f;d++){const p=r[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:i,init:s,push:l,unshift:c,finish:u,sort:h}}function kC(){let r=new WeakMap;function t(n,i){const s=r.get(n);let o;return s===void 0?(o=new yx,r.set(n,[o])):i>=s.length?(o=new yx,s.push(o)):o=s[i],o}function e(){r=new WeakMap}return{get:t,dispose:e}}function GC(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new R,color:new wt};break;case"SpotLight":e={position:new R,direction:new R,color:new wt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new wt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new wt,groundColor:new wt};break;case"RectAreaLight":e={color:new wt,position:new R,halfWidth:new R,halfHeight:new R};break}return r[t.id]=e,e}}}function HC(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tt,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[t.id]=e,e}}}let WC=0;function XC(r,t){return(t.castShadow?2:0)-(r.castShadow?2:0)+(t.map?1:0)-(r.map?1:0)}function $C(r){const t=new GC,e=HC(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new R);const i=new R,s=new Qt,o=new Qt;function a(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,p=0,x=0,g=0,m=0,y=0,v=0,_=0,w=0,T=0,E=0;c.sort(XC);for(let b=0,P=c.length;b<P;b++){const N=c[b],L=N.color,U=N.intensity,V=N.distance;let O=null;if(N.shadow&&N.shadow.map&&(N.shadow.map.texture.format===ar?O=N.shadow.map.texture:O=N.shadow.map.depthTexture||N.shadow.map.texture),N.isAmbientLight)h+=L.r*U,u+=L.g*U,d+=L.b*U;else if(N.isLightProbe){for(let k=0;k<9;k++)n.probe[k].addScaledVector(N.sh.coefficients[k],U);E++}else if(N.isDirectionalLight){const k=t.get(N);if(k.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){const G=N.shadow,it=e.get(N);it.shadowIntensity=G.intensity,it.shadowBias=G.bias,it.shadowNormalBias=G.normalBias,it.shadowRadius=G.radius,it.shadowMapSize=G.mapSize,n.directionalShadow[f]=it,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=N.shadow.matrix,y++}n.directional[f]=k,f++}else if(N.isSpotLight){const k=t.get(N);k.position.setFromMatrixPosition(N.matrixWorld),k.color.copy(L).multiplyScalar(U),k.distance=V,k.coneCos=Math.cos(N.angle),k.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),k.decay=N.decay,n.spot[x]=k;const G=N.shadow;if(N.map&&(n.spotLightMap[w]=N.map,w++,G.updateMatrices(N),N.castShadow&&T++),n.spotLightMatrix[x]=G.matrix,N.castShadow){const it=e.get(N);it.shadowIntensity=G.intensity,it.shadowBias=G.bias,it.shadowNormalBias=G.normalBias,it.shadowRadius=G.radius,it.shadowMapSize=G.mapSize,n.spotShadow[x]=it,n.spotShadowMap[x]=O,_++}x++}else if(N.isRectAreaLight){const k=t.get(N);k.color.copy(L).multiplyScalar(U),k.halfWidth.set(N.width*.5,0,0),k.halfHeight.set(0,N.height*.5,0),n.rectArea[g]=k,g++}else if(N.isPointLight){const k=t.get(N);if(k.color.copy(N.color).multiplyScalar(N.intensity),k.distance=N.distance,k.decay=N.decay,N.castShadow){const G=N.shadow,it=e.get(N);it.shadowIntensity=G.intensity,it.shadowBias=G.bias,it.shadowNormalBias=G.normalBias,it.shadowRadius=G.radius,it.shadowMapSize=G.mapSize,it.shadowCameraNear=G.camera.near,it.shadowCameraFar=G.camera.far,n.pointShadow[p]=it,n.pointShadowMap[p]=O,n.pointShadowMatrix[p]=N.shadow.matrix,v++}n.point[p]=k,p++}else if(N.isHemisphereLight){const k=t.get(N);k.skyColor.copy(N.color).multiplyScalar(U),k.groundColor.copy(N.groundColor).multiplyScalar(U),n.hemi[m]=k,m++}}g>0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=gt.LTC_FLOAT_1,n.rectAreaLTC2=gt.LTC_FLOAT_2):(n.rectAreaLTC1=gt.LTC_HALF_1,n.rectAreaLTC2=gt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const M=n.hash;(M.directionalLength!==f||M.pointLength!==p||M.spotLength!==x||M.rectAreaLength!==g||M.hemiLength!==m||M.numDirectionalShadows!==y||M.numPointShadows!==v||M.numSpotShadows!==_||M.numSpotMaps!==w||M.numLightProbes!==E)&&(n.directional.length=f,n.spot.length=x,n.rectArea.length=g,n.point.length=p,n.hemi.length=m,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=_+w-T,n.spotLightMap.length=w,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=E,M.directionalLength=f,M.pointLength=p,M.spotLength=x,M.rectAreaLength=g,M.hemiLength=m,M.numDirectionalShadows=y,M.numPointShadows=v,M.numSpotShadows=_,M.numSpotMaps=w,M.numLightProbes=E,n.version=WC++)}function l(c,h){let u=0,d=0,f=0,p=0,x=0;const g=h.matrixWorldInverse;for(let m=0,y=c.length;m<y;m++){const v=c[m];if(v.isDirectionalLight){const _=n.directional[u];_.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(g),u++}else if(v.isSpotLight){const _=n.spot[f];_.position.setFromMatrixPosition(v.matrixWorld),_.position.applyMatrix4(g),_.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(g),f++}else if(v.isRectAreaLight){const _=n.rectArea[p];_.position.setFromMatrixPosition(v.matrixWorld),_.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),_.halfWidth.set(v.width*.5,0,0),_.halfHeight.set(0,v.height*.5,0),_.halfWidth.applyMatrix4(o),_.halfHeight.applyMatrix4(o),p++}else if(v.isPointLight){const _=n.point[d];_.position.setFromMatrixPosition(v.matrixWorld),_.position.applyMatrix4(g),d++}else if(v.isHemisphereLight){const _=n.hemi[x];_.direction.setFromMatrixPosition(v.matrixWorld),_.direction.transformDirection(g),x++}}}return{setup:a,setupView:l,state:n}}function _x(r){const t=new $C(r),e=[],n=[];function i(h){c.camera=h,e.length=0,n.length=0}function s(h){e.push(h)}function o(h){n.push(h)}function a(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function qC(r){let t=new WeakMap;function e(i,s=0){const o=t.get(i);let a;return o===void 0?(a=new _x(r),t.set(i,[a])):s>=o.length?(a=new _x(r),o.push(a)):a=o[s],a}function n(){t=new WeakMap}return{get:e,dispose:n}}const YC=`void main() {
|
|
4006
|
+
`+xt)}else O!==""?pt("WebGLProgram: Program Info Log:",O):(k===""||G==="")&&(nt=!1);nt&&(N.diagnostics={runnable:it,programLog:O,vertexShader:{log:k,prefix:g},fragmentShader:{log:G,prefix:m}})}i.deleteShader(w),i.deleteShader(T),M=new lu(i,x),b=_C(i,x)}let M;this.getUniforms=function(){return M===void 0&&E(this),M};let b;this.getAttributes=function(){return b===void 0&&E(this),b};let P=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(x,cC)),P},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=hC++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=w,this.fragmentShader=T,this}let DC=0;class UC{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new OC(t),e.set(t,n)),n}}class OC{constructor(t){this.id=DC++,this.code=t,this.usedTimes=0}}function BC(r,t,e,n,i,s){const o=new gc,a=new UC,l=new Set,c=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(M){return l.add(M),M===0?"uv":`uv${M}`}function x(M,b,P,N,L){const U=N.fog,V=L.geometry,O=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?N.environment:null,k=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap,G=t.get(M.envMap||O,k),it=G&&G.mapping===to?G.image.height:null,nt=f[M.type];M.precision!==null&&(d=n.getMaxPrecision(M.precision),d!==M.precision&&pt("WebGLProgram.getParameters:",M.precision,"not supported, using",d,"instead."));const mt=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,xt=mt!==void 0?mt.length:0;let bt=0;V.morphAttributes.position!==void 0&&(bt=1),V.morphAttributes.normal!==void 0&&(bt=2),V.morphAttributes.color!==void 0&&(bt=3);let jt,Me,we,j;if(nt){const Se=ci[nt];jt=Se.vertexShader,Me=Se.fragmentShader}else jt=M.vertexShader,Me=M.fragmentShader,a.update(M),we=a.getVertexShaderID(M),j=a.getFragmentShaderID(M);const ct=r.getRenderTarget(),ht=r.state.buffers.depth.getReversed(),qt=L.isInstancedMesh===!0,Xt=L.isBatchedMesh===!0,Kt=!!M.map,Ae=!!M.matcap,ie=!!G,Q=!!M.aoMap,rt=!!M.lightMap,et=!!M.bumpMap,yt=!!M.normalMap,I=!!M.displacementMap,$t=!!M.emissiveMap,Tt=!!M.metalnessMap,Yt=!!M.roughnessMap,ut=M.anisotropy>0,C=M.clearcoat>0,S=M.dispersion>0,D=M.iridescence>0,Y=M.sheen>0,K=M.transmission>0,Z=ut&&!!M.anisotropyMap,It=C&&!!M.clearcoatMap,dt=C&&!!M.clearcoatNormalMap,Ht=C&&!!M.clearcoatRoughnessMap,Zt=D&&!!M.iridescenceMap,st=D&&!!M.iridescenceThicknessMap,at=Y&&!!M.sheenColorMap,Lt=Y&&!!M.sheenRoughnessMap,Dt=!!M.specularMap,Et=!!M.specularColorMap,ce=!!M.specularIntensityMap,F=K&&!!M.transmissionMap,ft=K&&!!M.thicknessMap,lt=!!M.gradientMap,Rt=!!M.alphaMap,ot=M.alphaTest>0,J=!!M.alphaHash,Ft=!!M.extensions;let ee=di;M.toneMapped&&(ct===null||ct.isXRRenderTarget===!0)&&(ee=r.toneMapping);const Ie={shaderID:nt,shaderType:M.type,shaderName:M.name,vertexShader:jt,fragmentShader:Me,defines:M.defines,customVertexShaderID:we,customFragmentShaderID:j,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:d,batching:Xt,batchingColor:Xt&&L._colorsTexture!==null,instancing:qt,instancingColor:qt&&L.instanceColor!==null,instancingMorph:qt&&L.morphTexture!==null,outputColorSpace:ct===null?r.outputColorSpace:ct.isXRRenderTarget===!0?ct.texture.colorSpace:lr,alphaToCoverage:!!M.alphaToCoverage,map:Kt,matcap:Ae,envMap:ie,envMapMode:ie&&G.mapping,envMapCubeUVHeight:it,aoMap:Q,lightMap:rt,bumpMap:et,normalMap:yt,displacementMap:I,emissiveMap:$t,normalMapObjectSpace:yt&&M.normalMapType===s_,normalMapTangentSpace:yt&&M.normalMapType===ur,metalnessMap:Tt,roughnessMap:Yt,anisotropy:ut,anisotropyMap:Z,clearcoat:C,clearcoatMap:It,clearcoatNormalMap:dt,clearcoatRoughnessMap:Ht,dispersion:S,iridescence:D,iridescenceMap:Zt,iridescenceThicknessMap:st,sheen:Y,sheenColorMap:at,sheenRoughnessMap:Lt,specularMap:Dt,specularColorMap:Et,specularIntensityMap:ce,transmission:K,transmissionMap:F,thicknessMap:ft,gradientMap:lt,opaque:M.transparent===!1&&M.blending===nr&&M.alphaToCoverage===!1,alphaMap:Rt,alphaTest:ot,alphaHash:J,combine:M.combine,mapUv:Kt&&p(M.map.channel),aoMapUv:Q&&p(M.aoMap.channel),lightMapUv:rt&&p(M.lightMap.channel),bumpMapUv:et&&p(M.bumpMap.channel),normalMapUv:yt&&p(M.normalMap.channel),displacementMapUv:I&&p(M.displacementMap.channel),emissiveMapUv:$t&&p(M.emissiveMap.channel),metalnessMapUv:Tt&&p(M.metalnessMap.channel),roughnessMapUv:Yt&&p(M.roughnessMap.channel),anisotropyMapUv:Z&&p(M.anisotropyMap.channel),clearcoatMapUv:It&&p(M.clearcoatMap.channel),clearcoatNormalMapUv:dt&&p(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ht&&p(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Zt&&p(M.iridescenceMap.channel),iridescenceThicknessMapUv:st&&p(M.iridescenceThicknessMap.channel),sheenColorMapUv:at&&p(M.sheenColorMap.channel),sheenRoughnessMapUv:Lt&&p(M.sheenRoughnessMap.channel),specularMapUv:Dt&&p(M.specularMap.channel),specularColorMapUv:Et&&p(M.specularColorMap.channel),specularIntensityMapUv:ce&&p(M.specularIntensityMap.channel),transmissionMapUv:F&&p(M.transmissionMap.channel),thicknessMapUv:ft&&p(M.thicknessMap.channel),alphaMapUv:Rt&&p(M.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(yt||ut),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!V.attributes.uv&&(Kt||Rt),fog:!!U,useFog:M.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:M.wireframe===!1&&(M.flatShading===!0||V.attributes.normal===void 0&&yt===!1&&(M.isMeshLambertMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isMeshPhysicalMaterial)),sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:ht,skinning:L.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:xt,morphTextureStride:bt,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:M.dithering,shadowMapEnabled:r.shadowMap.enabled&&P.length>0,shadowMapType:r.shadowMap.type,toneMapping:ee,decodeVideoTexture:Kt&&M.map.isVideoTexture===!0&&fe.getTransfer(M.map.colorSpace)===_e,decodeVideoTextureEmissive:$t&&M.emissiveMap.isVideoTexture===!0&&fe.getTransfer(M.emissiveMap.colorSpace)===_e,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Ri,flipSided:M.side===An,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:Ft&&M.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ft&&M.extensions.multiDraw===!0||Xt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return Ie.vertexUv1s=l.has(1),Ie.vertexUv2s=l.has(2),Ie.vertexUv3s=l.has(3),l.clear(),Ie}function g(M){const b=[];if(M.shaderID?b.push(M.shaderID):(b.push(M.customVertexShaderID),b.push(M.customFragmentShaderID)),M.defines!==void 0)for(const P in M.defines)b.push(P),b.push(M.defines[P]);return M.isRawShaderMaterial===!1&&(m(b,M),y(b,M),b.push(r.outputColorSpace)),b.push(M.customProgramCacheKey),b.join()}function m(M,b){M.push(b.precision),M.push(b.outputColorSpace),M.push(b.envMapMode),M.push(b.envMapCubeUVHeight),M.push(b.mapUv),M.push(b.alphaMapUv),M.push(b.lightMapUv),M.push(b.aoMapUv),M.push(b.bumpMapUv),M.push(b.normalMapUv),M.push(b.displacementMapUv),M.push(b.emissiveMapUv),M.push(b.metalnessMapUv),M.push(b.roughnessMapUv),M.push(b.anisotropyMapUv),M.push(b.clearcoatMapUv),M.push(b.clearcoatNormalMapUv),M.push(b.clearcoatRoughnessMapUv),M.push(b.iridescenceMapUv),M.push(b.iridescenceThicknessMapUv),M.push(b.sheenColorMapUv),M.push(b.sheenRoughnessMapUv),M.push(b.specularMapUv),M.push(b.specularColorMapUv),M.push(b.specularIntensityMapUv),M.push(b.transmissionMapUv),M.push(b.thicknessMapUv),M.push(b.combine),M.push(b.fogExp2),M.push(b.sizeAttenuation),M.push(b.morphTargetsCount),M.push(b.morphAttributeCount),M.push(b.numDirLights),M.push(b.numPointLights),M.push(b.numSpotLights),M.push(b.numSpotLightMaps),M.push(b.numHemiLights),M.push(b.numRectAreaLights),M.push(b.numDirLightShadows),M.push(b.numPointLightShadows),M.push(b.numSpotLightShadows),M.push(b.numSpotLightShadowsWithMaps),M.push(b.numLightProbes),M.push(b.shadowMapType),M.push(b.toneMapping),M.push(b.numClippingPlanes),M.push(b.numClipIntersection),M.push(b.depthPacking)}function y(M,b){o.disableAll(),b.instancing&&o.enable(0),b.instancingColor&&o.enable(1),b.instancingMorph&&o.enable(2),b.matcap&&o.enable(3),b.envMap&&o.enable(4),b.normalMapObjectSpace&&o.enable(5),b.normalMapTangentSpace&&o.enable(6),b.clearcoat&&o.enable(7),b.iridescence&&o.enable(8),b.alphaTest&&o.enable(9),b.vertexColors&&o.enable(10),b.vertexAlphas&&o.enable(11),b.vertexUv1s&&o.enable(12),b.vertexUv2s&&o.enable(13),b.vertexUv3s&&o.enable(14),b.vertexTangents&&o.enable(15),b.anisotropy&&o.enable(16),b.alphaHash&&o.enable(17),b.batching&&o.enable(18),b.dispersion&&o.enable(19),b.batchingColor&&o.enable(20),b.gradientMap&&o.enable(21),M.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reversedDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.decodeVideoTextureEmissive&&o.enable(20),b.alphaToCoverage&&o.enable(21),M.push(o.mask)}function v(M){const b=f[M.type];let P;if(b){const N=ci[b];P=Rm.clone(N.uniforms)}else P=M.uniforms;return P}function _(M,b){let P=h.get(b);return P!==void 0?++P.usedTimes:(P=new FC(r,b,M,i),c.push(P),h.set(b,P)),P}function w(M){if(--M.usedTimes===0){const b=c.indexOf(M);c[b]=c[c.length-1],c.pop(),h.delete(M.cacheKey),M.destroy()}}function T(M){a.remove(M)}function E(){a.dispose()}return{getParameters:x,getProgramCacheKey:g,getUniforms:v,acquireProgram:_,releaseProgram:w,releaseShaderCache:T,programs:c,dispose:E}}function zC(){let r=new WeakMap;function t(o){return r.has(o)}function e(o){let a=r.get(o);return a===void 0&&(a={},r.set(o,a)),a}function n(o){r.delete(o)}function i(o,a,l){r.get(o)[a]=l}function s(){r=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:s}}function VC(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.material.id!==t.material.id?r.material.id-t.material.id:r.materialVariant!==t.materialVariant?r.materialVariant-t.materialVariant:r.z!==t.z?r.z-t.z:r.id-t.id}function gx(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.z!==t.z?t.z-r.z:r.id-t.id}function xx(){const r=[];let t=0;const e=[],n=[],i=[];function s(){t=0,e.length=0,n.length=0,i.length=0}function o(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function a(d,f,p,x,g,m){let y=r[t];return y===void 0?(y={id:d.id,object:d,geometry:f,material:p,materialVariant:o(d),groupOrder:x,renderOrder:d.renderOrder,z:g,group:m},r[t]=y):(y.id=d.id,y.object=d,y.geometry=f,y.material=p,y.materialVariant=o(d),y.groupOrder=x,y.renderOrder=d.renderOrder,y.z=g,y.group=m),t++,y}function l(d,f,p,x,g,m){const y=a(d,f,p,x,g,m);d.onBeforeRenderListPush?.(d,f,p,m),p.transmission>0?n.push(y):p.transparent===!0?i.push(y):e.push(y),d.onAfterRenderListPush?.(d,f,p,m)}function c(d,f,p,x,g,m){const y=a(d,f,p,x,g,m);p.transmission>0?n.unshift(y):p.transparent===!0?i.unshift(y):e.unshift(y)}function h(d,f){e.length>1&&e.sort(d||VC),n.length>1&&n.sort(f||gx),i.length>1&&i.sort(f||gx)}function u(){for(let d=t,f=r.length;d<f;d++){const p=r[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:i,init:s,push:l,unshift:c,finish:u,sort:h}}function kC(){let r=new WeakMap;function t(n,i){const s=r.get(n);let o;return s===void 0?(o=new xx,r.set(n,[o])):i>=s.length?(o=new xx,s.push(o)):o=s[i],o}function e(){r=new WeakMap}return{get:t,dispose:e}}function GC(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new R,color:new wt};break;case"SpotLight":e={position:new R,direction:new R,color:new wt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new wt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new wt,groundColor:new wt};break;case"RectAreaLight":e={color:new wt,position:new R,halfWidth:new R,halfHeight:new R};break}return r[t.id]=e,e}}}function HC(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tt,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[t.id]=e,e}}}let WC=0;function XC(r,t){return(t.castShadow?2:0)-(r.castShadow?2:0)+(t.map?1:0)-(r.map?1:0)}function $C(r){const t=new GC,e=HC(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new R);const i=new R,s=new Qt,o=new Qt;function a(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,p=0,x=0,g=0,m=0,y=0,v=0,_=0,w=0,T=0,E=0;c.sort(XC);for(let b=0,P=c.length;b<P;b++){const N=c[b],L=N.color,U=N.intensity,V=N.distance;let O=null;if(N.shadow&&N.shadow.map&&(N.shadow.map.texture.format===ar?O=N.shadow.map.texture:O=N.shadow.map.depthTexture||N.shadow.map.texture),N.isAmbientLight)h+=L.r*U,u+=L.g*U,d+=L.b*U;else if(N.isLightProbe){for(let k=0;k<9;k++)n.probe[k].addScaledVector(N.sh.coefficients[k],U);E++}else if(N.isDirectionalLight){const k=t.get(N);if(k.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){const G=N.shadow,it=e.get(N);it.shadowIntensity=G.intensity,it.shadowBias=G.bias,it.shadowNormalBias=G.normalBias,it.shadowRadius=G.radius,it.shadowMapSize=G.mapSize,n.directionalShadow[f]=it,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=N.shadow.matrix,y++}n.directional[f]=k,f++}else if(N.isSpotLight){const k=t.get(N);k.position.setFromMatrixPosition(N.matrixWorld),k.color.copy(L).multiplyScalar(U),k.distance=V,k.coneCos=Math.cos(N.angle),k.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),k.decay=N.decay,n.spot[x]=k;const G=N.shadow;if(N.map&&(n.spotLightMap[w]=N.map,w++,G.updateMatrices(N),N.castShadow&&T++),n.spotLightMatrix[x]=G.matrix,N.castShadow){const it=e.get(N);it.shadowIntensity=G.intensity,it.shadowBias=G.bias,it.shadowNormalBias=G.normalBias,it.shadowRadius=G.radius,it.shadowMapSize=G.mapSize,n.spotShadow[x]=it,n.spotShadowMap[x]=O,_++}x++}else if(N.isRectAreaLight){const k=t.get(N);k.color.copy(L).multiplyScalar(U),k.halfWidth.set(N.width*.5,0,0),k.halfHeight.set(0,N.height*.5,0),n.rectArea[g]=k,g++}else if(N.isPointLight){const k=t.get(N);if(k.color.copy(N.color).multiplyScalar(N.intensity),k.distance=N.distance,k.decay=N.decay,N.castShadow){const G=N.shadow,it=e.get(N);it.shadowIntensity=G.intensity,it.shadowBias=G.bias,it.shadowNormalBias=G.normalBias,it.shadowRadius=G.radius,it.shadowMapSize=G.mapSize,it.shadowCameraNear=G.camera.near,it.shadowCameraFar=G.camera.far,n.pointShadow[p]=it,n.pointShadowMap[p]=O,n.pointShadowMatrix[p]=N.shadow.matrix,v++}n.point[p]=k,p++}else if(N.isHemisphereLight){const k=t.get(N);k.skyColor.copy(N.color).multiplyScalar(U),k.groundColor.copy(N.groundColor).multiplyScalar(U),n.hemi[m]=k,m++}}g>0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=gt.LTC_FLOAT_1,n.rectAreaLTC2=gt.LTC_FLOAT_2):(n.rectAreaLTC1=gt.LTC_HALF_1,n.rectAreaLTC2=gt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const M=n.hash;(M.directionalLength!==f||M.pointLength!==p||M.spotLength!==x||M.rectAreaLength!==g||M.hemiLength!==m||M.numDirectionalShadows!==y||M.numPointShadows!==v||M.numSpotShadows!==_||M.numSpotMaps!==w||M.numLightProbes!==E)&&(n.directional.length=f,n.spot.length=x,n.rectArea.length=g,n.point.length=p,n.hemi.length=m,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=_+w-T,n.spotLightMap.length=w,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=E,M.directionalLength=f,M.pointLength=p,M.spotLength=x,M.rectAreaLength=g,M.hemiLength=m,M.numDirectionalShadows=y,M.numPointShadows=v,M.numSpotShadows=_,M.numSpotMaps=w,M.numLightProbes=E,n.version=WC++)}function l(c,h){let u=0,d=0,f=0,p=0,x=0;const g=h.matrixWorldInverse;for(let m=0,y=c.length;m<y;m++){const v=c[m];if(v.isDirectionalLight){const _=n.directional[u];_.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(g),u++}else if(v.isSpotLight){const _=n.spot[f];_.position.setFromMatrixPosition(v.matrixWorld),_.position.applyMatrix4(g),_.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(g),f++}else if(v.isRectAreaLight){const _=n.rectArea[p];_.position.setFromMatrixPosition(v.matrixWorld),_.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),_.halfWidth.set(v.width*.5,0,0),_.halfHeight.set(0,v.height*.5,0),_.halfWidth.applyMatrix4(o),_.halfHeight.applyMatrix4(o),p++}else if(v.isPointLight){const _=n.point[d];_.position.setFromMatrixPosition(v.matrixWorld),_.position.applyMatrix4(g),d++}else if(v.isHemisphereLight){const _=n.hemi[x];_.direction.setFromMatrixPosition(v.matrixWorld),_.direction.transformDirection(g),x++}}}return{setup:a,setupView:l,state:n}}function yx(r){const t=new $C(r),e=[],n=[];function i(h){c.camera=h,e.length=0,n.length=0}function s(h){e.push(h)}function o(h){n.push(h)}function a(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function qC(r){let t=new WeakMap;function e(i,s=0){const o=t.get(i);let a;return o===void 0?(a=new yx(r),t.set(i,[a])):s>=o.length?(a=new yx(r),o.push(a)):a=o[s],a}function n(){t=new WeakMap}return{get:e,dispose:n}}const YC=`void main() {
|
|
4007
4007
|
gl_Position = vec4( position, 1.0 );
|
|
4008
4008
|
}`,ZC=`uniform sampler2D shadow_pass;
|
|
4009
4009
|
uniform vec2 resolution;
|
|
@@ -4030,7 +4030,7 @@ void main() {
|
|
|
4030
4030
|
squared_mean = squared_mean / samples;
|
|
4031
4031
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4032
4032
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4033
|
-
}`,JC=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],jC=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],vx=new Qt,Za=new R,Bf=new R;function KC(r,t,e){let n=new no;const i=new tt,s=new tt,o=new Le,a=new wd,l=new Um,c={},h=e.maxTextureSize,u={[is]:An,[An]:is,[Ri]:Ri},d=new si({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new tt},radius:{value:4}},vertexShader:YC,fragmentShader:ZC}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new se;p.setAttribute("position",new Te(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Ye(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ul;let m=this.type;this.render=function(T,E,M){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;this.type===Yp&&(pt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ul);const b=r.getRenderTarget(),P=r.getActiveCubeFace(),N=r.getActiveMipmapLevel(),L=r.state;L.setBlending(Di),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const U=m!==this.type;U&&E.traverse(function(V){V.material&&(Array.isArray(V.material)?V.material.forEach(O=>O.needsUpdate=!0):V.material.needsUpdate=!0)});for(let V=0,O=T.length;V<O;V++){const k=T[V],G=k.shadow;if(G===void 0){pt("WebGLShadowMap:",k,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const it=G.getFrameExtents();i.multiply(it),s.copy(G.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/it.x),i.x=s.x*it.x,G.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/it.y),i.y=s.y*it.y,G.mapSize.y=s.y));const nt=r.state.buffers.depth.getReversed();if(G.camera._reversedDepth=nt,G.map===null||U===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===Yo){if(k.isPointLight){pt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new qn(i.x,i.y,{format:ar,type:Ui,minFilter:Fe,magFilter:Fe,generateMipmaps:!1}),G.map.texture.name=k.name+".shadowMap",G.map.depthTexture=new jr(i.x,i.y,Tn),G.map.depthTexture.name=k.name+".shadowMapDepth",G.map.depthTexture.format=Oi,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Xe,G.map.depthTexture.magFilter=Xe}else k.isPointLight?(G.map=new Pd(i.x),G.map.depthTexture=new W_(i.x,ii)):(G.map=new qn(i.x,i.y),G.map.depthTexture=new jr(i.x,i.y,ii)),G.map.depthTexture.name=k.name+".shadowMap",G.map.depthTexture.format=Oi,this.type===ul?(G.map.depthTexture.compareFunction=nt?rd:sd,G.map.depthTexture.minFilter=Fe,G.map.depthTexture.magFilter=Fe):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Xe,G.map.depthTexture.magFilter=Xe);G.camera.updateProjectionMatrix()}const mt=G.map.isWebGLCubeRenderTarget?6:1;for(let xt=0;xt<mt;xt++){if(G.map.isWebGLCubeRenderTarget)r.setRenderTarget(G.map,xt),r.clear();else{xt===0&&(r.setRenderTarget(G.map),r.clear());const bt=G.getViewport(xt);o.set(s.x*bt.x,s.y*bt.y,s.x*bt.z,s.y*bt.w),L.viewport(o)}if(k.isPointLight){const bt=G.camera,jt=G.matrix,Me=k.distance||bt.far;Me!==bt.far&&(bt.far=Me,bt.updateProjectionMatrix()),Za.setFromMatrixPosition(k.matrixWorld),bt.position.copy(Za),Bf.copy(bt.position),Bf.add(JC[xt]),bt.up.copy(jC[xt]),bt.lookAt(Bf),bt.updateMatrixWorld(),jt.makeTranslation(-Za.x,-Za.y,-Za.z),vx.multiplyMatrices(bt.projectionMatrix,bt.matrixWorldInverse),G._frustum.setFromProjectionMatrix(vx,bt.coordinateSystem,bt.reversedDepth)}else G.updateMatrices(k);n=G.getFrustum(),_(E,M,G.camera,k,this.type)}G.isPointLightShadow!==!0&&this.type===Yo&&y(G,M),G.needsUpdate=!1}m=this.type,g.needsUpdate=!1,r.setRenderTarget(b,P,N)};function y(T,E){const M=t.update(x);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new qn(i.x,i.y,{format:ar,type:Ui})),d.uniforms.shadow_pass.value=T.map.depthTexture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,r.setRenderTarget(T.mapPass),r.clear(),r.renderBufferDirect(E,null,M,d,x,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,r.setRenderTarget(T.map),r.clear(),r.renderBufferDirect(E,null,M,f,x,null)}function v(T,E,M,b){let P=null;const N=M.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(N!==void 0)P=N;else if(P=M.isPointLight===!0?l:a,r.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const L=P.uuid,U=E.uuid;let V=c[L];V===void 0&&(V={},c[L]=V);let O=V[U];O===void 0&&(O=P.clone(),V[U]=O,E.addEventListener("dispose",w)),P=O}if(P.visible=E.visible,P.wireframe=E.wireframe,b===Yo?P.side=E.shadowSide!==null?E.shadowSide:E.side:P.side=E.shadowSide!==null?E.shadowSide:u[E.side],P.alphaMap=E.alphaMap,P.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,P.map=E.map,P.clipShadows=E.clipShadows,P.clippingPlanes=E.clippingPlanes,P.clipIntersection=E.clipIntersection,P.displacementMap=E.displacementMap,P.displacementScale=E.displacementScale,P.displacementBias=E.displacementBias,P.wireframeLinewidth=E.wireframeLinewidth,P.linewidth=E.linewidth,M.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const L=r.properties.get(P);L.light=M}return P}function _(T,E,M,b,P){if(T.visible===!1)return;if(T.layers.test(E.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&P===Yo)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,T.matrixWorld);const U=t.update(T),V=T.material;if(Array.isArray(V)){const O=U.groups;for(let k=0,G=O.length;k<G;k++){const it=O[k],nt=V[it.materialIndex];if(nt&&nt.visible){const mt=v(T,nt,b,P);T.onBeforeShadow(r,T,E,M,U,mt,it),r.renderBufferDirect(M,null,U,mt,T,it),T.onAfterShadow(r,T,E,M,U,mt,it)}}}else if(V.visible){const O=v(T,V,b,P);T.onBeforeShadow(r,T,E,M,U,O,null),r.renderBufferDirect(M,null,U,O,T,null),T.onAfterShadow(r,T,E,M,U,O,null)}}const L=T.children;for(let U=0,V=L.length;U<V;U++)_(L[U],E,M,b,P)}function w(T){T.target.removeEventListener("dispose",w);for(const M in c){const b=c[M],P=T.target.uuid;P in b&&(b[P].dispose(),delete b[P])}}}function QC(r,t){function e(){let F=!1;const ft=new Le;let lt=null;const Rt=new Le(0,0,0,0);return{setMask:function(ot){lt!==ot&&!F&&(r.colorMask(ot,ot,ot,ot),lt=ot)},setLocked:function(ot){F=ot},setClear:function(ot,J,Ft,ee,Ie){Ie===!0&&(ot*=ee,J*=ee,Ft*=ee),ft.set(ot,J,Ft,ee),Rt.equals(ft)===!1&&(r.clearColor(ot,J,Ft,ee),Rt.copy(ft))},reset:function(){F=!1,lt=null,Rt.set(-1,0,0,0)}}}function n(){let F=!1,ft=!1,lt=null,Rt=null,ot=null;return{setReversed:function(J){if(ft!==J){const Ft=t.get("EXT_clip_control");J?Ft.clipControlEXT(Ft.LOWER_LEFT_EXT,Ft.ZERO_TO_ONE_EXT):Ft.clipControlEXT(Ft.LOWER_LEFT_EXT,Ft.NEGATIVE_ONE_TO_ONE_EXT),ft=J;const ee=ot;ot=null,this.setClear(ee)}},getReversed:function(){return ft},setTest:function(J){J?ct(r.DEPTH_TEST):ht(r.DEPTH_TEST)},setMask:function(J){lt!==J&&!F&&(r.depthMask(J),lt=J)},setFunc:function(J){if(ft&&(J=GS[J]),Rt!==J){switch(J){case bl:r.depthFunc(r.NEVER);break;case Tl:r.depthFunc(r.ALWAYS);break;case wl:r.depthFunc(r.LESS);break;case rr:r.depthFunc(r.LEQUAL);break;case Al:r.depthFunc(r.EQUAL);break;case El:r.depthFunc(r.GEQUAL);break;case Cl:r.depthFunc(r.GREATER);break;case Nl:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Rt=J}},setLocked:function(J){F=J},setClear:function(J){ot!==J&&(ot=J,ft&&(J=1-J),r.clearDepth(J))},reset:function(){F=!1,lt=null,Rt=null,ot=null,ft=!1}}}function i(){let F=!1,ft=null,lt=null,Rt=null,ot=null,J=null,Ft=null,ee=null,Ie=null;return{setTest:function(Se){F||(Se?ct(r.STENCIL_TEST):ht(r.STENCIL_TEST))},setMask:function(Se){ft!==Se&&!F&&(r.stencilMask(Se),ft=Se)},setFunc:function(Se,us,ds){(lt!==Se||Rt!==us||ot!==ds)&&(r.stencilFunc(Se,us,ds),lt=Se,Rt=us,ot=ds)},setOp:function(Se,us,ds){(J!==Se||Ft!==us||ee!==ds)&&(r.stencilOp(Se,us,ds),J=Se,Ft=us,ee=ds)},setLocked:function(Se){F=Se},setClear:function(Se){Ie!==Se&&(r.clearStencil(Se),Ie=Se)},reset:function(){F=!1,ft=null,lt=null,Rt=null,ot=null,J=null,Ft=null,ee=null,Ie=null}}}const s=new e,o=new n,a=new i,l=new WeakMap,c=new WeakMap;let h={},u={},d=new WeakMap,f=[],p=null,x=!1,g=null,m=null,y=null,v=null,_=null,w=null,T=null,E=new wt(0,0,0),M=0,b=!1,P=null,N=null,L=null,U=null,V=null;const O=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,G=0;const it=r.getParameter(r.VERSION);it.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(it)[1]),k=G>=1):it.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(it)[1]),k=G>=2);let nt=null,mt={};const xt=r.getParameter(r.SCISSOR_BOX),bt=r.getParameter(r.VIEWPORT),jt=new Le().fromArray(xt),Me=new Le().fromArray(bt);function we(F,ft,lt,Rt){const ot=new Uint8Array(4),J=r.createTexture();r.bindTexture(F,J),r.texParameteri(F,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(F,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Ft=0;Ft<lt;Ft++)F===r.TEXTURE_3D||F===r.TEXTURE_2D_ARRAY?r.texImage3D(ft,0,r.RGBA,1,1,Rt,0,r.RGBA,r.UNSIGNED_BYTE,ot):r.texImage2D(ft+Ft,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,ot);return J}const j={};j[r.TEXTURE_2D]=we(r.TEXTURE_2D,r.TEXTURE_2D,1),j[r.TEXTURE_CUBE_MAP]=we(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),j[r.TEXTURE_2D_ARRAY]=we(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),j[r.TEXTURE_3D]=we(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),ct(r.DEPTH_TEST),o.setFunc(rr),et(!1),yt(vp),ct(r.CULL_FACE),Q(Di);function ct(F){h[F]!==!0&&(r.enable(F),h[F]=!0)}function ht(F){h[F]!==!1&&(r.disable(F),h[F]=!1)}function qt(F,ft){return u[F]!==ft?(r.bindFramebuffer(F,ft),u[F]=ft,F===r.DRAW_FRAMEBUFFER&&(u[r.FRAMEBUFFER]=ft),F===r.FRAMEBUFFER&&(u[r.DRAW_FRAMEBUFFER]=ft),!0):!1}function Xt(F,ft){let lt=f,Rt=!1;if(F){lt=d.get(ft),lt===void 0&&(lt=[],d.set(ft,lt));const ot=F.textures;if(lt.length!==ot.length||lt[0]!==r.COLOR_ATTACHMENT0){for(let J=0,Ft=ot.length;J<Ft;J++)lt[J]=r.COLOR_ATTACHMENT0+J;lt.length=ot.length,Rt=!0}}else lt[0]!==r.BACK&&(lt[0]=r.BACK,Rt=!0);Rt&&r.drawBuffers(lt)}function Kt(F){return p!==F?(r.useProgram(F),p=F,!0):!1}const Ae={[Qs]:r.FUNC_ADD,[Py]:r.FUNC_SUBTRACT,[Ly]:r.FUNC_REVERSE_SUBTRACT};Ae[Fy]=r.MIN,Ae[Jp]=r.MAX;const ie={[Dy]:r.ZERO,[Uy]:r.ONE,[Oy]:r.SRC_COLOR,[du]:r.SRC_ALPHA,[Hy]:r.SRC_ALPHA_SATURATE,[ky]:r.DST_COLOR,[zy]:r.DST_ALPHA,[By]:r.ONE_MINUS_SRC_COLOR,[fu]:r.ONE_MINUS_SRC_ALPHA,[Gy]:r.ONE_MINUS_DST_COLOR,[Vy]:r.ONE_MINUS_DST_ALPHA,[Wy]:r.CONSTANT_COLOR,[Xy]:r.ONE_MINUS_CONSTANT_COLOR,[$y]:r.CONSTANT_ALPHA,[qy]:r.ONE_MINUS_CONSTANT_ALPHA};function Q(F,ft,lt,Rt,ot,J,Ft,ee,Ie,Se){if(F===Di){x===!0&&(ht(r.BLEND),x=!1);return}if(x===!1&&(ct(r.BLEND),x=!0),F!==Zp){if(F!==g||Se!==b){if((m!==Qs||_!==Qs)&&(r.blendEquation(r.FUNC_ADD),m=Qs,_=Qs),Se)switch(F){case nr:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case uu:r.blendFunc(r.ONE,r.ONE);break;case Mp:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Sp:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:Vt("WebGLState: Invalid blending: ",F);break}else switch(F){case nr:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case uu:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case Mp:Vt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Sp:Vt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Vt("WebGLState: Invalid blending: ",F);break}y=null,v=null,w=null,T=null,E.set(0,0,0),M=0,g=F,b=Se}return}ot=ot||ft,J=J||lt,Ft=Ft||Rt,(ft!==m||ot!==_)&&(r.blendEquationSeparate(Ae[ft],Ae[ot]),m=ft,_=ot),(lt!==y||Rt!==v||J!==w||Ft!==T)&&(r.blendFuncSeparate(ie[lt],ie[Rt],ie[J],ie[Ft]),y=lt,v=Rt,w=J,T=Ft),(ee.equals(E)===!1||Ie!==M)&&(r.blendColor(ee.r,ee.g,ee.b,Ie),E.copy(ee),M=Ie),g=F,b=!1}function rt(F,ft){F.side===Ri?ht(r.CULL_FACE):ct(r.CULL_FACE);let lt=F.side===An;ft&&(lt=!lt),et(lt),F.blending===nr&&F.transparent===!1?Q(Di):Q(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);const Rt=F.stencilWrite;a.setTest(Rt),Rt&&(a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass)),$t(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?ct(r.SAMPLE_ALPHA_TO_COVERAGE):ht(r.SAMPLE_ALPHA_TO_COVERAGE)}function et(F){P!==F&&(F?r.frontFace(r.CW):r.frontFace(r.CCW),P=F)}function yt(F){F!==Ry?(ct(r.CULL_FACE),F!==N&&(F===vp?r.cullFace(r.BACK):F===Iy?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):ht(r.CULL_FACE),N=F}function I(F){F!==L&&(k&&r.lineWidth(F),L=F)}function $t(F,ft,lt){F?(ct(r.POLYGON_OFFSET_FILL),(U!==ft||V!==lt)&&(U=ft,V=lt,o.getReversed()&&(ft=-ft),r.polygonOffset(ft,lt))):ht(r.POLYGON_OFFSET_FILL)}function Tt(F){F?ct(r.SCISSOR_TEST):ht(r.SCISSOR_TEST)}function Yt(F){F===void 0&&(F=r.TEXTURE0+O-1),nt!==F&&(r.activeTexture(F),nt=F)}function ut(F,ft,lt){lt===void 0&&(nt===null?lt=r.TEXTURE0+O-1:lt=nt);let Rt=mt[lt];Rt===void 0&&(Rt={type:void 0,texture:void 0},mt[lt]=Rt),(Rt.type!==F||Rt.texture!==ft)&&(nt!==lt&&(r.activeTexture(lt),nt=lt),r.bindTexture(F,ft||j[F]),Rt.type=F,Rt.texture=ft)}function C(){const F=mt[nt];F!==void 0&&F.type!==void 0&&(r.bindTexture(F.type,null),F.type=void 0,F.texture=void 0)}function S(){try{r.compressedTexImage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function D(){try{r.compressedTexImage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function Y(){try{r.texSubImage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function K(){try{r.texSubImage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function Z(){try{r.compressedTexSubImage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function It(){try{r.compressedTexSubImage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function dt(){try{r.texStorage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function Ht(){try{r.texStorage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function Zt(){try{r.texImage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function st(){try{r.texImage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function at(F){jt.equals(F)===!1&&(r.scissor(F.x,F.y,F.z,F.w),jt.copy(F))}function Lt(F){Me.equals(F)===!1&&(r.viewport(F.x,F.y,F.z,F.w),Me.copy(F))}function Dt(F,ft){let lt=c.get(ft);lt===void 0&&(lt=new WeakMap,c.set(ft,lt));let Rt=lt.get(F);Rt===void 0&&(Rt=r.getUniformBlockIndex(ft,F.name),lt.set(F,Rt))}function Et(F,ft){const Rt=c.get(ft).get(F);l.get(ft)!==Rt&&(r.uniformBlockBinding(ft,Rt,F.__bindingPointIndex),l.set(ft,Rt))}function ce(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),o.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},nt=null,mt={},u={},d=new WeakMap,f=[],p=null,x=!1,g=null,m=null,y=null,v=null,_=null,w=null,T=null,E=new wt(0,0,0),M=0,b=!1,P=null,N=null,L=null,U=null,V=null,jt.set(0,0,r.canvas.width,r.canvas.height),Me.set(0,0,r.canvas.width,r.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:ct,disable:ht,bindFramebuffer:qt,drawBuffers:Xt,useProgram:Kt,setBlending:Q,setMaterial:rt,setFlipSided:et,setCullFace:yt,setLineWidth:I,setPolygonOffset:$t,setScissorTest:Tt,activeTexture:Yt,bindTexture:ut,unbindTexture:C,compressedTexImage2D:S,compressedTexImage3D:D,texImage2D:Zt,texImage3D:st,updateUBOMapping:Dt,uniformBlockBinding:Et,texStorage2D:dt,texStorage3D:Ht,texSubImage2D:Y,texSubImage3D:K,compressedTexSubImage2D:Z,compressedTexSubImage3D:It,scissor:at,viewport:Lt,reset:ce}}function tN(r,t,e,n,i,s,o){const a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new tt,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(C,S){return f?new OffscreenCanvas(C,S):Kl("canvas")}function x(C,S,D){let Y=1;const K=ut(C);if((K.width>D||K.height>D)&&(Y=D/Math.max(K.width,K.height)),Y<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const Z=Math.floor(Y*K.width),It=Math.floor(Y*K.height);u===void 0&&(u=p(Z,It));const dt=S?p(Z,It):u;return dt.width=Z,dt.height=It,dt.getContext("2d").drawImage(C,0,0,Z,It),pt("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+Z+"x"+It+")."),dt}else return"data"in C&&pt("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),C;return C}function g(C){return C.generateMipmaps}function m(C){r.generateMipmap(C)}function y(C){return C.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?r.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function v(C,S,D,Y,K=!1){if(C!==null){if(r[C]!==void 0)return r[C];pt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let Z=S;if(S===r.RED&&(D===r.FLOAT&&(Z=r.R32F),D===r.HALF_FLOAT&&(Z=r.R16F),D===r.UNSIGNED_BYTE&&(Z=r.R8)),S===r.RED_INTEGER&&(D===r.UNSIGNED_BYTE&&(Z=r.R8UI),D===r.UNSIGNED_SHORT&&(Z=r.R16UI),D===r.UNSIGNED_INT&&(Z=r.R32UI),D===r.BYTE&&(Z=r.R8I),D===r.SHORT&&(Z=r.R16I),D===r.INT&&(Z=r.R32I)),S===r.RG&&(D===r.FLOAT&&(Z=r.RG32F),D===r.HALF_FLOAT&&(Z=r.RG16F),D===r.UNSIGNED_BYTE&&(Z=r.RG8)),S===r.RG_INTEGER&&(D===r.UNSIGNED_BYTE&&(Z=r.RG8UI),D===r.UNSIGNED_SHORT&&(Z=r.RG16UI),D===r.UNSIGNED_INT&&(Z=r.RG32UI),D===r.BYTE&&(Z=r.RG8I),D===r.SHORT&&(Z=r.RG16I),D===r.INT&&(Z=r.RG32I)),S===r.RGB_INTEGER&&(D===r.UNSIGNED_BYTE&&(Z=r.RGB8UI),D===r.UNSIGNED_SHORT&&(Z=r.RGB16UI),D===r.UNSIGNED_INT&&(Z=r.RGB32UI),D===r.BYTE&&(Z=r.RGB8I),D===r.SHORT&&(Z=r.RGB16I),D===r.INT&&(Z=r.RGB32I)),S===r.RGBA_INTEGER&&(D===r.UNSIGNED_BYTE&&(Z=r.RGBA8UI),D===r.UNSIGNED_SHORT&&(Z=r.RGBA16UI),D===r.UNSIGNED_INT&&(Z=r.RGBA32UI),D===r.BYTE&&(Z=r.RGBA8I),D===r.SHORT&&(Z=r.RGBA16I),D===r.INT&&(Z=r.RGBA32I)),S===r.RGB&&(D===r.UNSIGNED_INT_5_9_9_9_REV&&(Z=r.RGB9_E5),D===r.UNSIGNED_INT_10F_11F_11F_REV&&(Z=r.R11F_G11F_B10F)),S===r.RGBA){const It=K?Jl:fe.getTransfer(Y);D===r.FLOAT&&(Z=r.RGBA32F),D===r.HALF_FLOAT&&(Z=r.RGBA16F),D===r.UNSIGNED_BYTE&&(Z=It===_e?r.SRGB8_ALPHA8:r.RGBA8),D===r.UNSIGNED_SHORT_4_4_4_4&&(Z=r.RGBA4),D===r.UNSIGNED_SHORT_5_5_5_1&&(Z=r.RGB5_A1)}return(Z===r.R16F||Z===r.R32F||Z===r.RG16F||Z===r.RG32F||Z===r.RGBA16F||Z===r.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function _(C,S){let D;return C?S===null||S===ii||S===Yr?D=r.DEPTH24_STENCIL8:S===Tn?D=r.DEPTH32F_STENCIL8:S===la&&(D=r.DEPTH24_STENCIL8,pt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===ii||S===Yr?D=r.DEPTH_COMPONENT24:S===Tn?D=r.DEPTH_COMPONENT32F:S===la&&(D=r.DEPTH_COMPONENT16),D}function w(C,S){return g(C)===!0||C.isFramebufferTexture&&C.minFilter!==Xe&&C.minFilter!==Fe?Math.log2(Math.max(S.width,S.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?S.mipmaps.length:1}function T(C){const S=C.target;S.removeEventListener("dispose",T),M(S),S.isVideoTexture&&h.delete(S)}function E(C){const S=C.target;S.removeEventListener("dispose",E),P(S)}function M(C){const S=n.get(C);if(S.__webglInit===void 0)return;const D=C.source,Y=d.get(D);if(Y){const K=Y[S.__cacheKey];K.usedTimes--,K.usedTimes===0&&b(C),Object.keys(Y).length===0&&d.delete(D)}n.remove(C)}function b(C){const S=n.get(C);r.deleteTexture(S.__webglTexture);const D=C.source,Y=d.get(D);delete Y[S.__cacheKey],o.memory.textures--}function P(C){const S=n.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),n.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(S.__webglFramebuffer[Y]))for(let K=0;K<S.__webglFramebuffer[Y].length;K++)r.deleteFramebuffer(S.__webglFramebuffer[Y][K]);else r.deleteFramebuffer(S.__webglFramebuffer[Y]);S.__webglDepthbuffer&&r.deleteRenderbuffer(S.__webglDepthbuffer[Y])}else{if(Array.isArray(S.__webglFramebuffer))for(let Y=0;Y<S.__webglFramebuffer.length;Y++)r.deleteFramebuffer(S.__webglFramebuffer[Y]);else r.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&r.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&r.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let Y=0;Y<S.__webglColorRenderbuffer.length;Y++)S.__webglColorRenderbuffer[Y]&&r.deleteRenderbuffer(S.__webglColorRenderbuffer[Y]);S.__webglDepthRenderbuffer&&r.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const D=C.textures;for(let Y=0,K=D.length;Y<K;Y++){const Z=n.get(D[Y]);Z.__webglTexture&&(r.deleteTexture(Z.__webglTexture),o.memory.textures--),n.remove(D[Y])}n.remove(C)}let N=0;function L(){N=0}function U(){const C=N;return C>=i.maxTextures&&pt("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+i.maxTextures),N+=1,C}function V(C){const S=[];return S.push(C.wrapS),S.push(C.wrapT),S.push(C.wrapR||0),S.push(C.magFilter),S.push(C.minFilter),S.push(C.anisotropy),S.push(C.internalFormat),S.push(C.format),S.push(C.type),S.push(C.generateMipmaps),S.push(C.premultiplyAlpha),S.push(C.flipY),S.push(C.unpackAlignment),S.push(C.colorSpace),S.join()}function O(C,S){const D=n.get(C);if(C.isVideoTexture&&Tt(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&D.__version!==C.version){const Y=C.image;if(Y===null)pt("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)pt("WebGLRenderer: Texture marked for update but image is incomplete");else{j(D,C,S);return}}else C.isExternalTexture&&(D.__webglTexture=C.sourceTexture?C.sourceTexture:null);e.bindTexture(r.TEXTURE_2D,D.__webglTexture,r.TEXTURE0+S)}function k(C,S){const D=n.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&D.__version!==C.version){j(D,C,S);return}else C.isExternalTexture&&(D.__webglTexture=C.sourceTexture?C.sourceTexture:null);e.bindTexture(r.TEXTURE_2D_ARRAY,D.__webglTexture,r.TEXTURE0+S)}function G(C,S){const D=n.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&D.__version!==C.version){j(D,C,S);return}e.bindTexture(r.TEXTURE_3D,D.__webglTexture,r.TEXTURE0+S)}function it(C,S){const D=n.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&D.__version!==C.version){ct(D,C,S);return}e.bindTexture(r.TEXTURE_CUBE_MAP,D.__webglTexture,r.TEXTURE0+S)}const nt={[oa]:r.REPEAT,[Bn]:r.CLAMP_TO_EDGE,[aa]:r.MIRRORED_REPEAT},mt={[Xe]:r.NEAREST,[Ju]:r.NEAREST_MIPMAP_NEAREST,[zr]:r.NEAREST_MIPMAP_LINEAR,[Fe]:r.LINEAR,[Ko]:r.LINEAR_MIPMAP_NEAREST,[Li]:r.LINEAR_MIPMAP_LINEAR},xt={[__]:r.NEVER,[T_]:r.ALWAYS,[v_]:r.LESS,[sd]:r.LEQUAL,[M_]:r.EQUAL,[rd]:r.GEQUAL,[S_]:r.GREATER,[b_]:r.NOTEQUAL};function bt(C,S){if(S.type===Tn&&t.has("OES_texture_float_linear")===!1&&(S.magFilter===Fe||S.magFilter===Ko||S.magFilter===zr||S.magFilter===Li||S.minFilter===Fe||S.minFilter===Ko||S.minFilter===zr||S.minFilter===Li)&&pt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(C,r.TEXTURE_WRAP_S,nt[S.wrapS]),r.texParameteri(C,r.TEXTURE_WRAP_T,nt[S.wrapT]),(C===r.TEXTURE_3D||C===r.TEXTURE_2D_ARRAY)&&r.texParameteri(C,r.TEXTURE_WRAP_R,nt[S.wrapR]),r.texParameteri(C,r.TEXTURE_MAG_FILTER,mt[S.magFilter]),r.texParameteri(C,r.TEXTURE_MIN_FILTER,mt[S.minFilter]),S.compareFunction&&(r.texParameteri(C,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(C,r.TEXTURE_COMPARE_FUNC,xt[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Xe||S.minFilter!==zr&&S.minFilter!==Li||S.type===Tn&&t.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){const D=t.get("EXT_texture_filter_anisotropic");r.texParameterf(C,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function jt(C,S){let D=!1;C.__webglInit===void 0&&(C.__webglInit=!0,S.addEventListener("dispose",T));const Y=S.source;let K=d.get(Y);K===void 0&&(K={},d.set(Y,K));const Z=V(S);if(Z!==C.__cacheKey){K[Z]===void 0&&(K[Z]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,D=!0),K[Z].usedTimes++;const It=K[C.__cacheKey];It!==void 0&&(K[C.__cacheKey].usedTimes--,It.usedTimes===0&&b(S)),C.__cacheKey=Z,C.__webglTexture=K[Z].texture}return D}function Me(C,S,D){return Math.floor(Math.floor(C/D)/S)}function we(C,S,D,Y){const Z=C.updateRanges;if(Z.length===0)e.texSubImage2D(r.TEXTURE_2D,0,0,0,S.width,S.height,D,Y,S.data);else{Z.sort((st,at)=>st.start-at.start);let It=0;for(let st=1;st<Z.length;st++){const at=Z[It],Lt=Z[st],Dt=at.start+at.count,Et=Me(Lt.start,S.width,4),ce=Me(at.start,S.width,4);Lt.start<=Dt+1&&Et===ce&&Me(Lt.start+Lt.count-1,S.width,4)===Et?at.count=Math.max(at.count,Lt.start+Lt.count-at.start):(++It,Z[It]=Lt)}Z.length=It+1;const dt=r.getParameter(r.UNPACK_ROW_LENGTH),Ht=r.getParameter(r.UNPACK_SKIP_PIXELS),Zt=r.getParameter(r.UNPACK_SKIP_ROWS);r.pixelStorei(r.UNPACK_ROW_LENGTH,S.width);for(let st=0,at=Z.length;st<at;st++){const Lt=Z[st],Dt=Math.floor(Lt.start/4),Et=Math.ceil(Lt.count/4),ce=Dt%S.width,F=Math.floor(Dt/S.width),ft=Et,lt=1;r.pixelStorei(r.UNPACK_SKIP_PIXELS,ce),r.pixelStorei(r.UNPACK_SKIP_ROWS,F),e.texSubImage2D(r.TEXTURE_2D,0,ce,F,ft,lt,D,Y,S.data)}C.clearUpdateRanges(),r.pixelStorei(r.UNPACK_ROW_LENGTH,dt),r.pixelStorei(r.UNPACK_SKIP_PIXELS,Ht),r.pixelStorei(r.UNPACK_SKIP_ROWS,Zt)}}function j(C,S,D){let Y=r.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(Y=r.TEXTURE_2D_ARRAY),S.isData3DTexture&&(Y=r.TEXTURE_3D);const K=jt(C,S),Z=S.source;e.bindTexture(Y,C.__webglTexture,r.TEXTURE0+D);const It=n.get(Z);if(Z.version!==It.__version||K===!0){e.activeTexture(r.TEXTURE0+D);const dt=fe.getPrimaries(fe.workingColorSpace),Ht=S.colorSpace===Ki?null:fe.getPrimaries(S.colorSpace),Zt=S.colorSpace===Ki||dt===Ht?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Zt);let st=x(S.image,!1,i.maxTextureSize);st=Yt(S,st);const at=s.convert(S.format,S.colorSpace),Lt=s.convert(S.type);let Dt=v(S.internalFormat,at,Lt,S.colorSpace,S.isVideoTexture);bt(Y,S);let Et;const ce=S.mipmaps,F=S.isVideoTexture!==!0,ft=It.__version===void 0||K===!0,lt=Z.dataReady,Rt=w(S,st);if(S.isDepthTexture)Dt=_(S.format===Cs,S.type),ft&&(F?e.texStorage2D(r.TEXTURE_2D,1,Dt,st.width,st.height):e.texImage2D(r.TEXTURE_2D,0,Dt,st.width,st.height,0,at,Lt,null));else if(S.isDataTexture)if(ce.length>0){F&&ft&&e.texStorage2D(r.TEXTURE_2D,Rt,Dt,ce[0].width,ce[0].height);for(let ot=0,J=ce.length;ot<J;ot++)Et=ce[ot],F?lt&&e.texSubImage2D(r.TEXTURE_2D,ot,0,0,Et.width,Et.height,at,Lt,Et.data):e.texImage2D(r.TEXTURE_2D,ot,Dt,Et.width,Et.height,0,at,Lt,Et.data);S.generateMipmaps=!1}else F?(ft&&e.texStorage2D(r.TEXTURE_2D,Rt,Dt,st.width,st.height),lt&&we(S,st,at,Lt)):e.texImage2D(r.TEXTURE_2D,0,Dt,st.width,st.height,0,at,Lt,st.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){F&&ft&&e.texStorage3D(r.TEXTURE_2D_ARRAY,Rt,Dt,ce[0].width,ce[0].height,st.depth);for(let ot=0,J=ce.length;ot<J;ot++)if(Et=ce[ot],S.format!==wn)if(at!==null)if(F){if(lt)if(S.layerUpdates.size>0){const Ft=Ip(Et.width,Et.height,S.format,S.type);for(const ee of S.layerUpdates){const Ie=Et.data.subarray(ee*Ft/Et.data.BYTES_PER_ELEMENT,(ee+1)*Ft/Et.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ot,0,0,ee,Et.width,Et.height,1,at,Ie)}S.clearLayerUpdates()}else e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ot,0,0,0,Et.width,Et.height,st.depth,at,Et.data)}else e.compressedTexImage3D(r.TEXTURE_2D_ARRAY,ot,Dt,Et.width,Et.height,st.depth,0,Et.data,0,0);else pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else F?lt&&e.texSubImage3D(r.TEXTURE_2D_ARRAY,ot,0,0,0,Et.width,Et.height,st.depth,at,Lt,Et.data):e.texImage3D(r.TEXTURE_2D_ARRAY,ot,Dt,Et.width,Et.height,st.depth,0,at,Lt,Et.data)}else{F&&ft&&e.texStorage2D(r.TEXTURE_2D,Rt,Dt,ce[0].width,ce[0].height);for(let ot=0,J=ce.length;ot<J;ot++)Et=ce[ot],S.format!==wn?at!==null?F?lt&&e.compressedTexSubImage2D(r.TEXTURE_2D,ot,0,0,Et.width,Et.height,at,Et.data):e.compressedTexImage2D(r.TEXTURE_2D,ot,Dt,Et.width,Et.height,0,Et.data):pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):F?lt&&e.texSubImage2D(r.TEXTURE_2D,ot,0,0,Et.width,Et.height,at,Lt,Et.data):e.texImage2D(r.TEXTURE_2D,ot,Dt,Et.width,Et.height,0,at,Lt,Et.data)}else if(S.isDataArrayTexture)if(F){if(ft&&e.texStorage3D(r.TEXTURE_2D_ARRAY,Rt,Dt,st.width,st.height,st.depth),lt)if(S.layerUpdates.size>0){const ot=Ip(st.width,st.height,S.format,S.type);for(const J of S.layerUpdates){const Ft=st.data.subarray(J*ot/st.data.BYTES_PER_ELEMENT,(J+1)*ot/st.data.BYTES_PER_ELEMENT);e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,J,st.width,st.height,1,at,Lt,Ft)}S.clearLayerUpdates()}else e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,st.width,st.height,st.depth,at,Lt,st.data)}else e.texImage3D(r.TEXTURE_2D_ARRAY,0,Dt,st.width,st.height,st.depth,0,at,Lt,st.data);else if(S.isData3DTexture)F?(ft&&e.texStorage3D(r.TEXTURE_3D,Rt,Dt,st.width,st.height,st.depth),lt&&e.texSubImage3D(r.TEXTURE_3D,0,0,0,0,st.width,st.height,st.depth,at,Lt,st.data)):e.texImage3D(r.TEXTURE_3D,0,Dt,st.width,st.height,st.depth,0,at,Lt,st.data);else if(S.isFramebufferTexture){if(ft)if(F)e.texStorage2D(r.TEXTURE_2D,Rt,Dt,st.width,st.height);else{let ot=st.width,J=st.height;for(let Ft=0;Ft<Rt;Ft++)e.texImage2D(r.TEXTURE_2D,Ft,Dt,ot,J,0,at,Lt,null),ot>>=1,J>>=1}}else if(ce.length>0){if(F&&ft){const ot=ut(ce[0]);e.texStorage2D(r.TEXTURE_2D,Rt,Dt,ot.width,ot.height)}for(let ot=0,J=ce.length;ot<J;ot++)Et=ce[ot],F?lt&&e.texSubImage2D(r.TEXTURE_2D,ot,0,0,at,Lt,Et):e.texImage2D(r.TEXTURE_2D,ot,Dt,at,Lt,Et);S.generateMipmaps=!1}else if(F){if(ft){const ot=ut(st);e.texStorage2D(r.TEXTURE_2D,Rt,Dt,ot.width,ot.height)}lt&&e.texSubImage2D(r.TEXTURE_2D,0,0,0,at,Lt,st)}else e.texImage2D(r.TEXTURE_2D,0,Dt,at,Lt,st);g(S)&&m(Y),It.__version=Z.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function ct(C,S,D){if(S.image.length!==6)return;const Y=jt(C,S),K=S.source;e.bindTexture(r.TEXTURE_CUBE_MAP,C.__webglTexture,r.TEXTURE0+D);const Z=n.get(K);if(K.version!==Z.__version||Y===!0){e.activeTexture(r.TEXTURE0+D);const It=fe.getPrimaries(fe.workingColorSpace),dt=S.colorSpace===Ki?null:fe.getPrimaries(S.colorSpace),Ht=S.colorSpace===Ki||It===dt?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ht);const Zt=S.isCompressedTexture||S.image[0].isCompressedTexture,st=S.image[0]&&S.image[0].isDataTexture,at=[];for(let J=0;J<6;J++)!Zt&&!st?at[J]=x(S.image[J],!0,i.maxCubemapSize):at[J]=st?S.image[J].image:S.image[J],at[J]=Yt(S,at[J]);const Lt=at[0],Dt=s.convert(S.format,S.colorSpace),Et=s.convert(S.type),ce=v(S.internalFormat,Dt,Et,S.colorSpace),F=S.isVideoTexture!==!0,ft=Z.__version===void 0||Y===!0,lt=K.dataReady;let Rt=w(S,Lt);bt(r.TEXTURE_CUBE_MAP,S);let ot;if(Zt){F&&ft&&e.texStorage2D(r.TEXTURE_CUBE_MAP,Rt,ce,Lt.width,Lt.height);for(let J=0;J<6;J++){ot=at[J].mipmaps;for(let Ft=0;Ft<ot.length;Ft++){const ee=ot[Ft];S.format!==wn?Dt!==null?F?lt&&e.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft,0,0,ee.width,ee.height,Dt,ee.data):e.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft,ce,ee.width,ee.height,0,ee.data):pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft,0,0,ee.width,ee.height,Dt,Et,ee.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft,ce,ee.width,ee.height,0,Dt,Et,ee.data)}}}else{if(ot=S.mipmaps,F&&ft){ot.length>0&&Rt++;const J=ut(at[0]);e.texStorage2D(r.TEXTURE_CUBE_MAP,Rt,ce,J.width,J.height)}for(let J=0;J<6;J++)if(st){F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,at[J].width,at[J].height,Dt,Et,at[J].data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,ce,at[J].width,at[J].height,0,Dt,Et,at[J].data);for(let Ft=0;Ft<ot.length;Ft++){const Ie=ot[Ft].image[J].image;F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft+1,0,0,Ie.width,Ie.height,Dt,Et,Ie.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft+1,ce,Ie.width,Ie.height,0,Dt,Et,Ie.data)}}else{F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,Dt,Et,at[J]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,ce,Dt,Et,at[J]);for(let Ft=0;Ft<ot.length;Ft++){const ee=ot[Ft];F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft+1,0,0,Dt,Et,ee.image[J]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft+1,ce,Dt,Et,ee.image[J])}}}g(S)&&m(r.TEXTURE_CUBE_MAP),Z.__version=K.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function ht(C,S,D,Y,K,Z){const It=s.convert(D.format,D.colorSpace),dt=s.convert(D.type),Ht=v(D.internalFormat,It,dt,D.colorSpace),Zt=n.get(S),st=n.get(D);if(st.__renderTarget=S,!Zt.__hasExternalTextures){const at=Math.max(1,S.width>>Z),Lt=Math.max(1,S.height>>Z);K===r.TEXTURE_3D||K===r.TEXTURE_2D_ARRAY?e.texImage3D(K,Z,Ht,at,Lt,S.depth,0,It,dt,null):e.texImage2D(K,Z,Ht,at,Lt,0,It,dt,null)}e.bindFramebuffer(r.FRAMEBUFFER,C),$t(S)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Y,K,st.__webglTexture,0,I(S)):(K===r.TEXTURE_2D||K>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,Y,K,st.__webglTexture,Z),e.bindFramebuffer(r.FRAMEBUFFER,null)}function qt(C,S,D){if(r.bindRenderbuffer(r.RENDERBUFFER,C),S.depthBuffer){const Y=S.depthTexture,K=Y&&Y.isDepthTexture?Y.type:null,Z=_(S.stencilBuffer,K),It=S.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;$t(S)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,I(S),Z,S.width,S.height):D?r.renderbufferStorageMultisample(r.RENDERBUFFER,I(S),Z,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,Z,S.width,S.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,It,r.RENDERBUFFER,C)}else{const Y=S.textures;for(let K=0;K<Y.length;K++){const Z=Y[K],It=s.convert(Z.format,Z.colorSpace),dt=s.convert(Z.type),Ht=v(Z.internalFormat,It,dt,Z.colorSpace);$t(S)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,I(S),Ht,S.width,S.height):D?r.renderbufferStorageMultisample(r.RENDERBUFFER,I(S),Ht,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,Ht,S.width,S.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Xt(C,S,D){const Y=S.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(r.FRAMEBUFFER,C),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const K=n.get(S.depthTexture);if(K.__renderTarget=S,(!K.__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),Y){if(K.__webglInit===void 0&&(K.__webglInit=!0,S.depthTexture.addEventListener("dispose",T)),K.__webglTexture===void 0){K.__webglTexture=r.createTexture(),e.bindTexture(r.TEXTURE_CUBE_MAP,K.__webglTexture),bt(r.TEXTURE_CUBE_MAP,S.depthTexture);const Zt=s.convert(S.depthTexture.format),st=s.convert(S.depthTexture.type);let at;S.depthTexture.format===Oi?at=r.DEPTH_COMPONENT24:S.depthTexture.format===Cs&&(at=r.DEPTH24_STENCIL8);for(let Lt=0;Lt<6;Lt++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Lt,0,at,S.width,S.height,0,Zt,st,null)}}else O(S.depthTexture,0);const Z=K.__webglTexture,It=I(S),dt=Y?r.TEXTURE_CUBE_MAP_POSITIVE_X+D:r.TEXTURE_2D,Ht=S.depthTexture.format===Cs?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;if(S.depthTexture.format===Oi)$t(S)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Ht,dt,Z,0,It):r.framebufferTexture2D(r.FRAMEBUFFER,Ht,dt,Z,0);else if(S.depthTexture.format===Cs)$t(S)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Ht,dt,Z,0,It):r.framebufferTexture2D(r.FRAMEBUFFER,Ht,dt,Z,0);else throw new Error("Unknown depthTexture format")}function Kt(C){const S=n.get(C),D=C.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==C.depthTexture){const Y=C.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),Y){const K=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,Y.removeEventListener("dispose",K)};Y.addEventListener("dispose",K),S.__depthDisposeCallback=K}S.__boundDepthTexture=Y}if(C.depthTexture&&!S.__autoAllocateDepthBuffer)if(D)for(let Y=0;Y<6;Y++)Xt(S.__webglFramebuffer[Y],C,Y);else{const Y=C.texture.mipmaps;Y&&Y.length>0?Xt(S.__webglFramebuffer[0],C,0):Xt(S.__webglFramebuffer,C,0)}else if(D){S.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer[Y]),S.__webglDepthbuffer[Y]===void 0)S.__webglDepthbuffer[Y]=r.createRenderbuffer(),qt(S.__webglDepthbuffer[Y],C,!1);else{const K=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Z=S.__webglDepthbuffer[Y];r.bindRenderbuffer(r.RENDERBUFFER,Z),r.framebufferRenderbuffer(r.FRAMEBUFFER,K,r.RENDERBUFFER,Z)}}else{const Y=C.texture.mipmaps;if(Y&&Y.length>0?e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer[0]):e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=r.createRenderbuffer(),qt(S.__webglDepthbuffer,C,!1);else{const K=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Z=S.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,Z),r.framebufferRenderbuffer(r.FRAMEBUFFER,K,r.RENDERBUFFER,Z)}}e.bindFramebuffer(r.FRAMEBUFFER,null)}function Ae(C,S,D){const Y=n.get(C);S!==void 0&&ht(Y.__webglFramebuffer,C,C.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),D!==void 0&&Kt(C)}function ie(C){const S=C.texture,D=n.get(C),Y=n.get(S);C.addEventListener("dispose",E);const K=C.textures,Z=C.isWebGLCubeRenderTarget===!0,It=K.length>1;if(It||(Y.__webglTexture===void 0&&(Y.__webglTexture=r.createTexture()),Y.__version=S.version,o.memory.textures++),Z){D.__webglFramebuffer=[];for(let dt=0;dt<6;dt++)if(S.mipmaps&&S.mipmaps.length>0){D.__webglFramebuffer[dt]=[];for(let Ht=0;Ht<S.mipmaps.length;Ht++)D.__webglFramebuffer[dt][Ht]=r.createFramebuffer()}else D.__webglFramebuffer[dt]=r.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){D.__webglFramebuffer=[];for(let dt=0;dt<S.mipmaps.length;dt++)D.__webglFramebuffer[dt]=r.createFramebuffer()}else D.__webglFramebuffer=r.createFramebuffer();if(It)for(let dt=0,Ht=K.length;dt<Ht;dt++){const Zt=n.get(K[dt]);Zt.__webglTexture===void 0&&(Zt.__webglTexture=r.createTexture(),o.memory.textures++)}if(C.samples>0&&$t(C)===!1){D.__webglMultisampledFramebuffer=r.createFramebuffer(),D.__webglColorRenderbuffer=[],e.bindFramebuffer(r.FRAMEBUFFER,D.__webglMultisampledFramebuffer);for(let dt=0;dt<K.length;dt++){const Ht=K[dt];D.__webglColorRenderbuffer[dt]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,D.__webglColorRenderbuffer[dt]);const Zt=s.convert(Ht.format,Ht.colorSpace),st=s.convert(Ht.type),at=v(Ht.internalFormat,Zt,st,Ht.colorSpace,C.isXRRenderTarget===!0),Lt=I(C);r.renderbufferStorageMultisample(r.RENDERBUFFER,Lt,at,C.width,C.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+dt,r.RENDERBUFFER,D.__webglColorRenderbuffer[dt])}r.bindRenderbuffer(r.RENDERBUFFER,null),C.depthBuffer&&(D.__webglDepthRenderbuffer=r.createRenderbuffer(),qt(D.__webglDepthRenderbuffer,C,!0)),e.bindFramebuffer(r.FRAMEBUFFER,null)}}if(Z){e.bindTexture(r.TEXTURE_CUBE_MAP,Y.__webglTexture),bt(r.TEXTURE_CUBE_MAP,S);for(let dt=0;dt<6;dt++)if(S.mipmaps&&S.mipmaps.length>0)for(let Ht=0;Ht<S.mipmaps.length;Ht++)ht(D.__webglFramebuffer[dt][Ht],C,S,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+dt,Ht);else ht(D.__webglFramebuffer[dt],C,S,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+dt,0);g(S)&&m(r.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(It){for(let dt=0,Ht=K.length;dt<Ht;dt++){const Zt=K[dt],st=n.get(Zt);let at=r.TEXTURE_2D;(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(at=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(at,st.__webglTexture),bt(at,Zt),ht(D.__webglFramebuffer,C,Zt,r.COLOR_ATTACHMENT0+dt,at,0),g(Zt)&&m(at)}e.unbindTexture()}else{let dt=r.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(dt=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(dt,Y.__webglTexture),bt(dt,S),S.mipmaps&&S.mipmaps.length>0)for(let Ht=0;Ht<S.mipmaps.length;Ht++)ht(D.__webglFramebuffer[Ht],C,S,r.COLOR_ATTACHMENT0,dt,Ht);else ht(D.__webglFramebuffer,C,S,r.COLOR_ATTACHMENT0,dt,0);g(S)&&m(dt),e.unbindTexture()}C.depthBuffer&&Kt(C)}function Q(C){const S=C.textures;for(let D=0,Y=S.length;D<Y;D++){const K=S[D];if(g(K)){const Z=y(C),It=n.get(K).__webglTexture;e.bindTexture(Z,It),m(Z),e.unbindTexture()}}}const rt=[],et=[];function yt(C){if(C.samples>0){if($t(C)===!1){const S=C.textures,D=C.width,Y=C.height;let K=r.COLOR_BUFFER_BIT;const Z=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,It=n.get(C),dt=S.length>1;if(dt)for(let Zt=0;Zt<S.length;Zt++)e.bindFramebuffer(r.FRAMEBUFFER,It.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Zt,r.RENDERBUFFER,null),e.bindFramebuffer(r.FRAMEBUFFER,It.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Zt,r.TEXTURE_2D,null,0);e.bindFramebuffer(r.READ_FRAMEBUFFER,It.__webglMultisampledFramebuffer);const Ht=C.texture.mipmaps;Ht&&Ht.length>0?e.bindFramebuffer(r.DRAW_FRAMEBUFFER,It.__webglFramebuffer[0]):e.bindFramebuffer(r.DRAW_FRAMEBUFFER,It.__webglFramebuffer);for(let Zt=0;Zt<S.length;Zt++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(K|=r.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(K|=r.STENCIL_BUFFER_BIT)),dt){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,It.__webglColorRenderbuffer[Zt]);const st=n.get(S[Zt]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,st,0)}r.blitFramebuffer(0,0,D,Y,0,0,D,Y,K,r.NEAREST),l===!0&&(rt.length=0,et.length=0,rt.push(r.COLOR_ATTACHMENT0+Zt),C.depthBuffer&&C.resolveDepthBuffer===!1&&(rt.push(Z),et.push(Z),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,et)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,rt))}if(e.bindFramebuffer(r.READ_FRAMEBUFFER,null),e.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),dt)for(let Zt=0;Zt<S.length;Zt++){e.bindFramebuffer(r.FRAMEBUFFER,It.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Zt,r.RENDERBUFFER,It.__webglColorRenderbuffer[Zt]);const st=n.get(S[Zt]).__webglTexture;e.bindFramebuffer(r.FRAMEBUFFER,It.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Zt,r.TEXTURE_2D,st,0)}e.bindFramebuffer(r.DRAW_FRAMEBUFFER,It.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const S=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[S])}}}function I(C){return Math.min(i.maxSamples,C.samples)}function $t(C){const S=n.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Tt(C){const S=o.render.frame;h.get(C)!==S&&(h.set(C,S),C.update())}function Yt(C,S){const D=C.colorSpace,Y=C.format,K=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||D!==lr&&D!==Ki&&(fe.getTransfer(D)===_e?(Y!==wn||K!==Un)&&pt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Vt("WebGLTextures: Unsupported texture color space:",D)),S}function ut(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=U,this.resetTextureUnits=L,this.setTexture2D=O,this.setTexture2DArray=k,this.setTexture3D=G,this.setTextureCube=it,this.rebindTextures=Ae,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Kt,this.setupFrameBufferTexture=ht,this.useMultisampledRTT=$t,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function zv(r,t){function e(n,i=Ki){let s;const o=fe.getTransfer(i);if(n===Un)return r.UNSIGNED_BYTE;if(n===Ku)return r.UNSIGNED_SHORT_4_4_4_4;if(n===Qu)return r.UNSIGNED_SHORT_5_5_5_1;if(n===td)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===ed)return r.UNSIGNED_INT_10F_11F_11F_REV;if(n===Qp)return r.BYTE;if(n===tm)return r.SHORT;if(n===la)return r.UNSIGNED_SHORT;if(n===ju)return r.INT;if(n===ii)return r.UNSIGNED_INT;if(n===Tn)return r.FLOAT;if(n===Ui)return r.HALF_FLOAT;if(n===em)return r.ALPHA;if(n===nd)return r.RGB;if(n===wn)return r.RGBA;if(n===Oi)return r.DEPTH_COMPONENT;if(n===Cs)return r.DEPTH_STENCIL;if(n===dc)return r.RED;if(n===Ma)return r.RED_INTEGER;if(n===ar)return r.RG;if(n===fc)return r.RG_INTEGER;if(n===pc)return r.RGBA_INTEGER;if(n===Qo||n===ta||n===dl||n===ea)if(o===_e)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Qo)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ta)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===dl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Qo)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ta)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===dl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ea)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Rl||n===pu||n===Il||n===Pl)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Rl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===pu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Il)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Pl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ll||n===Fl||n===Dl||n===Ul||n===Ol||n===Bl||n===zl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Ll||n===Fl)return o===_e?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Dl)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===Ul)return s.COMPRESSED_R11_EAC;if(n===Ol)return s.COMPRESSED_SIGNED_R11_EAC;if(n===Bl)return s.COMPRESSED_RG11_EAC;if(n===zl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Vl||n===mu||n===gu||n===xu||n===kl||n===yu||n===_u||n===vu||n===Mu||n===Su||n===bu||n===Tu||n===wu||n===Au)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Vl)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===mu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===gu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===xu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===kl)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===yu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===_u)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===vu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Mu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Su)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===bu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Tu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===wu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Au)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Gl||n===Eu||n===Hl)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===Gl)return o===_e?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Eu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Hl)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Wl||n===Xl||n===$l||n===ql)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===Wl)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Xl)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===$l)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ql)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Yr?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:e}}const eN=`
|
|
4033
|
+
}`,JC=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],jC=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],_x=new Qt,Ja=new R,Bf=new R;function KC(r,t,e){let n=new no;const i=new tt,s=new tt,o=new Le,a=new wd,l=new Dm,c={},h=e.maxTextureSize,u={[is]:An,[An]:is,[Ri]:Ri},d=new si({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new tt},radius:{value:4}},vertexShader:YC,fragmentShader:ZC}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new se;p.setAttribute("position",new Te(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Ye(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Jo;let m=this.type;this.render=function(T,E,M){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;this.type===Iy&&(pt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Jo);const b=r.getRenderTarget(),P=r.getActiveCubeFace(),N=r.getActiveMipmapLevel(),L=r.state;L.setBlending(Di),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const U=m!==this.type;U&&E.traverse(function(V){V.material&&(Array.isArray(V.material)?V.material.forEach(O=>O.needsUpdate=!0):V.material.needsUpdate=!0)});for(let V=0,O=T.length;V<O;V++){const k=T[V],G=k.shadow;if(G===void 0){pt("WebGLShadowMap:",k,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const it=G.getFrameExtents();i.multiply(it),s.copy(G.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/it.x),i.x=s.x*it.x,G.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/it.y),i.y=s.y*it.y,G.mapSize.y=s.y));const nt=r.state.buffers.depth.getReversed();if(G.camera._reversedDepth=nt,G.map===null||U===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===Yo){if(k.isPointLight){pt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new qn(i.x,i.y,{format:ar,type:Ui,minFilter:Fe,magFilter:Fe,generateMipmaps:!1}),G.map.texture.name=k.name+".shadowMap",G.map.depthTexture=new jr(i.x,i.y,Tn),G.map.depthTexture.name=k.name+".shadowMapDepth",G.map.depthTexture.format=Oi,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Xe,G.map.depthTexture.magFilter=Xe}else k.isPointLight?(G.map=new Pd(i.x),G.map.depthTexture=new W_(i.x,ii)):(G.map=new qn(i.x,i.y),G.map.depthTexture=new jr(i.x,i.y,ii)),G.map.depthTexture.name=k.name+".shadowMap",G.map.depthTexture.format=Oi,this.type===Jo?(G.map.depthTexture.compareFunction=nt?rd:sd,G.map.depthTexture.minFilter=Fe,G.map.depthTexture.magFilter=Fe):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Xe,G.map.depthTexture.magFilter=Xe);G.camera.updateProjectionMatrix()}const mt=G.map.isWebGLCubeRenderTarget?6:1;for(let xt=0;xt<mt;xt++){if(G.map.isWebGLCubeRenderTarget)r.setRenderTarget(G.map,xt),r.clear();else{xt===0&&(r.setRenderTarget(G.map),r.clear());const bt=G.getViewport(xt);o.set(s.x*bt.x,s.y*bt.y,s.x*bt.z,s.y*bt.w),L.viewport(o)}if(k.isPointLight){const bt=G.camera,jt=G.matrix,Me=k.distance||bt.far;Me!==bt.far&&(bt.far=Me,bt.updateProjectionMatrix()),Ja.setFromMatrixPosition(k.matrixWorld),bt.position.copy(Ja),Bf.copy(bt.position),Bf.add(JC[xt]),bt.up.copy(jC[xt]),bt.lookAt(Bf),bt.updateMatrixWorld(),jt.makeTranslation(-Ja.x,-Ja.y,-Ja.z),_x.multiplyMatrices(bt.projectionMatrix,bt.matrixWorldInverse),G._frustum.setFromProjectionMatrix(_x,bt.coordinateSystem,bt.reversedDepth)}else G.updateMatrices(k);n=G.getFrustum(),_(E,M,G.camera,k,this.type)}G.isPointLightShadow!==!0&&this.type===Yo&&y(G,M),G.needsUpdate=!1}m=this.type,g.needsUpdate=!1,r.setRenderTarget(b,P,N)};function y(T,E){const M=t.update(x);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new qn(i.x,i.y,{format:ar,type:Ui})),d.uniforms.shadow_pass.value=T.map.depthTexture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,r.setRenderTarget(T.mapPass),r.clear(),r.renderBufferDirect(E,null,M,d,x,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,r.setRenderTarget(T.map),r.clear(),r.renderBufferDirect(E,null,M,f,x,null)}function v(T,E,M,b){let P=null;const N=M.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(N!==void 0)P=N;else if(P=M.isPointLight===!0?l:a,r.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const L=P.uuid,U=E.uuid;let V=c[L];V===void 0&&(V={},c[L]=V);let O=V[U];O===void 0&&(O=P.clone(),V[U]=O,E.addEventListener("dispose",w)),P=O}if(P.visible=E.visible,P.wireframe=E.wireframe,b===Yo?P.side=E.shadowSide!==null?E.shadowSide:E.side:P.side=E.shadowSide!==null?E.shadowSide:u[E.side],P.alphaMap=E.alphaMap,P.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,P.map=E.map,P.clipShadows=E.clipShadows,P.clippingPlanes=E.clippingPlanes,P.clipIntersection=E.clipIntersection,P.displacementMap=E.displacementMap,P.displacementScale=E.displacementScale,P.displacementBias=E.displacementBias,P.wireframeLinewidth=E.wireframeLinewidth,P.linewidth=E.linewidth,M.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const L=r.properties.get(P);L.light=M}return P}function _(T,E,M,b,P){if(T.visible===!1)return;if(T.layers.test(E.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&P===Yo)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,T.matrixWorld);const U=t.update(T),V=T.material;if(Array.isArray(V)){const O=U.groups;for(let k=0,G=O.length;k<G;k++){const it=O[k],nt=V[it.materialIndex];if(nt&&nt.visible){const mt=v(T,nt,b,P);T.onBeforeShadow(r,T,E,M,U,mt,it),r.renderBufferDirect(M,null,U,mt,T,it),T.onAfterShadow(r,T,E,M,U,mt,it)}}}else if(V.visible){const O=v(T,V,b,P);T.onBeforeShadow(r,T,E,M,U,O,null),r.renderBufferDirect(M,null,U,O,T,null),T.onAfterShadow(r,T,E,M,U,O,null)}}const L=T.children;for(let U=0,V=L.length;U<V;U++)_(L[U],E,M,b,P)}function w(T){T.target.removeEventListener("dispose",w);for(const M in c){const b=c[M],P=T.target.uuid;P in b&&(b[P].dispose(),delete b[P])}}}function QC(r,t){function e(){let F=!1;const ft=new Le;let lt=null;const Rt=new Le(0,0,0,0);return{setMask:function(ot){lt!==ot&&!F&&(r.colorMask(ot,ot,ot,ot),lt=ot)},setLocked:function(ot){F=ot},setClear:function(ot,J,Ft,ee,Ie){Ie===!0&&(ot*=ee,J*=ee,Ft*=ee),ft.set(ot,J,Ft,ee),Rt.equals(ft)===!1&&(r.clearColor(ot,J,Ft,ee),Rt.copy(ft))},reset:function(){F=!1,lt=null,Rt.set(-1,0,0,0)}}}function n(){let F=!1,ft=!1,lt=null,Rt=null,ot=null;return{setReversed:function(J){if(ft!==J){const Ft=t.get("EXT_clip_control");J?Ft.clipControlEXT(Ft.LOWER_LEFT_EXT,Ft.ZERO_TO_ONE_EXT):Ft.clipControlEXT(Ft.LOWER_LEFT_EXT,Ft.NEGATIVE_ONE_TO_ONE_EXT),ft=J;const ee=ot;ot=null,this.setClear(ee)}},getReversed:function(){return ft},setTest:function(J){J?ct(r.DEPTH_TEST):ht(r.DEPTH_TEST)},setMask:function(J){lt!==J&&!F&&(r.depthMask(J),lt=J)},setFunc:function(J){if(ft&&(J=GS[J]),Rt!==J){switch(J){case bl:r.depthFunc(r.NEVER);break;case Tl:r.depthFunc(r.ALWAYS);break;case wl:r.depthFunc(r.LESS);break;case rr:r.depthFunc(r.LEQUAL);break;case Al:r.depthFunc(r.EQUAL);break;case El:r.depthFunc(r.GEQUAL);break;case Cl:r.depthFunc(r.GREATER);break;case Nl:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Rt=J}},setLocked:function(J){F=J},setClear:function(J){ot!==J&&(ot=J,ft&&(J=1-J),r.clearDepth(J))},reset:function(){F=!1,lt=null,Rt=null,ot=null,ft=!1}}}function i(){let F=!1,ft=null,lt=null,Rt=null,ot=null,J=null,Ft=null,ee=null,Ie=null;return{setTest:function(Se){F||(Se?ct(r.STENCIL_TEST):ht(r.STENCIL_TEST))},setMask:function(Se){ft!==Se&&!F&&(r.stencilMask(Se),ft=Se)},setFunc:function(Se,us,ds){(lt!==Se||Rt!==us||ot!==ds)&&(r.stencilFunc(Se,us,ds),lt=Se,Rt=us,ot=ds)},setOp:function(Se,us,ds){(J!==Se||Ft!==us||ee!==ds)&&(r.stencilOp(Se,us,ds),J=Se,Ft=us,ee=ds)},setLocked:function(Se){F=Se},setClear:function(Se){Ie!==Se&&(r.clearStencil(Se),Ie=Se)},reset:function(){F=!1,ft=null,lt=null,Rt=null,ot=null,J=null,Ft=null,ee=null,Ie=null}}}const s=new e,o=new n,a=new i,l=new WeakMap,c=new WeakMap;let h={},u={},d=new WeakMap,f=[],p=null,x=!1,g=null,m=null,y=null,v=null,_=null,w=null,T=null,E=new wt(0,0,0),M=0,b=!1,P=null,N=null,L=null,U=null,V=null;const O=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,G=0;const it=r.getParameter(r.VERSION);it.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(it)[1]),k=G>=1):it.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(it)[1]),k=G>=2);let nt=null,mt={};const xt=r.getParameter(r.SCISSOR_BOX),bt=r.getParameter(r.VIEWPORT),jt=new Le().fromArray(xt),Me=new Le().fromArray(bt);function we(F,ft,lt,Rt){const ot=new Uint8Array(4),J=r.createTexture();r.bindTexture(F,J),r.texParameteri(F,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(F,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Ft=0;Ft<lt;Ft++)F===r.TEXTURE_3D||F===r.TEXTURE_2D_ARRAY?r.texImage3D(ft,0,r.RGBA,1,1,Rt,0,r.RGBA,r.UNSIGNED_BYTE,ot):r.texImage2D(ft+Ft,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,ot);return J}const j={};j[r.TEXTURE_2D]=we(r.TEXTURE_2D,r.TEXTURE_2D,1),j[r.TEXTURE_CUBE_MAP]=we(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),j[r.TEXTURE_2D_ARRAY]=we(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),j[r.TEXTURE_3D]=we(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),ct(r.DEPTH_TEST),o.setFunc(rr),et(!1),yt(vp),ct(r.CULL_FACE),Q(Di);function ct(F){h[F]!==!0&&(r.enable(F),h[F]=!0)}function ht(F){h[F]!==!1&&(r.disable(F),h[F]=!1)}function qt(F,ft){return u[F]!==ft?(r.bindFramebuffer(F,ft),u[F]=ft,F===r.DRAW_FRAMEBUFFER&&(u[r.FRAMEBUFFER]=ft),F===r.FRAMEBUFFER&&(u[r.DRAW_FRAMEBUFFER]=ft),!0):!1}function Xt(F,ft){let lt=f,Rt=!1;if(F){lt=d.get(ft),lt===void 0&&(lt=[],d.set(ft,lt));const ot=F.textures;if(lt.length!==ot.length||lt[0]!==r.COLOR_ATTACHMENT0){for(let J=0,Ft=ot.length;J<Ft;J++)lt[J]=r.COLOR_ATTACHMENT0+J;lt.length=ot.length,Rt=!0}}else lt[0]!==r.BACK&&(lt[0]=r.BACK,Rt=!0);Rt&&r.drawBuffers(lt)}function Kt(F){return p!==F?(r.useProgram(F),p=F,!0):!1}const Ae={[Qs]:r.FUNC_ADD,[Py]:r.FUNC_SUBTRACT,[Ly]:r.FUNC_REVERSE_SUBTRACT};Ae[Fy]=r.MIN,Ae[Zp]=r.MAX;const ie={[Dy]:r.ZERO,[Uy]:r.ONE,[Oy]:r.SRC_COLOR,[du]:r.SRC_ALPHA,[Hy]:r.SRC_ALPHA_SATURATE,[ky]:r.DST_COLOR,[zy]:r.DST_ALPHA,[By]:r.ONE_MINUS_SRC_COLOR,[fu]:r.ONE_MINUS_SRC_ALPHA,[Gy]:r.ONE_MINUS_DST_COLOR,[Vy]:r.ONE_MINUS_DST_ALPHA,[Wy]:r.CONSTANT_COLOR,[Xy]:r.ONE_MINUS_CONSTANT_COLOR,[$y]:r.CONSTANT_ALPHA,[qy]:r.ONE_MINUS_CONSTANT_ALPHA};function Q(F,ft,lt,Rt,ot,J,Ft,ee,Ie,Se){if(F===Di){x===!0&&(ht(r.BLEND),x=!1);return}if(x===!1&&(ct(r.BLEND),x=!0),F!==Yp){if(F!==g||Se!==b){if((m!==Qs||_!==Qs)&&(r.blendEquation(r.FUNC_ADD),m=Qs,_=Qs),Se)switch(F){case nr:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case uu:r.blendFunc(r.ONE,r.ONE);break;case Mp:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Sp:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:Vt("WebGLState: Invalid blending: ",F);break}else switch(F){case nr:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case uu:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case Mp:Vt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Sp:Vt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Vt("WebGLState: Invalid blending: ",F);break}y=null,v=null,w=null,T=null,E.set(0,0,0),M=0,g=F,b=Se}return}ot=ot||ft,J=J||lt,Ft=Ft||Rt,(ft!==m||ot!==_)&&(r.blendEquationSeparate(Ae[ft],Ae[ot]),m=ft,_=ot),(lt!==y||Rt!==v||J!==w||Ft!==T)&&(r.blendFuncSeparate(ie[lt],ie[Rt],ie[J],ie[Ft]),y=lt,v=Rt,w=J,T=Ft),(ee.equals(E)===!1||Ie!==M)&&(r.blendColor(ee.r,ee.g,ee.b,Ie),E.copy(ee),M=Ie),g=F,b=!1}function rt(F,ft){F.side===Ri?ht(r.CULL_FACE):ct(r.CULL_FACE);let lt=F.side===An;ft&&(lt=!lt),et(lt),F.blending===nr&&F.transparent===!1?Q(Di):Q(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);const Rt=F.stencilWrite;a.setTest(Rt),Rt&&(a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass)),$t(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?ct(r.SAMPLE_ALPHA_TO_COVERAGE):ht(r.SAMPLE_ALPHA_TO_COVERAGE)}function et(F){P!==F&&(F?r.frontFace(r.CW):r.frontFace(r.CCW),P=F)}function yt(F){F!==Ny?(ct(r.CULL_FACE),F!==N&&(F===vp?r.cullFace(r.BACK):F===Ry?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):ht(r.CULL_FACE),N=F}function I(F){F!==L&&(k&&r.lineWidth(F),L=F)}function $t(F,ft,lt){F?(ct(r.POLYGON_OFFSET_FILL),(U!==ft||V!==lt)&&(U=ft,V=lt,o.getReversed()&&(ft=-ft),r.polygonOffset(ft,lt))):ht(r.POLYGON_OFFSET_FILL)}function Tt(F){F?ct(r.SCISSOR_TEST):ht(r.SCISSOR_TEST)}function Yt(F){F===void 0&&(F=r.TEXTURE0+O-1),nt!==F&&(r.activeTexture(F),nt=F)}function ut(F,ft,lt){lt===void 0&&(nt===null?lt=r.TEXTURE0+O-1:lt=nt);let Rt=mt[lt];Rt===void 0&&(Rt={type:void 0,texture:void 0},mt[lt]=Rt),(Rt.type!==F||Rt.texture!==ft)&&(nt!==lt&&(r.activeTexture(lt),nt=lt),r.bindTexture(F,ft||j[F]),Rt.type=F,Rt.texture=ft)}function C(){const F=mt[nt];F!==void 0&&F.type!==void 0&&(r.bindTexture(F.type,null),F.type=void 0,F.texture=void 0)}function S(){try{r.compressedTexImage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function D(){try{r.compressedTexImage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function Y(){try{r.texSubImage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function K(){try{r.texSubImage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function Z(){try{r.compressedTexSubImage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function It(){try{r.compressedTexSubImage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function dt(){try{r.texStorage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function Ht(){try{r.texStorage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function Zt(){try{r.texImage2D(...arguments)}catch(F){Vt("WebGLState:",F)}}function st(){try{r.texImage3D(...arguments)}catch(F){Vt("WebGLState:",F)}}function at(F){jt.equals(F)===!1&&(r.scissor(F.x,F.y,F.z,F.w),jt.copy(F))}function Lt(F){Me.equals(F)===!1&&(r.viewport(F.x,F.y,F.z,F.w),Me.copy(F))}function Dt(F,ft){let lt=c.get(ft);lt===void 0&&(lt=new WeakMap,c.set(ft,lt));let Rt=lt.get(F);Rt===void 0&&(Rt=r.getUniformBlockIndex(ft,F.name),lt.set(F,Rt))}function Et(F,ft){const Rt=c.get(ft).get(F);l.get(ft)!==Rt&&(r.uniformBlockBinding(ft,Rt,F.__bindingPointIndex),l.set(ft,Rt))}function ce(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),o.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},nt=null,mt={},u={},d=new WeakMap,f=[],p=null,x=!1,g=null,m=null,y=null,v=null,_=null,w=null,T=null,E=new wt(0,0,0),M=0,b=!1,P=null,N=null,L=null,U=null,V=null,jt.set(0,0,r.canvas.width,r.canvas.height),Me.set(0,0,r.canvas.width,r.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:ct,disable:ht,bindFramebuffer:qt,drawBuffers:Xt,useProgram:Kt,setBlending:Q,setMaterial:rt,setFlipSided:et,setCullFace:yt,setLineWidth:I,setPolygonOffset:$t,setScissorTest:Tt,activeTexture:Yt,bindTexture:ut,unbindTexture:C,compressedTexImage2D:S,compressedTexImage3D:D,texImage2D:Zt,texImage3D:st,updateUBOMapping:Dt,uniformBlockBinding:Et,texStorage2D:dt,texStorage3D:Ht,texSubImage2D:Y,texSubImage3D:K,compressedTexSubImage2D:Z,compressedTexSubImage3D:It,scissor:at,viewport:Lt,reset:ce}}function tN(r,t,e,n,i,s,o){const a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new tt,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(C,S){return f?new OffscreenCanvas(C,S):Kl("canvas")}function x(C,S,D){let Y=1;const K=ut(C);if((K.width>D||K.height>D)&&(Y=D/Math.max(K.width,K.height)),Y<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const Z=Math.floor(Y*K.width),It=Math.floor(Y*K.height);u===void 0&&(u=p(Z,It));const dt=S?p(Z,It):u;return dt.width=Z,dt.height=It,dt.getContext("2d").drawImage(C,0,0,Z,It),pt("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+Z+"x"+It+")."),dt}else return"data"in C&&pt("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),C;return C}function g(C){return C.generateMipmaps}function m(C){r.generateMipmap(C)}function y(C){return C.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?r.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function v(C,S,D,Y,K=!1){if(C!==null){if(r[C]!==void 0)return r[C];pt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let Z=S;if(S===r.RED&&(D===r.FLOAT&&(Z=r.R32F),D===r.HALF_FLOAT&&(Z=r.R16F),D===r.UNSIGNED_BYTE&&(Z=r.R8)),S===r.RED_INTEGER&&(D===r.UNSIGNED_BYTE&&(Z=r.R8UI),D===r.UNSIGNED_SHORT&&(Z=r.R16UI),D===r.UNSIGNED_INT&&(Z=r.R32UI),D===r.BYTE&&(Z=r.R8I),D===r.SHORT&&(Z=r.R16I),D===r.INT&&(Z=r.R32I)),S===r.RG&&(D===r.FLOAT&&(Z=r.RG32F),D===r.HALF_FLOAT&&(Z=r.RG16F),D===r.UNSIGNED_BYTE&&(Z=r.RG8)),S===r.RG_INTEGER&&(D===r.UNSIGNED_BYTE&&(Z=r.RG8UI),D===r.UNSIGNED_SHORT&&(Z=r.RG16UI),D===r.UNSIGNED_INT&&(Z=r.RG32UI),D===r.BYTE&&(Z=r.RG8I),D===r.SHORT&&(Z=r.RG16I),D===r.INT&&(Z=r.RG32I)),S===r.RGB_INTEGER&&(D===r.UNSIGNED_BYTE&&(Z=r.RGB8UI),D===r.UNSIGNED_SHORT&&(Z=r.RGB16UI),D===r.UNSIGNED_INT&&(Z=r.RGB32UI),D===r.BYTE&&(Z=r.RGB8I),D===r.SHORT&&(Z=r.RGB16I),D===r.INT&&(Z=r.RGB32I)),S===r.RGBA_INTEGER&&(D===r.UNSIGNED_BYTE&&(Z=r.RGBA8UI),D===r.UNSIGNED_SHORT&&(Z=r.RGBA16UI),D===r.UNSIGNED_INT&&(Z=r.RGBA32UI),D===r.BYTE&&(Z=r.RGBA8I),D===r.SHORT&&(Z=r.RGBA16I),D===r.INT&&(Z=r.RGBA32I)),S===r.RGB&&(D===r.UNSIGNED_INT_5_9_9_9_REV&&(Z=r.RGB9_E5),D===r.UNSIGNED_INT_10F_11F_11F_REV&&(Z=r.R11F_G11F_B10F)),S===r.RGBA){const It=K?Jl:fe.getTransfer(Y);D===r.FLOAT&&(Z=r.RGBA32F),D===r.HALF_FLOAT&&(Z=r.RGBA16F),D===r.UNSIGNED_BYTE&&(Z=It===_e?r.SRGB8_ALPHA8:r.RGBA8),D===r.UNSIGNED_SHORT_4_4_4_4&&(Z=r.RGBA4),D===r.UNSIGNED_SHORT_5_5_5_1&&(Z=r.RGB5_A1)}return(Z===r.R16F||Z===r.R32F||Z===r.RG16F||Z===r.RG32F||Z===r.RGBA16F||Z===r.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function _(C,S){let D;return C?S===null||S===ii||S===Yr?D=r.DEPTH24_STENCIL8:S===Tn?D=r.DEPTH32F_STENCIL8:S===ca&&(D=r.DEPTH24_STENCIL8,pt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===ii||S===Yr?D=r.DEPTH_COMPONENT24:S===Tn?D=r.DEPTH_COMPONENT32F:S===ca&&(D=r.DEPTH_COMPONENT16),D}function w(C,S){return g(C)===!0||C.isFramebufferTexture&&C.minFilter!==Xe&&C.minFilter!==Fe?Math.log2(Math.max(S.width,S.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?S.mipmaps.length:1}function T(C){const S=C.target;S.removeEventListener("dispose",T),M(S),S.isVideoTexture&&h.delete(S)}function E(C){const S=C.target;S.removeEventListener("dispose",E),P(S)}function M(C){const S=n.get(C);if(S.__webglInit===void 0)return;const D=C.source,Y=d.get(D);if(Y){const K=Y[S.__cacheKey];K.usedTimes--,K.usedTimes===0&&b(C),Object.keys(Y).length===0&&d.delete(D)}n.remove(C)}function b(C){const S=n.get(C);r.deleteTexture(S.__webglTexture);const D=C.source,Y=d.get(D);delete Y[S.__cacheKey],o.memory.textures--}function P(C){const S=n.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),n.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(S.__webglFramebuffer[Y]))for(let K=0;K<S.__webglFramebuffer[Y].length;K++)r.deleteFramebuffer(S.__webglFramebuffer[Y][K]);else r.deleteFramebuffer(S.__webglFramebuffer[Y]);S.__webglDepthbuffer&&r.deleteRenderbuffer(S.__webglDepthbuffer[Y])}else{if(Array.isArray(S.__webglFramebuffer))for(let Y=0;Y<S.__webglFramebuffer.length;Y++)r.deleteFramebuffer(S.__webglFramebuffer[Y]);else r.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&r.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&r.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let Y=0;Y<S.__webglColorRenderbuffer.length;Y++)S.__webglColorRenderbuffer[Y]&&r.deleteRenderbuffer(S.__webglColorRenderbuffer[Y]);S.__webglDepthRenderbuffer&&r.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const D=C.textures;for(let Y=0,K=D.length;Y<K;Y++){const Z=n.get(D[Y]);Z.__webglTexture&&(r.deleteTexture(Z.__webglTexture),o.memory.textures--),n.remove(D[Y])}n.remove(C)}let N=0;function L(){N=0}function U(){const C=N;return C>=i.maxTextures&&pt("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+i.maxTextures),N+=1,C}function V(C){const S=[];return S.push(C.wrapS),S.push(C.wrapT),S.push(C.wrapR||0),S.push(C.magFilter),S.push(C.minFilter),S.push(C.anisotropy),S.push(C.internalFormat),S.push(C.format),S.push(C.type),S.push(C.generateMipmaps),S.push(C.premultiplyAlpha),S.push(C.flipY),S.push(C.unpackAlignment),S.push(C.colorSpace),S.join()}function O(C,S){const D=n.get(C);if(C.isVideoTexture&&Tt(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&D.__version!==C.version){const Y=C.image;if(Y===null)pt("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)pt("WebGLRenderer: Texture marked for update but image is incomplete");else{j(D,C,S);return}}else C.isExternalTexture&&(D.__webglTexture=C.sourceTexture?C.sourceTexture:null);e.bindTexture(r.TEXTURE_2D,D.__webglTexture,r.TEXTURE0+S)}function k(C,S){const D=n.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&D.__version!==C.version){j(D,C,S);return}else C.isExternalTexture&&(D.__webglTexture=C.sourceTexture?C.sourceTexture:null);e.bindTexture(r.TEXTURE_2D_ARRAY,D.__webglTexture,r.TEXTURE0+S)}function G(C,S){const D=n.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&D.__version!==C.version){j(D,C,S);return}e.bindTexture(r.TEXTURE_3D,D.__webglTexture,r.TEXTURE0+S)}function it(C,S){const D=n.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&D.__version!==C.version){ct(D,C,S);return}e.bindTexture(r.TEXTURE_CUBE_MAP,D.__webglTexture,r.TEXTURE0+S)}const nt={[aa]:r.REPEAT,[Bn]:r.CLAMP_TO_EDGE,[la]:r.MIRRORED_REPEAT},mt={[Xe]:r.NEAREST,[Ju]:r.NEAREST_MIPMAP_NEAREST,[zr]:r.NEAREST_MIPMAP_LINEAR,[Fe]:r.LINEAR,[Qo]:r.LINEAR_MIPMAP_NEAREST,[Li]:r.LINEAR_MIPMAP_LINEAR},xt={[__]:r.NEVER,[T_]:r.ALWAYS,[v_]:r.LESS,[sd]:r.LEQUAL,[M_]:r.EQUAL,[rd]:r.GEQUAL,[S_]:r.GREATER,[b_]:r.NOTEQUAL};function bt(C,S){if(S.type===Tn&&t.has("OES_texture_float_linear")===!1&&(S.magFilter===Fe||S.magFilter===Qo||S.magFilter===zr||S.magFilter===Li||S.minFilter===Fe||S.minFilter===Qo||S.minFilter===zr||S.minFilter===Li)&&pt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(C,r.TEXTURE_WRAP_S,nt[S.wrapS]),r.texParameteri(C,r.TEXTURE_WRAP_T,nt[S.wrapT]),(C===r.TEXTURE_3D||C===r.TEXTURE_2D_ARRAY)&&r.texParameteri(C,r.TEXTURE_WRAP_R,nt[S.wrapR]),r.texParameteri(C,r.TEXTURE_MAG_FILTER,mt[S.magFilter]),r.texParameteri(C,r.TEXTURE_MIN_FILTER,mt[S.minFilter]),S.compareFunction&&(r.texParameteri(C,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(C,r.TEXTURE_COMPARE_FUNC,xt[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Xe||S.minFilter!==zr&&S.minFilter!==Li||S.type===Tn&&t.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){const D=t.get("EXT_texture_filter_anisotropic");r.texParameterf(C,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function jt(C,S){let D=!1;C.__webglInit===void 0&&(C.__webglInit=!0,S.addEventListener("dispose",T));const Y=S.source;let K=d.get(Y);K===void 0&&(K={},d.set(Y,K));const Z=V(S);if(Z!==C.__cacheKey){K[Z]===void 0&&(K[Z]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,D=!0),K[Z].usedTimes++;const It=K[C.__cacheKey];It!==void 0&&(K[C.__cacheKey].usedTimes--,It.usedTimes===0&&b(S)),C.__cacheKey=Z,C.__webglTexture=K[Z].texture}return D}function Me(C,S,D){return Math.floor(Math.floor(C/D)/S)}function we(C,S,D,Y){const Z=C.updateRanges;if(Z.length===0)e.texSubImage2D(r.TEXTURE_2D,0,0,0,S.width,S.height,D,Y,S.data);else{Z.sort((st,at)=>st.start-at.start);let It=0;for(let st=1;st<Z.length;st++){const at=Z[It],Lt=Z[st],Dt=at.start+at.count,Et=Me(Lt.start,S.width,4),ce=Me(at.start,S.width,4);Lt.start<=Dt+1&&Et===ce&&Me(Lt.start+Lt.count-1,S.width,4)===Et?at.count=Math.max(at.count,Lt.start+Lt.count-at.start):(++It,Z[It]=Lt)}Z.length=It+1;const dt=r.getParameter(r.UNPACK_ROW_LENGTH),Ht=r.getParameter(r.UNPACK_SKIP_PIXELS),Zt=r.getParameter(r.UNPACK_SKIP_ROWS);r.pixelStorei(r.UNPACK_ROW_LENGTH,S.width);for(let st=0,at=Z.length;st<at;st++){const Lt=Z[st],Dt=Math.floor(Lt.start/4),Et=Math.ceil(Lt.count/4),ce=Dt%S.width,F=Math.floor(Dt/S.width),ft=Et,lt=1;r.pixelStorei(r.UNPACK_SKIP_PIXELS,ce),r.pixelStorei(r.UNPACK_SKIP_ROWS,F),e.texSubImage2D(r.TEXTURE_2D,0,ce,F,ft,lt,D,Y,S.data)}C.clearUpdateRanges(),r.pixelStorei(r.UNPACK_ROW_LENGTH,dt),r.pixelStorei(r.UNPACK_SKIP_PIXELS,Ht),r.pixelStorei(r.UNPACK_SKIP_ROWS,Zt)}}function j(C,S,D){let Y=r.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(Y=r.TEXTURE_2D_ARRAY),S.isData3DTexture&&(Y=r.TEXTURE_3D);const K=jt(C,S),Z=S.source;e.bindTexture(Y,C.__webglTexture,r.TEXTURE0+D);const It=n.get(Z);if(Z.version!==It.__version||K===!0){e.activeTexture(r.TEXTURE0+D);const dt=fe.getPrimaries(fe.workingColorSpace),Ht=S.colorSpace===Ki?null:fe.getPrimaries(S.colorSpace),Zt=S.colorSpace===Ki||dt===Ht?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Zt);let st=x(S.image,!1,i.maxTextureSize);st=Yt(S,st);const at=s.convert(S.format,S.colorSpace),Lt=s.convert(S.type);let Dt=v(S.internalFormat,at,Lt,S.colorSpace,S.isVideoTexture);bt(Y,S);let Et;const ce=S.mipmaps,F=S.isVideoTexture!==!0,ft=It.__version===void 0||K===!0,lt=Z.dataReady,Rt=w(S,st);if(S.isDepthTexture)Dt=_(S.format===Cs,S.type),ft&&(F?e.texStorage2D(r.TEXTURE_2D,1,Dt,st.width,st.height):e.texImage2D(r.TEXTURE_2D,0,Dt,st.width,st.height,0,at,Lt,null));else if(S.isDataTexture)if(ce.length>0){F&&ft&&e.texStorage2D(r.TEXTURE_2D,Rt,Dt,ce[0].width,ce[0].height);for(let ot=0,J=ce.length;ot<J;ot++)Et=ce[ot],F?lt&&e.texSubImage2D(r.TEXTURE_2D,ot,0,0,Et.width,Et.height,at,Lt,Et.data):e.texImage2D(r.TEXTURE_2D,ot,Dt,Et.width,Et.height,0,at,Lt,Et.data);S.generateMipmaps=!1}else F?(ft&&e.texStorage2D(r.TEXTURE_2D,Rt,Dt,st.width,st.height),lt&&we(S,st,at,Lt)):e.texImage2D(r.TEXTURE_2D,0,Dt,st.width,st.height,0,at,Lt,st.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){F&&ft&&e.texStorage3D(r.TEXTURE_2D_ARRAY,Rt,Dt,ce[0].width,ce[0].height,st.depth);for(let ot=0,J=ce.length;ot<J;ot++)if(Et=ce[ot],S.format!==wn)if(at!==null)if(F){if(lt)if(S.layerUpdates.size>0){const Ft=Ip(Et.width,Et.height,S.format,S.type);for(const ee of S.layerUpdates){const Ie=Et.data.subarray(ee*Ft/Et.data.BYTES_PER_ELEMENT,(ee+1)*Ft/Et.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ot,0,0,ee,Et.width,Et.height,1,at,Ie)}S.clearLayerUpdates()}else e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ot,0,0,0,Et.width,Et.height,st.depth,at,Et.data)}else e.compressedTexImage3D(r.TEXTURE_2D_ARRAY,ot,Dt,Et.width,Et.height,st.depth,0,Et.data,0,0);else pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else F?lt&&e.texSubImage3D(r.TEXTURE_2D_ARRAY,ot,0,0,0,Et.width,Et.height,st.depth,at,Lt,Et.data):e.texImage3D(r.TEXTURE_2D_ARRAY,ot,Dt,Et.width,Et.height,st.depth,0,at,Lt,Et.data)}else{F&&ft&&e.texStorage2D(r.TEXTURE_2D,Rt,Dt,ce[0].width,ce[0].height);for(let ot=0,J=ce.length;ot<J;ot++)Et=ce[ot],S.format!==wn?at!==null?F?lt&&e.compressedTexSubImage2D(r.TEXTURE_2D,ot,0,0,Et.width,Et.height,at,Et.data):e.compressedTexImage2D(r.TEXTURE_2D,ot,Dt,Et.width,Et.height,0,Et.data):pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):F?lt&&e.texSubImage2D(r.TEXTURE_2D,ot,0,0,Et.width,Et.height,at,Lt,Et.data):e.texImage2D(r.TEXTURE_2D,ot,Dt,Et.width,Et.height,0,at,Lt,Et.data)}else if(S.isDataArrayTexture)if(F){if(ft&&e.texStorage3D(r.TEXTURE_2D_ARRAY,Rt,Dt,st.width,st.height,st.depth),lt)if(S.layerUpdates.size>0){const ot=Ip(st.width,st.height,S.format,S.type);for(const J of S.layerUpdates){const Ft=st.data.subarray(J*ot/st.data.BYTES_PER_ELEMENT,(J+1)*ot/st.data.BYTES_PER_ELEMENT);e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,J,st.width,st.height,1,at,Lt,Ft)}S.clearLayerUpdates()}else e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,st.width,st.height,st.depth,at,Lt,st.data)}else e.texImage3D(r.TEXTURE_2D_ARRAY,0,Dt,st.width,st.height,st.depth,0,at,Lt,st.data);else if(S.isData3DTexture)F?(ft&&e.texStorage3D(r.TEXTURE_3D,Rt,Dt,st.width,st.height,st.depth),lt&&e.texSubImage3D(r.TEXTURE_3D,0,0,0,0,st.width,st.height,st.depth,at,Lt,st.data)):e.texImage3D(r.TEXTURE_3D,0,Dt,st.width,st.height,st.depth,0,at,Lt,st.data);else if(S.isFramebufferTexture){if(ft)if(F)e.texStorage2D(r.TEXTURE_2D,Rt,Dt,st.width,st.height);else{let ot=st.width,J=st.height;for(let Ft=0;Ft<Rt;Ft++)e.texImage2D(r.TEXTURE_2D,Ft,Dt,ot,J,0,at,Lt,null),ot>>=1,J>>=1}}else if(ce.length>0){if(F&&ft){const ot=ut(ce[0]);e.texStorage2D(r.TEXTURE_2D,Rt,Dt,ot.width,ot.height)}for(let ot=0,J=ce.length;ot<J;ot++)Et=ce[ot],F?lt&&e.texSubImage2D(r.TEXTURE_2D,ot,0,0,at,Lt,Et):e.texImage2D(r.TEXTURE_2D,ot,Dt,at,Lt,Et);S.generateMipmaps=!1}else if(F){if(ft){const ot=ut(st);e.texStorage2D(r.TEXTURE_2D,Rt,Dt,ot.width,ot.height)}lt&&e.texSubImage2D(r.TEXTURE_2D,0,0,0,at,Lt,st)}else e.texImage2D(r.TEXTURE_2D,0,Dt,at,Lt,st);g(S)&&m(Y),It.__version=Z.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function ct(C,S,D){if(S.image.length!==6)return;const Y=jt(C,S),K=S.source;e.bindTexture(r.TEXTURE_CUBE_MAP,C.__webglTexture,r.TEXTURE0+D);const Z=n.get(K);if(K.version!==Z.__version||Y===!0){e.activeTexture(r.TEXTURE0+D);const It=fe.getPrimaries(fe.workingColorSpace),dt=S.colorSpace===Ki?null:fe.getPrimaries(S.colorSpace),Ht=S.colorSpace===Ki||It===dt?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ht);const Zt=S.isCompressedTexture||S.image[0].isCompressedTexture,st=S.image[0]&&S.image[0].isDataTexture,at=[];for(let J=0;J<6;J++)!Zt&&!st?at[J]=x(S.image[J],!0,i.maxCubemapSize):at[J]=st?S.image[J].image:S.image[J],at[J]=Yt(S,at[J]);const Lt=at[0],Dt=s.convert(S.format,S.colorSpace),Et=s.convert(S.type),ce=v(S.internalFormat,Dt,Et,S.colorSpace),F=S.isVideoTexture!==!0,ft=Z.__version===void 0||Y===!0,lt=K.dataReady;let Rt=w(S,Lt);bt(r.TEXTURE_CUBE_MAP,S);let ot;if(Zt){F&&ft&&e.texStorage2D(r.TEXTURE_CUBE_MAP,Rt,ce,Lt.width,Lt.height);for(let J=0;J<6;J++){ot=at[J].mipmaps;for(let Ft=0;Ft<ot.length;Ft++){const ee=ot[Ft];S.format!==wn?Dt!==null?F?lt&&e.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft,0,0,ee.width,ee.height,Dt,ee.data):e.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft,ce,ee.width,ee.height,0,ee.data):pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft,0,0,ee.width,ee.height,Dt,Et,ee.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft,ce,ee.width,ee.height,0,Dt,Et,ee.data)}}}else{if(ot=S.mipmaps,F&&ft){ot.length>0&&Rt++;const J=ut(at[0]);e.texStorage2D(r.TEXTURE_CUBE_MAP,Rt,ce,J.width,J.height)}for(let J=0;J<6;J++)if(st){F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,at[J].width,at[J].height,Dt,Et,at[J].data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,ce,at[J].width,at[J].height,0,Dt,Et,at[J].data);for(let Ft=0;Ft<ot.length;Ft++){const Ie=ot[Ft].image[J].image;F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft+1,0,0,Ie.width,Ie.height,Dt,Et,Ie.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft+1,ce,Ie.width,Ie.height,0,Dt,Et,Ie.data)}}else{F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,Dt,Et,at[J]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,ce,Dt,Et,at[J]);for(let Ft=0;Ft<ot.length;Ft++){const ee=ot[Ft];F?lt&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft+1,0,0,Dt,Et,ee.image[J]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ft+1,ce,Dt,Et,ee.image[J])}}}g(S)&&m(r.TEXTURE_CUBE_MAP),Z.__version=K.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function ht(C,S,D,Y,K,Z){const It=s.convert(D.format,D.colorSpace),dt=s.convert(D.type),Ht=v(D.internalFormat,It,dt,D.colorSpace),Zt=n.get(S),st=n.get(D);if(st.__renderTarget=S,!Zt.__hasExternalTextures){const at=Math.max(1,S.width>>Z),Lt=Math.max(1,S.height>>Z);K===r.TEXTURE_3D||K===r.TEXTURE_2D_ARRAY?e.texImage3D(K,Z,Ht,at,Lt,S.depth,0,It,dt,null):e.texImage2D(K,Z,Ht,at,Lt,0,It,dt,null)}e.bindFramebuffer(r.FRAMEBUFFER,C),$t(S)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Y,K,st.__webglTexture,0,I(S)):(K===r.TEXTURE_2D||K>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,Y,K,st.__webglTexture,Z),e.bindFramebuffer(r.FRAMEBUFFER,null)}function qt(C,S,D){if(r.bindRenderbuffer(r.RENDERBUFFER,C),S.depthBuffer){const Y=S.depthTexture,K=Y&&Y.isDepthTexture?Y.type:null,Z=_(S.stencilBuffer,K),It=S.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;$t(S)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,I(S),Z,S.width,S.height):D?r.renderbufferStorageMultisample(r.RENDERBUFFER,I(S),Z,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,Z,S.width,S.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,It,r.RENDERBUFFER,C)}else{const Y=S.textures;for(let K=0;K<Y.length;K++){const Z=Y[K],It=s.convert(Z.format,Z.colorSpace),dt=s.convert(Z.type),Ht=v(Z.internalFormat,It,dt,Z.colorSpace);$t(S)?a.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,I(S),Ht,S.width,S.height):D?r.renderbufferStorageMultisample(r.RENDERBUFFER,I(S),Ht,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,Ht,S.width,S.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Xt(C,S,D){const Y=S.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(r.FRAMEBUFFER,C),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const K=n.get(S.depthTexture);if(K.__renderTarget=S,(!K.__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),Y){if(K.__webglInit===void 0&&(K.__webglInit=!0,S.depthTexture.addEventListener("dispose",T)),K.__webglTexture===void 0){K.__webglTexture=r.createTexture(),e.bindTexture(r.TEXTURE_CUBE_MAP,K.__webglTexture),bt(r.TEXTURE_CUBE_MAP,S.depthTexture);const Zt=s.convert(S.depthTexture.format),st=s.convert(S.depthTexture.type);let at;S.depthTexture.format===Oi?at=r.DEPTH_COMPONENT24:S.depthTexture.format===Cs&&(at=r.DEPTH24_STENCIL8);for(let Lt=0;Lt<6;Lt++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Lt,0,at,S.width,S.height,0,Zt,st,null)}}else O(S.depthTexture,0);const Z=K.__webglTexture,It=I(S),dt=Y?r.TEXTURE_CUBE_MAP_POSITIVE_X+D:r.TEXTURE_2D,Ht=S.depthTexture.format===Cs?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;if(S.depthTexture.format===Oi)$t(S)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Ht,dt,Z,0,It):r.framebufferTexture2D(r.FRAMEBUFFER,Ht,dt,Z,0);else if(S.depthTexture.format===Cs)$t(S)?a.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Ht,dt,Z,0,It):r.framebufferTexture2D(r.FRAMEBUFFER,Ht,dt,Z,0);else throw new Error("Unknown depthTexture format")}function Kt(C){const S=n.get(C),D=C.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==C.depthTexture){const Y=C.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),Y){const K=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,Y.removeEventListener("dispose",K)};Y.addEventListener("dispose",K),S.__depthDisposeCallback=K}S.__boundDepthTexture=Y}if(C.depthTexture&&!S.__autoAllocateDepthBuffer)if(D)for(let Y=0;Y<6;Y++)Xt(S.__webglFramebuffer[Y],C,Y);else{const Y=C.texture.mipmaps;Y&&Y.length>0?Xt(S.__webglFramebuffer[0],C,0):Xt(S.__webglFramebuffer,C,0)}else if(D){S.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer[Y]),S.__webglDepthbuffer[Y]===void 0)S.__webglDepthbuffer[Y]=r.createRenderbuffer(),qt(S.__webglDepthbuffer[Y],C,!1);else{const K=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Z=S.__webglDepthbuffer[Y];r.bindRenderbuffer(r.RENDERBUFFER,Z),r.framebufferRenderbuffer(r.FRAMEBUFFER,K,r.RENDERBUFFER,Z)}}else{const Y=C.texture.mipmaps;if(Y&&Y.length>0?e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer[0]):e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=r.createRenderbuffer(),qt(S.__webglDepthbuffer,C,!1);else{const K=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Z=S.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,Z),r.framebufferRenderbuffer(r.FRAMEBUFFER,K,r.RENDERBUFFER,Z)}}e.bindFramebuffer(r.FRAMEBUFFER,null)}function Ae(C,S,D){const Y=n.get(C);S!==void 0&&ht(Y.__webglFramebuffer,C,C.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),D!==void 0&&Kt(C)}function ie(C){const S=C.texture,D=n.get(C),Y=n.get(S);C.addEventListener("dispose",E);const K=C.textures,Z=C.isWebGLCubeRenderTarget===!0,It=K.length>1;if(It||(Y.__webglTexture===void 0&&(Y.__webglTexture=r.createTexture()),Y.__version=S.version,o.memory.textures++),Z){D.__webglFramebuffer=[];for(let dt=0;dt<6;dt++)if(S.mipmaps&&S.mipmaps.length>0){D.__webglFramebuffer[dt]=[];for(let Ht=0;Ht<S.mipmaps.length;Ht++)D.__webglFramebuffer[dt][Ht]=r.createFramebuffer()}else D.__webglFramebuffer[dt]=r.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){D.__webglFramebuffer=[];for(let dt=0;dt<S.mipmaps.length;dt++)D.__webglFramebuffer[dt]=r.createFramebuffer()}else D.__webglFramebuffer=r.createFramebuffer();if(It)for(let dt=0,Ht=K.length;dt<Ht;dt++){const Zt=n.get(K[dt]);Zt.__webglTexture===void 0&&(Zt.__webglTexture=r.createTexture(),o.memory.textures++)}if(C.samples>0&&$t(C)===!1){D.__webglMultisampledFramebuffer=r.createFramebuffer(),D.__webglColorRenderbuffer=[],e.bindFramebuffer(r.FRAMEBUFFER,D.__webglMultisampledFramebuffer);for(let dt=0;dt<K.length;dt++){const Ht=K[dt];D.__webglColorRenderbuffer[dt]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,D.__webglColorRenderbuffer[dt]);const Zt=s.convert(Ht.format,Ht.colorSpace),st=s.convert(Ht.type),at=v(Ht.internalFormat,Zt,st,Ht.colorSpace,C.isXRRenderTarget===!0),Lt=I(C);r.renderbufferStorageMultisample(r.RENDERBUFFER,Lt,at,C.width,C.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+dt,r.RENDERBUFFER,D.__webglColorRenderbuffer[dt])}r.bindRenderbuffer(r.RENDERBUFFER,null),C.depthBuffer&&(D.__webglDepthRenderbuffer=r.createRenderbuffer(),qt(D.__webglDepthRenderbuffer,C,!0)),e.bindFramebuffer(r.FRAMEBUFFER,null)}}if(Z){e.bindTexture(r.TEXTURE_CUBE_MAP,Y.__webglTexture),bt(r.TEXTURE_CUBE_MAP,S);for(let dt=0;dt<6;dt++)if(S.mipmaps&&S.mipmaps.length>0)for(let Ht=0;Ht<S.mipmaps.length;Ht++)ht(D.__webglFramebuffer[dt][Ht],C,S,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+dt,Ht);else ht(D.__webglFramebuffer[dt],C,S,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+dt,0);g(S)&&m(r.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(It){for(let dt=0,Ht=K.length;dt<Ht;dt++){const Zt=K[dt],st=n.get(Zt);let at=r.TEXTURE_2D;(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(at=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(at,st.__webglTexture),bt(at,Zt),ht(D.__webglFramebuffer,C,Zt,r.COLOR_ATTACHMENT0+dt,at,0),g(Zt)&&m(at)}e.unbindTexture()}else{let dt=r.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(dt=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(dt,Y.__webglTexture),bt(dt,S),S.mipmaps&&S.mipmaps.length>0)for(let Ht=0;Ht<S.mipmaps.length;Ht++)ht(D.__webglFramebuffer[Ht],C,S,r.COLOR_ATTACHMENT0,dt,Ht);else ht(D.__webglFramebuffer,C,S,r.COLOR_ATTACHMENT0,dt,0);g(S)&&m(dt),e.unbindTexture()}C.depthBuffer&&Kt(C)}function Q(C){const S=C.textures;for(let D=0,Y=S.length;D<Y;D++){const K=S[D];if(g(K)){const Z=y(C),It=n.get(K).__webglTexture;e.bindTexture(Z,It),m(Z),e.unbindTexture()}}}const rt=[],et=[];function yt(C){if(C.samples>0){if($t(C)===!1){const S=C.textures,D=C.width,Y=C.height;let K=r.COLOR_BUFFER_BIT;const Z=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,It=n.get(C),dt=S.length>1;if(dt)for(let Zt=0;Zt<S.length;Zt++)e.bindFramebuffer(r.FRAMEBUFFER,It.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Zt,r.RENDERBUFFER,null),e.bindFramebuffer(r.FRAMEBUFFER,It.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Zt,r.TEXTURE_2D,null,0);e.bindFramebuffer(r.READ_FRAMEBUFFER,It.__webglMultisampledFramebuffer);const Ht=C.texture.mipmaps;Ht&&Ht.length>0?e.bindFramebuffer(r.DRAW_FRAMEBUFFER,It.__webglFramebuffer[0]):e.bindFramebuffer(r.DRAW_FRAMEBUFFER,It.__webglFramebuffer);for(let Zt=0;Zt<S.length;Zt++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(K|=r.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(K|=r.STENCIL_BUFFER_BIT)),dt){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,It.__webglColorRenderbuffer[Zt]);const st=n.get(S[Zt]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,st,0)}r.blitFramebuffer(0,0,D,Y,0,0,D,Y,K,r.NEAREST),l===!0&&(rt.length=0,et.length=0,rt.push(r.COLOR_ATTACHMENT0+Zt),C.depthBuffer&&C.resolveDepthBuffer===!1&&(rt.push(Z),et.push(Z),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,et)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,rt))}if(e.bindFramebuffer(r.READ_FRAMEBUFFER,null),e.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),dt)for(let Zt=0;Zt<S.length;Zt++){e.bindFramebuffer(r.FRAMEBUFFER,It.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Zt,r.RENDERBUFFER,It.__webglColorRenderbuffer[Zt]);const st=n.get(S[Zt]).__webglTexture;e.bindFramebuffer(r.FRAMEBUFFER,It.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Zt,r.TEXTURE_2D,st,0)}e.bindFramebuffer(r.DRAW_FRAMEBUFFER,It.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const S=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[S])}}}function I(C){return Math.min(i.maxSamples,C.samples)}function $t(C){const S=n.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Tt(C){const S=o.render.frame;h.get(C)!==S&&(h.set(C,S),C.update())}function Yt(C,S){const D=C.colorSpace,Y=C.format,K=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||D!==lr&&D!==Ki&&(fe.getTransfer(D)===_e?(Y!==wn||K!==Un)&&pt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Vt("WebGLTextures: Unsupported texture color space:",D)),S}function ut(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=U,this.resetTextureUnits=L,this.setTexture2D=O,this.setTexture2DArray=k,this.setTexture3D=G,this.setTextureCube=it,this.rebindTextures=Ae,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Kt,this.setupFrameBufferTexture=ht,this.useMultisampledRTT=$t,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function zv(r,t){function e(n,i=Ki){let s;const o=fe.getTransfer(i);if(n===Un)return r.UNSIGNED_BYTE;if(n===Ku)return r.UNSIGNED_SHORT_4_4_4_4;if(n===Qu)return r.UNSIGNED_SHORT_5_5_5_1;if(n===td)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===ed)return r.UNSIGNED_INT_10F_11F_11F_REV;if(n===Kp)return r.BYTE;if(n===Qp)return r.SHORT;if(n===ca)return r.UNSIGNED_SHORT;if(n===ju)return r.INT;if(n===ii)return r.UNSIGNED_INT;if(n===Tn)return r.FLOAT;if(n===Ui)return r.HALF_FLOAT;if(n===tm)return r.ALPHA;if(n===nd)return r.RGB;if(n===wn)return r.RGBA;if(n===Oi)return r.DEPTH_COMPONENT;if(n===Cs)return r.DEPTH_STENCIL;if(n===dc)return r.RED;if(n===Sa)return r.RED_INTEGER;if(n===ar)return r.RG;if(n===fc)return r.RG_INTEGER;if(n===pc)return r.RGBA_INTEGER;if(n===ta||n===ea||n===dl||n===na)if(o===_e)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===ta)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===dl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===na)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===ta)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ea)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===dl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===na)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Rl||n===pu||n===Il||n===Pl)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Rl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===pu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Il)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Pl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ll||n===Fl||n===Dl||n===Ul||n===Ol||n===Bl||n===zl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Ll||n===Fl)return o===_e?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Dl)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===Ul)return s.COMPRESSED_R11_EAC;if(n===Ol)return s.COMPRESSED_SIGNED_R11_EAC;if(n===Bl)return s.COMPRESSED_RG11_EAC;if(n===zl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Vl||n===mu||n===gu||n===xu||n===kl||n===yu||n===_u||n===vu||n===Mu||n===Su||n===bu||n===Tu||n===wu||n===Au)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Vl)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===mu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===gu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===xu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===kl)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===yu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===_u)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===vu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Mu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Su)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===bu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Tu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===wu)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Au)return o===_e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Gl||n===Eu||n===Hl)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===Gl)return o===_e?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Eu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Hl)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Wl||n===Xl||n===$l||n===ql)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===Wl)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Xl)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===$l)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ql)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Yr?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:e}}const eN=`
|
|
4034
4034
|
void main() {
|
|
4035
4035
|
|
|
4036
4036
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -4054,10 +4054,10 @@ void main() {
|
|
|
4054
4054
|
|
|
4055
4055
|
}
|
|
4056
4056
|
|
|
4057
|
-
}`;class iN{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new vm(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new si({vertexShader:eN,fragmentShader:nN,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ye(new io(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class sN extends Bi{constructor(t,e){super();const n=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,p=null;const x=typeof XRWebGLBinding<"u",g=new iN,m={},y=e.getContextAttributes();let v=null,_=null;const w=[],T=[],E=new tt;let M=null;const b=new cn;b.viewport=new Le;const P=new cn;P.viewport=new Le;const N=[b,P],L=new Zm;let U=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(j){let ct=w[j];return ct===void 0&&(ct=new au,w[j]=ct),ct.getTargetRaySpace()},this.getControllerGrip=function(j){let ct=w[j];return ct===void 0&&(ct=new au,w[j]=ct),ct.getGripSpace()},this.getHand=function(j){let ct=w[j];return ct===void 0&&(ct=new au,w[j]=ct),ct.getHandSpace()};function O(j){const ct=T.indexOf(j.inputSource);if(ct===-1)return;const ht=w[ct];ht!==void 0&&(ht.update(j.inputSource,j.frame,c||o),ht.dispatchEvent({type:j.type,data:j.inputSource}))}function k(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",k),i.removeEventListener("inputsourceschange",G);for(let j=0;j<w.length;j++){const ct=T[j];ct!==null&&(T[j]=null,w[j]&&w[j].disconnect(ct))}U=null,V=null,g.reset();for(const j in m)delete m[j];t.setRenderTarget(v),f=null,d=null,u=null,i=null,_=null,we.stop(),n.isPresenting=!1,t.setPixelRatio(M),t.setSize(E.width,E.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,n.isPresenting===!0&&pt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){a=j,n.isPresenting===!0&&pt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(i,e)),u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(j){if(i=j,i!==null){if(v=t.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",k),i.addEventListener("inputsourceschange",G),y.xrCompatible!==!0&&await e.makeXRCompatible(),M=t.getPixelRatio(),t.getSize(E),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ht=null,qt=null,Xt=null;y.depth&&(Xt=y.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,ht=y.stencil?Cs:Oi,qt=y.stencil?Yr:ii);const Kt={colorFormat:e.RGBA8,depthFormat:Xt,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Kt),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),_=new qn(d.textureWidth,d.textureHeight,{format:wn,type:Un,depthTexture:new jr(d.textureWidth,d.textureHeight,qt,void 0,void 0,void 0,void 0,void 0,void 0,ht),stencilBuffer:y.stencil,colorSpace:t.outputColorSpace,samples:y.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ht={antialias:y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,ht),i.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new qn(f.framebufferWidth,f.framebufferHeight,{format:wn,type:Un,colorSpace:t.outputColorSpace,stencilBuffer:y.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),we.setContext(i),we.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function G(j){for(let ct=0;ct<j.removed.length;ct++){const ht=j.removed[ct],qt=T.indexOf(ht);qt>=0&&(T[qt]=null,w[qt]&&w[qt].disconnect(ht))}for(let ct=0;ct<j.added.length;ct++){const ht=j.added[ct];let qt=T.indexOf(ht);if(qt===-1){for(let Kt=0;Kt<w.length;Kt++)if(Kt>=T.length){T.push(ht),qt=Kt;break}else if(T[Kt]===null){T[Kt]=ht,qt=Kt;break}if(qt===-1)break}const Xt=w[qt];Xt&&Xt.connect(ht)}}const it=new R,nt=new R;function mt(j,ct,ht){it.setFromMatrixPosition(ct.matrixWorld),nt.setFromMatrixPosition(ht.matrixWorld);const qt=it.distanceTo(nt),Xt=ct.projectionMatrix.elements,Kt=ht.projectionMatrix.elements,Ae=Xt[14]/(Xt[10]-1),ie=Xt[14]/(Xt[10]+1),Q=(Xt[9]+1)/Xt[5],rt=(Xt[9]-1)/Xt[5],et=(Xt[8]-1)/Xt[0],yt=(Kt[8]+1)/Kt[0],I=Ae*et,$t=Ae*yt,Tt=qt/(-et+yt),Yt=Tt*-et;if(ct.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Yt),j.translateZ(Tt),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),Xt[10]===-1)j.projectionMatrix.copy(ct.projectionMatrix),j.projectionMatrixInverse.copy(ct.projectionMatrixInverse);else{const ut=Ae+Tt,C=ie+Tt,S=I-Yt,D=$t+(qt-Yt),Y=Q*ie/C*ut,K=rt*ie/C*ut;j.projectionMatrix.makePerspective(S,D,Y,K,ut,C),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function xt(j,ct){ct===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(ct.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(i===null)return;let ct=j.near,ht=j.far;g.texture!==null&&(g.depthNear>0&&(ct=g.depthNear),g.depthFar>0&&(ht=g.depthFar)),L.near=P.near=b.near=ct,L.far=P.far=b.far=ht,(U!==L.near||V!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),U=L.near,V=L.far),L.layers.mask=j.layers.mask|6,b.layers.mask=L.layers.mask&-5,P.layers.mask=L.layers.mask&-3;const qt=j.parent,Xt=L.cameras;xt(L,qt);for(let Kt=0;Kt<Xt.length;Kt++)xt(Xt[Kt],qt);Xt.length===2?mt(L,b,P):L.projectionMatrix.copy(b.projectionMatrix),bt(j,L,qt)};function bt(j,ct,ht){ht===null?j.matrix.copy(ct.matrixWorld):(j.matrix.copy(ht.matrixWorld),j.matrix.invert(),j.matrix.multiply(ct.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(ct.projectionMatrix),j.projectionMatrixInverse.copy(ct.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=ha*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(j){l=j,d!==null&&(d.fixedFoveation=j),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=j)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(L)},this.getCameraTexture=function(j){return m[j]};let jt=null;function Me(j,ct){if(h=ct.getViewerPose(c||o),p=ct,h!==null){const ht=h.views;f!==null&&(t.setRenderTargetFramebuffer(_,f.framebuffer),t.setRenderTarget(_));let qt=!1;ht.length!==L.cameras.length&&(L.cameras.length=0,qt=!0);for(let ie=0;ie<ht.length;ie++){const Q=ht[ie];let rt=null;if(f!==null)rt=f.getViewport(Q);else{const yt=u.getViewSubImage(d,Q);rt=yt.viewport,ie===0&&(t.setRenderTargetTextures(_,yt.colorTexture,yt.depthStencilTexture),t.setRenderTarget(_))}let et=N[ie];et===void 0&&(et=new cn,et.layers.enable(ie),et.viewport=new Le,N[ie]=et),et.matrix.fromArray(Q.transform.matrix),et.matrix.decompose(et.position,et.quaternion,et.scale),et.projectionMatrix.fromArray(Q.projectionMatrix),et.projectionMatrixInverse.copy(et.projectionMatrix).invert(),et.viewport.set(rt.x,rt.y,rt.width,rt.height),ie===0&&(L.matrix.copy(et.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),qt===!0&&L.cameras.push(et)}const Xt=i.enabledFeatures;if(Xt&&Xt.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const ie=u.getDepthInformation(ht[0]);ie&&ie.isValid&&ie.texture&&g.init(ie,i.renderState)}if(Xt&&Xt.includes("camera-access")&&x){t.state.unbindTexture(),u=n.getBinding();for(let ie=0;ie<ht.length;ie++){const Q=ht[ie].camera;if(Q){let rt=m[Q];rt||(rt=new vm,m[Q]=rt);const et=u.getCameraImage(Q);rt.sourceTexture=et}}}}if(n.controllerAutoUpdate)for(let ht=0;ht<w.length;ht++){const qt=T[ht],Xt=w[ht];qt!==null&&Xt!==void 0&&Xt.update(qt,ct,c||o)}jt&&jt(j,ct),ct.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ct}),p=null}const we=new Fv;we.setAnimationLoop(Me),this.setAnimationLoop=function(j){jt=j},this.dispose=function(){}}}const Rr=new mi,rN=new Qt;function oN(r,t){function e(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function n(g,m){m.color.getRGB(g.fogColor.value,Q_(r)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function i(g,m,y,v,_){m.isMeshBasicMaterial?s(g,m):m.isMeshLambertMaterial?(s(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(s(g,m),d(g,m),m.isMeshPhysicalMaterial&&f(g,m,_)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),x(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(o(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?l(g,m,y,v):m.isSpriteMaterial?c(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,e(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,e(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===An&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,e(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===An&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,e(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,e(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);const y=t.get(m),v=y.envMap,_=y.envMapRotation;v&&(g.envMap.value=v,Rr.copy(_),Rr.x*=-1,Rr.y*=-1,Rr.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Rr.y*=-1,Rr.z*=-1),g.envMapRotation.value.setFromMatrix4(rN.makeRotationFromEuler(Rr)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,g.lightMapTransform)),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,g.aoMapTransform))}function o(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,e(m.map,g.mapTransform))}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function l(g,m,y,v){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*y,g.scale.value=v*.5,m.map&&(g.map.value=m.map,e(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function c(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,e(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function d(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,y){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===An&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function x(g,m){const y=t.get(m).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function aN(r,t,e,n){let i={},s={},o=[];const a=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,v){const _=v.program;n.uniformBlockBinding(y,_)}function c(y,v){let _=i[y.id];_===void 0&&(p(y),_=h(y),i[y.id]=_,y.addEventListener("dispose",g));const w=v.program;n.updateUBOMapping(y,w);const T=t.render.frame;s[y.id]!==T&&(d(y),s[y.id]=T)}function h(y){const v=u();y.__bindingPointIndex=v;const _=r.createBuffer(),w=y.__size,T=y.usage;return r.bindBuffer(r.UNIFORM_BUFFER,_),r.bufferData(r.UNIFORM_BUFFER,w,T),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,_),_}function u(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return Vt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const v=i[y.id],_=y.uniforms,w=y.__cache;r.bindBuffer(r.UNIFORM_BUFFER,v);for(let T=0,E=_.length;T<E;T++){const M=Array.isArray(_[T])?_[T]:[_[T]];for(let b=0,P=M.length;b<P;b++){const N=M[b];if(f(N,T,b,w)===!0){const L=N.__offset,U=Array.isArray(N.value)?N.value:[N.value];let V=0;for(let O=0;O<U.length;O++){const k=U[O],G=x(k);typeof k=="number"||typeof k=="boolean"?(N.__data[0]=k,r.bufferSubData(r.UNIFORM_BUFFER,L+V,N.__data)):k.isMatrix3?(N.__data[0]=k.elements[0],N.__data[1]=k.elements[1],N.__data[2]=k.elements[2],N.__data[3]=0,N.__data[4]=k.elements[3],N.__data[5]=k.elements[4],N.__data[6]=k.elements[5],N.__data[7]=0,N.__data[8]=k.elements[6],N.__data[9]=k.elements[7],N.__data[10]=k.elements[8],N.__data[11]=0):(k.toArray(N.__data,V),V+=G.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,L,N.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(y,v,_,w){const T=y.value,E=v+"_"+_;if(w[E]===void 0)return typeof T=="number"||typeof T=="boolean"?w[E]=T:w[E]=T.clone(),!0;{const M=w[E];if(typeof T=="number"||typeof T=="boolean"){if(M!==T)return w[E]=T,!0}else if(M.equals(T)===!1)return M.copy(T),!0}return!1}function p(y){const v=y.uniforms;let _=0;const w=16;for(let E=0,M=v.length;E<M;E++){const b=Array.isArray(v[E])?v[E]:[v[E]];for(let P=0,N=b.length;P<N;P++){const L=b[P],U=Array.isArray(L.value)?L.value:[L.value];for(let V=0,O=U.length;V<O;V++){const k=U[V],G=x(k),it=_%w,nt=it%G.boundary,mt=it+nt;_+=nt,mt!==0&&w-mt<G.storage&&(_+=w-mt),L.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=_,_+=G.storage}}}const T=_%w;return T>0&&(_+=w-T),y.__size=_,y.__cache={},this}function x(y){const v={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(v.boundary=4,v.storage=4):y.isVector2?(v.boundary=8,v.storage=8):y.isVector3||y.isColor?(v.boundary=16,v.storage=12):y.isVector4?(v.boundary=16,v.storage=16):y.isMatrix3?(v.boundary=48,v.storage=48):y.isMatrix4?(v.boundary=64,v.storage=64):y.isTexture?pt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):pt("WebGLRenderer: Unsupported uniform value type.",y),v}function g(y){const v=y.target;v.removeEventListener("dispose",g);const _=o.indexOf(v.__bindingPointIndex);o.splice(_,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function m(){for(const y in i)r.deleteBuffer(i[y]);o=[],i={},s={}}return{bind:l,update:c,dispose:m}}const lN=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let $i=null;function cN(){return $i===null&&($i=new fi(lN,16,16,ar,Ui),$i.name="DFG_LUT",$i.minFilter=Fe,$i.magFilter=Fe,$i.wrapS=Bn,$i.wrapT=Bn,$i.generateMipmaps=!1,$i.needsUpdate=!0),$i}class Vv{constructor(t={}){const{canvas:e=E_(),context:n=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Un}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;const x=f,g=new Set([pc,fc,Ma]),m=new Set([Un,ii,la,Yr,Ku,Qu]),y=new Uint32Array(4),v=new Int32Array(4);let _=null,w=null;const T=[],E=[];let M=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=di,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const b=this;let P=!1;this._outputColorSpace=Fn;let N=0,L=0,U=null,V=-1,O=null;const k=new Le,G=new Le;let it=null;const nt=new wt(0);let mt=0,xt=e.width,bt=e.height,jt=1,Me=null,we=null;const j=new Le(0,0,xt,bt),ct=new Le(0,0,xt,bt);let ht=!1;const qt=new no;let Xt=!1,Kt=!1;const Ae=new Qt,ie=new R,Q=new Le,rt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let et=!1;function yt(){return U===null?jt:1}let I=n;function $t(A,B){return e.getContext(A,B)}try{const A={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Wr}`),e.addEventListener("webglcontextlost",Ft,!1),e.addEventListener("webglcontextrestored",ee,!1),e.addEventListener("webglcontextcreationerror",Ie,!1),I===null){const B="webgl2";if(I=$t(B,A),I===null)throw $t(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw Vt("WebGLRenderer: "+A.message),A}let Tt,Yt,ut,C,S,D,Y,K,Z,It,dt,Ht,Zt,st,at,Lt,Dt,Et,ce,F,ft,lt,Rt;function ot(){Tt=new uE(I),Tt.init(),ft=new zv(I,Tt),Yt=new sE(I,Tt,t,ft),ut=new QC(I,Tt),Yt.reversedDepthBuffer&&d&&ut.buffers.depth.setReversed(!0),C=new pE(I),S=new zC,D=new tN(I,Tt,ut,S,Yt,ft,C),Y=new hE(b),K=new v1(I),lt=new nE(I,K),Z=new dE(I,K,C,lt),It=new gE(I,Z,K,lt,C),Et=new mE(I,Yt,D),at=new rE(S),dt=new BC(b,Y,Tt,Yt,lt,at),Ht=new oN(b,S),Zt=new kC,st=new qC(Tt),Dt=new eE(b,Y,ut,It,p,l),Lt=new KC(b,It,Yt),Rt=new aN(I,C,Yt,ut),ce=new iE(I,Tt,C),F=new fE(I,Tt,C),C.programs=dt.programs,b.capabilities=Yt,b.extensions=Tt,b.properties=S,b.renderLists=Zt,b.shadowMap=Lt,b.state=ut,b.info=C}ot(),x!==Un&&(M=new yE(x,e.width,e.height,i,s));const J=new sN(b,I);this.xr=J,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const A=Tt.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=Tt.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return jt},this.setPixelRatio=function(A){A!==void 0&&(jt=A,this.setSize(xt,bt,!1))},this.getSize=function(A){return A.set(xt,bt)},this.setSize=function(A,B,$=!0){if(J.isPresenting){pt("WebGLRenderer: Can't change size while VR device is presenting.");return}xt=A,bt=B,e.width=Math.floor(A*jt),e.height=Math.floor(B*jt),$===!0&&(e.style.width=A+"px",e.style.height=B+"px"),M!==null&&M.setSize(e.width,e.height),this.setViewport(0,0,A,B)},this.getDrawingBufferSize=function(A){return A.set(xt*jt,bt*jt).floor()},this.setDrawingBufferSize=function(A,B,$){xt=A,bt=B,jt=$,e.width=Math.floor(A*$),e.height=Math.floor(B*$),this.setViewport(0,0,A,B)},this.setEffects=function(A){if(x===Un){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(A){for(let B=0;B<A.length;B++)if(A[B].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}M.setEffects(A||[])},this.getCurrentViewport=function(A){return A.copy(k)},this.getViewport=function(A){return A.copy(j)},this.setViewport=function(A,B,$,X){A.isVector4?j.set(A.x,A.y,A.z,A.w):j.set(A,B,$,X),ut.viewport(k.copy(j).multiplyScalar(jt).round())},this.getScissor=function(A){return A.copy(ct)},this.setScissor=function(A,B,$,X){A.isVector4?ct.set(A.x,A.y,A.z,A.w):ct.set(A,B,$,X),ut.scissor(G.copy(ct).multiplyScalar(jt).round())},this.getScissorTest=function(){return ht},this.setScissorTest=function(A){ut.setScissorTest(ht=A)},this.setOpaqueSort=function(A){Me=A},this.setTransparentSort=function(A){we=A},this.getClearColor=function(A){return A.copy(Dt.getClearColor())},this.setClearColor=function(){Dt.setClearColor(...arguments)},this.getClearAlpha=function(){return Dt.getClearAlpha()},this.setClearAlpha=function(){Dt.setClearAlpha(...arguments)},this.clear=function(A=!0,B=!0,$=!0){let X=0;if(A){let W=!1;if(U!==null){const St=U.texture.format;W=g.has(St)}if(W){const St=U.texture.type,Nt=m.has(St),_t=Dt.getClearColor(),Ut=Dt.getClearAlpha(),Gt=_t.r,re=_t.g,he=_t.b;Nt?(y[0]=Gt,y[1]=re,y[2]=he,y[3]=Ut,I.clearBufferuiv(I.COLOR,0,y)):(v[0]=Gt,v[1]=re,v[2]=he,v[3]=Ut,I.clearBufferiv(I.COLOR,0,v))}else X|=I.COLOR_BUFFER_BIT}B&&(X|=I.DEPTH_BUFFER_BIT),$&&(X|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),X!==0&&I.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Ft,!1),e.removeEventListener("webglcontextrestored",ee,!1),e.removeEventListener("webglcontextcreationerror",Ie,!1),Dt.dispose(),Zt.dispose(),st.dispose(),S.dispose(),Y.dispose(),It.dispose(),lt.dispose(),Rt.dispose(),dt.dispose(),J.dispose(),J.removeEventListener("sessionstart",Og),J.removeEventListener("sessionend",Bg),gr.stop()};function Ft(A){A.preventDefault(),Ql("WebGLRenderer: Context Lost."),P=!0}function ee(){Ql("WebGLRenderer: Context Restored."),P=!1;const A=C.autoReset,B=Lt.enabled,$=Lt.autoUpdate,X=Lt.needsUpdate,W=Lt.type;ot(),C.autoReset=A,Lt.enabled=B,Lt.autoUpdate=$,Lt.needsUpdate=X,Lt.type=W}function Ie(A){Vt("WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Se(A){const B=A.target;B.removeEventListener("dispose",Se),us(B)}function us(A){ds(A),S.remove(A)}function ds(A){const B=S.get(A).programs;B!==void 0&&(B.forEach(function($){dt.releaseProgram($)}),A.isShaderMaterial&&dt.releaseShaderCache(A))}this.renderBufferDirect=function(A,B,$,X,W,St){B===null&&(B=rt);const Nt=W.isMesh&&W.matrixWorld.determinant()<0,_t=lS(A,B,$,X,W);ut.setMaterial(X,Nt);let Ut=$.index,Gt=1;if(X.wireframe===!0){if(Ut=Z.getWireframeAttribute($),Ut===void 0)return;Gt=2}const re=$.drawRange,he=$.attributes.position;let Wt=re.start*Gt,Ee=(re.start+re.count)*Gt;St!==null&&(Wt=Math.max(Wt,St.start*Gt),Ee=Math.min(Ee,(St.start+St.count)*Gt)),Ut!==null?(Wt=Math.max(Wt,0),Ee=Math.min(Ee,Ut.count)):he!=null&&(Wt=Math.max(Wt,0),Ee=Math.min(Ee,he.count));const $e=Ee-Wt;if($e<0||$e===1/0)return;lt.setup(W,X,_t,$,Ut);let He,Ce=ce;if(Ut!==null&&(He=K.get(Ut),Ce=F,Ce.setIndex(He)),W.isMesh)X.wireframe===!0?(ut.setLineWidth(X.wireframeLinewidth*yt()),Ce.setMode(I.LINES)):Ce.setMode(I.TRIANGLES);else if(W.isLine){let yn=X.linewidth;yn===void 0&&(yn=1),ut.setLineWidth(yn*yt()),W.isLineSegments?Ce.setMode(I.LINES):W.isLineLoop?Ce.setMode(I.LINE_LOOP):Ce.setMode(I.LINE_STRIP)}else W.isPoints?Ce.setMode(I.POINTS):W.isSprite&&Ce.setMode(I.TRIANGLES);if(W.isBatchedMesh)if(W._multiDrawInstances!==null)tc("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Ce.renderMultiDrawInstances(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount,W._multiDrawInstances);else if(Tt.get("WEBGL_multi_draw"))Ce.renderMultiDraw(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount);else{const yn=W._multiDrawStarts,zt=W._multiDrawCounts,Yn=W._multiDrawCount,ye=Ut?K.get(Ut).bytesPerElement:1,Si=S.get(X).currentProgram.getUniforms();for(let ki=0;ki<Yn;ki++)Si.setValue(I,"_gl_DrawID",ki),Ce.render(yn[ki]/ye,zt[ki])}else if(W.isInstancedMesh)Ce.renderInstances(Wt,$e,W.count);else if($.isInstancedBufferGeometry){const yn=$._maxInstanceCount!==void 0?$._maxInstanceCount:1/0,zt=Math.min($.instanceCount,yn);Ce.renderInstances(Wt,$e,zt)}else Ce.render(Wt,$e)};function Ug(A,B,$){A.transparent===!0&&A.side===Ri&&A.forceSinglePass===!1?(A.side=An,A.needsUpdate=!0,Fc(A,B,$),A.side=is,A.needsUpdate=!0,Fc(A,B,$),A.side=Ri):Fc(A,B,$)}this.compile=function(A,B,$=null){$===null&&($=A),w=st.get($),w.init(B),E.push(w),$.traverseVisible(function(W){W.isLight&&W.layers.test(B.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),A!==$&&A.traverseVisible(function(W){W.isLight&&W.layers.test(B.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),w.setupLights();const X=new Set;return A.traverse(function(W){if(!(W.isMesh||W.isPoints||W.isLine||W.isSprite))return;const St=W.material;if(St)if(Array.isArray(St))for(let Nt=0;Nt<St.length;Nt++){const _t=St[Nt];Ug(_t,$,W),X.add(_t)}else Ug(St,$,W),X.add(St)}),w=E.pop(),X},this.compileAsync=function(A,B,$=null){const X=this.compile(A,B,$);return new Promise(W=>{function St(){if(X.forEach(function(Nt){S.get(Nt).currentProgram.isReady()&&X.delete(Nt)}),X.size===0){W(A);return}setTimeout(St,10)}Tt.get("KHR_parallel_shader_compile")!==null?St():setTimeout(St,10)})};let qd=null;function aS(A){qd&&qd(A)}function Og(){gr.stop()}function Bg(){gr.start()}const gr=new Fv;gr.setAnimationLoop(aS),typeof self<"u"&&gr.setContext(self),this.setAnimationLoop=function(A){qd=A,J.setAnimationLoop(A),A===null?gr.stop():gr.start()},J.addEventListener("sessionstart",Og),J.addEventListener("sessionend",Bg),this.render=function(A,B){if(B!==void 0&&B.isCamera!==!0){Vt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;const $=J.enabled===!0&&J.isPresenting===!0,X=M!==null&&(U===null||$)&&M.begin(b,U);if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),J.enabled===!0&&J.isPresenting===!0&&(M===null||M.isCompositing()===!1)&&(J.cameraAutoUpdate===!0&&J.updateCamera(B),B=J.getCamera()),A.isScene===!0&&A.onBeforeRender(b,A,B,U),w=st.get(A,E.length),w.init(B),E.push(w),Ae.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),qt.setFromProjectionMatrix(Ae,ti,B.reversedDepth),Kt=this.localClippingEnabled,Xt=at.init(this.clippingPlanes,Kt),_=Zt.get(A,T.length),_.init(),T.push(_),J.enabled===!0&&J.isPresenting===!0){const Nt=b.xr.getDepthSensingMesh();Nt!==null&&Yd(Nt,B,-1/0,b.sortObjects)}Yd(A,B,0,b.sortObjects),_.finish(),b.sortObjects===!0&&_.sort(Me,we),et=J.enabled===!1||J.isPresenting===!1||J.hasDepthSensing()===!1,et&&Dt.addToRenderList(_,A),this.info.render.frame++,Xt===!0&&at.beginShadows();const W=w.state.shadowsArray;if(Lt.render(W,A,B),Xt===!0&&at.endShadows(),this.info.autoReset===!0&&this.info.reset(),(X&&M.hasRenderPass())===!1){const Nt=_.opaque,_t=_.transmissive;if(w.setupLights(),B.isArrayCamera){const Ut=B.cameras;if(_t.length>0)for(let Gt=0,re=Ut.length;Gt<re;Gt++){const he=Ut[Gt];Vg(Nt,_t,A,he)}et&&Dt.render(A);for(let Gt=0,re=Ut.length;Gt<re;Gt++){const he=Ut[Gt];zg(_,A,he,he.viewport)}}else _t.length>0&&Vg(Nt,_t,A,B),et&&Dt.render(A),zg(_,A,B)}U!==null&&L===0&&(D.updateMultisampleRenderTarget(U),D.updateRenderTargetMipmap(U)),X&&M.end(b),A.isScene===!0&&A.onAfterRender(b,A,B),lt.resetDefaultState(),V=-1,O=null,E.pop(),E.length>0?(w=E[E.length-1],Xt===!0&&at.setGlobalState(b.clippingPlanes,w.state.camera)):w=null,T.pop(),T.length>0?_=T[T.length-1]:_=null};function Yd(A,B,$,X){if(A.visible===!1)return;if(A.layers.test(B.layers)){if(A.isGroup)$=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(B);else if(A.isLight)w.pushLight(A),A.castShadow&&w.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||qt.intersectsSprite(A)){X&&Q.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Ae);const Nt=It.update(A),_t=A.material;_t.visible&&_.push(A,Nt,_t,$,Q.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||qt.intersectsObject(A))){const Nt=It.update(A),_t=A.material;if(X&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),Q.copy(A.boundingSphere.center)):(Nt.boundingSphere===null&&Nt.computeBoundingSphere(),Q.copy(Nt.boundingSphere.center)),Q.applyMatrix4(A.matrixWorld).applyMatrix4(Ae)),Array.isArray(_t)){const Ut=Nt.groups;for(let Gt=0,re=Ut.length;Gt<re;Gt++){const he=Ut[Gt],Wt=_t[he.materialIndex];Wt&&Wt.visible&&_.push(A,Nt,Wt,$,Q.z,he)}}else _t.visible&&_.push(A,Nt,_t,$,Q.z,null)}}const St=A.children;for(let Nt=0,_t=St.length;Nt<_t;Nt++)Yd(St[Nt],B,$,X)}function zg(A,B,$,X){const{opaque:W,transmissive:St,transparent:Nt}=A;w.setupLightsView($),Xt===!0&&at.setGlobalState(b.clippingPlanes,$),X&&ut.viewport(k.copy(X)),W.length>0&&Lc(W,B,$),St.length>0&&Lc(St,B,$),Nt.length>0&&Lc(Nt,B,$),ut.buffers.depth.setTest(!0),ut.buffers.depth.setMask(!0),ut.buffers.color.setMask(!0),ut.setPolygonOffset(!1)}function Vg(A,B,$,X){if(($.isScene===!0?$.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[X.id]===void 0){const Wt=Tt.has("EXT_color_buffer_half_float")||Tt.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[X.id]=new qn(1,1,{generateMipmaps:!0,type:Wt?Ui:Un,minFilter:Li,samples:Math.max(4,Yt.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:fe.workingColorSpace})}const St=w.state.transmissionRenderTarget[X.id],Nt=X.viewport||k;St.setSize(Nt.z*b.transmissionResolutionScale,Nt.w*b.transmissionResolutionScale);const _t=b.getRenderTarget(),Ut=b.getActiveCubeFace(),Gt=b.getActiveMipmapLevel();b.setRenderTarget(St),b.getClearColor(nt),mt=b.getClearAlpha(),mt<1&&b.setClearColor(16777215,.5),b.clear(),et&&Dt.render($);const re=b.toneMapping;b.toneMapping=di;const he=X.viewport;if(X.viewport!==void 0&&(X.viewport=void 0),w.setupLightsView(X),Xt===!0&&at.setGlobalState(b.clippingPlanes,X),Lc(A,$,X),D.updateMultisampleRenderTarget(St),D.updateRenderTargetMipmap(St),Tt.has("WEBGL_multisampled_render_to_texture")===!1){let Wt=!1;for(let Ee=0,$e=B.length;Ee<$e;Ee++){const He=B[Ee],{object:Ce,geometry:yn,material:zt,group:Yn}=He;if(zt.side===Ri&&Ce.layers.test(X.layers)){const ye=zt.side;zt.side=An,zt.needsUpdate=!0,kg(Ce,$,X,yn,zt,Yn),zt.side=ye,zt.needsUpdate=!0,Wt=!0}}Wt===!0&&(D.updateMultisampleRenderTarget(St),D.updateRenderTargetMipmap(St))}b.setRenderTarget(_t,Ut,Gt),b.setClearColor(nt,mt),he!==void 0&&(X.viewport=he),b.toneMapping=re}function Lc(A,B,$){const X=B.isScene===!0?B.overrideMaterial:null;for(let W=0,St=A.length;W<St;W++){const Nt=A[W],{object:_t,geometry:Ut,group:Gt}=Nt;let re=Nt.material;re.allowOverride===!0&&X!==null&&(re=X),_t.layers.test($.layers)&&kg(_t,B,$,Ut,re,Gt)}}function kg(A,B,$,X,W,St){A.onBeforeRender(b,B,$,X,W,St),A.modelViewMatrix.multiplyMatrices($.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),W.onBeforeRender(b,B,$,X,A,St),W.transparent===!0&&W.side===Ri&&W.forceSinglePass===!1?(W.side=An,W.needsUpdate=!0,b.renderBufferDirect($,B,X,W,A,St),W.side=is,W.needsUpdate=!0,b.renderBufferDirect($,B,X,W,A,St),W.side=Ri):b.renderBufferDirect($,B,X,W,A,St),A.onAfterRender(b,B,$,X,W,St)}function Fc(A,B,$){B.isScene!==!0&&(B=rt);const X=S.get(A),W=w.state.lights,St=w.state.shadowsArray,Nt=W.state.version,_t=dt.getParameters(A,W.state,St,B,$),Ut=dt.getProgramCacheKey(_t);let Gt=X.programs;X.environment=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?B.environment:null,X.fog=B.fog;const re=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap;X.envMap=Y.get(A.envMap||X.environment,re),X.envMapRotation=X.environment!==null&&A.envMap===null?B.environmentRotation:A.envMapRotation,Gt===void 0&&(A.addEventListener("dispose",Se),Gt=new Map,X.programs=Gt);let he=Gt.get(Ut);if(he!==void 0){if(X.currentProgram===he&&X.lightsStateVersion===Nt)return Hg(A,_t),he}else _t.uniforms=dt.getUniforms(A),A.onBuild($,_t,b),A.onBeforeCompile(_t,b),he=dt.acquireProgram(_t,Ut),Gt.set(Ut,he),X.uniforms=_t.uniforms;const Wt=X.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Wt.clippingPlanes=at.uniform),Hg(A,_t),X.needsLights=hS(A),X.lightsStateVersion=Nt,X.needsLights&&(Wt.ambientLightColor.value=W.state.ambient,Wt.lightProbe.value=W.state.probe,Wt.directionalLights.value=W.state.directional,Wt.directionalLightShadows.value=W.state.directionalShadow,Wt.spotLights.value=W.state.spot,Wt.spotLightShadows.value=W.state.spotShadow,Wt.rectAreaLights.value=W.state.rectArea,Wt.ltc_1.value=W.state.rectAreaLTC1,Wt.ltc_2.value=W.state.rectAreaLTC2,Wt.pointLights.value=W.state.point,Wt.pointLightShadows.value=W.state.pointShadow,Wt.hemisphereLights.value=W.state.hemi,Wt.directionalShadowMatrix.value=W.state.directionalShadowMatrix,Wt.spotLightMatrix.value=W.state.spotLightMatrix,Wt.spotLightMap.value=W.state.spotLightMap,Wt.pointShadowMatrix.value=W.state.pointShadowMatrix),X.currentProgram=he,X.uniformsList=null,he}function Gg(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=lu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function Hg(A,B){const $=S.get(A);$.outputColorSpace=B.outputColorSpace,$.batching=B.batching,$.batchingColor=B.batchingColor,$.instancing=B.instancing,$.instancingColor=B.instancingColor,$.instancingMorph=B.instancingMorph,$.skinning=B.skinning,$.morphTargets=B.morphTargets,$.morphNormals=B.morphNormals,$.morphColors=B.morphColors,$.morphTargetsCount=B.morphTargetsCount,$.numClippingPlanes=B.numClippingPlanes,$.numIntersection=B.numClipIntersection,$.vertexAlphas=B.vertexAlphas,$.vertexTangents=B.vertexTangents,$.toneMapping=B.toneMapping}function lS(A,B,$,X,W){B.isScene!==!0&&(B=rt),D.resetTextureUnits();const St=B.fog,Nt=X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial?B.environment:null,_t=U===null?b.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:lr,Ut=X.isMeshStandardMaterial||X.isMeshLambertMaterial&&!X.envMap||X.isMeshPhongMaterial&&!X.envMap,Gt=Y.get(X.envMap||Nt,Ut),re=X.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,he=!!$.attributes.tangent&&(!!X.normalMap||X.anisotropy>0),Wt=!!$.morphAttributes.position,Ee=!!$.morphAttributes.normal,$e=!!$.morphAttributes.color;let He=di;X.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(He=b.toneMapping);const Ce=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,yn=Ce!==void 0?Ce.length:0,zt=S.get(X),Yn=w.state.lights;if(Xt===!0&&(Kt===!0||A!==O)){const on=A===O&&X.id===V;at.setState(X,A,on)}let ye=!1;X.version===zt.__version?(zt.needsLights&&zt.lightsStateVersion!==Yn.state.version||zt.outputColorSpace!==_t||W.isBatchedMesh&&zt.batching===!1||!W.isBatchedMesh&&zt.batching===!0||W.isBatchedMesh&&zt.batchingColor===!0&&W.colorTexture===null||W.isBatchedMesh&&zt.batchingColor===!1&&W.colorTexture!==null||W.isInstancedMesh&&zt.instancing===!1||!W.isInstancedMesh&&zt.instancing===!0||W.isSkinnedMesh&&zt.skinning===!1||!W.isSkinnedMesh&&zt.skinning===!0||W.isInstancedMesh&&zt.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&zt.instancingColor===!1&&W.instanceColor!==null||W.isInstancedMesh&&zt.instancingMorph===!0&&W.morphTexture===null||W.isInstancedMesh&&zt.instancingMorph===!1&&W.morphTexture!==null||zt.envMap!==Gt||X.fog===!0&&zt.fog!==St||zt.numClippingPlanes!==void 0&&(zt.numClippingPlanes!==at.numPlanes||zt.numIntersection!==at.numIntersection)||zt.vertexAlphas!==re||zt.vertexTangents!==he||zt.morphTargets!==Wt||zt.morphNormals!==Ee||zt.morphColors!==$e||zt.toneMapping!==He||zt.morphTargetsCount!==yn)&&(ye=!0):(ye=!0,zt.__version=X.version);let Si=zt.currentProgram;ye===!0&&(Si=Fc(X,B,W));let ki=!1,xr=!1,lo=!1;const Re=Si.getUniforms(),dn=zt.uniforms;if(ut.useProgram(Si.program)&&(ki=!0,xr=!0,lo=!0),(X.id!==V||X._forceRefresh)&&(V=X.id,xr=!0,X._forceRefresh=!1),ki||O!==A){ut.buffers.depth.getReversed()&&A.reversedDepth!==!0&&(A._reversedDepth=!0,A.updateProjectionMatrix()),Re.setValue(I,"projectionMatrix",A.projectionMatrix),Re.setValue(I,"viewMatrix",A.matrixWorldInverse);const Os=Re.map.cameraPosition;Os!==void 0&&Os.setValue(I,ie.setFromMatrixPosition(A.matrixWorld)),Yt.logarithmicDepthBuffer&&Re.setValue(I,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(X.isMeshPhongMaterial||X.isMeshToonMaterial||X.isMeshLambertMaterial||X.isMeshBasicMaterial||X.isMeshStandardMaterial||X.isShaderMaterial)&&Re.setValue(I,"isOrthographic",A.isOrthographicCamera===!0),O!==A&&(O=A,xr=!0,lo=!0)}if(zt.needsLights&&(Yn.state.directionalShadowMap.length>0&&Re.setValue(I,"directionalShadowMap",Yn.state.directionalShadowMap,D),Yn.state.spotShadowMap.length>0&&Re.setValue(I,"spotShadowMap",Yn.state.spotShadowMap,D),Yn.state.pointShadowMap.length>0&&Re.setValue(I,"pointShadowMap",Yn.state.pointShadowMap,D)),W.isSkinnedMesh){Re.setOptional(I,W,"bindMatrix"),Re.setOptional(I,W,"bindMatrixInverse");const on=W.skeleton;on&&(on.boneTexture===null&&on.computeBoneTexture(),Re.setValue(I,"boneTexture",on.boneTexture,D))}W.isBatchedMesh&&(Re.setOptional(I,W,"batchingTexture"),Re.setValue(I,"batchingTexture",W._matricesTexture,D),Re.setOptional(I,W,"batchingIdTexture"),Re.setValue(I,"batchingIdTexture",W._indirectTexture,D),Re.setOptional(I,W,"batchingColorTexture"),W._colorsTexture!==null&&Re.setValue(I,"batchingColorTexture",W._colorsTexture,D));const Us=$.morphAttributes;if((Us.position!==void 0||Us.normal!==void 0||Us.color!==void 0)&&Et.update(W,$,Si),(xr||zt.receiveShadow!==W.receiveShadow)&&(zt.receiveShadow=W.receiveShadow,Re.setValue(I,"receiveShadow",W.receiveShadow)),(X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial)&&X.envMap===null&&B.environment!==null&&(dn.envMapIntensity.value=B.environmentIntensity),dn.dfgLUT!==void 0&&(dn.dfgLUT.value=cN()),xr&&(Re.setValue(I,"toneMappingExposure",b.toneMappingExposure),zt.needsLights&&cS(dn,lo),St&&X.fog===!0&&Ht.refreshFogUniforms(dn,St),Ht.refreshMaterialUniforms(dn,X,jt,bt,w.state.transmissionRenderTarget[A.id]),lu.upload(I,Gg(zt),dn,D)),X.isShaderMaterial&&X.uniformsNeedUpdate===!0&&(lu.upload(I,Gg(zt),dn,D),X.uniformsNeedUpdate=!1),X.isSpriteMaterial&&Re.setValue(I,"center",W.center),Re.setValue(I,"modelViewMatrix",W.modelViewMatrix),Re.setValue(I,"normalMatrix",W.normalMatrix),Re.setValue(I,"modelMatrix",W.matrixWorld),X.isShaderMaterial||X.isRawShaderMaterial){const on=X.uniformsGroups;for(let Os=0,co=on.length;Os<co;Os++){const Wg=on[Os];Rt.update(Wg,Si),Rt.bind(Wg,Si)}}return Si}function cS(A,B){A.ambientLightColor.needsUpdate=B,A.lightProbe.needsUpdate=B,A.directionalLights.needsUpdate=B,A.directionalLightShadows.needsUpdate=B,A.pointLights.needsUpdate=B,A.pointLightShadows.needsUpdate=B,A.spotLights.needsUpdate=B,A.spotLightShadows.needsUpdate=B,A.rectAreaLights.needsUpdate=B,A.hemisphereLights.needsUpdate=B}function hS(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(A,B,$){const X=S.get(A);X.__autoAllocateDepthBuffer=A.resolveDepthBuffer===!1,X.__autoAllocateDepthBuffer===!1&&(X.__useRenderToTexture=!1),S.get(A.texture).__webglTexture=B,S.get(A.depthTexture).__webglTexture=X.__autoAllocateDepthBuffer?void 0:$,X.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(A,B){const $=S.get(A);$.__webglFramebuffer=B,$.__useDefaultFramebuffer=B===void 0};const uS=I.createFramebuffer();this.setRenderTarget=function(A,B=0,$=0){U=A,N=B,L=$;let X=null,W=!1,St=!1;if(A){const _t=S.get(A);if(_t.__useDefaultFramebuffer!==void 0){ut.bindFramebuffer(I.FRAMEBUFFER,_t.__webglFramebuffer),k.copy(A.viewport),G.copy(A.scissor),it=A.scissorTest,ut.viewport(k),ut.scissor(G),ut.setScissorTest(it),V=-1;return}else if(_t.__webglFramebuffer===void 0)D.setupRenderTarget(A);else if(_t.__hasExternalTextures)D.rebindTextures(A,S.get(A.texture).__webglTexture,S.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const re=A.depthTexture;if(_t.__boundDepthTexture!==re){if(re!==null&&S.has(re)&&(A.width!==re.image.width||A.height!==re.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");D.setupDepthRenderbuffer(A)}}const Ut=A.texture;(Ut.isData3DTexture||Ut.isDataArrayTexture||Ut.isCompressedArrayTexture)&&(St=!0);const Gt=S.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Gt[B])?X=Gt[B][$]:X=Gt[B],W=!0):A.samples>0&&D.useMultisampledRTT(A)===!1?X=S.get(A).__webglMultisampledFramebuffer:Array.isArray(Gt)?X=Gt[$]:X=Gt,k.copy(A.viewport),G.copy(A.scissor),it=A.scissorTest}else k.copy(j).multiplyScalar(jt).floor(),G.copy(ct).multiplyScalar(jt).floor(),it=ht;if($!==0&&(X=uS),ut.bindFramebuffer(I.FRAMEBUFFER,X)&&ut.drawBuffers(A,X),ut.viewport(k),ut.scissor(G),ut.setScissorTest(it),W){const _t=S.get(A.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+B,_t.__webglTexture,$)}else if(St){const _t=B;for(let Ut=0;Ut<A.textures.length;Ut++){const Gt=S.get(A.textures[Ut]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+Ut,Gt.__webglTexture,$,_t)}}else if(A!==null&&$!==0){const _t=S.get(A.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,_t.__webglTexture,$)}V=-1},this.readRenderTargetPixels=function(A,B,$,X,W,St,Nt,_t=0){if(!(A&&A.isWebGLRenderTarget)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ut=S.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Nt!==void 0&&(Ut=Ut[Nt]),Ut){ut.bindFramebuffer(I.FRAMEBUFFER,Ut);try{const Gt=A.textures[_t],re=Gt.format,he=Gt.type;if(A.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_t),!Yt.textureFormatReadable(re)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Yt.textureTypeReadable(he)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=A.width-X&&$>=0&&$<=A.height-W&&I.readPixels(B,$,X,W,ft.convert(re),ft.convert(he),St)}finally{const Gt=U!==null?S.get(U).__webglFramebuffer:null;ut.bindFramebuffer(I.FRAMEBUFFER,Gt)}}},this.readRenderTargetPixelsAsync=async function(A,B,$,X,W,St,Nt,_t=0){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ut=S.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Nt!==void 0&&(Ut=Ut[Nt]),Ut)if(B>=0&&B<=A.width-X&&$>=0&&$<=A.height-W){ut.bindFramebuffer(I.FRAMEBUFFER,Ut);const Gt=A.textures[_t],re=Gt.format,he=Gt.type;if(A.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_t),!Yt.textureFormatReadable(re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Yt.textureTypeReadable(he))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Wt=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,Wt),I.bufferData(I.PIXEL_PACK_BUFFER,St.byteLength,I.STREAM_READ),I.readPixels(B,$,X,W,ft.convert(re),ft.convert(he),0);const Ee=U!==null?S.get(U).__webglFramebuffer:null;ut.bindFramebuffer(I.FRAMEBUFFER,Ee);const $e=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await kS(I,$e,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,Wt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,St),I.deleteBuffer(Wt),I.deleteSync($e),St}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(A,B=null,$=0){const X=Math.pow(2,-$),W=Math.floor(A.image.width*X),St=Math.floor(A.image.height*X),Nt=B!==null?B.x:0,_t=B!==null?B.y:0;D.setTexture2D(A,0),I.copyTexSubImage2D(I.TEXTURE_2D,$,0,0,Nt,_t,W,St),ut.unbindTexture()};const dS=I.createFramebuffer(),fS=I.createFramebuffer();this.copyTextureToTexture=function(A,B,$=null,X=null,W=0,St=0){let Nt,_t,Ut,Gt,re,he,Wt,Ee,$e;const He=A.isCompressedTexture?A.mipmaps[St]:A.image;if($!==null)Nt=$.max.x-$.min.x,_t=$.max.y-$.min.y,Ut=$.isBox3?$.max.z-$.min.z:1,Gt=$.min.x,re=$.min.y,he=$.isBox3?$.min.z:0;else{const dn=Math.pow(2,-W);Nt=Math.floor(He.width*dn),_t=Math.floor(He.height*dn),A.isDataArrayTexture?Ut=He.depth:A.isData3DTexture?Ut=Math.floor(He.depth*dn):Ut=1,Gt=0,re=0,he=0}X!==null?(Wt=X.x,Ee=X.y,$e=X.z):(Wt=0,Ee=0,$e=0);const Ce=ft.convert(B.format),yn=ft.convert(B.type);let zt;B.isData3DTexture?(D.setTexture3D(B,0),zt=I.TEXTURE_3D):B.isDataArrayTexture||B.isCompressedArrayTexture?(D.setTexture2DArray(B,0),zt=I.TEXTURE_2D_ARRAY):(D.setTexture2D(B,0),zt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,B.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,B.unpackAlignment);const Yn=I.getParameter(I.UNPACK_ROW_LENGTH),ye=I.getParameter(I.UNPACK_IMAGE_HEIGHT),Si=I.getParameter(I.UNPACK_SKIP_PIXELS),ki=I.getParameter(I.UNPACK_SKIP_ROWS),xr=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,He.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,He.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Gt),I.pixelStorei(I.UNPACK_SKIP_ROWS,re),I.pixelStorei(I.UNPACK_SKIP_IMAGES,he);const lo=A.isDataArrayTexture||A.isData3DTexture,Re=B.isDataArrayTexture||B.isData3DTexture;if(A.isDepthTexture){const dn=S.get(A),Us=S.get(B),on=S.get(dn.__renderTarget),Os=S.get(Us.__renderTarget);ut.bindFramebuffer(I.READ_FRAMEBUFFER,on.__webglFramebuffer),ut.bindFramebuffer(I.DRAW_FRAMEBUFFER,Os.__webglFramebuffer);for(let co=0;co<Ut;co++)lo&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,S.get(A).__webglTexture,W,he+co),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,S.get(B).__webglTexture,St,$e+co)),I.blitFramebuffer(Gt,re,Nt,_t,Wt,Ee,Nt,_t,I.DEPTH_BUFFER_BIT,I.NEAREST);ut.bindFramebuffer(I.READ_FRAMEBUFFER,null),ut.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(W!==0||A.isRenderTargetTexture||S.has(A)){const dn=S.get(A),Us=S.get(B);ut.bindFramebuffer(I.READ_FRAMEBUFFER,dS),ut.bindFramebuffer(I.DRAW_FRAMEBUFFER,fS);for(let on=0;on<Ut;on++)lo?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,dn.__webglTexture,W,he+on):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,dn.__webglTexture,W),Re?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Us.__webglTexture,St,$e+on):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Us.__webglTexture,St),W!==0?I.blitFramebuffer(Gt,re,Nt,_t,Wt,Ee,Nt,_t,I.COLOR_BUFFER_BIT,I.NEAREST):Re?I.copyTexSubImage3D(zt,St,Wt,Ee,$e+on,Gt,re,Nt,_t):I.copyTexSubImage2D(zt,St,Wt,Ee,Gt,re,Nt,_t);ut.bindFramebuffer(I.READ_FRAMEBUFFER,null),ut.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else Re?A.isDataTexture||A.isData3DTexture?I.texSubImage3D(zt,St,Wt,Ee,$e,Nt,_t,Ut,Ce,yn,He.data):B.isCompressedArrayTexture?I.compressedTexSubImage3D(zt,St,Wt,Ee,$e,Nt,_t,Ut,Ce,He.data):I.texSubImage3D(zt,St,Wt,Ee,$e,Nt,_t,Ut,Ce,yn,He):A.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,St,Wt,Ee,Nt,_t,Ce,yn,He.data):A.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,St,Wt,Ee,He.width,He.height,Ce,He.data):I.texSubImage2D(I.TEXTURE_2D,St,Wt,Ee,Nt,_t,Ce,yn,He);I.pixelStorei(I.UNPACK_ROW_LENGTH,Yn),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,ye),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Si),I.pixelStorei(I.UNPACK_SKIP_ROWS,ki),I.pixelStorei(I.UNPACK_SKIP_IMAGES,xr),St===0&&B.generateMipmaps&&I.generateMipmap(zt),ut.unbindTexture()},this.initRenderTarget=function(A){S.get(A).__webglFramebuffer===void 0&&D.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?D.setTextureCube(A,0):A.isData3DTexture?D.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?D.setTexture2DArray(A,0):D.setTexture2D(A,0),ut.unbindTexture()},this.resetState=function(){N=0,L=0,U=null,ut.reset(),lt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ti}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=fe._getDrawingBufferColorSpace(t),e.unpackColorSpace=fe._getUnpackColorSpace()}}const hN=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:$u,AddEquation:Qs,AddOperation:Zy,AdditiveAnimationBlendMode:sm,AdditiveBlending:uu,AgXToneMapping:qu,AlphaFormat:em,AlwaysCompare:T_,AlwaysDepth:Tl,AlwaysStencilFunc:Cu,AmbientLight:Xm,AnimationAction:yv,AnimationClip:ga,AnimationLoader:ET,AnimationMixer:_v,AnimationObjectGroup:ZT,AnimationUtils:bT,ArcCurve:X_,ArrayCamera:Zm,ArrowHelper:p1,AttachedBindMode:bp,Audio:jm,AudioAnalyser:zT,AudioContext:Nd,AudioListener:mv,AudioLoader:pv,AxesHelper:Iv,BackSide:An,BasicDepthPacking:rm,BasicShadowMap:mS,BatchedMesh:gm,BezierInterpolant:ov,Bone:hd,BooleanKeyframeTrack:pr,Box2:s1,Box3:mn,Box3Helper:Rv,BoxGeometry:dr,BoxHelper:Nv,BufferAttribute:Te,BufferGeometry:se,BufferGeometryLoader:dv,ByteType:Qp,Cache:Fi,Camera:Tc,CameraHelper:Cv,CanvasTexture:H_,CapsuleGeometry:fd,CatmullRomCurve3:bm,CineonToneMapping:jp,CircleGeometry:pd,ClampToEdgeWrapping:Bn,Clock:e1,Color:wt,ColorKeyframeTrack:Ad,ColorManagement:fe,Compatibility:US,CompressedArrayTexture:k_,CompressedCubeTexture:G_,CompressedTexture:_c,CompressedTextureLoader:CT,ConeGeometry:vc,ConstantAlphaFactor:$y,ConstantColorFactor:Wy,Controls:Lv,CubeCamera:Ym,CubeDepthTexture:W_,CubeReflectionMapping:ss,CubeRefractionMapping:or,CubeTexture:Sa,CubeTextureLoader:NT,CubeUVReflectionMapping:to,CubicBezierCurve:Tm,CubicBezierCurve3:$_,CubicInterpolant:sv,CullFaceBack:vp,CullFaceFront:Iy,CullFaceFrontBack:pS,CullFaceNone:Ry,Curve:vi,CurvePath:Y_,CustomBlending:Zp,CustomToneMapping:Kp,CylinderGeometry:ba,Cylindrical:n1,Data3DTexture:mc,DataArrayTexture:od,DataTexture:fi,DataTextureLoader:lv,DataUtils:O_,DecrementStencilOp:l_,DecrementWrapStencilOp:h_,DefaultLoadingManager:zm,DepthFormat:Oi,DepthStencilFormat:Cs,DepthTexture:jr,DetachedBindMode:Jy,DirectionalLight:Wm,DirectionalLightHelper:Ev,DiscreteInterpolant:rv,DodecahedronGeometry:md,DoubleSide:Ri,DstAlphaFactor:zy,DstColorFactor:ky,DynamicCopyUsage:RS,DynamicDrawUsage:w_,DynamicReadUsage:ES,EdgesGeometry:Mm,EllipseCurve:gd,EqualCompare:M_,EqualDepth:Al,EqualStencilFunc:p_,EquirectangularReflectionMapping:Jo,EquirectangularRefractionMapping:jo,Euler:mi,EventDispatcher:Bi,ExternalTexture:vm,ExtrudeGeometry:Mc,FileLoader:rs,Float16BufferAttribute:Tb,Float32BufferAttribute:Ct,FloatType:Tn,Fog:cm,FogExp2:ad,FramebufferTexture:Hb,FrontSide:is,Frustum:no,FrustumArray:ud,GLBufferAttribute:t1,GLSL1:PS,GLSL3:Nu,GreaterCompare:S_,GreaterDepth:Cl,GreaterEqualCompare:rd,GreaterEqualDepth:El,GreaterEqualStencilFunc:y_,GreaterStencilFunc:g_,GridHelper:Av,Group:Gr,HalfFloatType:Ui,HemisphereLight:Vm,HemisphereLightHelper:u1,IcosahedronGeometry:xd,ImageBitmapLoader:fv,ImageLoader:sc,ImageUtils:am,IncrementStencilOp:a_,IncrementWrapStencilOp:c_,InstancedBufferAttribute:Jr,InstancedBufferGeometry:qm,InstancedInterleavedBuffer:vv,InstancedMesh:mm,Int16BufferAttribute:Sb,Int32BufferAttribute:bb,Int8BufferAttribute:_b,IntType:ju,InterleavedBuffer:xc,InterleavedBufferAttribute:ua,Interpolant:so,InterpolateBezier:Tp,InterpolateDiscrete:ca,InterpolateLinear:Yl,InterpolateSmooth:su,InterpolationSamplingMode:DS,InterpolationSamplingType:FS,InvertStencilOp:u_,KeepStencilOp:Ks,KeyframeTrack:ri,LOD:fm,LatheGeometry:yd,Layers:gc,LessCompare:v_,LessDepth:wl,LessEqualCompare:sd,LessEqualDepth:rr,LessEqualStencilFunc:m_,LessStencilFunc:f_,Light:mr,LightProbe:uv,Line:Fs,Line3:Tv,LineBasicMaterial:Rn,LineCurve:wm,LineCurve3:q_,LineDashedMaterial:nv,LineLoop:xm,LineSegments:zi,LinearFilter:Fe,LinearInterpolant:Bm,LinearMipMapLinearFilter:Ky,LinearMipMapNearestFilter:yS,LinearMipmapLinearFilter:Li,LinearMipmapNearestFilter:Ko,LinearSRGBColorSpace:lr,LinearToneMapping:Wu,LinearTransfer:Jl,Loader:Vn,LoaderUtils:Fu,LoadingManager:Ed,LoopOnce:nm,LoopPingPong:Qy,LoopRepeat:im,MOUSE:Cy,Material:gn,MaterialBlending:gS,MaterialLoader:Cd,MathUtils:N_,Matrix2:i1,Matrix3:ae,Matrix4:Qt,MaxEquation:Jp,Mesh:Ye,MeshBasicMaterial:Ds,MeshDepthMaterial:wd,MeshDistanceMaterial:Um,MeshLambertMaterial:Dm,MeshMatcapMaterial:ev,MeshNormalMaterial:Fm,MeshPhongMaterial:Lm,MeshPhysicalMaterial:Pm,MeshStandardMaterial:Td,MeshToonMaterial:tv,MinEquation:Fy,MirroredRepeatWrapping:aa,MixOperation:Yy,MultiplyBlending:Sp,MultiplyOperation:uc,NearestFilter:Xe,NearestMipMapLinearFilter:xS,NearestMipMapNearestFilter:jy,NearestMipmapLinearFilter:zr,NearestMipmapNearestFilter:Ju,NeutralToneMapping:Yu,NeverCompare:__,NeverDepth:bl,NeverStencilFunc:d_,NoBlending:Di,NoColorSpace:Ki,NoNormalPacking:SS,NoToneMapping:di,NormalAnimationBlendMode:id,NormalBlending:nr,NormalGAPacking:TS,NormalRGPacking:bS,NotEqualCompare:b_,NotEqualDepth:Nl,NotEqualStencilFunc:x_,NumberKeyframeTrack:pa,Object3D:ve,ObjectLoader:LT,ObjectSpaceNormalMap:s_,OctahedronGeometry:Ta,OneFactor:Uy,OneMinusConstantAlphaFactor:qy,OneMinusConstantColorFactor:Xy,OneMinusDstAlphaFactor:Vy,OneMinusDstColorFactor:Gy,OneMinusSrcAlphaFactor:fu,OneMinusSrcColorFactor:By,OrthographicCamera:Ea,PCFShadowMap:ul,PCFSoftShadowMap:Yp,PMREMGenerator:Du,Path:Lu,PerspectiveCamera:cn,Plane:Ts,PlaneGeometry:io,PlaneHelper:f1,PointLight:Hm,PointLightHelper:c1,Points:ym,PointsMaterial:dd,PolarGridHelper:d1,PolyhedronGeometry:fr,PositionalAudio:gv,PropertyBinding:me,PropertyMixer:xv,QuadraticBezierCurve:Am,QuadraticBezierCurve3:Em,Quaternion:En,QuaternionKeyframeTrack:Aa,QuaternionLinearInterpolant:av,R11_EAC_Format:Ul,RED_GREEN_RGTC2_Format:$l,RED_RGTC1_Format:Wl,REVISION:Wr,RG11_EAC_Format:Bl,RGBADepthPacking:i_,RGBAFormat:wn,RGBAIntegerFormat:pc,RGBA_ASTC_10x10_Format:Tu,RGBA_ASTC_10x5_Format:Mu,RGBA_ASTC_10x6_Format:Su,RGBA_ASTC_10x8_Format:bu,RGBA_ASTC_12x10_Format:wu,RGBA_ASTC_12x12_Format:Au,RGBA_ASTC_4x4_Format:Vl,RGBA_ASTC_5x4_Format:mu,RGBA_ASTC_5x5_Format:gu,RGBA_ASTC_6x5_Format:xu,RGBA_ASTC_6x6_Format:kl,RGBA_ASTC_8x5_Format:yu,RGBA_ASTC_8x6_Format:_u,RGBA_ASTC_8x8_Format:vu,RGBA_BPTC_Format:Gl,RGBA_ETC2_EAC_Format:Dl,RGBA_PVRTC_2BPPV1_Format:Pl,RGBA_PVRTC_4BPPV1_Format:Il,RGBA_S3TC_DXT1_Format:ta,RGBA_S3TC_DXT3_Format:dl,RGBA_S3TC_DXT5_Format:ea,RGBDepthPacking:vS,RGBFormat:nd,RGBIntegerFormat:_S,RGB_BPTC_SIGNED_Format:Eu,RGB_BPTC_UNSIGNED_Format:Hl,RGB_ETC1_Format:Ll,RGB_ETC2_Format:Fl,RGB_PVRTC_2BPPV1_Format:pu,RGB_PVRTC_4BPPV1_Format:Rl,RGB_S3TC_DXT1_Format:Qo,RGDepthPacking:MS,RGFormat:ar,RGIntegerFormat:fc,RawShaderMaterial:bd,Ray:eo,Raycaster:Mv,RectAreaLight:hv,RedFormat:dc,RedIntegerFormat:Ma,ReinhardToneMapping:Xu,RenderTarget:lm,RenderTarget3D:jT,RepeatWrapping:oa,ReplaceStencilOp:o_,ReverseSubtractEquation:Ly,RingGeometry:Sc,SIGNED_R11_EAC_Format:Ol,SIGNED_RED_GREEN_RGTC2_Format:ql,SIGNED_RED_RGTC1_Format:Xl,SIGNED_RG11_EAC_Format:zl,SRGBColorSpace:Fn,SRGBTransfer:_e,Scene:hm,ShaderChunk:oe,ShaderLib:ci,ShaderMaterial:si,ShadowMaterial:Rm,Shape:ir,ShapeGeometry:_d,ShapePath:Pv,ShapeUtils:ui,ShortType:tm,Skeleton:yc,SkeletonHelper:l1,SkinnedMesh:pm,Source:Ns,Sphere:un,SphereGeometry:wa,Spherical:Sv,SphericalHarmonics3:$m,SplineCurve:Cm,SpotLight:Gm,SpotLightHelper:a1,Sprite:dm,SpriteMaterial:cd,SrcAlphaFactor:du,SrcAlphaSaturateFactor:Hy,SrcColorFactor:Oy,StaticCopyUsage:NS,StaticDrawUsage:jl,StaticReadUsage:AS,StereoCamera:DT,StreamCopyUsage:IS,StreamDrawUsage:wS,StreamReadUsage:CS,StringKeyframeTrack:ro,SubtractEquation:Py,SubtractiveBlending:Mp,TOUCH:Ny,TangentSpaceNormalMap:ur,TetrahedronGeometry:vd,Texture:rn,TextureLoader:cv,TextureUtils:_1,Timer:Jm,TimestampQuery:LS,TorusGeometry:bc,TorusKnotGeometry:Md,Triangle:ws,TriangleFanDrawMode:n_,TriangleStripDrawMode:e_,TrianglesDrawMode:t_,TubeGeometry:Sd,UVMapping:Zu,Uint16BufferAttribute:ld,Uint32BufferAttribute:um,Uint8BufferAttribute:vb,Uint8ClampedBufferAttribute:Mb,Uniform:Rd,UniformsGroup:QT,UniformsLib:gt,UniformsUtils:Im,UnsignedByteType:Un,UnsignedInt101111Type:ed,UnsignedInt248Type:Yr,UnsignedInt5999Type:td,UnsignedIntType:ii,UnsignedShort4444Type:Ku,UnsignedShort5551Type:Qu,UnsignedShortType:la,VSMShadowMap:Yo,Vector2:tt,Vector3:R,Vector4:Le,VectorKeyframeTrack:ma,VideoFrameTexture:Gb,VideoTexture:_m,WebGL3DRenderTarget:cb,WebGLArrayRenderTarget:lb,WebGLCoordinateSystem:ti,WebGLCubeRenderTarget:Pd,WebGLRenderTarget:qn,WebGLRenderer:Vv,WebGLUtils:zv,WebGPUCoordinateSystem:Zr,WebXRController:au,WireframeGeometry:Nm,WrapAroundEnding:Zl,ZeroCurvatureEnding:Vr,ZeroFactor:Dy,ZeroSlopeEnding:kr,ZeroStencilOp:r_,createCanvasElement:E_,error:Vt,getConsoleFunction:VS,log:Ql,setConsoleFunction:zS,warn:pt,warnOnce:tc},Symbol.toStringTag,{value:"Module"})),Eh={VERTEX:"vertex"},ue={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Mx={READ_ONLY:"readOnly",READ_WRITE:"readWrite"},wc=["x","y","z","w"],uN=0,dN=1,fN=2,cu=3,Fp=0,tg=1,pN=2,mN=0,Sx=1,bx=100,Tx=204,wx=205,Ax=3,gN=0,Dp=0,xN=1,yN=2,_N=3,vN=4,MN=6,SN=7,kv=300,eg=301,bN=302,Ex=1e3,ll=1001,Cx=1002,gi=1003,rc=1006,Gv=1008,Hv=1009,TN=1013,ng=1014,Wv=1015,cl=1016,wN=1023,Up=1026,AN=1027,hl=1030,EN=37490,CN=36285,zf=0,NN=1,Uu="",Ni="srgb",Nx="srgb-linear",Rx="linear",gl="srgb",Vf="",Xv="rg",RN="ga",Lo=7680,Ix=519,IN=513,ig=515,Px=516,Ou=518,xa=35044,Op=35048,ns=2e3,hr=2001,$v={TEXTURE_COMPARE:"depthTextureCompare"};function PN(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function Lx(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Fx={};function Bp(...r){const t="THREE."+r.shift();console.log(t,...r)}function qv(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function ne(...r){r=qv(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function Ne(...r){r=qv(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function ya(...r){const t=r.join(" ");t in Fx||(Fx[t]=!0,ne(...r))}const Sn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Dx=1234567;const xl=Math.PI/180,oc=180/Math.PI;function Ps(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Sn[r&255]+Sn[r>>8&255]+Sn[r>>16&255]+Sn[r>>24&255]+"-"+Sn[t&255]+Sn[t>>8&255]+"-"+Sn[t>>16&15|64]+Sn[t>>24&255]+"-"+Sn[e&63|128]+Sn[e>>8&255]+"-"+Sn[e>>16&255]+Sn[e>>24&255]+Sn[n&255]+Sn[n>>8&255]+Sn[n>>16&255]+Sn[n>>24&255]).toLowerCase()}function pe(r,t,e){return Math.max(t,Math.min(e,r))}function sg(r,t){return(r%t+t)%t}function LN(r,t,e,n,i){return n+(r-t)*(i-n)/(e-t)}function FN(r,t,e){return r!==t?(e-r)/(t-r):0}function yl(r,t,e){return(1-e)*r+e*t}function DN(r,t,e,n){return yl(r,t,1-Math.exp(-e*n))}function UN(r,t=1){return t-Math.abs(sg(r,t*2)-t)}function ON(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function BN(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function zN(r,t){return r+Math.floor(Math.random()*(t-r+1))}function VN(r,t){return r+Math.random()*(t-r)}function kN(r){return r*(.5-Math.random())}function GN(r){r!==void 0&&(Dx=r);let t=Dx+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function HN(r){return r*xl}function WN(r){return r*oc}function XN(r){return(r&r-1)===0&&r!==0}function $N(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function qN(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function YN(r,t,e,n,i){const s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),c=s((t+n)/2),h=o((t+n)/2),u=s((t-n)/2),d=o((t-n)/2),f=s((n-t)/2),p=o((n-t)/2);switch(i){case"XYX":r.set(a*h,l*u,l*d,a*c);break;case"YZY":r.set(l*d,a*h,l*u,a*c);break;case"ZXZ":r.set(l*u,l*d,a*h,a*c);break;case"XZX":r.set(a*h,l*p,l*f,a*c);break;case"YXY":r.set(l*f,a*h,l*p,a*c);break;case"ZYZ":r.set(l*p,l*f,a*h,a*c);break;default:ne("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ii(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function be(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const ZN={DEG2RAD:xl,RAD2DEG:oc,generateUUID:Ps,clamp:pe,euclideanModulo:sg,mapLinear:LN,inverseLerp:FN,lerp:yl,damp:DN,pingpong:UN,smoothstep:ON,smootherstep:BN,randInt:zN,randFloat:VN,randFloatSpread:kN,seededRandom:GN,degToRad:HN,radToDeg:WN,isPowerOfTwo:XN,ceilPowerOfTwo:$N,floorPowerOfTwo:qN,setQuaternionFromProperEuler:YN,normalize:be,denormalize:Ii};class Mi{constructor(t,e,n,i,s,o,a,l,c){Mi.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,o,a,l,c)}set(t,e,n,i,s,o,a,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=s,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.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 n=t.elements,i=e.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],p=n[8],x=i[0],g=i[3],m=i[6],y=i[1],v=i[4],_=i[7],w=i[2],T=i[5],E=i[8];return s[0]=o*x+a*y+l*w,s[3]=o*g+a*v+l*T,s[6]=o*m+a*_+l*E,s[1]=c*x+h*y+u*w,s[4]=c*g+h*v+u*T,s[7]=c*m+h*_+u*E,s[2]=d*x+f*y+p*w,s[5]=d*g+f*v+p*T,s[8]=d*m+f*_+p*E,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],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*s*h+n*a*l+i*s*c-i*o*l}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*o-a*c,d=a*l-h*s,f=c*s-o*l,p=e*u+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/p;return t[0]=u*x,t[1]=(i*c-h*n)*x,t[2]=(a*n-i*o)*x,t[3]=d*x,t[4]=(h*e-i*l)*x,t[5]=(i*s-a*e)*x,t[6]=f*x,t[7]=(n*l-c*e)*x,t[8]=(o*e-n*s)*x,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,n,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(kf.makeScale(t,e)),this}rotate(t){return this.premultiply(kf.makeRotation(-t)),this}translate(t,e){return this.premultiply(kf.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),n=Math.sin(t);return this.set(e,-n,0,n,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,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const kf=new Mi,Ux=new Mi().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ox=new Mi().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function JN(){const r={enabled:!0,workingColorSpace:Nx,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===gl&&(i.r=Ls(i.r),i.g=Ls(i.g),i.b=Ls(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===gl&&(i.r=ia(i.r),i.g=ia(i.g),i.b=ia(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Uu?Rx:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return ya("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return ya("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[Nx]:{primaries:t,whitePoint:n,transfer:Rx,toXYZ:Ux,fromXYZ:Ox,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ni},outputColorSpaceConfig:{drawingBufferColorSpace:Ni}},[Ni]:{primaries:t,whitePoint:n,transfer:gl,toXYZ:Ux,fromXYZ:Ox,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ni}}}),r}const Qe=JN();function Ls(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ia(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}const Yv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Xs={h:0,s:0,l:0},Ch={h:0,s:0,l:0};function Gf(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class Vi{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ni){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Qe.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=Qe.workingColorSpace){return this.r=t,this.g=e,this.b=n,Qe.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=Qe.workingColorSpace){if(t=sg(t,1),e=pe(e,0,1),n=pe(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,o=2*n-s;this.r=Gf(o,s,t+1/3),this.g=Gf(o,s,t),this.b=Gf(o,s,t-1/3)}return Qe.colorSpaceToWorking(this,i),this}setStyle(t,e=Ni){function n(s){s!==void 0&&parseFloat(s)<1&&ne("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:ne("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);ne("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ni){const n=Yv[t.toLowerCase()];return n!==void 0?this.setHex(n,e):ne("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=Ls(t.r),this.g=Ls(t.g),this.b=Ls(t.b),this}copyLinearToSRGB(t){return this.r=ia(t.r),this.g=ia(t.g),this.b=ia(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ni){return Qe.workingToColorSpace(bn.copy(this),t),Math.round(pe(bn.r*255,0,255))*65536+Math.round(pe(bn.g*255,0,255))*256+Math.round(pe(bn.b*255,0,255))}getHexString(t=Ni){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Qe.workingColorSpace){Qe.workingToColorSpace(bn.copy(this),e);const n=bn.r,i=bn.g,s=bn.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Qe.workingColorSpace){return Qe.workingToColorSpace(bn.copy(this),e),t.r=bn.r,t.g=bn.g,t.b=bn.b,t}getStyle(t=Ni){Qe.workingToColorSpace(bn.copy(this),t);const e=bn.r,n=bn.g,i=bn.b;return t!==Ni?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(Xs),this.setHSL(Xs.h+t,Xs.s+e,Xs.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Xs),t.getHSL(Ch);const n=yl(Xs.h,Ch.h,e),i=yl(Xs.s,Ch.s,e),s=yl(Xs.l,Ch.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const bn=new Vi;Vi.NAMES=Yv;class rg{constructor(t,e,n,i){rg.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}}class Na{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,o,a){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3],d=s[o+0],f=s[o+1],p=s[o+2],x=s[o+3];if(u!==x||l!==d||c!==f||h!==p){let g=l*d+c*f+h*p+u*x;g<0&&(d=-d,f=-f,p=-p,x=-x,g=-g);let m=1-a;if(g<.9995){const y=Math.acos(g),v=Math.sin(y);m=Math.sin(m*y)/v,a=Math.sin(a*y)/v,l=l*m+d*a,c=c*m+f*a,h=h*m+p*a,u=u*m+x*a}else{l=l*m+d*a,c=c*m+f*a,h=h*m+p*a,u=u*m+x*a;const y=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=y,c*=y,h*=y,u*=y}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+h*u+l*f-c*d,t[e+1]=l*p+h*d+c*u-a*f,t[e+2]=c*p+h*f+a*d-l*u,t[e+3]=h*p-a*u-l*d-c*f,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,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,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 n=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(i/2),u=a(s/2),d=l(n/2),f=l(i/2),p=l(s/2);switch(o){case"XYZ":this._x=d*h*u+c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u+d*f*p;break;case"YZX":this._x=d*h*u+c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u-d*f*p;break;case"XZY":this._x=d*h*u-c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u+d*f*p;break;default:ne("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+a+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(n>a&&n>u){const f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>u){const f=2*Math.sqrt(1+a-n-u);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(pe(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),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 n=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-n*c,this._z=s*h+o*c+n*l-i*a,this._w=o*h-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,s=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,i=-i,s=-s,o=-o,a=-a);let l=1-e;if(a<.9995){const c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+i*e,this._z=this._z*l+s*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+i*e,this._z=this._z*l+s*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}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 H{constructor(t=0,e=0,n=0){H.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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(Bx.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Bx.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*i-a*n),h=2*(a*e-s*i),u=2*(s*n-o*e);return this.x=e+l*c+o*u-a*h,this.y=n+l*h+a*c-s*u,this.z=i+l*u+s*h-o*c,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,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,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=pe(this.x,t.x,e.x),this.y=pe(this.y,t.y,e.y),this.z=pe(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=pe(this.x,t,e),this.y=pe(this.y,t,e),this.z=pe(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pe(n,t,e))}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Hf.copy(this).projectOnVector(t),this.sub(Hf)}reflect(t){return this.sub(Hf.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 n=this.dot(t)/e;return Math.acos(pe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,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(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Hf=new H,Bx=new Na;class ke{constructor(t,e,n,i,s,o,a,l,c,h,u,d,f,p,x,g){ke.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,n,i,s,o,a,l,c,h,u,d,f,p,x,g)}set(t,e,n,i,s,o,a,l,c,h,u,d,f,p,x,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=p,m[11]=x,m[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 ke().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[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,n){return this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();const e=this.elements,n=t.elements,i=1/Fo.setFromMatrixColumn(t,0).length(),s=1/Fo.setFromMatrixColumn(t,1).length(),o=1/Fo.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,s=t.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=o*h,f=o*u,p=a*h,x=a*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+p*c,e[5]=d-x*c,e[9]=-a*l,e[2]=x-d*c,e[6]=p+f*c,e[10]=o*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,p=c*h,x=c*u;e[0]=d+x*a,e[4]=p*a-f,e[8]=o*c,e[1]=o*u,e[5]=o*h,e[9]=-a,e[2]=f*a-p,e[6]=x+d*a,e[10]=o*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,p=c*h,x=c*u;e[0]=d-x*a,e[4]=-o*u,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*h,e[9]=x-d*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const d=o*h,f=o*u,p=a*h,x=a*u;e[0]=l*h,e[4]=p*c-f,e[8]=d*c+x,e[1]=l*u,e[5]=x*c+d,e[9]=f*c-p,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const d=o*l,f=o*c,p=a*l,x=a*c;e[0]=l*h,e[4]=x-d*u,e[8]=p*u+f,e[1]=u,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=f*u+p,e[10]=d-x*u}else if(t.order==="XZY"){const d=o*l,f=o*c,p=a*l,x=a*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+x,e[5]=o*h,e[9]=f*u-p,e[2]=p*u-f,e[6]=a*h,e[10]=x*u+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(jN,t,KN)}lookAt(t,e,n){const i=this.elements;return jn.subVectors(t,e),jn.lengthSq()===0&&(jn.z=1),jn.normalize(),$s.crossVectors(n,jn),$s.lengthSq()===0&&(Math.abs(n.z)===1?jn.x+=1e-4:jn.z+=1e-4,jn.normalize(),$s.crossVectors(n,jn)),$s.normalize(),Nh.crossVectors(jn,$s),i[0]=$s.x,i[4]=Nh.x,i[8]=jn.x,i[1]=$s.y,i[5]=Nh.y,i[9]=jn.y,i[2]=$s.z,i[6]=Nh.z,i[10]=jn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],p=n[2],x=n[6],g=n[10],m=n[14],y=n[3],v=n[7],_=n[11],w=n[15],T=i[0],E=i[4],M=i[8],b=i[12],P=i[1],N=i[5],L=i[9],U=i[13],V=i[2],O=i[6],k=i[10],G=i[14],it=i[3],nt=i[7],mt=i[11],xt=i[15];return s[0]=o*T+a*P+l*V+c*it,s[4]=o*E+a*N+l*O+c*nt,s[8]=o*M+a*L+l*k+c*mt,s[12]=o*b+a*U+l*G+c*xt,s[1]=h*T+u*P+d*V+f*it,s[5]=h*E+u*N+d*O+f*nt,s[9]=h*M+u*L+d*k+f*mt,s[13]=h*b+u*U+d*G+f*xt,s[2]=p*T+x*P+g*V+m*it,s[6]=p*E+x*N+g*O+m*nt,s[10]=p*M+x*L+g*k+m*mt,s[14]=p*b+x*U+g*G+m*xt,s[3]=y*T+v*P+_*V+w*it,s[7]=y*E+v*N+_*O+w*nt,s[11]=y*M+v*L+_*k+w*mt,s[15]=y*b+v*U+_*G+w*xt,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],n=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],p=t[3],x=t[7],g=t[11],m=t[15],y=l*f-c*d,v=a*f-c*u,_=a*d-l*u,w=o*f-c*h,T=o*d-l*h,E=o*u-a*h;return e*(x*y-g*v+m*_)-n*(p*y-g*w+m*T)+i*(p*v-x*w+m*E)-s*(p*_-x*T+g*E)}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,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],p=t[12],x=t[13],g=t[14],m=t[15],y=e*a-n*o,v=e*l-i*o,_=e*c-s*o,w=n*l-i*a,T=n*c-s*a,E=i*c-s*l,M=h*x-u*p,b=h*g-d*p,P=h*m-f*p,N=u*g-d*x,L=u*m-f*x,U=d*m-f*g,V=y*U-v*L+_*N+w*P-T*b+E*M;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/V;return t[0]=(a*U-l*L+c*N)*O,t[1]=(i*L-n*U-s*N)*O,t[2]=(x*E-g*T+m*w)*O,t[3]=(d*T-u*E-f*w)*O,t[4]=(l*P-o*U-c*b)*O,t[5]=(e*U-i*P+s*b)*O,t[6]=(g*_-p*E-m*v)*O,t[7]=(h*E-d*_+f*v)*O,t[8]=(o*L-a*P+c*M)*O,t[9]=(n*P-e*L-s*M)*O,t[10]=(p*T-x*_+m*y)*O,t[11]=(u*_-h*T-f*y)*O,t[12]=(a*b-o*N-l*M)*O,t[13]=(e*N-n*b+i*M)*O,t[14]=(x*v-p*w-g*y)*O,t[15]=(h*w-u*v+d*y)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),s=1-n,o=t.x,a=t.y,l=t.z,c=s*o,h=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+n,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,o){return this.set(1,n,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,h=o+o,u=a+a,d=s*c,f=s*h,p=s*u,x=o*h,g=o*u,m=a*u,y=l*c,v=l*h,_=l*u,w=n.x,T=n.y,E=n.z;return i[0]=(1-(x+m))*w,i[1]=(f+_)*w,i[2]=(p-v)*w,i[3]=0,i[4]=(f-_)*T,i[5]=(1-(d+m))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+v)*E,i[9]=(g-y)*E,i[10]=(1-(d+x))*E,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const s=this.determinant();if(s===0)return n.set(1,1,1),e.identity(),this;let o=Fo.set(i[0],i[1],i[2]).length();const a=Fo.set(i[4],i[5],i[6]).length(),l=Fo.set(i[8],i[9],i[10]).length();s<0&&(o=-o),Ai.copy(this);const c=1/o,h=1/a,u=1/l;return Ai.elements[0]*=c,Ai.elements[1]*=c,Ai.elements[2]*=c,Ai.elements[4]*=h,Ai.elements[5]*=h,Ai.elements[6]*=h,Ai.elements[8]*=u,Ai.elements[9]*=u,Ai.elements[10]*=u,e.setFromRotationMatrix(Ai),n.x=o,n.y=a,n.z=l,this}makePerspective(t,e,n,i,s,o,a=ns,l=!1){const c=this.elements,h=2*s/(e-t),u=2*s/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i);let p,x;if(l)p=s/(o-s),x=o*s/(o-s);else if(a===ns)p=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(a===hr)p=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,s,o,a=ns,l=!1){const c=this.elements,h=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),f=-(n+i)/(n-i);let p,x;if(l)p=1/(o-s),x=o/(o-s);else if(a===ns)p=-2/(o-s),x=-(o+s)/(o-s);else if(a===hr)p=-1/(o-s),x=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Fo=new H,Ai=new ke,jN=new H(0,0,0),KN=new H(1,1,1),$s=new H,Nh=new H,jn=new H;class Ge{constructor(t=0,e=0){Ge.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,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=pe(this.x,t.x,e.x),this.y=pe(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=pe(this.x,t,e),this.y=pe(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pe(n,t,e))}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 n=this.dot(t)/e;return Math.acos(pe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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 n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*n-o*i+t.x,this.y=s*i+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Nn{constructor(t=0,e=0,n=0,i=1){Nn.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=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;case 3:this.w=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;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}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!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=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.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=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.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,s;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],p=l[9],x=l[2],g=l[6],m=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(p+g)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const v=(c+1)/2,_=(f+1)/2,w=(m+1)/2,T=(h+d)/4,E=(u+x)/4,M=(p+g)/4;return v>_&&v>w?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=T/n,s=E/n):_>w?_<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(_),n=T/i,s=M/i):w<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),n=E/s,i=M/s),this.set(n,i,s,e),this}let y=Math.sqrt((g-p)*(g-p)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-x)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}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.w=Math.min(this.w,t.w),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.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=pe(this.x,t.x,e.x),this.y=pe(this.y,t.y,e.y),this.z=pe(this.z,t.z,e.z),this.w=pe(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=pe(this.x,t,e),this.y=pe(this.y,t,e),this.z=pe(this.z,t,e),this.w=pe(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pe(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}const QN=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function tR(r){const t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return r.split(`
|
|
4057
|
+
}`;class iN{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new _m(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new si({vertexShader:eN,fragmentShader:nN,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ye(new io(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class sN extends Bi{constructor(t,e){super();const n=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,p=null;const x=typeof XRWebGLBinding<"u",g=new iN,m={},y=e.getContextAttributes();let v=null,_=null;const w=[],T=[],E=new tt;let M=null;const b=new cn;b.viewport=new Le;const P=new cn;P.viewport=new Le;const N=[b,P],L=new Ym;let U=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(j){let ct=w[j];return ct===void 0&&(ct=new au,w[j]=ct),ct.getTargetRaySpace()},this.getControllerGrip=function(j){let ct=w[j];return ct===void 0&&(ct=new au,w[j]=ct),ct.getGripSpace()},this.getHand=function(j){let ct=w[j];return ct===void 0&&(ct=new au,w[j]=ct),ct.getHandSpace()};function O(j){const ct=T.indexOf(j.inputSource);if(ct===-1)return;const ht=w[ct];ht!==void 0&&(ht.update(j.inputSource,j.frame,c||o),ht.dispatchEvent({type:j.type,data:j.inputSource}))}function k(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",k),i.removeEventListener("inputsourceschange",G);for(let j=0;j<w.length;j++){const ct=T[j];ct!==null&&(T[j]=null,w[j]&&w[j].disconnect(ct))}U=null,V=null,g.reset();for(const j in m)delete m[j];t.setRenderTarget(v),f=null,d=null,u=null,i=null,_=null,we.stop(),n.isPresenting=!1,t.setPixelRatio(M),t.setSize(E.width,E.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,n.isPresenting===!0&&pt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){a=j,n.isPresenting===!0&&pt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(i,e)),u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(j){if(i=j,i!==null){if(v=t.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",k),i.addEventListener("inputsourceschange",G),y.xrCompatible!==!0&&await e.makeXRCompatible(),M=t.getPixelRatio(),t.getSize(E),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ht=null,qt=null,Xt=null;y.depth&&(Xt=y.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,ht=y.stencil?Cs:Oi,qt=y.stencil?Yr:ii);const Kt={colorFormat:e.RGBA8,depthFormat:Xt,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Kt),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),_=new qn(d.textureWidth,d.textureHeight,{format:wn,type:Un,depthTexture:new jr(d.textureWidth,d.textureHeight,qt,void 0,void 0,void 0,void 0,void 0,void 0,ht),stencilBuffer:y.stencil,colorSpace:t.outputColorSpace,samples:y.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ht={antialias:y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,ht),i.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new qn(f.framebufferWidth,f.framebufferHeight,{format:wn,type:Un,colorSpace:t.outputColorSpace,stencilBuffer:y.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),we.setContext(i),we.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function G(j){for(let ct=0;ct<j.removed.length;ct++){const ht=j.removed[ct],qt=T.indexOf(ht);qt>=0&&(T[qt]=null,w[qt]&&w[qt].disconnect(ht))}for(let ct=0;ct<j.added.length;ct++){const ht=j.added[ct];let qt=T.indexOf(ht);if(qt===-1){for(let Kt=0;Kt<w.length;Kt++)if(Kt>=T.length){T.push(ht),qt=Kt;break}else if(T[Kt]===null){T[Kt]=ht,qt=Kt;break}if(qt===-1)break}const Xt=w[qt];Xt&&Xt.connect(ht)}}const it=new R,nt=new R;function mt(j,ct,ht){it.setFromMatrixPosition(ct.matrixWorld),nt.setFromMatrixPosition(ht.matrixWorld);const qt=it.distanceTo(nt),Xt=ct.projectionMatrix.elements,Kt=ht.projectionMatrix.elements,Ae=Xt[14]/(Xt[10]-1),ie=Xt[14]/(Xt[10]+1),Q=(Xt[9]+1)/Xt[5],rt=(Xt[9]-1)/Xt[5],et=(Xt[8]-1)/Xt[0],yt=(Kt[8]+1)/Kt[0],I=Ae*et,$t=Ae*yt,Tt=qt/(-et+yt),Yt=Tt*-et;if(ct.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Yt),j.translateZ(Tt),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),Xt[10]===-1)j.projectionMatrix.copy(ct.projectionMatrix),j.projectionMatrixInverse.copy(ct.projectionMatrixInverse);else{const ut=Ae+Tt,C=ie+Tt,S=I-Yt,D=$t+(qt-Yt),Y=Q*ie/C*ut,K=rt*ie/C*ut;j.projectionMatrix.makePerspective(S,D,Y,K,ut,C),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function xt(j,ct){ct===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(ct.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(i===null)return;let ct=j.near,ht=j.far;g.texture!==null&&(g.depthNear>0&&(ct=g.depthNear),g.depthFar>0&&(ht=g.depthFar)),L.near=P.near=b.near=ct,L.far=P.far=b.far=ht,(U!==L.near||V!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),U=L.near,V=L.far),L.layers.mask=j.layers.mask|6,b.layers.mask=L.layers.mask&-5,P.layers.mask=L.layers.mask&-3;const qt=j.parent,Xt=L.cameras;xt(L,qt);for(let Kt=0;Kt<Xt.length;Kt++)xt(Xt[Kt],qt);Xt.length===2?mt(L,b,P):L.projectionMatrix.copy(b.projectionMatrix),bt(j,L,qt)};function bt(j,ct,ht){ht===null?j.matrix.copy(ct.matrixWorld):(j.matrix.copy(ht.matrixWorld),j.matrix.invert(),j.matrix.multiply(ct.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(ct.projectionMatrix),j.projectionMatrixInverse.copy(ct.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=ua*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(j){l=j,d!==null&&(d.fixedFoveation=j),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=j)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(L)},this.getCameraTexture=function(j){return m[j]};let jt=null;function Me(j,ct){if(h=ct.getViewerPose(c||o),p=ct,h!==null){const ht=h.views;f!==null&&(t.setRenderTargetFramebuffer(_,f.framebuffer),t.setRenderTarget(_));let qt=!1;ht.length!==L.cameras.length&&(L.cameras.length=0,qt=!0);for(let ie=0;ie<ht.length;ie++){const Q=ht[ie];let rt=null;if(f!==null)rt=f.getViewport(Q);else{const yt=u.getViewSubImage(d,Q);rt=yt.viewport,ie===0&&(t.setRenderTargetTextures(_,yt.colorTexture,yt.depthStencilTexture),t.setRenderTarget(_))}let et=N[ie];et===void 0&&(et=new cn,et.layers.enable(ie),et.viewport=new Le,N[ie]=et),et.matrix.fromArray(Q.transform.matrix),et.matrix.decompose(et.position,et.quaternion,et.scale),et.projectionMatrix.fromArray(Q.projectionMatrix),et.projectionMatrixInverse.copy(et.projectionMatrix).invert(),et.viewport.set(rt.x,rt.y,rt.width,rt.height),ie===0&&(L.matrix.copy(et.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),qt===!0&&L.cameras.push(et)}const Xt=i.enabledFeatures;if(Xt&&Xt.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const ie=u.getDepthInformation(ht[0]);ie&&ie.isValid&&ie.texture&&g.init(ie,i.renderState)}if(Xt&&Xt.includes("camera-access")&&x){t.state.unbindTexture(),u=n.getBinding();for(let ie=0;ie<ht.length;ie++){const Q=ht[ie].camera;if(Q){let rt=m[Q];rt||(rt=new _m,m[Q]=rt);const et=u.getCameraImage(Q);rt.sourceTexture=et}}}}if(n.controllerAutoUpdate)for(let ht=0;ht<w.length;ht++){const qt=T[ht],Xt=w[ht];qt!==null&&Xt!==void 0&&Xt.update(qt,ct,c||o)}jt&&jt(j,ct),ct.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ct}),p=null}const we=new Fv;we.setAnimationLoop(Me),this.setAnimationLoop=function(j){jt=j},this.dispose=function(){}}}const Rr=new mi,rN=new Qt;function oN(r,t){function e(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function n(g,m){m.color.getRGB(g.fogColor.value,Q_(r)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function i(g,m,y,v,_){m.isMeshBasicMaterial?s(g,m):m.isMeshLambertMaterial?(s(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(s(g,m),d(g,m),m.isMeshPhysicalMaterial&&f(g,m,_)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),x(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(o(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?l(g,m,y,v):m.isSpriteMaterial?c(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,e(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,e(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===An&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,e(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===An&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,e(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,e(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);const y=t.get(m),v=y.envMap,_=y.envMapRotation;v&&(g.envMap.value=v,Rr.copy(_),Rr.x*=-1,Rr.y*=-1,Rr.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Rr.y*=-1,Rr.z*=-1),g.envMapRotation.value.setFromMatrix4(rN.makeRotationFromEuler(Rr)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,g.lightMapTransform)),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,g.aoMapTransform))}function o(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,e(m.map,g.mapTransform))}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function l(g,m,y,v){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*y,g.scale.value=v*.5,m.map&&(g.map.value=m.map,e(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function c(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,e(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function d(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,y){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===An&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function x(g,m){const y=t.get(m).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function aN(r,t,e,n){let i={},s={},o=[];const a=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,v){const _=v.program;n.uniformBlockBinding(y,_)}function c(y,v){let _=i[y.id];_===void 0&&(p(y),_=h(y),i[y.id]=_,y.addEventListener("dispose",g));const w=v.program;n.updateUBOMapping(y,w);const T=t.render.frame;s[y.id]!==T&&(d(y),s[y.id]=T)}function h(y){const v=u();y.__bindingPointIndex=v;const _=r.createBuffer(),w=y.__size,T=y.usage;return r.bindBuffer(r.UNIFORM_BUFFER,_),r.bufferData(r.UNIFORM_BUFFER,w,T),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,_),_}function u(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return Vt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const v=i[y.id],_=y.uniforms,w=y.__cache;r.bindBuffer(r.UNIFORM_BUFFER,v);for(let T=0,E=_.length;T<E;T++){const M=Array.isArray(_[T])?_[T]:[_[T]];for(let b=0,P=M.length;b<P;b++){const N=M[b];if(f(N,T,b,w)===!0){const L=N.__offset,U=Array.isArray(N.value)?N.value:[N.value];let V=0;for(let O=0;O<U.length;O++){const k=U[O],G=x(k);typeof k=="number"||typeof k=="boolean"?(N.__data[0]=k,r.bufferSubData(r.UNIFORM_BUFFER,L+V,N.__data)):k.isMatrix3?(N.__data[0]=k.elements[0],N.__data[1]=k.elements[1],N.__data[2]=k.elements[2],N.__data[3]=0,N.__data[4]=k.elements[3],N.__data[5]=k.elements[4],N.__data[6]=k.elements[5],N.__data[7]=0,N.__data[8]=k.elements[6],N.__data[9]=k.elements[7],N.__data[10]=k.elements[8],N.__data[11]=0):(k.toArray(N.__data,V),V+=G.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,L,N.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(y,v,_,w){const T=y.value,E=v+"_"+_;if(w[E]===void 0)return typeof T=="number"||typeof T=="boolean"?w[E]=T:w[E]=T.clone(),!0;{const M=w[E];if(typeof T=="number"||typeof T=="boolean"){if(M!==T)return w[E]=T,!0}else if(M.equals(T)===!1)return M.copy(T),!0}return!1}function p(y){const v=y.uniforms;let _=0;const w=16;for(let E=0,M=v.length;E<M;E++){const b=Array.isArray(v[E])?v[E]:[v[E]];for(let P=0,N=b.length;P<N;P++){const L=b[P],U=Array.isArray(L.value)?L.value:[L.value];for(let V=0,O=U.length;V<O;V++){const k=U[V],G=x(k),it=_%w,nt=it%G.boundary,mt=it+nt;_+=nt,mt!==0&&w-mt<G.storage&&(_+=w-mt),L.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=_,_+=G.storage}}}const T=_%w;return T>0&&(_+=w-T),y.__size=_,y.__cache={},this}function x(y){const v={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(v.boundary=4,v.storage=4):y.isVector2?(v.boundary=8,v.storage=8):y.isVector3||y.isColor?(v.boundary=16,v.storage=12):y.isVector4?(v.boundary=16,v.storage=16):y.isMatrix3?(v.boundary=48,v.storage=48):y.isMatrix4?(v.boundary=64,v.storage=64):y.isTexture?pt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):pt("WebGLRenderer: Unsupported uniform value type.",y),v}function g(y){const v=y.target;v.removeEventListener("dispose",g);const _=o.indexOf(v.__bindingPointIndex);o.splice(_,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function m(){for(const y in i)r.deleteBuffer(i[y]);o=[],i={},s={}}return{bind:l,update:c,dispose:m}}const lN=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let $i=null;function cN(){return $i===null&&($i=new fi(lN,16,16,ar,Ui),$i.name="DFG_LUT",$i.minFilter=Fe,$i.magFilter=Fe,$i.wrapS=Bn,$i.wrapT=Bn,$i.generateMipmaps=!1,$i.needsUpdate=!0),$i}class Vv{constructor(t={}){const{canvas:e=E_(),context:n=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Un}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;const x=f,g=new Set([pc,fc,Sa]),m=new Set([Un,ii,ca,Yr,Ku,Qu]),y=new Uint32Array(4),v=new Int32Array(4);let _=null,w=null;const T=[],E=[];let M=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=di,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const b=this;let P=!1;this._outputColorSpace=Fn;let N=0,L=0,U=null,V=-1,O=null;const k=new Le,G=new Le;let it=null;const nt=new wt(0);let mt=0,xt=e.width,bt=e.height,jt=1,Me=null,we=null;const j=new Le(0,0,xt,bt),ct=new Le(0,0,xt,bt);let ht=!1;const qt=new no;let Xt=!1,Kt=!1;const Ae=new Qt,ie=new R,Q=new Le,rt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let et=!1;function yt(){return U===null?jt:1}let I=n;function $t(A,B){return e.getContext(A,B)}try{const A={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Wr}`),e.addEventListener("webglcontextlost",Ft,!1),e.addEventListener("webglcontextrestored",ee,!1),e.addEventListener("webglcontextcreationerror",Ie,!1),I===null){const B="webgl2";if(I=$t(B,A),I===null)throw $t(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw Vt("WebGLRenderer: "+A.message),A}let Tt,Yt,ut,C,S,D,Y,K,Z,It,dt,Ht,Zt,st,at,Lt,Dt,Et,ce,F,ft,lt,Rt;function ot(){Tt=new uE(I),Tt.init(),ft=new zv(I,Tt),Yt=new sE(I,Tt,t,ft),ut=new QC(I,Tt),Yt.reversedDepthBuffer&&d&&ut.buffers.depth.setReversed(!0),C=new pE(I),S=new zC,D=new tN(I,Tt,ut,S,Yt,ft,C),Y=new hE(b),K=new v1(I),lt=new nE(I,K),Z=new dE(I,K,C,lt),It=new gE(I,Z,K,lt,C),Et=new mE(I,Yt,D),at=new rE(S),dt=new BC(b,Y,Tt,Yt,lt,at),Ht=new oN(b,S),Zt=new kC,st=new qC(Tt),Dt=new eE(b,Y,ut,It,p,l),Lt=new KC(b,It,Yt),Rt=new aN(I,C,Yt,ut),ce=new iE(I,Tt,C),F=new fE(I,Tt,C),C.programs=dt.programs,b.capabilities=Yt,b.extensions=Tt,b.properties=S,b.renderLists=Zt,b.shadowMap=Lt,b.state=ut,b.info=C}ot(),x!==Un&&(M=new yE(x,e.width,e.height,i,s));const J=new sN(b,I);this.xr=J,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const A=Tt.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=Tt.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return jt},this.setPixelRatio=function(A){A!==void 0&&(jt=A,this.setSize(xt,bt,!1))},this.getSize=function(A){return A.set(xt,bt)},this.setSize=function(A,B,$=!0){if(J.isPresenting){pt("WebGLRenderer: Can't change size while VR device is presenting.");return}xt=A,bt=B,e.width=Math.floor(A*jt),e.height=Math.floor(B*jt),$===!0&&(e.style.width=A+"px",e.style.height=B+"px"),M!==null&&M.setSize(e.width,e.height),this.setViewport(0,0,A,B)},this.getDrawingBufferSize=function(A){return A.set(xt*jt,bt*jt).floor()},this.setDrawingBufferSize=function(A,B,$){xt=A,bt=B,jt=$,e.width=Math.floor(A*$),e.height=Math.floor(B*$),this.setViewport(0,0,A,B)},this.setEffects=function(A){if(x===Un){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(A){for(let B=0;B<A.length;B++)if(A[B].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}M.setEffects(A||[])},this.getCurrentViewport=function(A){return A.copy(k)},this.getViewport=function(A){return A.copy(j)},this.setViewport=function(A,B,$,X){A.isVector4?j.set(A.x,A.y,A.z,A.w):j.set(A,B,$,X),ut.viewport(k.copy(j).multiplyScalar(jt).round())},this.getScissor=function(A){return A.copy(ct)},this.setScissor=function(A,B,$,X){A.isVector4?ct.set(A.x,A.y,A.z,A.w):ct.set(A,B,$,X),ut.scissor(G.copy(ct).multiplyScalar(jt).round())},this.getScissorTest=function(){return ht},this.setScissorTest=function(A){ut.setScissorTest(ht=A)},this.setOpaqueSort=function(A){Me=A},this.setTransparentSort=function(A){we=A},this.getClearColor=function(A){return A.copy(Dt.getClearColor())},this.setClearColor=function(){Dt.setClearColor(...arguments)},this.getClearAlpha=function(){return Dt.getClearAlpha()},this.setClearAlpha=function(){Dt.setClearAlpha(...arguments)},this.clear=function(A=!0,B=!0,$=!0){let X=0;if(A){let W=!1;if(U!==null){const St=U.texture.format;W=g.has(St)}if(W){const St=U.texture.type,Nt=m.has(St),_t=Dt.getClearColor(),Ut=Dt.getClearAlpha(),Gt=_t.r,re=_t.g,he=_t.b;Nt?(y[0]=Gt,y[1]=re,y[2]=he,y[3]=Ut,I.clearBufferuiv(I.COLOR,0,y)):(v[0]=Gt,v[1]=re,v[2]=he,v[3]=Ut,I.clearBufferiv(I.COLOR,0,v))}else X|=I.COLOR_BUFFER_BIT}B&&(X|=I.DEPTH_BUFFER_BIT),$&&(X|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),X!==0&&I.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Ft,!1),e.removeEventListener("webglcontextrestored",ee,!1),e.removeEventListener("webglcontextcreationerror",Ie,!1),Dt.dispose(),Zt.dispose(),st.dispose(),S.dispose(),Y.dispose(),It.dispose(),lt.dispose(),Rt.dispose(),dt.dispose(),J.dispose(),J.removeEventListener("sessionstart",Ug),J.removeEventListener("sessionend",Og),gr.stop()};function Ft(A){A.preventDefault(),Ql("WebGLRenderer: Context Lost."),P=!0}function ee(){Ql("WebGLRenderer: Context Restored."),P=!1;const A=C.autoReset,B=Lt.enabled,$=Lt.autoUpdate,X=Lt.needsUpdate,W=Lt.type;ot(),C.autoReset=A,Lt.enabled=B,Lt.autoUpdate=$,Lt.needsUpdate=X,Lt.type=W}function Ie(A){Vt("WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Se(A){const B=A.target;B.removeEventListener("dispose",Se),us(B)}function us(A){ds(A),S.remove(A)}function ds(A){const B=S.get(A).programs;B!==void 0&&(B.forEach(function($){dt.releaseProgram($)}),A.isShaderMaterial&&dt.releaseShaderCache(A))}this.renderBufferDirect=function(A,B,$,X,W,St){B===null&&(B=rt);const Nt=W.isMesh&&W.matrixWorld.determinant()<0,_t=lS(A,B,$,X,W);ut.setMaterial(X,Nt);let Ut=$.index,Gt=1;if(X.wireframe===!0){if(Ut=Z.getWireframeAttribute($),Ut===void 0)return;Gt=2}const re=$.drawRange,he=$.attributes.position;let Wt=re.start*Gt,Ee=(re.start+re.count)*Gt;St!==null&&(Wt=Math.max(Wt,St.start*Gt),Ee=Math.min(Ee,(St.start+St.count)*Gt)),Ut!==null?(Wt=Math.max(Wt,0),Ee=Math.min(Ee,Ut.count)):he!=null&&(Wt=Math.max(Wt,0),Ee=Math.min(Ee,he.count));const $e=Ee-Wt;if($e<0||$e===1/0)return;lt.setup(W,X,_t,$,Ut);let He,Ce=ce;if(Ut!==null&&(He=K.get(Ut),Ce=F,Ce.setIndex(He)),W.isMesh)X.wireframe===!0?(ut.setLineWidth(X.wireframeLinewidth*yt()),Ce.setMode(I.LINES)):Ce.setMode(I.TRIANGLES);else if(W.isLine){let yn=X.linewidth;yn===void 0&&(yn=1),ut.setLineWidth(yn*yt()),W.isLineSegments?Ce.setMode(I.LINES):W.isLineLoop?Ce.setMode(I.LINE_LOOP):Ce.setMode(I.LINE_STRIP)}else W.isPoints?Ce.setMode(I.POINTS):W.isSprite&&Ce.setMode(I.TRIANGLES);if(W.isBatchedMesh)if(W._multiDrawInstances!==null)tc("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Ce.renderMultiDrawInstances(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount,W._multiDrawInstances);else if(Tt.get("WEBGL_multi_draw"))Ce.renderMultiDraw(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount);else{const yn=W._multiDrawStarts,zt=W._multiDrawCounts,Yn=W._multiDrawCount,ye=Ut?K.get(Ut).bytesPerElement:1,Si=S.get(X).currentProgram.getUniforms();for(let ki=0;ki<Yn;ki++)Si.setValue(I,"_gl_DrawID",ki),Ce.render(yn[ki]/ye,zt[ki])}else if(W.isInstancedMesh)Ce.renderInstances(Wt,$e,W.count);else if($.isInstancedBufferGeometry){const yn=$._maxInstanceCount!==void 0?$._maxInstanceCount:1/0,zt=Math.min($.instanceCount,yn);Ce.renderInstances(Wt,$e,zt)}else Ce.render(Wt,$e)};function Dg(A,B,$){A.transparent===!0&&A.side===Ri&&A.forceSinglePass===!1?(A.side=An,A.needsUpdate=!0,Fc(A,B,$),A.side=is,A.needsUpdate=!0,Fc(A,B,$),A.side=Ri):Fc(A,B,$)}this.compile=function(A,B,$=null){$===null&&($=A),w=st.get($),w.init(B),E.push(w),$.traverseVisible(function(W){W.isLight&&W.layers.test(B.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),A!==$&&A.traverseVisible(function(W){W.isLight&&W.layers.test(B.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),w.setupLights();const X=new Set;return A.traverse(function(W){if(!(W.isMesh||W.isPoints||W.isLine||W.isSprite))return;const St=W.material;if(St)if(Array.isArray(St))for(let Nt=0;Nt<St.length;Nt++){const _t=St[Nt];Dg(_t,$,W),X.add(_t)}else Dg(St,$,W),X.add(St)}),w=E.pop(),X},this.compileAsync=function(A,B,$=null){const X=this.compile(A,B,$);return new Promise(W=>{function St(){if(X.forEach(function(Nt){S.get(Nt).currentProgram.isReady()&&X.delete(Nt)}),X.size===0){W(A);return}setTimeout(St,10)}Tt.get("KHR_parallel_shader_compile")!==null?St():setTimeout(St,10)})};let qd=null;function aS(A){qd&&qd(A)}function Ug(){gr.stop()}function Og(){gr.start()}const gr=new Fv;gr.setAnimationLoop(aS),typeof self<"u"&&gr.setContext(self),this.setAnimationLoop=function(A){qd=A,J.setAnimationLoop(A),A===null?gr.stop():gr.start()},J.addEventListener("sessionstart",Ug),J.addEventListener("sessionend",Og),this.render=function(A,B){if(B!==void 0&&B.isCamera!==!0){Vt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;const $=J.enabled===!0&&J.isPresenting===!0,X=M!==null&&(U===null||$)&&M.begin(b,U);if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),J.enabled===!0&&J.isPresenting===!0&&(M===null||M.isCompositing()===!1)&&(J.cameraAutoUpdate===!0&&J.updateCamera(B),B=J.getCamera()),A.isScene===!0&&A.onBeforeRender(b,A,B,U),w=st.get(A,E.length),w.init(B),E.push(w),Ae.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),qt.setFromProjectionMatrix(Ae,ti,B.reversedDepth),Kt=this.localClippingEnabled,Xt=at.init(this.clippingPlanes,Kt),_=Zt.get(A,T.length),_.init(),T.push(_),J.enabled===!0&&J.isPresenting===!0){const Nt=b.xr.getDepthSensingMesh();Nt!==null&&Yd(Nt,B,-1/0,b.sortObjects)}Yd(A,B,0,b.sortObjects),_.finish(),b.sortObjects===!0&&_.sort(Me,we),et=J.enabled===!1||J.isPresenting===!1||J.hasDepthSensing()===!1,et&&Dt.addToRenderList(_,A),this.info.render.frame++,Xt===!0&&at.beginShadows();const W=w.state.shadowsArray;if(Lt.render(W,A,B),Xt===!0&&at.endShadows(),this.info.autoReset===!0&&this.info.reset(),(X&&M.hasRenderPass())===!1){const Nt=_.opaque,_t=_.transmissive;if(w.setupLights(),B.isArrayCamera){const Ut=B.cameras;if(_t.length>0)for(let Gt=0,re=Ut.length;Gt<re;Gt++){const he=Ut[Gt];zg(Nt,_t,A,he)}et&&Dt.render(A);for(let Gt=0,re=Ut.length;Gt<re;Gt++){const he=Ut[Gt];Bg(_,A,he,he.viewport)}}else _t.length>0&&zg(Nt,_t,A,B),et&&Dt.render(A),Bg(_,A,B)}U!==null&&L===0&&(D.updateMultisampleRenderTarget(U),D.updateRenderTargetMipmap(U)),X&&M.end(b),A.isScene===!0&&A.onAfterRender(b,A,B),lt.resetDefaultState(),V=-1,O=null,E.pop(),E.length>0?(w=E[E.length-1],Xt===!0&&at.setGlobalState(b.clippingPlanes,w.state.camera)):w=null,T.pop(),T.length>0?_=T[T.length-1]:_=null};function Yd(A,B,$,X){if(A.visible===!1)return;if(A.layers.test(B.layers)){if(A.isGroup)$=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(B);else if(A.isLight)w.pushLight(A),A.castShadow&&w.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||qt.intersectsSprite(A)){X&&Q.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Ae);const Nt=It.update(A),_t=A.material;_t.visible&&_.push(A,Nt,_t,$,Q.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||qt.intersectsObject(A))){const Nt=It.update(A),_t=A.material;if(X&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),Q.copy(A.boundingSphere.center)):(Nt.boundingSphere===null&&Nt.computeBoundingSphere(),Q.copy(Nt.boundingSphere.center)),Q.applyMatrix4(A.matrixWorld).applyMatrix4(Ae)),Array.isArray(_t)){const Ut=Nt.groups;for(let Gt=0,re=Ut.length;Gt<re;Gt++){const he=Ut[Gt],Wt=_t[he.materialIndex];Wt&&Wt.visible&&_.push(A,Nt,Wt,$,Q.z,he)}}else _t.visible&&_.push(A,Nt,_t,$,Q.z,null)}}const St=A.children;for(let Nt=0,_t=St.length;Nt<_t;Nt++)Yd(St[Nt],B,$,X)}function Bg(A,B,$,X){const{opaque:W,transmissive:St,transparent:Nt}=A;w.setupLightsView($),Xt===!0&&at.setGlobalState(b.clippingPlanes,$),X&&ut.viewport(k.copy(X)),W.length>0&&Lc(W,B,$),St.length>0&&Lc(St,B,$),Nt.length>0&&Lc(Nt,B,$),ut.buffers.depth.setTest(!0),ut.buffers.depth.setMask(!0),ut.buffers.color.setMask(!0),ut.setPolygonOffset(!1)}function zg(A,B,$,X){if(($.isScene===!0?$.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[X.id]===void 0){const Wt=Tt.has("EXT_color_buffer_half_float")||Tt.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[X.id]=new qn(1,1,{generateMipmaps:!0,type:Wt?Ui:Un,minFilter:Li,samples:Math.max(4,Yt.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:fe.workingColorSpace})}const St=w.state.transmissionRenderTarget[X.id],Nt=X.viewport||k;St.setSize(Nt.z*b.transmissionResolutionScale,Nt.w*b.transmissionResolutionScale);const _t=b.getRenderTarget(),Ut=b.getActiveCubeFace(),Gt=b.getActiveMipmapLevel();b.setRenderTarget(St),b.getClearColor(nt),mt=b.getClearAlpha(),mt<1&&b.setClearColor(16777215,.5),b.clear(),et&&Dt.render($);const re=b.toneMapping;b.toneMapping=di;const he=X.viewport;if(X.viewport!==void 0&&(X.viewport=void 0),w.setupLightsView(X),Xt===!0&&at.setGlobalState(b.clippingPlanes,X),Lc(A,$,X),D.updateMultisampleRenderTarget(St),D.updateRenderTargetMipmap(St),Tt.has("WEBGL_multisampled_render_to_texture")===!1){let Wt=!1;for(let Ee=0,$e=B.length;Ee<$e;Ee++){const He=B[Ee],{object:Ce,geometry:yn,material:zt,group:Yn}=He;if(zt.side===Ri&&Ce.layers.test(X.layers)){const ye=zt.side;zt.side=An,zt.needsUpdate=!0,Vg(Ce,$,X,yn,zt,Yn),zt.side=ye,zt.needsUpdate=!0,Wt=!0}}Wt===!0&&(D.updateMultisampleRenderTarget(St),D.updateRenderTargetMipmap(St))}b.setRenderTarget(_t,Ut,Gt),b.setClearColor(nt,mt),he!==void 0&&(X.viewport=he),b.toneMapping=re}function Lc(A,B,$){const X=B.isScene===!0?B.overrideMaterial:null;for(let W=0,St=A.length;W<St;W++){const Nt=A[W],{object:_t,geometry:Ut,group:Gt}=Nt;let re=Nt.material;re.allowOverride===!0&&X!==null&&(re=X),_t.layers.test($.layers)&&Vg(_t,B,$,Ut,re,Gt)}}function Vg(A,B,$,X,W,St){A.onBeforeRender(b,B,$,X,W,St),A.modelViewMatrix.multiplyMatrices($.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),W.onBeforeRender(b,B,$,X,A,St),W.transparent===!0&&W.side===Ri&&W.forceSinglePass===!1?(W.side=An,W.needsUpdate=!0,b.renderBufferDirect($,B,X,W,A,St),W.side=is,W.needsUpdate=!0,b.renderBufferDirect($,B,X,W,A,St),W.side=Ri):b.renderBufferDirect($,B,X,W,A,St),A.onAfterRender(b,B,$,X,W,St)}function Fc(A,B,$){B.isScene!==!0&&(B=rt);const X=S.get(A),W=w.state.lights,St=w.state.shadowsArray,Nt=W.state.version,_t=dt.getParameters(A,W.state,St,B,$),Ut=dt.getProgramCacheKey(_t);let Gt=X.programs;X.environment=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?B.environment:null,X.fog=B.fog;const re=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap;X.envMap=Y.get(A.envMap||X.environment,re),X.envMapRotation=X.environment!==null&&A.envMap===null?B.environmentRotation:A.envMapRotation,Gt===void 0&&(A.addEventListener("dispose",Se),Gt=new Map,X.programs=Gt);let he=Gt.get(Ut);if(he!==void 0){if(X.currentProgram===he&&X.lightsStateVersion===Nt)return Gg(A,_t),he}else _t.uniforms=dt.getUniforms(A),A.onBuild($,_t,b),A.onBeforeCompile(_t,b),he=dt.acquireProgram(_t,Ut),Gt.set(Ut,he),X.uniforms=_t.uniforms;const Wt=X.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Wt.clippingPlanes=at.uniform),Gg(A,_t),X.needsLights=hS(A),X.lightsStateVersion=Nt,X.needsLights&&(Wt.ambientLightColor.value=W.state.ambient,Wt.lightProbe.value=W.state.probe,Wt.directionalLights.value=W.state.directional,Wt.directionalLightShadows.value=W.state.directionalShadow,Wt.spotLights.value=W.state.spot,Wt.spotLightShadows.value=W.state.spotShadow,Wt.rectAreaLights.value=W.state.rectArea,Wt.ltc_1.value=W.state.rectAreaLTC1,Wt.ltc_2.value=W.state.rectAreaLTC2,Wt.pointLights.value=W.state.point,Wt.pointLightShadows.value=W.state.pointShadow,Wt.hemisphereLights.value=W.state.hemi,Wt.directionalShadowMatrix.value=W.state.directionalShadowMatrix,Wt.spotLightMatrix.value=W.state.spotLightMatrix,Wt.spotLightMap.value=W.state.spotLightMap,Wt.pointShadowMatrix.value=W.state.pointShadowMatrix),X.currentProgram=he,X.uniformsList=null,he}function kg(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=lu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function Gg(A,B){const $=S.get(A);$.outputColorSpace=B.outputColorSpace,$.batching=B.batching,$.batchingColor=B.batchingColor,$.instancing=B.instancing,$.instancingColor=B.instancingColor,$.instancingMorph=B.instancingMorph,$.skinning=B.skinning,$.morphTargets=B.morphTargets,$.morphNormals=B.morphNormals,$.morphColors=B.morphColors,$.morphTargetsCount=B.morphTargetsCount,$.numClippingPlanes=B.numClippingPlanes,$.numIntersection=B.numClipIntersection,$.vertexAlphas=B.vertexAlphas,$.vertexTangents=B.vertexTangents,$.toneMapping=B.toneMapping}function lS(A,B,$,X,W){B.isScene!==!0&&(B=rt),D.resetTextureUnits();const St=B.fog,Nt=X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial?B.environment:null,_t=U===null?b.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:lr,Ut=X.isMeshStandardMaterial||X.isMeshLambertMaterial&&!X.envMap||X.isMeshPhongMaterial&&!X.envMap,Gt=Y.get(X.envMap||Nt,Ut),re=X.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,he=!!$.attributes.tangent&&(!!X.normalMap||X.anisotropy>0),Wt=!!$.morphAttributes.position,Ee=!!$.morphAttributes.normal,$e=!!$.morphAttributes.color;let He=di;X.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(He=b.toneMapping);const Ce=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,yn=Ce!==void 0?Ce.length:0,zt=S.get(X),Yn=w.state.lights;if(Xt===!0&&(Kt===!0||A!==O)){const on=A===O&&X.id===V;at.setState(X,A,on)}let ye=!1;X.version===zt.__version?(zt.needsLights&&zt.lightsStateVersion!==Yn.state.version||zt.outputColorSpace!==_t||W.isBatchedMesh&&zt.batching===!1||!W.isBatchedMesh&&zt.batching===!0||W.isBatchedMesh&&zt.batchingColor===!0&&W.colorTexture===null||W.isBatchedMesh&&zt.batchingColor===!1&&W.colorTexture!==null||W.isInstancedMesh&&zt.instancing===!1||!W.isInstancedMesh&&zt.instancing===!0||W.isSkinnedMesh&&zt.skinning===!1||!W.isSkinnedMesh&&zt.skinning===!0||W.isInstancedMesh&&zt.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&zt.instancingColor===!1&&W.instanceColor!==null||W.isInstancedMesh&&zt.instancingMorph===!0&&W.morphTexture===null||W.isInstancedMesh&&zt.instancingMorph===!1&&W.morphTexture!==null||zt.envMap!==Gt||X.fog===!0&&zt.fog!==St||zt.numClippingPlanes!==void 0&&(zt.numClippingPlanes!==at.numPlanes||zt.numIntersection!==at.numIntersection)||zt.vertexAlphas!==re||zt.vertexTangents!==he||zt.morphTargets!==Wt||zt.morphNormals!==Ee||zt.morphColors!==$e||zt.toneMapping!==He||zt.morphTargetsCount!==yn)&&(ye=!0):(ye=!0,zt.__version=X.version);let Si=zt.currentProgram;ye===!0&&(Si=Fc(X,B,W));let ki=!1,xr=!1,lo=!1;const Re=Si.getUniforms(),dn=zt.uniforms;if(ut.useProgram(Si.program)&&(ki=!0,xr=!0,lo=!0),(X.id!==V||X._forceRefresh)&&(V=X.id,xr=!0,X._forceRefresh=!1),ki||O!==A){ut.buffers.depth.getReversed()&&A.reversedDepth!==!0&&(A._reversedDepth=!0,A.updateProjectionMatrix()),Re.setValue(I,"projectionMatrix",A.projectionMatrix),Re.setValue(I,"viewMatrix",A.matrixWorldInverse);const Os=Re.map.cameraPosition;Os!==void 0&&Os.setValue(I,ie.setFromMatrixPosition(A.matrixWorld)),Yt.logarithmicDepthBuffer&&Re.setValue(I,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(X.isMeshPhongMaterial||X.isMeshToonMaterial||X.isMeshLambertMaterial||X.isMeshBasicMaterial||X.isMeshStandardMaterial||X.isShaderMaterial)&&Re.setValue(I,"isOrthographic",A.isOrthographicCamera===!0),O!==A&&(O=A,xr=!0,lo=!0)}if(zt.needsLights&&(Yn.state.directionalShadowMap.length>0&&Re.setValue(I,"directionalShadowMap",Yn.state.directionalShadowMap,D),Yn.state.spotShadowMap.length>0&&Re.setValue(I,"spotShadowMap",Yn.state.spotShadowMap,D),Yn.state.pointShadowMap.length>0&&Re.setValue(I,"pointShadowMap",Yn.state.pointShadowMap,D)),W.isSkinnedMesh){Re.setOptional(I,W,"bindMatrix"),Re.setOptional(I,W,"bindMatrixInverse");const on=W.skeleton;on&&(on.boneTexture===null&&on.computeBoneTexture(),Re.setValue(I,"boneTexture",on.boneTexture,D))}W.isBatchedMesh&&(Re.setOptional(I,W,"batchingTexture"),Re.setValue(I,"batchingTexture",W._matricesTexture,D),Re.setOptional(I,W,"batchingIdTexture"),Re.setValue(I,"batchingIdTexture",W._indirectTexture,D),Re.setOptional(I,W,"batchingColorTexture"),W._colorsTexture!==null&&Re.setValue(I,"batchingColorTexture",W._colorsTexture,D));const Us=$.morphAttributes;if((Us.position!==void 0||Us.normal!==void 0||Us.color!==void 0)&&Et.update(W,$,Si),(xr||zt.receiveShadow!==W.receiveShadow)&&(zt.receiveShadow=W.receiveShadow,Re.setValue(I,"receiveShadow",W.receiveShadow)),(X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial)&&X.envMap===null&&B.environment!==null&&(dn.envMapIntensity.value=B.environmentIntensity),dn.dfgLUT!==void 0&&(dn.dfgLUT.value=cN()),xr&&(Re.setValue(I,"toneMappingExposure",b.toneMappingExposure),zt.needsLights&&cS(dn,lo),St&&X.fog===!0&&Ht.refreshFogUniforms(dn,St),Ht.refreshMaterialUniforms(dn,X,jt,bt,w.state.transmissionRenderTarget[A.id]),lu.upload(I,kg(zt),dn,D)),X.isShaderMaterial&&X.uniformsNeedUpdate===!0&&(lu.upload(I,kg(zt),dn,D),X.uniformsNeedUpdate=!1),X.isSpriteMaterial&&Re.setValue(I,"center",W.center),Re.setValue(I,"modelViewMatrix",W.modelViewMatrix),Re.setValue(I,"normalMatrix",W.normalMatrix),Re.setValue(I,"modelMatrix",W.matrixWorld),X.isShaderMaterial||X.isRawShaderMaterial){const on=X.uniformsGroups;for(let Os=0,co=on.length;Os<co;Os++){const Hg=on[Os];Rt.update(Hg,Si),Rt.bind(Hg,Si)}}return Si}function cS(A,B){A.ambientLightColor.needsUpdate=B,A.lightProbe.needsUpdate=B,A.directionalLights.needsUpdate=B,A.directionalLightShadows.needsUpdate=B,A.pointLights.needsUpdate=B,A.pointLightShadows.needsUpdate=B,A.spotLights.needsUpdate=B,A.spotLightShadows.needsUpdate=B,A.rectAreaLights.needsUpdate=B,A.hemisphereLights.needsUpdate=B}function hS(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(A,B,$){const X=S.get(A);X.__autoAllocateDepthBuffer=A.resolveDepthBuffer===!1,X.__autoAllocateDepthBuffer===!1&&(X.__useRenderToTexture=!1),S.get(A.texture).__webglTexture=B,S.get(A.depthTexture).__webglTexture=X.__autoAllocateDepthBuffer?void 0:$,X.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(A,B){const $=S.get(A);$.__webglFramebuffer=B,$.__useDefaultFramebuffer=B===void 0};const uS=I.createFramebuffer();this.setRenderTarget=function(A,B=0,$=0){U=A,N=B,L=$;let X=null,W=!1,St=!1;if(A){const _t=S.get(A);if(_t.__useDefaultFramebuffer!==void 0){ut.bindFramebuffer(I.FRAMEBUFFER,_t.__webglFramebuffer),k.copy(A.viewport),G.copy(A.scissor),it=A.scissorTest,ut.viewport(k),ut.scissor(G),ut.setScissorTest(it),V=-1;return}else if(_t.__webglFramebuffer===void 0)D.setupRenderTarget(A);else if(_t.__hasExternalTextures)D.rebindTextures(A,S.get(A.texture).__webglTexture,S.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const re=A.depthTexture;if(_t.__boundDepthTexture!==re){if(re!==null&&S.has(re)&&(A.width!==re.image.width||A.height!==re.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");D.setupDepthRenderbuffer(A)}}const Ut=A.texture;(Ut.isData3DTexture||Ut.isDataArrayTexture||Ut.isCompressedArrayTexture)&&(St=!0);const Gt=S.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Gt[B])?X=Gt[B][$]:X=Gt[B],W=!0):A.samples>0&&D.useMultisampledRTT(A)===!1?X=S.get(A).__webglMultisampledFramebuffer:Array.isArray(Gt)?X=Gt[$]:X=Gt,k.copy(A.viewport),G.copy(A.scissor),it=A.scissorTest}else k.copy(j).multiplyScalar(jt).floor(),G.copy(ct).multiplyScalar(jt).floor(),it=ht;if($!==0&&(X=uS),ut.bindFramebuffer(I.FRAMEBUFFER,X)&&ut.drawBuffers(A,X),ut.viewport(k),ut.scissor(G),ut.setScissorTest(it),W){const _t=S.get(A.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+B,_t.__webglTexture,$)}else if(St){const _t=B;for(let Ut=0;Ut<A.textures.length;Ut++){const Gt=S.get(A.textures[Ut]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+Ut,Gt.__webglTexture,$,_t)}}else if(A!==null&&$!==0){const _t=S.get(A.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,_t.__webglTexture,$)}V=-1},this.readRenderTargetPixels=function(A,B,$,X,W,St,Nt,_t=0){if(!(A&&A.isWebGLRenderTarget)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ut=S.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Nt!==void 0&&(Ut=Ut[Nt]),Ut){ut.bindFramebuffer(I.FRAMEBUFFER,Ut);try{const Gt=A.textures[_t],re=Gt.format,he=Gt.type;if(A.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_t),!Yt.textureFormatReadable(re)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Yt.textureTypeReadable(he)){Vt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=A.width-X&&$>=0&&$<=A.height-W&&I.readPixels(B,$,X,W,ft.convert(re),ft.convert(he),St)}finally{const Gt=U!==null?S.get(U).__webglFramebuffer:null;ut.bindFramebuffer(I.FRAMEBUFFER,Gt)}}},this.readRenderTargetPixelsAsync=async function(A,B,$,X,W,St,Nt,_t=0){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ut=S.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Nt!==void 0&&(Ut=Ut[Nt]),Ut)if(B>=0&&B<=A.width-X&&$>=0&&$<=A.height-W){ut.bindFramebuffer(I.FRAMEBUFFER,Ut);const Gt=A.textures[_t],re=Gt.format,he=Gt.type;if(A.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_t),!Yt.textureFormatReadable(re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Yt.textureTypeReadable(he))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Wt=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,Wt),I.bufferData(I.PIXEL_PACK_BUFFER,St.byteLength,I.STREAM_READ),I.readPixels(B,$,X,W,ft.convert(re),ft.convert(he),0);const Ee=U!==null?S.get(U).__webglFramebuffer:null;ut.bindFramebuffer(I.FRAMEBUFFER,Ee);const $e=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await kS(I,$e,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,Wt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,St),I.deleteBuffer(Wt),I.deleteSync($e),St}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(A,B=null,$=0){const X=Math.pow(2,-$),W=Math.floor(A.image.width*X),St=Math.floor(A.image.height*X),Nt=B!==null?B.x:0,_t=B!==null?B.y:0;D.setTexture2D(A,0),I.copyTexSubImage2D(I.TEXTURE_2D,$,0,0,Nt,_t,W,St),ut.unbindTexture()};const dS=I.createFramebuffer(),fS=I.createFramebuffer();this.copyTextureToTexture=function(A,B,$=null,X=null,W=0,St=0){let Nt,_t,Ut,Gt,re,he,Wt,Ee,$e;const He=A.isCompressedTexture?A.mipmaps[St]:A.image;if($!==null)Nt=$.max.x-$.min.x,_t=$.max.y-$.min.y,Ut=$.isBox3?$.max.z-$.min.z:1,Gt=$.min.x,re=$.min.y,he=$.isBox3?$.min.z:0;else{const dn=Math.pow(2,-W);Nt=Math.floor(He.width*dn),_t=Math.floor(He.height*dn),A.isDataArrayTexture?Ut=He.depth:A.isData3DTexture?Ut=Math.floor(He.depth*dn):Ut=1,Gt=0,re=0,he=0}X!==null?(Wt=X.x,Ee=X.y,$e=X.z):(Wt=0,Ee=0,$e=0);const Ce=ft.convert(B.format),yn=ft.convert(B.type);let zt;B.isData3DTexture?(D.setTexture3D(B,0),zt=I.TEXTURE_3D):B.isDataArrayTexture||B.isCompressedArrayTexture?(D.setTexture2DArray(B,0),zt=I.TEXTURE_2D_ARRAY):(D.setTexture2D(B,0),zt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,B.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,B.unpackAlignment);const Yn=I.getParameter(I.UNPACK_ROW_LENGTH),ye=I.getParameter(I.UNPACK_IMAGE_HEIGHT),Si=I.getParameter(I.UNPACK_SKIP_PIXELS),ki=I.getParameter(I.UNPACK_SKIP_ROWS),xr=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,He.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,He.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Gt),I.pixelStorei(I.UNPACK_SKIP_ROWS,re),I.pixelStorei(I.UNPACK_SKIP_IMAGES,he);const lo=A.isDataArrayTexture||A.isData3DTexture,Re=B.isDataArrayTexture||B.isData3DTexture;if(A.isDepthTexture){const dn=S.get(A),Us=S.get(B),on=S.get(dn.__renderTarget),Os=S.get(Us.__renderTarget);ut.bindFramebuffer(I.READ_FRAMEBUFFER,on.__webglFramebuffer),ut.bindFramebuffer(I.DRAW_FRAMEBUFFER,Os.__webglFramebuffer);for(let co=0;co<Ut;co++)lo&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,S.get(A).__webglTexture,W,he+co),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,S.get(B).__webglTexture,St,$e+co)),I.blitFramebuffer(Gt,re,Nt,_t,Wt,Ee,Nt,_t,I.DEPTH_BUFFER_BIT,I.NEAREST);ut.bindFramebuffer(I.READ_FRAMEBUFFER,null),ut.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(W!==0||A.isRenderTargetTexture||S.has(A)){const dn=S.get(A),Us=S.get(B);ut.bindFramebuffer(I.READ_FRAMEBUFFER,dS),ut.bindFramebuffer(I.DRAW_FRAMEBUFFER,fS);for(let on=0;on<Ut;on++)lo?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,dn.__webglTexture,W,he+on):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,dn.__webglTexture,W),Re?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Us.__webglTexture,St,$e+on):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Us.__webglTexture,St),W!==0?I.blitFramebuffer(Gt,re,Nt,_t,Wt,Ee,Nt,_t,I.COLOR_BUFFER_BIT,I.NEAREST):Re?I.copyTexSubImage3D(zt,St,Wt,Ee,$e+on,Gt,re,Nt,_t):I.copyTexSubImage2D(zt,St,Wt,Ee,Gt,re,Nt,_t);ut.bindFramebuffer(I.READ_FRAMEBUFFER,null),ut.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else Re?A.isDataTexture||A.isData3DTexture?I.texSubImage3D(zt,St,Wt,Ee,$e,Nt,_t,Ut,Ce,yn,He.data):B.isCompressedArrayTexture?I.compressedTexSubImage3D(zt,St,Wt,Ee,$e,Nt,_t,Ut,Ce,He.data):I.texSubImage3D(zt,St,Wt,Ee,$e,Nt,_t,Ut,Ce,yn,He):A.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,St,Wt,Ee,Nt,_t,Ce,yn,He.data):A.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,St,Wt,Ee,He.width,He.height,Ce,He.data):I.texSubImage2D(I.TEXTURE_2D,St,Wt,Ee,Nt,_t,Ce,yn,He);I.pixelStorei(I.UNPACK_ROW_LENGTH,Yn),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,ye),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Si),I.pixelStorei(I.UNPACK_SKIP_ROWS,ki),I.pixelStorei(I.UNPACK_SKIP_IMAGES,xr),St===0&&B.generateMipmaps&&I.generateMipmap(zt),ut.unbindTexture()},this.initRenderTarget=function(A){S.get(A).__webglFramebuffer===void 0&&D.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?D.setTextureCube(A,0):A.isData3DTexture?D.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?D.setTexture2DArray(A,0):D.setTexture2D(A,0),ut.unbindTexture()},this.resetState=function(){N=0,L=0,U=null,ut.reset(),lt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ti}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=fe._getDrawingBufferColorSpace(t),e.unpackColorSpace=fe._getUnpackColorSpace()}}const hN=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:$u,AddEquation:Qs,AddOperation:Zy,AdditiveAnimationBlendMode:im,AdditiveBlending:uu,AgXToneMapping:qu,AlphaFormat:tm,AlwaysCompare:T_,AlwaysDepth:Tl,AlwaysStencilFunc:Cu,AmbientLight:Wm,AnimationAction:yv,AnimationClip:xa,AnimationLoader:ET,AnimationMixer:_v,AnimationObjectGroup:ZT,AnimationUtils:bT,ArcCurve:X_,ArrayCamera:Ym,ArrowHelper:p1,AttachedBindMode:bp,Audio:Jm,AudioAnalyser:zT,AudioContext:Nd,AudioListener:mv,AudioLoader:pv,AxesHelper:Iv,BackSide:An,BasicDepthPacking:sm,BasicShadowMap:mS,BatchedMesh:mm,BezierInterpolant:ov,Bone:hd,BooleanKeyframeTrack:pr,Box2:s1,Box3:mn,Box3Helper:Rv,BoxGeometry:dr,BoxHelper:Nv,BufferAttribute:Te,BufferGeometry:se,BufferGeometryLoader:dv,ByteType:Kp,Cache:Fi,Camera:Tc,CameraHelper:Cv,CanvasTexture:H_,CapsuleGeometry:fd,CatmullRomCurve3:Sm,CineonToneMapping:Jp,CircleGeometry:pd,ClampToEdgeWrapping:Bn,Clock:e1,Color:wt,ColorKeyframeTrack:Ad,ColorManagement:fe,Compatibility:US,CompressedArrayTexture:k_,CompressedCubeTexture:G_,CompressedTexture:_c,CompressedTextureLoader:CT,ConeGeometry:vc,ConstantAlphaFactor:$y,ConstantColorFactor:Wy,Controls:Lv,CubeCamera:qm,CubeDepthTexture:W_,CubeReflectionMapping:ss,CubeRefractionMapping:or,CubeTexture:ba,CubeTextureLoader:NT,CubeUVReflectionMapping:to,CubicBezierCurve:bm,CubicBezierCurve3:$_,CubicInterpolant:sv,CullFaceBack:vp,CullFaceFront:Ry,CullFaceFrontBack:pS,CullFaceNone:Ny,Curve:vi,CurvePath:Y_,CustomBlending:Yp,CustomToneMapping:jp,CylinderGeometry:Ta,Cylindrical:n1,Data3DTexture:mc,DataArrayTexture:od,DataTexture:fi,DataTextureLoader:lv,DataUtils:O_,DecrementStencilOp:l_,DecrementWrapStencilOp:h_,DefaultLoadingManager:Bm,DepthFormat:Oi,DepthStencilFormat:Cs,DepthTexture:jr,DetachedBindMode:Jy,DirectionalLight:Hm,DirectionalLightHelper:Ev,DiscreteInterpolant:rv,DodecahedronGeometry:md,DoubleSide:Ri,DstAlphaFactor:zy,DstColorFactor:ky,DynamicCopyUsage:RS,DynamicDrawUsage:w_,DynamicReadUsage:ES,EdgesGeometry:vm,EllipseCurve:gd,EqualCompare:M_,EqualDepth:Al,EqualStencilFunc:p_,EquirectangularReflectionMapping:jo,EquirectangularRefractionMapping:Ko,Euler:mi,EventDispatcher:Bi,ExternalTexture:_m,ExtrudeGeometry:Mc,FileLoader:rs,Float16BufferAttribute:Tb,Float32BufferAttribute:Ct,FloatType:Tn,Fog:lm,FogExp2:ad,FramebufferTexture:Hb,FrontSide:is,Frustum:no,FrustumArray:ud,GLBufferAttribute:t1,GLSL1:PS,GLSL3:Nu,GreaterCompare:S_,GreaterDepth:Cl,GreaterEqualCompare:rd,GreaterEqualDepth:El,GreaterEqualStencilFunc:y_,GreaterStencilFunc:g_,GridHelper:Av,Group:Gr,HalfFloatType:Ui,HemisphereLight:zm,HemisphereLightHelper:u1,IcosahedronGeometry:xd,ImageBitmapLoader:fv,ImageLoader:sc,ImageUtils:om,IncrementStencilOp:a_,IncrementWrapStencilOp:c_,InstancedBufferAttribute:Jr,InstancedBufferGeometry:$m,InstancedInterleavedBuffer:vv,InstancedMesh:pm,Int16BufferAttribute:Sb,Int32BufferAttribute:bb,Int8BufferAttribute:_b,IntType:ju,InterleavedBuffer:xc,InterleavedBufferAttribute:da,Interpolant:so,InterpolateBezier:Tp,InterpolateDiscrete:ha,InterpolateLinear:Yl,InterpolateSmooth:su,InterpolationSamplingMode:DS,InterpolationSamplingType:FS,InvertStencilOp:u_,KeepStencilOp:Ks,KeyframeTrack:ri,LOD:dm,LatheGeometry:yd,Layers:gc,LessCompare:v_,LessDepth:wl,LessEqualCompare:sd,LessEqualDepth:rr,LessEqualStencilFunc:m_,LessStencilFunc:f_,Light:mr,LightProbe:uv,Line:Fs,Line3:Tv,LineBasicMaterial:Rn,LineCurve:Tm,LineCurve3:q_,LineDashedMaterial:nv,LineLoop:gm,LineSegments:zi,LinearFilter:Fe,LinearInterpolant:Om,LinearMipMapLinearFilter:Ky,LinearMipMapNearestFilter:yS,LinearMipmapLinearFilter:Li,LinearMipmapNearestFilter:Qo,LinearSRGBColorSpace:lr,LinearToneMapping:Wu,LinearTransfer:Jl,Loader:Vn,LoaderUtils:Fu,LoadingManager:Ed,LoopOnce:em,LoopPingPong:Qy,LoopRepeat:nm,MOUSE:Ey,Material:gn,MaterialBlending:gS,MaterialLoader:Cd,MathUtils:N_,Matrix2:i1,Matrix3:ae,Matrix4:Qt,MaxEquation:Zp,Mesh:Ye,MeshBasicMaterial:Ds,MeshDepthMaterial:wd,MeshDistanceMaterial:Dm,MeshLambertMaterial:Fm,MeshMatcapMaterial:ev,MeshNormalMaterial:Lm,MeshPhongMaterial:Pm,MeshPhysicalMaterial:Im,MeshStandardMaterial:Td,MeshToonMaterial:tv,MinEquation:Fy,MirroredRepeatWrapping:la,MixOperation:Yy,MultiplyBlending:Sp,MultiplyOperation:uc,NearestFilter:Xe,NearestMipMapLinearFilter:xS,NearestMipMapNearestFilter:jy,NearestMipmapLinearFilter:zr,NearestMipmapNearestFilter:Ju,NeutralToneMapping:Yu,NeverCompare:__,NeverDepth:bl,NeverStencilFunc:d_,NoBlending:Di,NoColorSpace:Ki,NoNormalPacking:SS,NoToneMapping:di,NormalAnimationBlendMode:id,NormalBlending:nr,NormalGAPacking:TS,NormalRGPacking:bS,NotEqualCompare:b_,NotEqualDepth:Nl,NotEqualStencilFunc:x_,NumberKeyframeTrack:ma,Object3D:ve,ObjectLoader:LT,ObjectSpaceNormalMap:s_,OctahedronGeometry:wa,OneFactor:Uy,OneMinusConstantAlphaFactor:qy,OneMinusConstantColorFactor:Xy,OneMinusDstAlphaFactor:Vy,OneMinusDstColorFactor:Gy,OneMinusSrcAlphaFactor:fu,OneMinusSrcColorFactor:By,OrthographicCamera:Ca,PCFShadowMap:Jo,PCFSoftShadowMap:Iy,PMREMGenerator:Du,Path:Lu,PerspectiveCamera:cn,Plane:Ts,PlaneGeometry:io,PlaneHelper:f1,PointLight:Gm,PointLightHelper:c1,Points:xm,PointsMaterial:dd,PolarGridHelper:d1,PolyhedronGeometry:fr,PositionalAudio:gv,PropertyBinding:me,PropertyMixer:xv,QuadraticBezierCurve:wm,QuadraticBezierCurve3:Am,Quaternion:En,QuaternionKeyframeTrack:Ea,QuaternionLinearInterpolant:av,R11_EAC_Format:Ul,RED_GREEN_RGTC2_Format:$l,RED_RGTC1_Format:Wl,REVISION:Wr,RG11_EAC_Format:Bl,RGBADepthPacking:i_,RGBAFormat:wn,RGBAIntegerFormat:pc,RGBA_ASTC_10x10_Format:Tu,RGBA_ASTC_10x5_Format:Mu,RGBA_ASTC_10x6_Format:Su,RGBA_ASTC_10x8_Format:bu,RGBA_ASTC_12x10_Format:wu,RGBA_ASTC_12x12_Format:Au,RGBA_ASTC_4x4_Format:Vl,RGBA_ASTC_5x4_Format:mu,RGBA_ASTC_5x5_Format:gu,RGBA_ASTC_6x5_Format:xu,RGBA_ASTC_6x6_Format:kl,RGBA_ASTC_8x5_Format:yu,RGBA_ASTC_8x6_Format:_u,RGBA_ASTC_8x8_Format:vu,RGBA_BPTC_Format:Gl,RGBA_ETC2_EAC_Format:Dl,RGBA_PVRTC_2BPPV1_Format:Pl,RGBA_PVRTC_4BPPV1_Format:Il,RGBA_S3TC_DXT1_Format:ea,RGBA_S3TC_DXT3_Format:dl,RGBA_S3TC_DXT5_Format:na,RGBDepthPacking:vS,RGBFormat:nd,RGBIntegerFormat:_S,RGB_BPTC_SIGNED_Format:Eu,RGB_BPTC_UNSIGNED_Format:Hl,RGB_ETC1_Format:Ll,RGB_ETC2_Format:Fl,RGB_PVRTC_2BPPV1_Format:pu,RGB_PVRTC_4BPPV1_Format:Rl,RGB_S3TC_DXT1_Format:ta,RGDepthPacking:MS,RGFormat:ar,RGIntegerFormat:fc,RawShaderMaterial:bd,Ray:eo,Raycaster:Mv,RectAreaLight:hv,RedFormat:dc,RedIntegerFormat:Sa,ReinhardToneMapping:Xu,RenderTarget:am,RenderTarget3D:jT,RepeatWrapping:aa,ReplaceStencilOp:o_,ReverseSubtractEquation:Ly,RingGeometry:Sc,SIGNED_R11_EAC_Format:Ol,SIGNED_RED_GREEN_RGTC2_Format:ql,SIGNED_RED_RGTC1_Format:Xl,SIGNED_RG11_EAC_Format:zl,SRGBColorSpace:Fn,SRGBTransfer:_e,Scene:cm,ShaderChunk:oe,ShaderLib:ci,ShaderMaterial:si,ShadowMaterial:Nm,Shape:ir,ShapeGeometry:_d,ShapePath:Pv,ShapeUtils:ui,ShortType:Qp,Skeleton:yc,SkeletonHelper:l1,SkinnedMesh:fm,Source:Ns,Sphere:un,SphereGeometry:Aa,Spherical:Sv,SphericalHarmonics3:Xm,SplineCurve:Em,SpotLight:km,SpotLightHelper:a1,Sprite:um,SpriteMaterial:cd,SrcAlphaFactor:du,SrcAlphaSaturateFactor:Hy,SrcColorFactor:Oy,StaticCopyUsage:NS,StaticDrawUsage:jl,StaticReadUsage:AS,StereoCamera:DT,StreamCopyUsage:IS,StreamDrawUsage:wS,StreamReadUsage:CS,StringKeyframeTrack:ro,SubtractEquation:Py,SubtractiveBlending:Mp,TOUCH:Cy,TangentSpaceNormalMap:ur,TetrahedronGeometry:vd,Texture:rn,TextureLoader:cv,TextureUtils:_1,Timer:Zm,TimestampQuery:LS,TorusGeometry:bc,TorusKnotGeometry:Md,Triangle:ws,TriangleFanDrawMode:n_,TriangleStripDrawMode:e_,TrianglesDrawMode:t_,TubeGeometry:Sd,UVMapping:Zu,Uint16BufferAttribute:ld,Uint32BufferAttribute:hm,Uint8BufferAttribute:vb,Uint8ClampedBufferAttribute:Mb,Uniform:Rd,UniformsGroup:QT,UniformsLib:gt,UniformsUtils:Rm,UnsignedByteType:Un,UnsignedInt101111Type:ed,UnsignedInt248Type:Yr,UnsignedInt5999Type:td,UnsignedIntType:ii,UnsignedShort4444Type:Ku,UnsignedShort5551Type:Qu,UnsignedShortType:ca,VSMShadowMap:Yo,Vector2:tt,Vector3:R,Vector4:Le,VectorKeyframeTrack:ga,VideoFrameTexture:Gb,VideoTexture:ym,WebGL3DRenderTarget:cb,WebGLArrayRenderTarget:lb,WebGLCoordinateSystem:ti,WebGLCubeRenderTarget:Pd,WebGLRenderTarget:qn,WebGLRenderer:Vv,WebGLUtils:zv,WebGPUCoordinateSystem:Zr,WebXRController:au,WireframeGeometry:Cm,WrapAroundEnding:Zl,ZeroCurvatureEnding:Vr,ZeroFactor:Dy,ZeroSlopeEnding:kr,ZeroStencilOp:r_,createCanvasElement:E_,error:Vt,getConsoleFunction:VS,log:Ql,setConsoleFunction:zS,warn:pt,warnOnce:tc},Symbol.toStringTag,{value:"Module"})),Eh={VERTEX:"vertex"},ue={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},vx={READ_ONLY:"readOnly",READ_WRITE:"readWrite"},wc=["x","y","z","w"],uN=0,dN=1,fN=2,cu=3,Fp=0,Qm=1,pN=2,mN=0,Mx=1,Sx=100,bx=204,Tx=205,wx=3,gN=0,Dp=0,xN=1,yN=2,_N=3,vN=4,MN=6,SN=7,kv=300,tg=301,bN=302,Ax=1e3,cl=1001,Ex=1002,gi=1003,rc=1006,Gv=1008,Hv=1009,TN=1013,eg=1014,Wv=1015,hl=1016,wN=1023,Up=1026,AN=1027,ul=1030,EN=37490,CN=36285,zf=0,NN=1,Uu="",Ni="srgb",Cx="srgb-linear",Nx="linear",gl="srgb",Vf="",Xv="rg",RN="ga",Lo=7680,Rx=519,IN=513,ng=515,Ix=516,Ou=518,ya=35044,Op=35048,ns=2e3,hr=2001,$v={TEXTURE_COMPARE:"depthTextureCompare"};function PN(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function Px(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Lx={};function Bp(...r){const t="THREE."+r.shift();console.log(t,...r)}function qv(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function ne(...r){r=qv(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function Ne(...r){r=qv(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function _a(...r){const t=r.join(" ");t in Lx||(Lx[t]=!0,ne(...r))}const Sn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Fx=1234567;const xl=Math.PI/180,oc=180/Math.PI;function Ps(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Sn[r&255]+Sn[r>>8&255]+Sn[r>>16&255]+Sn[r>>24&255]+"-"+Sn[t&255]+Sn[t>>8&255]+"-"+Sn[t>>16&15|64]+Sn[t>>24&255]+"-"+Sn[e&63|128]+Sn[e>>8&255]+"-"+Sn[e>>16&255]+Sn[e>>24&255]+Sn[n&255]+Sn[n>>8&255]+Sn[n>>16&255]+Sn[n>>24&255]).toLowerCase()}function pe(r,t,e){return Math.max(t,Math.min(e,r))}function ig(r,t){return(r%t+t)%t}function LN(r,t,e,n,i){return n+(r-t)*(i-n)/(e-t)}function FN(r,t,e){return r!==t?(e-r)/(t-r):0}function yl(r,t,e){return(1-e)*r+e*t}function DN(r,t,e,n){return yl(r,t,1-Math.exp(-e*n))}function UN(r,t=1){return t-Math.abs(ig(r,t*2)-t)}function ON(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function BN(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function zN(r,t){return r+Math.floor(Math.random()*(t-r+1))}function VN(r,t){return r+Math.random()*(t-r)}function kN(r){return r*(.5-Math.random())}function GN(r){r!==void 0&&(Fx=r);let t=Fx+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function HN(r){return r*xl}function WN(r){return r*oc}function XN(r){return(r&r-1)===0&&r!==0}function $N(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function qN(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function YN(r,t,e,n,i){const s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),c=s((t+n)/2),h=o((t+n)/2),u=s((t-n)/2),d=o((t-n)/2),f=s((n-t)/2),p=o((n-t)/2);switch(i){case"XYX":r.set(a*h,l*u,l*d,a*c);break;case"YZY":r.set(l*d,a*h,l*u,a*c);break;case"ZXZ":r.set(l*u,l*d,a*h,a*c);break;case"XZX":r.set(a*h,l*p,l*f,a*c);break;case"YXY":r.set(l*f,a*h,l*p,a*c);break;case"ZYZ":r.set(l*p,l*f,a*h,a*c);break;default:ne("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ii(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function be(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const ZN={DEG2RAD:xl,RAD2DEG:oc,generateUUID:Ps,clamp:pe,euclideanModulo:ig,mapLinear:LN,inverseLerp:FN,lerp:yl,damp:DN,pingpong:UN,smoothstep:ON,smootherstep:BN,randInt:zN,randFloat:VN,randFloatSpread:kN,seededRandom:GN,degToRad:HN,radToDeg:WN,isPowerOfTwo:XN,ceilPowerOfTwo:$N,floorPowerOfTwo:qN,setQuaternionFromProperEuler:YN,normalize:be,denormalize:Ii};class Mi{constructor(t,e,n,i,s,o,a,l,c){Mi.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,o,a,l,c)}set(t,e,n,i,s,o,a,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=s,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.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 n=t.elements,i=e.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],p=n[8],x=i[0],g=i[3],m=i[6],y=i[1],v=i[4],_=i[7],w=i[2],T=i[5],E=i[8];return s[0]=o*x+a*y+l*w,s[3]=o*g+a*v+l*T,s[6]=o*m+a*_+l*E,s[1]=c*x+h*y+u*w,s[4]=c*g+h*v+u*T,s[7]=c*m+h*_+u*E,s[2]=d*x+f*y+p*w,s[5]=d*g+f*v+p*T,s[8]=d*m+f*_+p*E,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],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*s*h+n*a*l+i*s*c-i*o*l}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*o-a*c,d=a*l-h*s,f=c*s-o*l,p=e*u+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/p;return t[0]=u*x,t[1]=(i*c-h*n)*x,t[2]=(a*n-i*o)*x,t[3]=d*x,t[4]=(h*e-i*l)*x,t[5]=(i*s-a*e)*x,t[6]=f*x,t[7]=(n*l-c*e)*x,t[8]=(o*e-n*s)*x,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,n,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(kf.makeScale(t,e)),this}rotate(t){return this.premultiply(kf.makeRotation(-t)),this}translate(t,e){return this.premultiply(kf.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),n=Math.sin(t);return this.set(e,-n,0,n,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,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const kf=new Mi,Dx=new Mi().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ux=new Mi().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function JN(){const r={enabled:!0,workingColorSpace:Cx,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===gl&&(i.r=Ls(i.r),i.g=Ls(i.g),i.b=Ls(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===gl&&(i.r=sa(i.r),i.g=sa(i.g),i.b=sa(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Uu?Nx:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return _a("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return _a("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[Cx]:{primaries:t,whitePoint:n,transfer:Nx,toXYZ:Dx,fromXYZ:Ux,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ni},outputColorSpaceConfig:{drawingBufferColorSpace:Ni}},[Ni]:{primaries:t,whitePoint:n,transfer:gl,toXYZ:Dx,fromXYZ:Ux,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ni}}}),r}const Qe=JN();function Ls(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function sa(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}const Yv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Xs={h:0,s:0,l:0},Ch={h:0,s:0,l:0};function Gf(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class Vi{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ni){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Qe.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=Qe.workingColorSpace){return this.r=t,this.g=e,this.b=n,Qe.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=Qe.workingColorSpace){if(t=ig(t,1),e=pe(e,0,1),n=pe(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,o=2*n-s;this.r=Gf(o,s,t+1/3),this.g=Gf(o,s,t),this.b=Gf(o,s,t-1/3)}return Qe.colorSpaceToWorking(this,i),this}setStyle(t,e=Ni){function n(s){s!==void 0&&parseFloat(s)<1&&ne("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:ne("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);ne("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ni){const n=Yv[t.toLowerCase()];return n!==void 0?this.setHex(n,e):ne("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=Ls(t.r),this.g=Ls(t.g),this.b=Ls(t.b),this}copyLinearToSRGB(t){return this.r=sa(t.r),this.g=sa(t.g),this.b=sa(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ni){return Qe.workingToColorSpace(bn.copy(this),t),Math.round(pe(bn.r*255,0,255))*65536+Math.round(pe(bn.g*255,0,255))*256+Math.round(pe(bn.b*255,0,255))}getHexString(t=Ni){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Qe.workingColorSpace){Qe.workingToColorSpace(bn.copy(this),e);const n=bn.r,i=bn.g,s=bn.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Qe.workingColorSpace){return Qe.workingToColorSpace(bn.copy(this),e),t.r=bn.r,t.g=bn.g,t.b=bn.b,t}getStyle(t=Ni){Qe.workingToColorSpace(bn.copy(this),t);const e=bn.r,n=bn.g,i=bn.b;return t!==Ni?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(Xs),this.setHSL(Xs.h+t,Xs.s+e,Xs.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Xs),t.getHSL(Ch);const n=yl(Xs.h,Ch.h,e),i=yl(Xs.s,Ch.s,e),s=yl(Xs.l,Ch.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const bn=new Vi;Vi.NAMES=Yv;class sg{constructor(t,e,n,i){sg.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}}class Ra{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,o,a){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3],d=s[o+0],f=s[o+1],p=s[o+2],x=s[o+3];if(u!==x||l!==d||c!==f||h!==p){let g=l*d+c*f+h*p+u*x;g<0&&(d=-d,f=-f,p=-p,x=-x,g=-g);let m=1-a;if(g<.9995){const y=Math.acos(g),v=Math.sin(y);m=Math.sin(m*y)/v,a=Math.sin(a*y)/v,l=l*m+d*a,c=c*m+f*a,h=h*m+p*a,u=u*m+x*a}else{l=l*m+d*a,c=c*m+f*a,h=h*m+p*a,u=u*m+x*a;const y=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=y,c*=y,h*=y,u*=y}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+h*u+l*f-c*d,t[e+1]=l*p+h*d+c*u-a*f,t[e+2]=c*p+h*f+a*d-l*u,t[e+3]=h*p-a*u-l*d-c*f,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,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,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 n=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(i/2),u=a(s/2),d=l(n/2),f=l(i/2),p=l(s/2);switch(o){case"XYZ":this._x=d*h*u+c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u+d*f*p;break;case"YZX":this._x=d*h*u+c*f*p,this._y=c*f*u+d*h*p,this._z=c*h*p-d*f*u,this._w=c*h*u-d*f*p;break;case"XZY":this._x=d*h*u-c*f*p,this._y=c*f*u-d*h*p,this._z=c*h*p+d*f*u,this._w=c*h*u+d*f*p;break;default:ne("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+a+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(n>a&&n>u){const f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>u){const f=2*Math.sqrt(1+a-n-u);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(pe(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),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 n=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-n*c,this._z=s*h+o*c+n*l-i*a,this._w=o*h-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,s=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,i=-i,s=-s,o=-o,a=-a);let l=1-e;if(a<.9995){const c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+i*e,this._z=this._z*l+s*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+i*e,this._z=this._z*l+s*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}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 H{constructor(t=0,e=0,n=0){H.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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(Ox.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ox.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*i-a*n),h=2*(a*e-s*i),u=2*(s*n-o*e);return this.x=e+l*c+o*u-a*h,this.y=n+l*h+a*c-s*u,this.z=i+l*u+s*h-o*c,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,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,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=pe(this.x,t.x,e.x),this.y=pe(this.y,t.y,e.y),this.z=pe(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=pe(this.x,t,e),this.y=pe(this.y,t,e),this.z=pe(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pe(n,t,e))}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Hf.copy(this).projectOnVector(t),this.sub(Hf)}reflect(t){return this.sub(Hf.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 n=this.dot(t)/e;return Math.acos(pe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,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(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Hf=new H,Ox=new Ra;class ke{constructor(t,e,n,i,s,o,a,l,c,h,u,d,f,p,x,g){ke.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,n,i,s,o,a,l,c,h,u,d,f,p,x,g)}set(t,e,n,i,s,o,a,l,c,h,u,d,f,p,x,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=p,m[11]=x,m[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 ke().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[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,n){return this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();const e=this.elements,n=t.elements,i=1/Fo.setFromMatrixColumn(t,0).length(),s=1/Fo.setFromMatrixColumn(t,1).length(),o=1/Fo.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,s=t.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=o*h,f=o*u,p=a*h,x=a*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+p*c,e[5]=d-x*c,e[9]=-a*l,e[2]=x-d*c,e[6]=p+f*c,e[10]=o*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,p=c*h,x=c*u;e[0]=d+x*a,e[4]=p*a-f,e[8]=o*c,e[1]=o*u,e[5]=o*h,e[9]=-a,e[2]=f*a-p,e[6]=x+d*a,e[10]=o*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,p=c*h,x=c*u;e[0]=d-x*a,e[4]=-o*u,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*h,e[9]=x-d*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const d=o*h,f=o*u,p=a*h,x=a*u;e[0]=l*h,e[4]=p*c-f,e[8]=d*c+x,e[1]=l*u,e[5]=x*c+d,e[9]=f*c-p,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const d=o*l,f=o*c,p=a*l,x=a*c;e[0]=l*h,e[4]=x-d*u,e[8]=p*u+f,e[1]=u,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=f*u+p,e[10]=d-x*u}else if(t.order==="XZY"){const d=o*l,f=o*c,p=a*l,x=a*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+x,e[5]=o*h,e[9]=f*u-p,e[2]=p*u-f,e[6]=a*h,e[10]=x*u+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(jN,t,KN)}lookAt(t,e,n){const i=this.elements;return jn.subVectors(t,e),jn.lengthSq()===0&&(jn.z=1),jn.normalize(),$s.crossVectors(n,jn),$s.lengthSq()===0&&(Math.abs(n.z)===1?jn.x+=1e-4:jn.z+=1e-4,jn.normalize(),$s.crossVectors(n,jn)),$s.normalize(),Nh.crossVectors(jn,$s),i[0]=$s.x,i[4]=Nh.x,i[8]=jn.x,i[1]=$s.y,i[5]=Nh.y,i[9]=jn.y,i[2]=$s.z,i[6]=Nh.z,i[10]=jn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],p=n[2],x=n[6],g=n[10],m=n[14],y=n[3],v=n[7],_=n[11],w=n[15],T=i[0],E=i[4],M=i[8],b=i[12],P=i[1],N=i[5],L=i[9],U=i[13],V=i[2],O=i[6],k=i[10],G=i[14],it=i[3],nt=i[7],mt=i[11],xt=i[15];return s[0]=o*T+a*P+l*V+c*it,s[4]=o*E+a*N+l*O+c*nt,s[8]=o*M+a*L+l*k+c*mt,s[12]=o*b+a*U+l*G+c*xt,s[1]=h*T+u*P+d*V+f*it,s[5]=h*E+u*N+d*O+f*nt,s[9]=h*M+u*L+d*k+f*mt,s[13]=h*b+u*U+d*G+f*xt,s[2]=p*T+x*P+g*V+m*it,s[6]=p*E+x*N+g*O+m*nt,s[10]=p*M+x*L+g*k+m*mt,s[14]=p*b+x*U+g*G+m*xt,s[3]=y*T+v*P+_*V+w*it,s[7]=y*E+v*N+_*O+w*nt,s[11]=y*M+v*L+_*k+w*mt,s[15]=y*b+v*U+_*G+w*xt,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],n=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],p=t[3],x=t[7],g=t[11],m=t[15],y=l*f-c*d,v=a*f-c*u,_=a*d-l*u,w=o*f-c*h,T=o*d-l*h,E=o*u-a*h;return e*(x*y-g*v+m*_)-n*(p*y-g*w+m*T)+i*(p*v-x*w+m*E)-s*(p*_-x*T+g*E)}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,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],p=t[12],x=t[13],g=t[14],m=t[15],y=e*a-n*o,v=e*l-i*o,_=e*c-s*o,w=n*l-i*a,T=n*c-s*a,E=i*c-s*l,M=h*x-u*p,b=h*g-d*p,P=h*m-f*p,N=u*g-d*x,L=u*m-f*x,U=d*m-f*g,V=y*U-v*L+_*N+w*P-T*b+E*M;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/V;return t[0]=(a*U-l*L+c*N)*O,t[1]=(i*L-n*U-s*N)*O,t[2]=(x*E-g*T+m*w)*O,t[3]=(d*T-u*E-f*w)*O,t[4]=(l*P-o*U-c*b)*O,t[5]=(e*U-i*P+s*b)*O,t[6]=(g*_-p*E-m*v)*O,t[7]=(h*E-d*_+f*v)*O,t[8]=(o*L-a*P+c*M)*O,t[9]=(n*P-e*L-s*M)*O,t[10]=(p*T-x*_+m*y)*O,t[11]=(u*_-h*T-f*y)*O,t[12]=(a*b-o*N-l*M)*O,t[13]=(e*N-n*b+i*M)*O,t[14]=(x*v-p*w-g*y)*O,t[15]=(h*w-u*v+d*y)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),s=1-n,o=t.x,a=t.y,l=t.z,c=s*o,h=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+n,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,o){return this.set(1,n,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,h=o+o,u=a+a,d=s*c,f=s*h,p=s*u,x=o*h,g=o*u,m=a*u,y=l*c,v=l*h,_=l*u,w=n.x,T=n.y,E=n.z;return i[0]=(1-(x+m))*w,i[1]=(f+_)*w,i[2]=(p-v)*w,i[3]=0,i[4]=(f-_)*T,i[5]=(1-(d+m))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+v)*E,i[9]=(g-y)*E,i[10]=(1-(d+x))*E,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const s=this.determinant();if(s===0)return n.set(1,1,1),e.identity(),this;let o=Fo.set(i[0],i[1],i[2]).length();const a=Fo.set(i[4],i[5],i[6]).length(),l=Fo.set(i[8],i[9],i[10]).length();s<0&&(o=-o),Ai.copy(this);const c=1/o,h=1/a,u=1/l;return Ai.elements[0]*=c,Ai.elements[1]*=c,Ai.elements[2]*=c,Ai.elements[4]*=h,Ai.elements[5]*=h,Ai.elements[6]*=h,Ai.elements[8]*=u,Ai.elements[9]*=u,Ai.elements[10]*=u,e.setFromRotationMatrix(Ai),n.x=o,n.y=a,n.z=l,this}makePerspective(t,e,n,i,s,o,a=ns,l=!1){const c=this.elements,h=2*s/(e-t),u=2*s/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i);let p,x;if(l)p=s/(o-s),x=o*s/(o-s);else if(a===ns)p=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(a===hr)p=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,s,o,a=ns,l=!1){const c=this.elements,h=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),f=-(n+i)/(n-i);let p,x;if(l)p=1/(o-s),x=o/(o-s);else if(a===ns)p=-2/(o-s),x=-(o+s)/(o-s);else if(a===hr)p=-1/(o-s),x=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Fo=new H,Ai=new ke,jN=new H(0,0,0),KN=new H(1,1,1),$s=new H,Nh=new H,jn=new H;class Ge{constructor(t=0,e=0){Ge.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,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=pe(this.x,t.x,e.x),this.y=pe(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=pe(this.x,t,e),this.y=pe(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pe(n,t,e))}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 n=this.dot(t)/e;return Math.acos(pe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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 n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*n-o*i+t.x,this.y=s*i+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Nn{constructor(t=0,e=0,n=0,i=1){Nn.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=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;case 3:this.w=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;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}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!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=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.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=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.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,s;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],p=l[9],x=l[2],g=l[6],m=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(p+g)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const v=(c+1)/2,_=(f+1)/2,w=(m+1)/2,T=(h+d)/4,E=(u+x)/4,M=(p+g)/4;return v>_&&v>w?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=T/n,s=E/n):_>w?_<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(_),n=T/i,s=M/i):w<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),n=E/s,i=M/s),this.set(n,i,s,e),this}let y=Math.sqrt((g-p)*(g-p)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-x)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}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.w=Math.min(this.w,t.w),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.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=pe(this.x,t.x,e.x),this.y=pe(this.y,t.y,e.y),this.z=pe(this.z,t.z,e.z),this.w=pe(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=pe(this.x,t,e),this.y=pe(this.y,t,e),this.z=pe(this.z,t,e),this.w=pe(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pe(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}const QN=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function tR(r){const t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return r.split(`
|
|
4058
4058
|
`).map(e=>{const n=e.match(t);if(!n)return null;const i=n[1]||n[2]||"",s=n[3].split("?")[0],o=parseInt(n[4],10),a=parseInt(n[5],10),l=s.split("/").pop();return{fn:i,file:l,line:o,column:a}}).filter(e=>e&&!QN.some(n=>n.test(e.file)))}class xi{constructor(t=null){this.isStackTrace=!0,this.stack=tR(t||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";const t=this.stack[0],e=t.fn;return`${e?`"${e}()" at `:""}"${t.file}:${t.line}"`}getError(t){if(this.stack.length===0)return t;const e=this.stack.map(n=>{const i=`${n.file}:${n.line}:${n.column}`;return n.fn?` at ${n.fn} (${i})`:` at ${i}`}).join(`
|
|
4059
4059
|
`);return`${t}
|
|
4060
|
-
${e}`}}function og(r,t=0){let e=3735928559^t,n=1103547991^t;if(r instanceof Array)for(let i=0,s;i<r.length;i++)s=r[i],e=Math.imul(e^s,2654435761),n=Math.imul(n^s,1597334677);else for(let i=0,s;i<r.length;i++)s=r.charCodeAt(i),e=Math.imul(e^s,2654435761),n=Math.imul(n^s,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&n)+(e>>>0)}const ag=r=>og(r),Zv=r=>og(r),Jv=(...r)=>og(r),eR=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),zx=new WeakMap;function nR(r){return eR.get(r)}function Bu(r){if(r==null)return null;const t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function lg(r,...t){const e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new Vi(...t):e==="vec2"?new Ge(...t):e==="vec3"?new H(...t):e==="vec4"?new Nn(...t):e==="mat2"?new rg(...t):e==="mat3"?new Mi(...t):e==="mat4"?new ke(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?rR(t[0]):null}function iR(r){let t=zx.get(r);return t===void 0&&(t={},zx.set(r,t)),t}function sR(r){let t="";const e=new Uint8Array(r);for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function rR(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}class Ra{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const i=n[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}}const oR={analyze:"setup",generate:"analyze"};let aR=0;class Bt extends Ra{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=ue.NONE,this.updateBeforeType=ue.NONE,this.updateAfterType=ue.NONE,this.uuid=ZN.generateUUID(),this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:aR++}),this.stackTrace=null,Bt.captureStackTrace===!0&&(this.stackTrace=new xi)}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this),this}onFrameUpdate(t){return this.onUpdate(t,ue.FRAME)}onRenderUpdate(t){return this.onUpdate(t,ue.RENDER)}onObjectUpdate(t){return this.onUpdate(t,ue.OBJECT)}onReference(t){return this.updateReference=t.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:t}of this._getChildren())yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(const e of this.getChildren())e.traverse(t)}_getChildren(t=new Set){const e=[];t.add(this);for(const n of Object.getOwnPropertyNames(this)){const i=this[n];if(!(n.startsWith("_")===!0||t.has(i))){if(Array.isArray(i)===!0)for(let s=0;s<i.length;s++){const o=i[s];o&&o.isNode===!0&&e.push({property:n,index:s,childNode:o})}else if(i&&i.isNode===!0)e.push({property:n,childNode:i});else if(i&&Object.getPrototypeOf(i)===Object.prototype)for(const s in i){if(s.startsWith("_")===!0)continue;const o=i[s];o&&o.isNode===!0&&e.push({property:n,index:s,childNode:o})}}}return e}getCacheKey(t=!1,e=null){if(t=t||this.version!==this._cacheKeyVersion,t===!0||this._cacheKey===null){e===null&&(e=new Set);const n=[];for(const{property:i,childNode:s}of this._getChildren(e))n.push(ag(i.slice(0,-4)),s.getCacheKey(t,e));this._cacheKey=Jv(Zv(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){const e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t){const e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){const e=this.getHash(t);return t.getNodeFromHash(e)||this}getArrayCount(){return null}setup(t){const e=t.getNodeProperties(this);let n=0;for(const i of this.getChildren())e["node"+n++]=i;return e.outputNode||null}analyze(t,e=null){const n=t.increaseUsage(this);if(this.parents===!0){const i=t.getDataFromNode(this,"any");i.stages=i.stages||{},i.stages[t.shaderStage]=i.stages[t.shaderStage]||[],i.stages[t.shaderStage].push(e)}if(n===1){const i=t.getNodeProperties(this);for(const s of Object.values(i))s&&s.isNode===!0&&s.build(t,this)}}generate(t,e){const{outputNode:n}=t.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(t,e)}updateBefore(){ne("Abstract function.")}updateAfter(){ne("Abstract function.")}update(){ne("Abstract function.")}before(t){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(t),this}build(t,e=null){const n=this.getShared(t);if(this!==n)return n.build(t,e);if(this._beforeNodes!==null){const l=this._beforeNodes;this._beforeNodes=null;for(const c of l)c.build(t,e);this._beforeNodes=l}const i=t.getDataFromNode(this);i.buildStages=i.buildStages||{},i.buildStages[t.buildStage]=!0;const s=oR[t.buildStage];if(s&&i.buildStages[s]!==!0){const l=t.getBuildStage();t.setBuildStage(s),this.build(t),t.setBuildStage(l)}t.addChain(this);let o=null;const a=t.getBuildStage();if(a==="setup"){t.addNode(this),this.updateReference(t);const l=t.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(t)||l.outputNode||null;for(const c of Object.values(l))if(c&&c.isNode===!0){if(c.parents===!0){const h=t.getNodeProperties(c);h.parents=h.parents||[],h.parents.push(this)}c.build(t)}t.addSequentialNode(this)}o=l.outputNode}else if(a==="analyze")this.analyze(t,e);else if(a==="generate"){if(this.generate.length<2){const c=this.getNodeType(t),h=t.getDataFromNode(this);o=h.snippet,o===void 0?h.generated===void 0?(h.generated=!0,o=this.generate(t)||"",h.snippet=o):(ne("Node: Recursion detected.",this),o="/* Recursion detected. */"):h.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),o=t.format(o,c,e)}else o=this.generate(t,e)||"";o===""&&e!==null&&e!=="void"&&e!=="OutputType"&&(Ne(`TSL: Invalid generated code, expected a "${e}".`),o=t.generateConst(e))}return t.removeChain(this),o}getSerializeChildren(){return this._getChildren()}serialize(t){const e=this.getSerializeChildren(),n={};for(const{property:i,index:s,childNode:o}of e)s!==void 0?(n[i]===void 0&&(n[i]=Number.isInteger(s)?[]:{}),n[i][s]=o.toJSON(t.meta).uuid):n[i]=o.toJSON(t.meta).uuid;Object.keys(n).length>0&&(t.inputNodes=n)}deserialize(t){if(t.inputNodes!==void 0){const e=t.meta.nodes;for(const n in t.inputNodes)if(Array.isArray(t.inputNodes[n])){const i=[];for(const s of t.inputNodes[n])i.push(e[s]);this[n]=i}else if(typeof t.inputNodes[n]=="object"){const i={};for(const s in t.inputNodes[n]){const o=t.inputNodes[n][s];i[s]=e[o]}this[n]=i}else{const i=t.inputNodes[n];this[n]=e[i]}}}toJSON(t){const{uuid:e,type:n}=this,i=t===void 0||typeof t=="string";i&&(t={textures:{},images:{},nodes:{}});let s=t.nodes[e];s===void 0&&(s={uuid:e,type:n,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},i!==!0&&(t.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}if(i){const a=o(t.textures),l=o(t.images),c=o(t.nodes);a.length>0&&(s.textures=a),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}Bt.captureStackTrace=!1;class Ia extends Bt{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}getMemberType(t,e){return this.node.getMemberType(t,e)}generate(t){const e=this.indexNode.getNodeType(t),n=this.node.build(t),i=this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint");return`${n}[ ${i} ]`}}class jv extends Bt{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){const e=this.node.getNodeType(t);let n=null;for(const i of this.convertTo.split("|"))(n===null||t.getTypeLength(e)===t.getTypeLength(i))&&(n=i);return n}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){const n=this.node,i=this.getNodeType(t),s=n.build(t,i);return t.format(s,i,e)}}class xn extends Bt{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){const i=t.getVectorType(this.getNodeType(t,e)),s=t.getDataFromNode(this);if(s.propertyName!==void 0)return t.format(s.propertyName,i,e);if(i!=="void"&&e!=="void"&&this.hasDependencies(t)){const o=super.build(t,i),a=t.getVarFromNode(this,null,i),l=t.getPropertyName(a);return t.addLineFlowCode(`${l} = ${o}`,this),s.snippet=o,s.propertyName=l,t.format(s.propertyName,i,e)}}return super.build(t,e)}}class lR extends xn{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,n)=>e+t.getTypeLength(n.getNodeType(t)),0))}generate(t,e){const n=this.getNodeType(t),i=t.getTypeLength(n),s=this.nodes,o=t.getComponentType(n),a=[];let l=0;for(const h of s){if(l>=i){Ne(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let u=h.getNodeType(t),d=t.getTypeLength(u),f;if(l+d>i&&(Ne(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),d=i-l,u=t.getTypeFromLength(d)),l+=d,f=h.build(t,u),t.getComponentType(u)!==o){const x=t.getTypeFromLength(d,o);f=t.format(f,u,x)}a.push(f)}const c=`${t.getType(n)}( ${a.join(", ")} )`;return t.format(c,n,e)}}const cR=wc.join("");class hR extends Bt{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(const e of this.components)t=Math.max(wc.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}getScope(){return this.node.getScope()}generate(t,e){const n=this.node,i=t.getTypeLength(n.getNodeType(t));let s=null;if(i>1){let o=null;this.getVectorLength()>=i&&(o=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));const l=n.build(t,o);this.components.length===i&&this.components===cR.slice(0,this.components.length)?s=t.format(l,o,e):s=t.format(`${l}.${this.components}`,this.getNodeType(t),e)}else s=n.build(t,e);return s}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}}class uR extends xn{static get type(){return"SetNode"}constructor(t,e,n){super(),this.sourceNode=t,this.components=e,this.targetNode=n}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{sourceNode:e,components:n,targetNode:i}=this,s=this.getNodeType(t),o=t.getComponentType(i.getNodeType(t)),a=t.getTypeFromLength(n.length,o),l=i.build(t,a),c=e.build(t,s),h=t.getTypeLength(s),u=[];for(let d=0;d<h;d++){const f=wc[d];f===n[0]?(u.push(l),d+=n.length-1):u.push(c+"."+f)}return`${t.getType(s)}( ${u.join(", ")} )`}}class dR extends xn{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{components:e,sourceNode:n}=this,i=this.getNodeType(t),s=n.build(t),o=t.getVarFromNode(this),a=t.getPropertyName(o);t.addLineFlowCode(a+" = "+s,this);const l=t.getTypeLength(i),c=[];let h=0;for(let u=0;u<l;u++){const d=wc[u];d===e[h]?(c.push("1.0 - "+(a+"."+d)),h++):c.push(a+"."+d)}return`${t.getType(i)}( ${c.join(", ")} )`}}class cg extends Bt{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return this.nodeType===null?Bu(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Bu(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=sR(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?lg(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){ne("Abstract function.")}}const Vx=/float|u?int/;class cs extends cg{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){const n=this.getNodeType(t);return Vx.test(n)&&Vx.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),n,e)}}class fR extends Bt{static get type(){return"MemberNode"}constructor(t,e){super(),this.structNode=t,this.property=e,this.isMemberNode=!0}hasMember(t){return this.structNode.isMemberNode&&this.structNode.hasMember(t)===!1?!1:this.structNode.getMemberType(t,this.property)!=="void"}getNodeType(t){return this.hasMember(t)===!1?"float":this.structNode.getMemberType(t,this.property)}getMemberType(t,e){if(this.hasMember(t)===!1)return"float";const n=this.getNodeType(t);return t.getStructTypeNode(n).getMemberType(t,e)}generate(t){if(this.hasMember(t)===!1){ne(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);const n=this.getNodeType(t);return t.generateConst(n)}return this.structNode.build(t)+"."+this.property}}let pR=null;const zp=new Map;function q(r,t){if(zp.has(r)){ne(`TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw new Error(`THREE.TSL: Node element ${r} is not a function`);zp.set(r,t),r!=="assign"&&(Bt.prototype[r]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},Bt.prototype[r+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}const mR=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),kx=r=>mR(r).split("").sort().join("");Bt.prototype.assign=function(...r){if(this.isStackNode!==!0)return Ne("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new xi),this;{const t=zp.get("assign");return this.addToStack(t(...r))}};Bt.prototype.toVarIntent=function(){return this};Bt.prototype.get=function(r){return new fR(this,r)};const _l={};function Rh(r,t,e){_l[r]=_l[t]=_l[e]={get(){this._cache=this._cache||{};let o=this._cache[r];return o===void 0&&(o=new hR(this,r),this._cache[r]=o),o},set(o){this[r].assign(Ot(o))}};const n=r.toUpperCase(),i=t.toUpperCase(),s=e.toUpperCase();Bt.prototype["set"+n]=Bt.prototype["set"+i]=Bt.prototype["set"+s]=function(o){const a=kx(r);return new uR(this,a,Ot(o))},Bt.prototype["flip"+n]=Bt.prototype["flip"+i]=Bt.prototype["flip"+s]=function(){const o=kx(r);return new dR(this,o)}}const qi=["x","y","z","w"],Yi=["r","g","b","a"],Zi=["s","t","p","q"];for(let r=0;r<4;r++){let t=qi[r],e=Yi[r],n=Zi[r];Rh(t,e,n);for(let i=0;i<4;i++){t=qi[r]+qi[i],e=Yi[r]+Yi[i],n=Zi[r]+Zi[i],Rh(t,e,n);for(let s=0;s<4;s++){t=qi[r]+qi[i]+qi[s],e=Yi[r]+Yi[i]+Yi[s],n=Zi[r]+Zi[i]+Zi[s],Rh(t,e,n);for(let o=0;o<4;o++)t=qi[r]+qi[i]+qi[s]+qi[o],e=Yi[r]+Yi[i]+Yi[s]+Yi[o],n=Zi[r]+Zi[i]+Zi[s]+Zi[o],Rh(t,e,n)}}}for(let r=0;r<32;r++)_l[r]={get(){this._cache=this._cache||{};let t=this._cache[r];return t===void 0&&(t=new Ia(this,new cs(r,"uint")),this._cache[r]=t),t},set(t){this[r].assign(Ot(t))}};Object.defineProperties(Bt.prototype,_l);const Gx=new WeakMap,gR=function(r,t=null){const e=Bu(r);return e==="node"?r:t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string"?Ot(Vp(r,t)):e==="shader"?r.isFn?r:Mt(r):r},xR=function(r,t=null){for(const e in r)r[e]=Ot(r[e],t);return r},yR=function(r,t=null){const e=r.length;for(let n=0;n<e;n++)r[n]=Ot(r[n],t);return r},Kv=function(r,t=null,e=null,n=null){function i(h){return n!==null?(h=Ot(Object.assign(h,n)),n.intent===!0&&(h=h.toVarIntent())):h=Ot(h),h}let s,o=t,a,l;function c(h){let u;return o?u=/[a-z]/i.test(o)?o+"()":o:u=r.type,a!==void 0&&h.length<a?(Ne(`TSL: "${u}" parameter length is less than minimum required.`,new xi),h.concat(new Array(a-h.length).fill(0))):l!==void 0&&h.length>l?(Ne(`TSL: "${u}" parameter length exceeds limit.`,new xi),h.slice(0,l)):h}return t===null?s=(...h)=>i(new r(...sa(c(h)))):e!==null?(e=Ot(e),s=(...h)=>i(new r(t,...sa(c(h)),e))):s=(...h)=>i(new r(t,...sa(c(h)))),s.setParameterLength=(...h)=>(h.length===1?a=l=h[0]:h.length===2&&([a,l]=h),s),s.setName=h=>(o=h,s),s},_R=function(r,...t){return new r(...sa(t))};class vR extends Bt{constructor(t,e){super(),this.shaderNode=t,this.rawInputs=e,this.isShaderCallNodeInternal=!0}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getElementType(t){return this.getOutputNode(t).getElementType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){const{shaderNode:e,rawInputs:n}=this,i=t.getNodeProperties(e),s=t.getClosestSubBuild(e.subBuilds)||"",o=s||"default";if(i[o])return i[o];const a=t.subBuildFn,l=t.fnCall;t.subBuildFn=s,t.fnCall=this;let c=null;if(e.layout){let h=Gx.get(t.constructor);h===void 0&&(h=new WeakMap,Gx.set(t.constructor,h));let u=h.get(e);u===void 0&&(u=Ot(t.buildFunctionNode(e)),h.set(e,u)),t.addInclude(u);const d=n?MR(n):null;c=Ot(u.call(d))}else{const h=new Proxy(t,{get:(x,g,m)=>{let y;return Symbol.iterator===g?y=function*(){yield void 0}:y=Reflect.get(x,g,m),y}}),u=n?SR(n):null,d=Array.isArray(n)?n.length>0:n!==null,f=e.jsFunc,p=d||f.length>1?f(u,h):f(h);c=Ot(p)}return t.subBuildFn=a,t.fnCall=l,e.once&&(i[o]=c),c}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){const e=t.getNodeProperties(this),n=t.getSubBuildOutput(this);return e[n]=e[n]||this.setupOutput(t),e[n].subBuild=t.getClosestSubBuild(this),e[n]}build(t,e=null){let n=null;const i=t.getBuildStage(),s=t.getNodeProperties(this),o=t.getSubBuildOutput(this),a=this.getOutputNode(t),l=t.fnCall;if(t.fnCall=this,i==="setup"){const c=t.getSubBuildProperty("initialized",this);if(s[c]!==!0&&(s[c]=!0,s[o]=this.getOutputNode(t),s[o].build(t),this.shaderNode.subBuilds))for(const h of t.chaining){const u=t.getDataFromNode(h,"any");u.subBuilds=u.subBuilds||new Set;for(const d of this.shaderNode.subBuilds)u.subBuilds.add(d)}n=s[o]}else i==="analyze"?a.build(t,e):i==="generate"&&(n=a.build(t,e)||"");return t.fnCall=l,n}}function MR(r){let t;return fg(r),r[0]&&(r[0].isNode||Object.getPrototypeOf(r[0])!==Object.prototype)?t=[...r]:t=r[0],t}function SR(r){let t=0;return fg(r),new Proxy(r,{get:(e,n,i)=>{let s;if(n==="length")return s=r.length,s;if(Symbol.iterator===n)s=function*(){for(const o of r)yield Ot(o)};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){const o=r[0];o[n]===void 0?s=o[t++]:s=Reflect.get(o,n,i)}else r[0]instanceof Bt&&(r[n]===void 0?s=r[t++]:s=Reflect.get(r,n,i));else s=Reflect.get(e,n,i);s=Ot(s)}return s}})}class bR extends Bt{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}getLayout(){return this.layout}call(t=null){return new vR(this,t)}setup(){return this.call()}}const TR=[!1,!0],wR=[0,1,2,3],AR=[-1,-2],Qv=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],hg=new Map;for(const r of TR)hg.set(r,new cs(r));const ug=new Map;for(const r of wR)ug.set(r,new cs(r,"uint"));const dg=new Map([...ug].map(r=>new cs(r.value,"int")));for(const r of AR)dg.set(r,new cs(r,"int"));const Fd=new Map([...dg].map(r=>new cs(r.value)));for(const r of Qv)Fd.set(r,new cs(r));for(const r of Qv)Fd.set(-r,new cs(-r));const Dd={bool:hg,uint:ug,ints:dg,float:Fd},Hx=new Map([...hg,...Fd]),Vp=(r,t)=>Hx.has(r)?Hx.get(r):r.isNode===!0?r:new cs(r,t),je=function(r,t=null){return(...e)=>{for(const i of e)if(i===void 0)return Ne(`TSL: Invalid parameter for the type "${r}".`,new xi),new cs(0,r);if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>{const s=typeof i;return s!=="object"&&s!=="function"}))&&(e=[lg(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return Ih(t.get(e[0]));if(e.length===1){const i=Vp(e[0],r);return i.nodeType===r?Ih(i):Ih(new jv(i,r))}const n=e.map(i=>Vp(i));return Ih(new lR(n,r))}},ER=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function CR(r,t){return new bR(r,t)}const Ot=(r,t=null)=>gR(r,t),Ih=(r,t=null)=>Ot(r,t).toVarIntent(),fg=(r,t=null)=>new xR(r,t),sa=(r,t=null)=>new yR(r,t),De=(r,t=null,e=null,n=null)=>new Kv(r,t,e,n),Ke=(r,...t)=>new _R(r,...t),At=(r,t=null,e=null,n={})=>new Kv(r,t,e,{...n,intent:!0});let NR=0;class RR extends Bt{constructor(t,e=null){super();let n=null;e!==null&&(typeof e=="object"?n=e.return:(typeof e=="string"?n=e:Ne("TSL: Invalid layout type.",new xi),e=null)),this.shaderNode=new CR(t,n),e!==null&&this.setLayout(e),this.isFn=!0}setLayout(t){const e=this.shaderNode.nodeType;if(typeof t.inputs!="object"){const n={name:"fn"+NR++,type:e,inputs:[]};for(const i in t)i!=="return"&&n.inputs.push({name:i,type:t[i]});t=n}return this.shaderNode.setLayout(t),this}getNodeType(t){return this.shaderNode.getNodeType(t)||"float"}call(...t){const e=this.shaderNode.call(t);return this.shaderNode.nodeType==="void"&&e.toStack(),e.toVarIntent()}once(t=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=t,this}generate(t){const e=this.getNodeType(t);return Ne('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),t.generateConst(e)}}function Mt(r,t=null){const e=new RR(r,t);return new Proxy(()=>{},{apply(n,i,s){return e.call(...s)},get(n,i,s){return Reflect.get(e,i,s)},set(n,i,s,o){return Reflect.set(e,i,s,o)}})}const hi=(...r)=>pR.If(...r);function IR(r){return r}q("toStack",IR);const PR=new je("color"),kt=new je("float",Dd.float),Be=new je("int",Dd.ints),fn=new je("uint",Dd.uint),pg=new je("bool",Dd.bool),xe=new je("vec2"),ji=new je("ivec2"),tM=new je("uvec2"),LR=new je("bvec2"),Pt=new je("vec3"),eM=new je("ivec3"),nM=new je("uvec3"),FR=new je("bvec3"),zn=new je("vec4"),iM=new je("ivec4"),sM=new je("uvec4"),DR=new je("bvec4"),rM=new je("mat2"),yi=new je("mat3"),Ud=new je("mat4");q("toColor",PR);q("toFloat",kt);q("toInt",Be);q("toUint",fn);q("toBool",pg);q("toVec2",xe);q("toIVec2",ji);q("toUVec2",tM);q("toBVec2",LR);q("toVec3",Pt);q("toIVec3",eM);q("toUVec3",nM);q("toBVec3",FR);q("toVec4",zn);q("toIVec4",iM);q("toUVec4",sM);q("toBVec4",DR);q("toMat2",rM);q("toMat3",yi);q("toMat4",Ud);const UR=De(Ia).setParameterLength(2),OR=(r,t)=>new jv(Ot(r),t);q("element",UR);q("convert",OR);q("append",r=>(ne("TSL: .append() has been renamed to .toStack().",new xi),r));class Wx extends xn{static get type(){return"ArrayNode"}constructor(t,e,n=null){super(t),this.count=e,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(t){return this.nodeType===null?this.values[0].getNodeType(t):this.nodeType}getElementType(t){return this.getNodeType(t)}getMemberType(t,e){return this.nodeType===null?this.values[0].getMemberType(t,e):super.getMemberType(t,e)}generate(t){const e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}}const BR=(...r)=>{let t;if(r.length===1){const e=r[0];t=new Wx(null,e.length,e)}else{const e=r[0],n=r[1];t=new Wx(e,n)}return Ot(t)};q("toArray",(r,t)=>BR(Array(t).fill(r)));class oM extends Bt{static get type(){return"UniformGroupNode"}constructor(t,e=!1,n=1){super("string"),this.name=t,this.shared=e,this.order=n,this.isUniformGroup=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}}const zR=r=>new oM(r),aM=(r,t=0)=>new oM(r,!0,t),te=aM("render"),VR=zR("object");class Ac extends cg{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=VR}setName(t){return this.name=t,this}label(t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.',new xi),this.setName(t)}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){return t=t.bind(this),super.onUpdate(n=>{const i=t(n,this);i!==void 0&&(this.value=i)},e)}getInputType(t){let e=super.getInputType(t);return e==="bool"&&(e="uint"),e}generate(t,e){const n=this.getNodeType(t),i=this.getUniformHash(t);let s=t.getNodeFromHash(i);s===void 0&&(t.setHashNode(this,i),s=this);const o=s.getInputType(t),a=t.getUniformFromNode(s,o,t.shaderStage,this.name||t.context.nodeName),l=t.getPropertyName(a);t.context.nodeName!==void 0&&delete t.context.nodeName;let c=l;if(n==="bool"){const h=t.getDataFromNode(this);let u=h.propertyName;if(u===void 0){const d=t.getVarFromNode(this,null,"bool");u=t.getPropertyName(d),h.propertyName=u,c=t.format(l,o,n),t.addLineFlowCode(`${u} = ${c}`,this)}c=u}return t.format(c,n,e)}}const de=(r,t)=>{const e=ER(t||r);if(e===r&&(r=lg(e)),r&&r.isNode===!0){let n=r.value;r.traverse(i=>{i.isConstNode===!0&&(n=i.value)}),r=n}return new Ac(r,e)};class Ec extends Bt{static get type(){return"PropertyNode"}constructor(t,e=null,n=!1){super(t),this.name=e,this.varying=n,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return ag(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(t){return this.name||super.getHash(t)}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}}const lM=(r,t)=>new Ec(r,t),zu=(r,t)=>new Ec(r,t,!0),Hn=Ke(Ec,"vec4","DiffuseColor"),Xx=Ke(Ec,"vec3","EmissiveColor"),Wf=Ke(Ec,"vec4","Output");class kR extends xn{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){const{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){const n=t.getTypeLength(e.node.getNodeType(t));return wc.join("").slice(0,n)!==e.components}return!1}setup(t){const{targetNode:e,sourceNode:n}=this,i=e.getScope(),s=t.getDataFromNode(i);s.assign=!0;const o=t.getNodeProperties(this);o.sourceNode=n,o.targetNode=e.context({assign:!0})}generate(t,e){const{targetNode:n,sourceNode:i}=t.getNodeProperties(this),s=this.needsSplitAssign(t),o=n.build(t),a=n.getNodeType(t),l=i.build(t,a),c=i.getNodeType(t),h=t.getDataFromNode(this);let u;if(h.initialized===!0)e!=="void"&&(u=o);else if(s){const d=t.getVarFromNode(this,null,a),f=t.getPropertyName(d);t.addLineFlowCode(`${f} = ${l}`,this);const p=n.node,g=p.node.context({assign:!0}).build(t);for(let m=0;m<p.components.length;m++){const y=p.components[m];t.addLineFlowCode(`${g}.${y} = ${f}[ ${m} ]`,this)}e!=="void"&&(u=o)}else u=`${o} = ${l}`,(e==="void"||c==="void")&&(t.addLineFlowCode(u,this),e!=="void"&&(u=o));return h.initialized=!0,t.format(u,a,e)}}const GR=De(kR).setParameterLength(2);q("assign",GR);class HR extends xn{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}getMemberType(t,e){return this.functionNode.getMemberType(t,e)}generate(t){const e=[],n=this.functionNode,i=n.getInputs(t),s=this.parameters,o=(l,c)=>{const h=c.type,u=h==="pointer";let d;return u?d="&"+l.build(t):d=l.build(t,h),d};if(Array.isArray(s)){if(s.length>i.length)Ne("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=i.length;else if(s.length<i.length)for(Ne("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<i.length;)s.push(kt(0));for(let l=0;l<s.length;l++)e.push(o(s[l],i[l]))}else for(const l of i){const c=s[l.name];c!==void 0?e.push(o(c,l)):(Ne(`TSL: Input '${l.name}' not found in 'Fn()'.`),e.push(o(kt(0),l)))}return`${n.build(t,"property")}( ${e.join(", ")} )`}}const WR=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?sa(t):fg(t[0]),new HR(Ot(r),t));q("call",WR);const XR={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Oe extends xn{static get type(){return"OperatorNode"}constructor(t,e,n,...i){if(super(),i.length>0){let s=new Oe(t,e,n);for(let o=0;o<i.length-1;o++)s=new Oe(t,s,i[o]);e=s,n=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=n,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(XR[this.op],e)}getNodeType(t,e=null){const n=this.op,i=this.aNode,s=this.bNode,o=i.getNodeType(t),a=s?s.getNodeType(t):null;if(o==="void"||a==="void")return e||"void";if(n==="%")return o;if(n==="~"||n==="&"||n==="|"||n==="^"||n===">>"||n==="<<")return t.getIntegerType(o);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){const l=Math.max(t.getTypeLength(o),t.getTypeLength(a));return l>1?`bvec${l}`:"bool"}else{if(t.isMatrix(o)){if(a==="float")return o;if(t.isVector(a))return t.getVectorFromMatrix(o);if(t.isMatrix(a))return o}else if(t.isMatrix(a)){if(o==="float")return a;if(t.isVector(o))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(o)?a:o}}generate(t,e){const n=this.op,{aNode:i,bNode:s}=this,o=this.getNodeType(t,e);let a=null,l=null;o!=="void"?(a=i.getNodeType(t),l=s?s.getNodeType(t):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?t.isVector(a)?l=a:t.isVector(l)?a=l:a!==l&&(a=l="float"):n===">>"||n==="<<"?(a=o,l=t.changeComponentType(l,"uint")):n==="%"?(a=o,l=t.isInteger(a)&&t.isInteger(l)?l:a):t.isMatrix(a)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(a):t.isMatrix(l)||(a=l=o):t.isMatrix(l)?a==="float"?a="float":t.isVector(a)?a=t.getVectorFromMatrix(l):a=l=o:a=l=o):a=l=o;const c=i.build(t,a),h=s?s.build(t,l):null,u=t.getFunctionOperator(n);if(e!=="void"){const d=t.renderer.coordinateSystem===ns;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return d?t.isVector(a)?t.format(`${this.getOperatorMethod(t,e)}( ${c}, ${h} )`,o,e):t.format(`( ${c} ${n} ${h} )`,o,e):t.format(`( ${c} ${n} ${h} )`,o,e);if(n==="%")return t.isInteger(l)?t.format(`( ${c} % ${h} )`,o,e):t.format(`${this.getOperatorMethod(t,o)}( ${c}, ${h} )`,o,e);if(n==="!"||n==="~")return t.format(`(${n}${c})`,a,e);if(u)return t.format(`${u}( ${c}, ${h} )`,o,e);if(t.isMatrix(a)&&l==="float")return t.format(`( ${h} ${n} ${c} )`,o,e);if(a==="float"&&t.isMatrix(l))return t.format(`${c} ${n} ${h}`,o,e);{let f=`( ${c} ${n} ${h} )`;return!d&&o==="bool"&&t.isVector(a)&&t.isVector(l)&&(f=`all${f}`),t.format(f,o,e)}}else if(a!=="void")return u?t.format(`${u}( ${c}, ${h} )`,o,e):t.isMatrix(a)&&l==="float"?t.format(`${h} ${n} ${c}`,o,e):t.format(`${c} ${n} ${h}`,o,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}}const os=At(Oe,"+").setParameterLength(2,1/0).setName("add"),Wn=At(Oe,"-").setParameterLength(2,1/0).setName("sub"),Ve=At(Oe,"*").setParameterLength(2,1/0).setName("mul"),Od=At(Oe,"/").setParameterLength(2,1/0).setName("div"),mg=At(Oe,"%").setParameterLength(2).setName("mod"),$R=At(Oe,"==").setParameterLength(2).setName("equal"),qR=At(Oe,"!=").setParameterLength(2).setName("notEqual"),YR=At(Oe,"<").setParameterLength(2).setName("lessThan"),ZR=At(Oe,">").setParameterLength(2).setName("greaterThan"),JR=At(Oe,"<=").setParameterLength(2).setName("lessThanEqual"),jR=At(Oe,">=").setParameterLength(2).setName("greaterThanEqual"),KR=At(Oe,"&&").setParameterLength(2,1/0).setName("and"),QR=At(Oe,"||").setParameterLength(2,1/0).setName("or"),tI=At(Oe,"!").setParameterLength(1).setName("not"),eI=At(Oe,"^^").setParameterLength(2).setName("xor"),nI=At(Oe,"&").setParameterLength(2).setName("bitAnd"),iI=At(Oe,"~").setParameterLength(1).setName("bitNot"),sI=At(Oe,"|").setParameterLength(2).setName("bitOr"),rI=At(Oe,"^").setParameterLength(2).setName("bitXor"),oI=At(Oe,"<<").setParameterLength(2).setName("shiftLeft"),aI=At(Oe,">>").setParameterLength(2).setName("shiftRight"),lI=Mt(([r])=>(r.addAssign(1),r)),cI=Mt(([r])=>(r.subAssign(1),r)),hI=Mt(([r])=>{const t=Be(r).toConst();return r.addAssign(1),t}),uI=Mt(([r])=>{const t=Be(r).toConst();return r.subAssign(1),t});q("add",os);q("sub",Wn);q("mul",Ve);q("div",Od);q("mod",mg);q("equal",$R);q("notEqual",qR);q("lessThan",YR);q("greaterThan",ZR);q("lessThanEqual",JR);q("greaterThanEqual",jR);q("and",KR);q("or",QR);q("not",tI);q("xor",eI);q("bitAnd",nI);q("bitNot",iI);q("bitOr",sI);q("bitXor",rI);q("shiftLeft",oI);q("shiftRight",aI);q("incrementBefore",lI);q("decrementBefore",cI);q("increment",hI);q("decrement",uI);const dI=(r,t)=>(ne('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.',new xi),mg(Be(r),Be(t)));q("modInt",dI);class z extends xn{static get type(){return"MathNode"}constructor(t,e,n=null,i=null){if(super(),(t===z.MAX||t===z.MIN)&&arguments.length>3){let s=new z(t,e,n);for(let o=2;o<arguments.length-1;o++)s=new z(t,s,arguments[o]);e=s,n=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=n,this.cNode=i,this.isMathNode=!0}getInputType(t){const e=this.aNode.getNodeType(t),n=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,s=t.isMatrix(e)?0:t.getTypeLength(e),o=t.isMatrix(n)?0:t.getTypeLength(n),a=t.isMatrix(i)?0:t.getTypeLength(i);return s>o&&s>a?e:o>a?n:a>s?i:e}getNodeType(t){const e=this.method;return e===z.LENGTH||e===z.DISTANCE||e===z.DOT?"float":e===z.CROSS?"vec3":e===z.ALL||e===z.ANY?"bool":e===z.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){const{aNode:e,bNode:n,method:i}=this;let s=null;if(i===z.ONE_MINUS)s=Wn(1,e);else if(i===z.RECIPROCAL)s=Od(1,e);else if(i===z.DIFFERENCE)s=Nc(Wn(e,n));else if(i===z.TRANSFORM_DIRECTION){let o=e,a=n;t.isMatrix(o.getNodeType(t))?a=zn(Pt(a),0):o=zn(Pt(o),0);const l=Ve(o,a).xyz;s=gg(l)}return s!==null?s:super.setup(t)}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method;const s=this.getNodeType(t),o=this.getInputType(t),a=this.aNode,l=this.bNode,c=this.cNode,h=t.renderer.coordinateSystem;if(i===z.NEGATE)return t.format("( - "+a.build(t,o)+" )",s,e);{const u=[];return i===z.CROSS?u.push(a.build(t,s),l.build(t,s)):h===ns&&i===z.STEP?u.push(a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":o),l.build(t,o)):h===ns&&(i===z.MIN||i===z.MAX)?u.push(a.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":o)):i===z.REFRACT?u.push(a.build(t,o),l.build(t,o),c.build(t,"float")):i===z.MIX?u.push(a.build(t,o),l.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?"float":o)):(h===hr&&i===z.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===z.DFDX||i===z.DFDY)&&(ne(`TSL: '${i}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),u.push(a.build(t,o)),l!==null&&u.push(l.build(t,o)),c!==null&&u.push(c.build(t,o))),t.format(`${t.getMethod(i,s)}( ${u.join(", ")} )`,s,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}z.ALL="all";z.ANY="any";z.RADIANS="radians";z.DEGREES="degrees";z.EXP="exp";z.EXP2="exp2";z.LOG="log";z.LOG2="log2";z.SQRT="sqrt";z.INVERSE_SQRT="inversesqrt";z.FLOOR="floor";z.CEIL="ceil";z.NORMALIZE="normalize";z.FRACT="fract";z.SIN="sin";z.COS="cos";z.TAN="tan";z.ASIN="asin";z.ACOS="acos";z.ATAN="atan";z.ABS="abs";z.SIGN="sign";z.LENGTH="length";z.NEGATE="negate";z.ONE_MINUS="oneMinus";z.DFDX="dFdx";z.DFDY="dFdy";z.ROUND="round";z.RECIPROCAL="reciprocal";z.TRUNC="trunc";z.FWIDTH="fwidth";z.TRANSPOSE="transpose";z.DETERMINANT="determinant";z.INVERSE="inverse";z.EQUALS="equals";z.MIN="min";z.MAX="max";z.STEP="step";z.REFLECT="reflect";z.DISTANCE="distance";z.DIFFERENCE="difference";z.DOT="dot";z.CROSS="cross";z.POW="pow";z.TRANSFORM_DIRECTION="transformDirection";z.MIX="mix";z.CLAMP="clamp";z.REFRACT="refract";z.SMOOTHSTEP="smoothstep";z.FACEFORWARD="faceforward";const fI=kt(Math.PI),pI=At(z,z.ALL).setParameterLength(1),mI=At(z,z.ANY).setParameterLength(1),gI=At(z,z.RADIANS).setParameterLength(1),xI=At(z,z.DEGREES).setParameterLength(1),yI=At(z,z.EXP).setParameterLength(1),kp=At(z,z.EXP2).setParameterLength(1),_I=At(z,z.LOG).setParameterLength(1),$r=At(z,z.LOG2).setParameterLength(1),Cc=At(z,z.SQRT).setParameterLength(1),vI=At(z,z.INVERSE_SQRT).setParameterLength(1),hu=At(z,z.FLOOR).setParameterLength(1),cM=At(z,z.CEIL).setParameterLength(1),gg=At(z,z.NORMALIZE).setParameterLength(1),Qr=At(z,z.FRACT).setParameterLength(1),ac=At(z,z.SIN).setParameterLength(1),hM=At(z,z.COS).setParameterLength(1),MI=At(z,z.TAN).setParameterLength(1),SI=At(z,z.ASIN).setParameterLength(1),uM=At(z,z.ACOS).setParameterLength(1),bI=At(z,z.ATAN).setParameterLength(1,2),Nc=At(z,z.ABS).setParameterLength(1),dM=At(z,z.SIGN).setParameterLength(1),Vu=At(z,z.LENGTH).setParameterLength(1),fM=At(z,z.NEGATE).setParameterLength(1),TI=At(z,z.ONE_MINUS).setParameterLength(1),pM=At(z,z.DFDX).setParameterLength(1),mM=At(z,z.DFDY).setParameterLength(1),wI=At(z,z.ROUND).setParameterLength(1),AI=At(z,z.RECIPROCAL).setParameterLength(1),EI=At(z,z.TRUNC).setParameterLength(1),gM=At(z,z.FWIDTH).setParameterLength(1),CI=At(z,z.TRANSPOSE).setParameterLength(1),NI=At(z,z.DETERMINANT).setParameterLength(1),RI=At(z,z.INVERSE).setParameterLength(1),lc=At(z,z.MIN).setParameterLength(2,1/0),as=At(z,z.MAX).setParameterLength(2,1/0),cc=At(z,z.STEP).setParameterLength(2),II=At(z,z.REFLECT).setParameterLength(2),PI=At(z,z.DISTANCE).setParameterLength(2),LI=At(z,z.DIFFERENCE).setParameterLength(2),Rc=At(z,z.DOT).setParameterLength(2),Gp=At(z,z.CROSS).setParameterLength(2),xg=At(z,z.POW).setParameterLength(2),FI=r=>Ve(r,r),DI=r=>Ve(r,r,r),UI=r=>Ve(r,r,r,r),OI=At(z,z.TRANSFORM_DIRECTION).setParameterLength(2),BI=r=>Ve(dM(r),xg(Nc(r),1/3)),zI=r=>Rc(r,r),Dn=At(z,z.MIX).setParameterLength(3),_a=(r,t=0,e=1)=>new z(z.CLAMP,Ot(r),Ot(t),Ot(e)),yg=r=>_a(r),VI=At(z,z.REFRACT).setParameterLength(3),hc=At(z,z.SMOOTHSTEP).setParameterLength(3),kI=At(z,z.FACEFORWARD).setParameterLength(3),GI=Mt(([r])=>{const n=43758.5453,i=Rc(r.xy,xe(12.9898,78.233)),s=mg(i,fI);return Qr(ac(s).mul(n))}),HI=(r,t,e)=>Dn(t,e,r),WI=(r,t,e)=>hc(t,e,r),XI=(r,t)=>cc(t,r);q("all",pI);q("any",mI);q("radians",gI);q("degrees",xI);q("exp",yI);q("exp2",kp);q("log",_I);q("log2",$r);q("sqrt",Cc);q("inverseSqrt",vI);q("floor",hu);q("ceil",cM);q("normalize",gg);q("fract",Qr);q("sin",ac);q("cos",hM);q("tan",MI);q("asin",SI);q("acos",uM);q("atan",bI);q("abs",Nc);q("sign",dM);q("length",Vu);q("lengthSq",zI);q("negate",fM);q("oneMinus",TI);q("dFdx",pM);q("dFdy",mM);q("round",wI);q("reciprocal",AI);q("trunc",EI);q("fwidth",gM);q("min",lc);q("max",as);q("step",XI);q("reflect",II);q("distance",PI);q("dot",Rc);q("cross",Gp);q("pow",xg);q("pow2",FI);q("pow3",DI);q("pow4",UI);q("transformDirection",OI);q("mix",HI);q("clamp",_a);q("refract",VI);q("smoothstep",WI);q("faceForward",kI);q("difference",LI);q("saturate",yg);q("cbrt",BI);q("transpose",CI);q("determinant",NI);q("inverse",RI);q("rand",GI);class $I extends Bt{static get type(){return"ConditionalNode"}constructor(t,e,n=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=n}getNodeType(t){const{ifNode:e,elseNode:n}=t.getNodeProperties(this);if(e===void 0)return t.flowBuildStage(this,"setup"),this.getNodeType(t);const i=e.getNodeType(t);if(n!==null){const s=n.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(i))return s}return i}setup(t){const e=this.condNode,n=this.ifNode.isolate(),i=this.elseNode?this.elseNode.isolate():null,s=t.context.nodeBlock;t.getDataFromNode(n).parentNodeBlock=s,i!==null&&(t.getDataFromNode(i).parentNodeBlock=s);const o=t.context.uniformFlow,a=t.getNodeProperties(this);a.condNode=e,a.ifNode=o?n:n.context({nodeBlock:n}),a.elseNode=i?o?i:i.context({nodeBlock:i}):null}generate(t,e){const n=this.getNodeType(t),i=t.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;const{condNode:s,ifNode:o,elseNode:a}=t.getNodeProperties(this),l=t.currentFunctionNode,c=e!=="void",h=c?lM(n).build(t):"";i.nodeProperty=h;const u=s.build(t,"bool");if(t.context.uniformFlow&&a!==null){const p=o.build(t,n),x=a.build(t,n),g=t.getTernary(u,p,x);return t.format(g,n,e)}t.addFlowCode(`
|
|
4060
|
+
${e}`}}function rg(r,t=0){let e=3735928559^t,n=1103547991^t;if(r instanceof Array)for(let i=0,s;i<r.length;i++)s=r[i],e=Math.imul(e^s,2654435761),n=Math.imul(n^s,1597334677);else for(let i=0,s;i<r.length;i++)s=r.charCodeAt(i),e=Math.imul(e^s,2654435761),n=Math.imul(n^s,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&n)+(e>>>0)}const og=r=>rg(r),Zv=r=>rg(r),Jv=(...r)=>rg(r),eR=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Bx=new WeakMap;function nR(r){return eR.get(r)}function Bu(r){if(r==null)return null;const t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function ag(r,...t){const e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new Vi(...t):e==="vec2"?new Ge(...t):e==="vec3"?new H(...t):e==="vec4"?new Nn(...t):e==="mat2"?new sg(...t):e==="mat3"?new Mi(...t):e==="mat4"?new ke(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?rR(t[0]):null}function iR(r){let t=Bx.get(r);return t===void 0&&(t={},Bx.set(r,t)),t}function sR(r){let t="";const e=new Uint8Array(r);for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function rR(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}class Ia{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const i=n[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}}const oR={analyze:"setup",generate:"analyze"};let aR=0;class Bt extends Ia{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=ue.NONE,this.updateBeforeType=ue.NONE,this.updateAfterType=ue.NONE,this.uuid=ZN.generateUUID(),this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:aR++}),this.stackTrace=null,Bt.captureStackTrace===!0&&(this.stackTrace=new xi)}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this),this}onFrameUpdate(t){return this.onUpdate(t,ue.FRAME)}onRenderUpdate(t){return this.onUpdate(t,ue.RENDER)}onObjectUpdate(t){return this.onUpdate(t,ue.OBJECT)}onReference(t){return this.updateReference=t.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:t}of this._getChildren())yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(const e of this.getChildren())e.traverse(t)}_getChildren(t=new Set){const e=[];t.add(this);for(const n of Object.getOwnPropertyNames(this)){const i=this[n];if(!(n.startsWith("_")===!0||t.has(i))){if(Array.isArray(i)===!0)for(let s=0;s<i.length;s++){const o=i[s];o&&o.isNode===!0&&e.push({property:n,index:s,childNode:o})}else if(i&&i.isNode===!0)e.push({property:n,childNode:i});else if(i&&Object.getPrototypeOf(i)===Object.prototype)for(const s in i){if(s.startsWith("_")===!0)continue;const o=i[s];o&&o.isNode===!0&&e.push({property:n,index:s,childNode:o})}}}return e}getCacheKey(t=!1,e=null){if(t=t||this.version!==this._cacheKeyVersion,t===!0||this._cacheKey===null){e===null&&(e=new Set);const n=[];for(const{property:i,childNode:s}of this._getChildren(e))n.push(og(i.slice(0,-4)),s.getCacheKey(t,e));this._cacheKey=Jv(Zv(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){const e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t){const e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){const e=this.getHash(t);return t.getNodeFromHash(e)||this}getArrayCount(){return null}setup(t){const e=t.getNodeProperties(this);let n=0;for(const i of this.getChildren())e["node"+n++]=i;return e.outputNode||null}analyze(t,e=null){const n=t.increaseUsage(this);if(this.parents===!0){const i=t.getDataFromNode(this,"any");i.stages=i.stages||{},i.stages[t.shaderStage]=i.stages[t.shaderStage]||[],i.stages[t.shaderStage].push(e)}if(n===1){const i=t.getNodeProperties(this);for(const s of Object.values(i))s&&s.isNode===!0&&s.build(t,this)}}generate(t,e){const{outputNode:n}=t.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(t,e)}updateBefore(){ne("Abstract function.")}updateAfter(){ne("Abstract function.")}update(){ne("Abstract function.")}before(t){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(t),this}build(t,e=null){const n=this.getShared(t);if(this!==n)return n.build(t,e);if(this._beforeNodes!==null){const l=this._beforeNodes;this._beforeNodes=null;for(const c of l)c.build(t,e);this._beforeNodes=l}const i=t.getDataFromNode(this);i.buildStages=i.buildStages||{},i.buildStages[t.buildStage]=!0;const s=oR[t.buildStage];if(s&&i.buildStages[s]!==!0){const l=t.getBuildStage();t.setBuildStage(s),this.build(t),t.setBuildStage(l)}t.addChain(this);let o=null;const a=t.getBuildStage();if(a==="setup"){t.addNode(this),this.updateReference(t);const l=t.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(t)||l.outputNode||null;for(const c of Object.values(l))if(c&&c.isNode===!0){if(c.parents===!0){const h=t.getNodeProperties(c);h.parents=h.parents||[],h.parents.push(this)}c.build(t)}t.addSequentialNode(this)}o=l.outputNode}else if(a==="analyze")this.analyze(t,e);else if(a==="generate"){if(this.generate.length<2){const c=this.getNodeType(t),h=t.getDataFromNode(this);o=h.snippet,o===void 0?h.generated===void 0?(h.generated=!0,o=this.generate(t)||"",h.snippet=o):(ne("Node: Recursion detected.",this),o="/* Recursion detected. */"):h.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),o=t.format(o,c,e)}else o=this.generate(t,e)||"";o===""&&e!==null&&e!=="void"&&e!=="OutputType"&&(Ne(`TSL: Invalid generated code, expected a "${e}".`),o=t.generateConst(e))}return t.removeChain(this),o}getSerializeChildren(){return this._getChildren()}serialize(t){const e=this.getSerializeChildren(),n={};for(const{property:i,index:s,childNode:o}of e)s!==void 0?(n[i]===void 0&&(n[i]=Number.isInteger(s)?[]:{}),n[i][s]=o.toJSON(t.meta).uuid):n[i]=o.toJSON(t.meta).uuid;Object.keys(n).length>0&&(t.inputNodes=n)}deserialize(t){if(t.inputNodes!==void 0){const e=t.meta.nodes;for(const n in t.inputNodes)if(Array.isArray(t.inputNodes[n])){const i=[];for(const s of t.inputNodes[n])i.push(e[s]);this[n]=i}else if(typeof t.inputNodes[n]=="object"){const i={};for(const s in t.inputNodes[n]){const o=t.inputNodes[n][s];i[s]=e[o]}this[n]=i}else{const i=t.inputNodes[n];this[n]=e[i]}}}toJSON(t){const{uuid:e,type:n}=this,i=t===void 0||typeof t=="string";i&&(t={textures:{},images:{},nodes:{}});let s=t.nodes[e];s===void 0&&(s={uuid:e,type:n,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},i!==!0&&(t.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}if(i){const a=o(t.textures),l=o(t.images),c=o(t.nodes);a.length>0&&(s.textures=a),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}Bt.captureStackTrace=!1;class Pa extends Bt{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}getMemberType(t,e){return this.node.getMemberType(t,e)}generate(t){const e=this.indexNode.getNodeType(t),n=this.node.build(t),i=this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint");return`${n}[ ${i} ]`}}class jv extends Bt{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){const e=this.node.getNodeType(t);let n=null;for(const i of this.convertTo.split("|"))(n===null||t.getTypeLength(e)===t.getTypeLength(i))&&(n=i);return n}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){const n=this.node,i=this.getNodeType(t),s=n.build(t,i);return t.format(s,i,e)}}class xn extends Bt{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){const i=t.getVectorType(this.getNodeType(t,e)),s=t.getDataFromNode(this);if(s.propertyName!==void 0)return t.format(s.propertyName,i,e);if(i!=="void"&&e!=="void"&&this.hasDependencies(t)){const o=super.build(t,i),a=t.getVarFromNode(this,null,i),l=t.getPropertyName(a);return t.addLineFlowCode(`${l} = ${o}`,this),s.snippet=o,s.propertyName=l,t.format(s.propertyName,i,e)}}return super.build(t,e)}}class lR extends xn{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,n)=>e+t.getTypeLength(n.getNodeType(t)),0))}generate(t,e){const n=this.getNodeType(t),i=t.getTypeLength(n),s=this.nodes,o=t.getComponentType(n),a=[];let l=0;for(const h of s){if(l>=i){Ne(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let u=h.getNodeType(t),d=t.getTypeLength(u),f;if(l+d>i&&(Ne(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),d=i-l,u=t.getTypeFromLength(d)),l+=d,f=h.build(t,u),t.getComponentType(u)!==o){const x=t.getTypeFromLength(d,o);f=t.format(f,u,x)}a.push(f)}const c=`${t.getType(n)}( ${a.join(", ")} )`;return t.format(c,n,e)}}const cR=wc.join("");class hR extends Bt{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(const e of this.components)t=Math.max(wc.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}getScope(){return this.node.getScope()}generate(t,e){const n=this.node,i=t.getTypeLength(n.getNodeType(t));let s=null;if(i>1){let o=null;this.getVectorLength()>=i&&(o=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));const l=n.build(t,o);this.components.length===i&&this.components===cR.slice(0,this.components.length)?s=t.format(l,o,e):s=t.format(`${l}.${this.components}`,this.getNodeType(t),e)}else s=n.build(t,e);return s}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}}class uR extends xn{static get type(){return"SetNode"}constructor(t,e,n){super(),this.sourceNode=t,this.components=e,this.targetNode=n}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{sourceNode:e,components:n,targetNode:i}=this,s=this.getNodeType(t),o=t.getComponentType(i.getNodeType(t)),a=t.getTypeFromLength(n.length,o),l=i.build(t,a),c=e.build(t,s),h=t.getTypeLength(s),u=[];for(let d=0;d<h;d++){const f=wc[d];f===n[0]?(u.push(l),d+=n.length-1):u.push(c+"."+f)}return`${t.getType(s)}( ${u.join(", ")} )`}}class dR extends xn{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{components:e,sourceNode:n}=this,i=this.getNodeType(t),s=n.build(t),o=t.getVarFromNode(this),a=t.getPropertyName(o);t.addLineFlowCode(a+" = "+s,this);const l=t.getTypeLength(i),c=[];let h=0;for(let u=0;u<l;u++){const d=wc[u];d===e[h]?(c.push("1.0 - "+(a+"."+d)),h++):c.push(a+"."+d)}return`${t.getType(i)}( ${c.join(", ")} )`}}class lg extends Bt{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return this.nodeType===null?Bu(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Bu(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=sR(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?ag(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){ne("Abstract function.")}}const zx=/float|u?int/;class cs extends lg{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){const n=this.getNodeType(t);return zx.test(n)&&zx.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),n,e)}}class fR extends Bt{static get type(){return"MemberNode"}constructor(t,e){super(),this.structNode=t,this.property=e,this.isMemberNode=!0}hasMember(t){return this.structNode.isMemberNode&&this.structNode.hasMember(t)===!1?!1:this.structNode.getMemberType(t,this.property)!=="void"}getNodeType(t){return this.hasMember(t)===!1?"float":this.structNode.getMemberType(t,this.property)}getMemberType(t,e){if(this.hasMember(t)===!1)return"float";const n=this.getNodeType(t);return t.getStructTypeNode(n).getMemberType(t,e)}generate(t){if(this.hasMember(t)===!1){ne(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);const n=this.getNodeType(t);return t.generateConst(n)}return this.structNode.build(t)+"."+this.property}}let pR=null;const zp=new Map;function q(r,t){if(zp.has(r)){ne(`TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw new Error(`THREE.TSL: Node element ${r} is not a function`);zp.set(r,t),r!=="assign"&&(Bt.prototype[r]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},Bt.prototype[r+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}const mR=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Vx=r=>mR(r).split("").sort().join("");Bt.prototype.assign=function(...r){if(this.isStackNode!==!0)return Ne("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new xi),this;{const t=zp.get("assign");return this.addToStack(t(...r))}};Bt.prototype.toVarIntent=function(){return this};Bt.prototype.get=function(r){return new fR(this,r)};const _l={};function Rh(r,t,e){_l[r]=_l[t]=_l[e]={get(){this._cache=this._cache||{};let o=this._cache[r];return o===void 0&&(o=new hR(this,r),this._cache[r]=o),o},set(o){this[r].assign(Ot(o))}};const n=r.toUpperCase(),i=t.toUpperCase(),s=e.toUpperCase();Bt.prototype["set"+n]=Bt.prototype["set"+i]=Bt.prototype["set"+s]=function(o){const a=Vx(r);return new uR(this,a,Ot(o))},Bt.prototype["flip"+n]=Bt.prototype["flip"+i]=Bt.prototype["flip"+s]=function(){const o=Vx(r);return new dR(this,o)}}const qi=["x","y","z","w"],Yi=["r","g","b","a"],Zi=["s","t","p","q"];for(let r=0;r<4;r++){let t=qi[r],e=Yi[r],n=Zi[r];Rh(t,e,n);for(let i=0;i<4;i++){t=qi[r]+qi[i],e=Yi[r]+Yi[i],n=Zi[r]+Zi[i],Rh(t,e,n);for(let s=0;s<4;s++){t=qi[r]+qi[i]+qi[s],e=Yi[r]+Yi[i]+Yi[s],n=Zi[r]+Zi[i]+Zi[s],Rh(t,e,n);for(let o=0;o<4;o++)t=qi[r]+qi[i]+qi[s]+qi[o],e=Yi[r]+Yi[i]+Yi[s]+Yi[o],n=Zi[r]+Zi[i]+Zi[s]+Zi[o],Rh(t,e,n)}}}for(let r=0;r<32;r++)_l[r]={get(){this._cache=this._cache||{};let t=this._cache[r];return t===void 0&&(t=new Pa(this,new cs(r,"uint")),this._cache[r]=t),t},set(t){this[r].assign(Ot(t))}};Object.defineProperties(Bt.prototype,_l);const kx=new WeakMap,gR=function(r,t=null){const e=Bu(r);return e==="node"?r:t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string"?Ot(Vp(r,t)):e==="shader"?r.isFn?r:Mt(r):r},xR=function(r,t=null){for(const e in r)r[e]=Ot(r[e],t);return r},yR=function(r,t=null){const e=r.length;for(let n=0;n<e;n++)r[n]=Ot(r[n],t);return r},Kv=function(r,t=null,e=null,n=null){function i(h){return n!==null?(h=Ot(Object.assign(h,n)),n.intent===!0&&(h=h.toVarIntent())):h=Ot(h),h}let s,o=t,a,l;function c(h){let u;return o?u=/[a-z]/i.test(o)?o+"()":o:u=r.type,a!==void 0&&h.length<a?(Ne(`TSL: "${u}" parameter length is less than minimum required.`,new xi),h.concat(new Array(a-h.length).fill(0))):l!==void 0&&h.length>l?(Ne(`TSL: "${u}" parameter length exceeds limit.`,new xi),h.slice(0,l)):h}return t===null?s=(...h)=>i(new r(...ra(c(h)))):e!==null?(e=Ot(e),s=(...h)=>i(new r(t,...ra(c(h)),e))):s=(...h)=>i(new r(t,...ra(c(h)))),s.setParameterLength=(...h)=>(h.length===1?a=l=h[0]:h.length===2&&([a,l]=h),s),s.setName=h=>(o=h,s),s},_R=function(r,...t){return new r(...ra(t))};class vR extends Bt{constructor(t,e){super(),this.shaderNode=t,this.rawInputs=e,this.isShaderCallNodeInternal=!0}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getElementType(t){return this.getOutputNode(t).getElementType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){const{shaderNode:e,rawInputs:n}=this,i=t.getNodeProperties(e),s=t.getClosestSubBuild(e.subBuilds)||"",o=s||"default";if(i[o])return i[o];const a=t.subBuildFn,l=t.fnCall;t.subBuildFn=s,t.fnCall=this;let c=null;if(e.layout){let h=kx.get(t.constructor);h===void 0&&(h=new WeakMap,kx.set(t.constructor,h));let u=h.get(e);u===void 0&&(u=Ot(t.buildFunctionNode(e)),h.set(e,u)),t.addInclude(u);const d=n?MR(n):null;c=Ot(u.call(d))}else{const h=new Proxy(t,{get:(x,g,m)=>{let y;return Symbol.iterator===g?y=function*(){yield void 0}:y=Reflect.get(x,g,m),y}}),u=n?SR(n):null,d=Array.isArray(n)?n.length>0:n!==null,f=e.jsFunc,p=d||f.length>1?f(u,h):f(h);c=Ot(p)}return t.subBuildFn=a,t.fnCall=l,e.once&&(i[o]=c),c}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){const e=t.getNodeProperties(this),n=t.getSubBuildOutput(this);return e[n]=e[n]||this.setupOutput(t),e[n].subBuild=t.getClosestSubBuild(this),e[n]}build(t,e=null){let n=null;const i=t.getBuildStage(),s=t.getNodeProperties(this),o=t.getSubBuildOutput(this),a=this.getOutputNode(t),l=t.fnCall;if(t.fnCall=this,i==="setup"){const c=t.getSubBuildProperty("initialized",this);if(s[c]!==!0&&(s[c]=!0,s[o]=this.getOutputNode(t),s[o].build(t),this.shaderNode.subBuilds))for(const h of t.chaining){const u=t.getDataFromNode(h,"any");u.subBuilds=u.subBuilds||new Set;for(const d of this.shaderNode.subBuilds)u.subBuilds.add(d)}n=s[o]}else i==="analyze"?a.build(t,e):i==="generate"&&(n=a.build(t,e)||"");return t.fnCall=l,n}}function MR(r){let t;return dg(r),r[0]&&(r[0].isNode||Object.getPrototypeOf(r[0])!==Object.prototype)?t=[...r]:t=r[0],t}function SR(r){let t=0;return dg(r),new Proxy(r,{get:(e,n,i)=>{let s;if(n==="length")return s=r.length,s;if(Symbol.iterator===n)s=function*(){for(const o of r)yield Ot(o)};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){const o=r[0];o[n]===void 0?s=o[t++]:s=Reflect.get(o,n,i)}else r[0]instanceof Bt&&(r[n]===void 0?s=r[t++]:s=Reflect.get(r,n,i));else s=Reflect.get(e,n,i);s=Ot(s)}return s}})}class bR extends Bt{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}getLayout(){return this.layout}call(t=null){return new vR(this,t)}setup(){return this.call()}}const TR=[!1,!0],wR=[0,1,2,3],AR=[-1,-2],Qv=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],cg=new Map;for(const r of TR)cg.set(r,new cs(r));const hg=new Map;for(const r of wR)hg.set(r,new cs(r,"uint"));const ug=new Map([...hg].map(r=>new cs(r.value,"int")));for(const r of AR)ug.set(r,new cs(r,"int"));const Fd=new Map([...ug].map(r=>new cs(r.value)));for(const r of Qv)Fd.set(r,new cs(r));for(const r of Qv)Fd.set(-r,new cs(-r));const Dd={bool:cg,uint:hg,ints:ug,float:Fd},Gx=new Map([...cg,...Fd]),Vp=(r,t)=>Gx.has(r)?Gx.get(r):r.isNode===!0?r:new cs(r,t),je=function(r,t=null){return(...e)=>{for(const i of e)if(i===void 0)return Ne(`TSL: Invalid parameter for the type "${r}".`,new xi),new cs(0,r);if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>{const s=typeof i;return s!=="object"&&s!=="function"}))&&(e=[ag(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return Ih(t.get(e[0]));if(e.length===1){const i=Vp(e[0],r);return i.nodeType===r?Ih(i):Ih(new jv(i,r))}const n=e.map(i=>Vp(i));return Ih(new lR(n,r))}},ER=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function CR(r,t){return new bR(r,t)}const Ot=(r,t=null)=>gR(r,t),Ih=(r,t=null)=>Ot(r,t).toVarIntent(),dg=(r,t=null)=>new xR(r,t),ra=(r,t=null)=>new yR(r,t),De=(r,t=null,e=null,n=null)=>new Kv(r,t,e,n),Ke=(r,...t)=>new _R(r,...t),At=(r,t=null,e=null,n={})=>new Kv(r,t,e,{...n,intent:!0});let NR=0;class RR extends Bt{constructor(t,e=null){super();let n=null;e!==null&&(typeof e=="object"?n=e.return:(typeof e=="string"?n=e:Ne("TSL: Invalid layout type.",new xi),e=null)),this.shaderNode=new CR(t,n),e!==null&&this.setLayout(e),this.isFn=!0}setLayout(t){const e=this.shaderNode.nodeType;if(typeof t.inputs!="object"){const n={name:"fn"+NR++,type:e,inputs:[]};for(const i in t)i!=="return"&&n.inputs.push({name:i,type:t[i]});t=n}return this.shaderNode.setLayout(t),this}getNodeType(t){return this.shaderNode.getNodeType(t)||"float"}call(...t){const e=this.shaderNode.call(t);return this.shaderNode.nodeType==="void"&&e.toStack(),e.toVarIntent()}once(t=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=t,this}generate(t){const e=this.getNodeType(t);return Ne('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),t.generateConst(e)}}function Mt(r,t=null){const e=new RR(r,t);return new Proxy(()=>{},{apply(n,i,s){return e.call(...s)},get(n,i,s){return Reflect.get(e,i,s)},set(n,i,s,o){return Reflect.set(e,i,s,o)}})}const hi=(...r)=>pR.If(...r);function IR(r){return r}q("toStack",IR);const PR=new je("color"),kt=new je("float",Dd.float),Be=new je("int",Dd.ints),fn=new je("uint",Dd.uint),fg=new je("bool",Dd.bool),xe=new je("vec2"),ji=new je("ivec2"),tM=new je("uvec2"),LR=new je("bvec2"),Pt=new je("vec3"),eM=new je("ivec3"),nM=new je("uvec3"),FR=new je("bvec3"),zn=new je("vec4"),iM=new je("ivec4"),sM=new je("uvec4"),DR=new je("bvec4"),rM=new je("mat2"),yi=new je("mat3"),Ud=new je("mat4");q("toColor",PR);q("toFloat",kt);q("toInt",Be);q("toUint",fn);q("toBool",fg);q("toVec2",xe);q("toIVec2",ji);q("toUVec2",tM);q("toBVec2",LR);q("toVec3",Pt);q("toIVec3",eM);q("toUVec3",nM);q("toBVec3",FR);q("toVec4",zn);q("toIVec4",iM);q("toUVec4",sM);q("toBVec4",DR);q("toMat2",rM);q("toMat3",yi);q("toMat4",Ud);const UR=De(Pa).setParameterLength(2),OR=(r,t)=>new jv(Ot(r),t);q("element",UR);q("convert",OR);q("append",r=>(ne("TSL: .append() has been renamed to .toStack().",new xi),r));class Hx extends xn{static get type(){return"ArrayNode"}constructor(t,e,n=null){super(t),this.count=e,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(t){return this.nodeType===null?this.values[0].getNodeType(t):this.nodeType}getElementType(t){return this.getNodeType(t)}getMemberType(t,e){return this.nodeType===null?this.values[0].getMemberType(t,e):super.getMemberType(t,e)}generate(t){const e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}}const BR=(...r)=>{let t;if(r.length===1){const e=r[0];t=new Hx(null,e.length,e)}else{const e=r[0],n=r[1];t=new Hx(e,n)}return Ot(t)};q("toArray",(r,t)=>BR(Array(t).fill(r)));class oM extends Bt{static get type(){return"UniformGroupNode"}constructor(t,e=!1,n=1){super("string"),this.name=t,this.shared=e,this.order=n,this.isUniformGroup=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}}const zR=r=>new oM(r),aM=(r,t=0)=>new oM(r,!0,t),te=aM("render"),VR=zR("object");class Ac extends lg{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=VR}setName(t){return this.name=t,this}label(t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.',new xi),this.setName(t)}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){return t=t.bind(this),super.onUpdate(n=>{const i=t(n,this);i!==void 0&&(this.value=i)},e)}getInputType(t){let e=super.getInputType(t);return e==="bool"&&(e="uint"),e}generate(t,e){const n=this.getNodeType(t),i=this.getUniformHash(t);let s=t.getNodeFromHash(i);s===void 0&&(t.setHashNode(this,i),s=this);const o=s.getInputType(t),a=t.getUniformFromNode(s,o,t.shaderStage,this.name||t.context.nodeName),l=t.getPropertyName(a);t.context.nodeName!==void 0&&delete t.context.nodeName;let c=l;if(n==="bool"){const h=t.getDataFromNode(this);let u=h.propertyName;if(u===void 0){const d=t.getVarFromNode(this,null,"bool");u=t.getPropertyName(d),h.propertyName=u,c=t.format(l,o,n),t.addLineFlowCode(`${u} = ${c}`,this)}c=u}return t.format(c,n,e)}}const de=(r,t)=>{const e=ER(t||r);if(e===r&&(r=ag(e)),r&&r.isNode===!0){let n=r.value;r.traverse(i=>{i.isConstNode===!0&&(n=i.value)}),r=n}return new Ac(r,e)};class Ec extends Bt{static get type(){return"PropertyNode"}constructor(t,e=null,n=!1){super(t),this.name=e,this.varying=n,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return og(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(t){return this.name||super.getHash(t)}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}}const lM=(r,t)=>new Ec(r,t),zu=(r,t)=>new Ec(r,t,!0),Hn=Ke(Ec,"vec4","DiffuseColor"),Wx=Ke(Ec,"vec3","EmissiveColor"),Wf=Ke(Ec,"vec4","Output");class kR extends xn{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){const{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){const n=t.getTypeLength(e.node.getNodeType(t));return wc.join("").slice(0,n)!==e.components}return!1}setup(t){const{targetNode:e,sourceNode:n}=this,i=e.getScope(),s=t.getDataFromNode(i);s.assign=!0;const o=t.getNodeProperties(this);o.sourceNode=n,o.targetNode=e.context({assign:!0})}generate(t,e){const{targetNode:n,sourceNode:i}=t.getNodeProperties(this),s=this.needsSplitAssign(t),o=n.build(t),a=n.getNodeType(t),l=i.build(t,a),c=i.getNodeType(t),h=t.getDataFromNode(this);let u;if(h.initialized===!0)e!=="void"&&(u=o);else if(s){const d=t.getVarFromNode(this,null,a),f=t.getPropertyName(d);t.addLineFlowCode(`${f} = ${l}`,this);const p=n.node,g=p.node.context({assign:!0}).build(t);for(let m=0;m<p.components.length;m++){const y=p.components[m];t.addLineFlowCode(`${g}.${y} = ${f}[ ${m} ]`,this)}e!=="void"&&(u=o)}else u=`${o} = ${l}`,(e==="void"||c==="void")&&(t.addLineFlowCode(u,this),e!=="void"&&(u=o));return h.initialized=!0,t.format(u,a,e)}}const GR=De(kR).setParameterLength(2);q("assign",GR);class HR extends xn{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}getMemberType(t,e){return this.functionNode.getMemberType(t,e)}generate(t){const e=[],n=this.functionNode,i=n.getInputs(t),s=this.parameters,o=(l,c)=>{const h=c.type,u=h==="pointer";let d;return u?d="&"+l.build(t):d=l.build(t,h),d};if(Array.isArray(s)){if(s.length>i.length)Ne("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=i.length;else if(s.length<i.length)for(Ne("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<i.length;)s.push(kt(0));for(let l=0;l<s.length;l++)e.push(o(s[l],i[l]))}else for(const l of i){const c=s[l.name];c!==void 0?e.push(o(c,l)):(Ne(`TSL: Input '${l.name}' not found in 'Fn()'.`),e.push(o(kt(0),l)))}return`${n.build(t,"property")}( ${e.join(", ")} )`}}const WR=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?ra(t):dg(t[0]),new HR(Ot(r),t));q("call",WR);const XR={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Oe extends xn{static get type(){return"OperatorNode"}constructor(t,e,n,...i){if(super(),i.length>0){let s=new Oe(t,e,n);for(let o=0;o<i.length-1;o++)s=new Oe(t,s,i[o]);e=s,n=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=n,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(XR[this.op],e)}getNodeType(t,e=null){const n=this.op,i=this.aNode,s=this.bNode,o=i.getNodeType(t),a=s?s.getNodeType(t):null;if(o==="void"||a==="void")return e||"void";if(n==="%")return o;if(n==="~"||n==="&"||n==="|"||n==="^"||n===">>"||n==="<<")return t.getIntegerType(o);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){const l=Math.max(t.getTypeLength(o),t.getTypeLength(a));return l>1?`bvec${l}`:"bool"}else{if(t.isMatrix(o)){if(a==="float")return o;if(t.isVector(a))return t.getVectorFromMatrix(o);if(t.isMatrix(a))return o}else if(t.isMatrix(a)){if(o==="float")return a;if(t.isVector(o))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(o)?a:o}}generate(t,e){const n=this.op,{aNode:i,bNode:s}=this,o=this.getNodeType(t,e);let a=null,l=null;o!=="void"?(a=i.getNodeType(t),l=s?s.getNodeType(t):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?t.isVector(a)?l=a:t.isVector(l)?a=l:a!==l&&(a=l="float"):n===">>"||n==="<<"?(a=o,l=t.changeComponentType(l,"uint")):n==="%"?(a=o,l=t.isInteger(a)&&t.isInteger(l)?l:a):t.isMatrix(a)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(a):t.isMatrix(l)||(a=l=o):t.isMatrix(l)?a==="float"?a="float":t.isVector(a)?a=t.getVectorFromMatrix(l):a=l=o:a=l=o):a=l=o;const c=i.build(t,a),h=s?s.build(t,l):null,u=t.getFunctionOperator(n);if(e!=="void"){const d=t.renderer.coordinateSystem===ns;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return d?t.isVector(a)?t.format(`${this.getOperatorMethod(t,e)}( ${c}, ${h} )`,o,e):t.format(`( ${c} ${n} ${h} )`,o,e):t.format(`( ${c} ${n} ${h} )`,o,e);if(n==="%")return t.isInteger(l)?t.format(`( ${c} % ${h} )`,o,e):t.format(`${this.getOperatorMethod(t,o)}( ${c}, ${h} )`,o,e);if(n==="!"||n==="~")return t.format(`(${n}${c})`,a,e);if(u)return t.format(`${u}( ${c}, ${h} )`,o,e);if(t.isMatrix(a)&&l==="float")return t.format(`( ${h} ${n} ${c} )`,o,e);if(a==="float"&&t.isMatrix(l))return t.format(`${c} ${n} ${h}`,o,e);{let f=`( ${c} ${n} ${h} )`;return!d&&o==="bool"&&t.isVector(a)&&t.isVector(l)&&(f=`all${f}`),t.format(f,o,e)}}else if(a!=="void")return u?t.format(`${u}( ${c}, ${h} )`,o,e):t.isMatrix(a)&&l==="float"?t.format(`${h} ${n} ${c}`,o,e):t.format(`${c} ${n} ${h}`,o,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}}const os=At(Oe,"+").setParameterLength(2,1/0).setName("add"),Wn=At(Oe,"-").setParameterLength(2,1/0).setName("sub"),Ve=At(Oe,"*").setParameterLength(2,1/0).setName("mul"),Od=At(Oe,"/").setParameterLength(2,1/0).setName("div"),pg=At(Oe,"%").setParameterLength(2).setName("mod"),$R=At(Oe,"==").setParameterLength(2).setName("equal"),qR=At(Oe,"!=").setParameterLength(2).setName("notEqual"),YR=At(Oe,"<").setParameterLength(2).setName("lessThan"),ZR=At(Oe,">").setParameterLength(2).setName("greaterThan"),JR=At(Oe,"<=").setParameterLength(2).setName("lessThanEqual"),jR=At(Oe,">=").setParameterLength(2).setName("greaterThanEqual"),KR=At(Oe,"&&").setParameterLength(2,1/0).setName("and"),QR=At(Oe,"||").setParameterLength(2,1/0).setName("or"),tI=At(Oe,"!").setParameterLength(1).setName("not"),eI=At(Oe,"^^").setParameterLength(2).setName("xor"),nI=At(Oe,"&").setParameterLength(2).setName("bitAnd"),iI=At(Oe,"~").setParameterLength(1).setName("bitNot"),sI=At(Oe,"|").setParameterLength(2).setName("bitOr"),rI=At(Oe,"^").setParameterLength(2).setName("bitXor"),oI=At(Oe,"<<").setParameterLength(2).setName("shiftLeft"),aI=At(Oe,">>").setParameterLength(2).setName("shiftRight"),lI=Mt(([r])=>(r.addAssign(1),r)),cI=Mt(([r])=>(r.subAssign(1),r)),hI=Mt(([r])=>{const t=Be(r).toConst();return r.addAssign(1),t}),uI=Mt(([r])=>{const t=Be(r).toConst();return r.subAssign(1),t});q("add",os);q("sub",Wn);q("mul",Ve);q("div",Od);q("mod",pg);q("equal",$R);q("notEqual",qR);q("lessThan",YR);q("greaterThan",ZR);q("lessThanEqual",JR);q("greaterThanEqual",jR);q("and",KR);q("or",QR);q("not",tI);q("xor",eI);q("bitAnd",nI);q("bitNot",iI);q("bitOr",sI);q("bitXor",rI);q("shiftLeft",oI);q("shiftRight",aI);q("incrementBefore",lI);q("decrementBefore",cI);q("increment",hI);q("decrement",uI);const dI=(r,t)=>(ne('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.',new xi),pg(Be(r),Be(t)));q("modInt",dI);class z extends xn{static get type(){return"MathNode"}constructor(t,e,n=null,i=null){if(super(),(t===z.MAX||t===z.MIN)&&arguments.length>3){let s=new z(t,e,n);for(let o=2;o<arguments.length-1;o++)s=new z(t,s,arguments[o]);e=s,n=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=n,this.cNode=i,this.isMathNode=!0}getInputType(t){const e=this.aNode.getNodeType(t),n=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,s=t.isMatrix(e)?0:t.getTypeLength(e),o=t.isMatrix(n)?0:t.getTypeLength(n),a=t.isMatrix(i)?0:t.getTypeLength(i);return s>o&&s>a?e:o>a?n:a>s?i:e}getNodeType(t){const e=this.method;return e===z.LENGTH||e===z.DISTANCE||e===z.DOT?"float":e===z.CROSS?"vec3":e===z.ALL||e===z.ANY?"bool":e===z.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){const{aNode:e,bNode:n,method:i}=this;let s=null;if(i===z.ONE_MINUS)s=Wn(1,e);else if(i===z.RECIPROCAL)s=Od(1,e);else if(i===z.DIFFERENCE)s=Nc(Wn(e,n));else if(i===z.TRANSFORM_DIRECTION){let o=e,a=n;t.isMatrix(o.getNodeType(t))?a=zn(Pt(a),0):o=zn(Pt(o),0);const l=Ve(o,a).xyz;s=mg(l)}return s!==null?s:super.setup(t)}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method;const s=this.getNodeType(t),o=this.getInputType(t),a=this.aNode,l=this.bNode,c=this.cNode,h=t.renderer.coordinateSystem;if(i===z.NEGATE)return t.format("( - "+a.build(t,o)+" )",s,e);{const u=[];return i===z.CROSS?u.push(a.build(t,s),l.build(t,s)):h===ns&&i===z.STEP?u.push(a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":o),l.build(t,o)):h===ns&&(i===z.MIN||i===z.MAX)?u.push(a.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":o)):i===z.REFRACT?u.push(a.build(t,o),l.build(t,o),c.build(t,"float")):i===z.MIX?u.push(a.build(t,o),l.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?"float":o)):(h===hr&&i===z.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===z.DFDX||i===z.DFDY)&&(ne(`TSL: '${i}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),u.push(a.build(t,o)),l!==null&&u.push(l.build(t,o)),c!==null&&u.push(c.build(t,o))),t.format(`${t.getMethod(i,s)}( ${u.join(", ")} )`,s,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}z.ALL="all";z.ANY="any";z.RADIANS="radians";z.DEGREES="degrees";z.EXP="exp";z.EXP2="exp2";z.LOG="log";z.LOG2="log2";z.SQRT="sqrt";z.INVERSE_SQRT="inversesqrt";z.FLOOR="floor";z.CEIL="ceil";z.NORMALIZE="normalize";z.FRACT="fract";z.SIN="sin";z.COS="cos";z.TAN="tan";z.ASIN="asin";z.ACOS="acos";z.ATAN="atan";z.ABS="abs";z.SIGN="sign";z.LENGTH="length";z.NEGATE="negate";z.ONE_MINUS="oneMinus";z.DFDX="dFdx";z.DFDY="dFdy";z.ROUND="round";z.RECIPROCAL="reciprocal";z.TRUNC="trunc";z.FWIDTH="fwidth";z.TRANSPOSE="transpose";z.DETERMINANT="determinant";z.INVERSE="inverse";z.EQUALS="equals";z.MIN="min";z.MAX="max";z.STEP="step";z.REFLECT="reflect";z.DISTANCE="distance";z.DIFFERENCE="difference";z.DOT="dot";z.CROSS="cross";z.POW="pow";z.TRANSFORM_DIRECTION="transformDirection";z.MIX="mix";z.CLAMP="clamp";z.REFRACT="refract";z.SMOOTHSTEP="smoothstep";z.FACEFORWARD="faceforward";const fI=kt(Math.PI),pI=At(z,z.ALL).setParameterLength(1),mI=At(z,z.ANY).setParameterLength(1),gI=At(z,z.RADIANS).setParameterLength(1),xI=At(z,z.DEGREES).setParameterLength(1),yI=At(z,z.EXP).setParameterLength(1),kp=At(z,z.EXP2).setParameterLength(1),_I=At(z,z.LOG).setParameterLength(1),$r=At(z,z.LOG2).setParameterLength(1),Cc=At(z,z.SQRT).setParameterLength(1),vI=At(z,z.INVERSE_SQRT).setParameterLength(1),hu=At(z,z.FLOOR).setParameterLength(1),cM=At(z,z.CEIL).setParameterLength(1),mg=At(z,z.NORMALIZE).setParameterLength(1),Qr=At(z,z.FRACT).setParameterLength(1),ac=At(z,z.SIN).setParameterLength(1),hM=At(z,z.COS).setParameterLength(1),MI=At(z,z.TAN).setParameterLength(1),SI=At(z,z.ASIN).setParameterLength(1),uM=At(z,z.ACOS).setParameterLength(1),bI=At(z,z.ATAN).setParameterLength(1,2),Nc=At(z,z.ABS).setParameterLength(1),dM=At(z,z.SIGN).setParameterLength(1),Vu=At(z,z.LENGTH).setParameterLength(1),fM=At(z,z.NEGATE).setParameterLength(1),TI=At(z,z.ONE_MINUS).setParameterLength(1),pM=At(z,z.DFDX).setParameterLength(1),mM=At(z,z.DFDY).setParameterLength(1),wI=At(z,z.ROUND).setParameterLength(1),AI=At(z,z.RECIPROCAL).setParameterLength(1),EI=At(z,z.TRUNC).setParameterLength(1),gM=At(z,z.FWIDTH).setParameterLength(1),CI=At(z,z.TRANSPOSE).setParameterLength(1),NI=At(z,z.DETERMINANT).setParameterLength(1),RI=At(z,z.INVERSE).setParameterLength(1),lc=At(z,z.MIN).setParameterLength(2,1/0),as=At(z,z.MAX).setParameterLength(2,1/0),cc=At(z,z.STEP).setParameterLength(2),II=At(z,z.REFLECT).setParameterLength(2),PI=At(z,z.DISTANCE).setParameterLength(2),LI=At(z,z.DIFFERENCE).setParameterLength(2),Rc=At(z,z.DOT).setParameterLength(2),Gp=At(z,z.CROSS).setParameterLength(2),gg=At(z,z.POW).setParameterLength(2),FI=r=>Ve(r,r),DI=r=>Ve(r,r,r),UI=r=>Ve(r,r,r,r),OI=At(z,z.TRANSFORM_DIRECTION).setParameterLength(2),BI=r=>Ve(dM(r),gg(Nc(r),1/3)),zI=r=>Rc(r,r),Dn=At(z,z.MIX).setParameterLength(3),va=(r,t=0,e=1)=>new z(z.CLAMP,Ot(r),Ot(t),Ot(e)),xg=r=>va(r),VI=At(z,z.REFRACT).setParameterLength(3),hc=At(z,z.SMOOTHSTEP).setParameterLength(3),kI=At(z,z.FACEFORWARD).setParameterLength(3),GI=Mt(([r])=>{const n=43758.5453,i=Rc(r.xy,xe(12.9898,78.233)),s=pg(i,fI);return Qr(ac(s).mul(n))}),HI=(r,t,e)=>Dn(t,e,r),WI=(r,t,e)=>hc(t,e,r),XI=(r,t)=>cc(t,r);q("all",pI);q("any",mI);q("radians",gI);q("degrees",xI);q("exp",yI);q("exp2",kp);q("log",_I);q("log2",$r);q("sqrt",Cc);q("inverseSqrt",vI);q("floor",hu);q("ceil",cM);q("normalize",mg);q("fract",Qr);q("sin",ac);q("cos",hM);q("tan",MI);q("asin",SI);q("acos",uM);q("atan",bI);q("abs",Nc);q("sign",dM);q("length",Vu);q("lengthSq",zI);q("negate",fM);q("oneMinus",TI);q("dFdx",pM);q("dFdy",mM);q("round",wI);q("reciprocal",AI);q("trunc",EI);q("fwidth",gM);q("min",lc);q("max",as);q("step",XI);q("reflect",II);q("distance",PI);q("dot",Rc);q("cross",Gp);q("pow",gg);q("pow2",FI);q("pow3",DI);q("pow4",UI);q("transformDirection",OI);q("mix",HI);q("clamp",va);q("refract",VI);q("smoothstep",WI);q("faceForward",kI);q("difference",LI);q("saturate",xg);q("cbrt",BI);q("transpose",CI);q("determinant",NI);q("inverse",RI);q("rand",GI);class $I extends Bt{static get type(){return"ConditionalNode"}constructor(t,e,n=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=n}getNodeType(t){const{ifNode:e,elseNode:n}=t.getNodeProperties(this);if(e===void 0)return t.flowBuildStage(this,"setup"),this.getNodeType(t);const i=e.getNodeType(t);if(n!==null){const s=n.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(i))return s}return i}setup(t){const e=this.condNode,n=this.ifNode.isolate(),i=this.elseNode?this.elseNode.isolate():null,s=t.context.nodeBlock;t.getDataFromNode(n).parentNodeBlock=s,i!==null&&(t.getDataFromNode(i).parentNodeBlock=s);const o=t.context.uniformFlow,a=t.getNodeProperties(this);a.condNode=e,a.ifNode=o?n:n.context({nodeBlock:n}),a.elseNode=i?o?i:i.context({nodeBlock:i}):null}generate(t,e){const n=this.getNodeType(t),i=t.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;const{condNode:s,ifNode:o,elseNode:a}=t.getNodeProperties(this),l=t.currentFunctionNode,c=e!=="void",h=c?lM(n).build(t):"";i.nodeProperty=h;const u=s.build(t,"bool");if(t.context.uniformFlow&&a!==null){const p=o.build(t,n),x=a.build(t,n),g=t.getTernary(u,p,x);return t.format(g,n,e)}t.addFlowCode(`
|
|
4061
4061
|
${t.tab}if ( ${u} ) {
|
|
4062
4062
|
|
|
4063
4063
|
`).addFlowTab();let f=o.build(t,n);if(f&&(c?f=h+" = "+f+";":(f="return "+f+";",l===null&&(ne("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),f="// "+f))),t.removeFlowTab().addFlowCode(t.tab+" "+f+`
|
|
@@ -4070,15 +4070,15 @@ ${t.tab}if ( ${u} ) {
|
|
|
4070
4070
|
|
|
4071
4071
|
`)}else t.addFlowCode(`
|
|
4072
4072
|
|
|
4073
|
-
`);return t.format(h,n,e)}}const _g=De($I).setParameterLength(2,3);q("select",_g);class xM extends Bt{static get type(){return"ContextNode"}constructor(t=null,e={}){super(),this.isContextNode=!0,this.node=t,this.value=e}getScope(){return this.node.getScope()}getNodeType(t){return this.node.getNodeType(t)}getFlowContextData(){const t=[];return this.traverse(e=>{e.isContextNode===!0&&t.push(e.value)}),Object.assign({},...t)}getMemberType(t,e){return this.node.getMemberType(t,e)}analyze(t){const e=t.addContext(this.value);this.node.build(t),t.setContext(e)}setup(t){const e=t.addContext(this.value);this.node.build(t),t.setContext(e)}generate(t,e){const n=t.addContext(this.value),i=this.node.build(t,e);return t.setContext(n),i}}const Pa=(r=null,t={})=>{let e=r;return(e===null||e.isNode!==!0)&&(t=e||t,e=null),new xM(e,t)},qI=r=>Pa(r,{uniformFlow:!0}),yM=(r,t)=>Pa(r,{nodeName:t});function YI(r,t,e=null){return Pa(e,{getShadow:({light:n,shadowColorNode:i})=>t===n?i.mul(r):i})}function ZI(r,t=null){return Pa(t,{getAO:(e,{material:n})=>n.transparent===!0?e:e!==null?e.mul(r):r})}function JI(r,t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),yM(r,t)}q("context",Pa);q("label",JI);q("uniformFlow",qI);q("setName",yM);q("builtinShadowContext",(r,t,e)=>YI(t,e,r));q("builtinAOContext",(r,t)=>ZI(t,r));class jI extends Bt{static get type(){return"VarNode"}constructor(t,e=null,n=!1){super(),this.node=t,this.name=e,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(t){return this.intent=t,this}isIntent(t){return t.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(t,e){return this.node.getMemberType(t,e)}getElementType(t){return this.node.getElementType(t)}getNodeType(t){return this.node.getNodeType(t)}getArrayCount(t){return this.node.getArrayCount(t)}isAssign(t){return t.getDataFromNode(this).assign}build(...t){const e=t[0];if(this._hasStack(e)===!1&&e.buildStage==="setup"&&(e.context.nodeLoop||e.context.nodeBlock)){let n=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&e.fnCall&&e.fnCall.shaderNode&&e.getDataFromNode(this.node.shaderNode).hasLoop){const o=e.getDataFromNode(this);o.forceDeclaration=!0,n=!0}const i=e.getBaseStack();n?i.addToStackBefore(this):i.addToStack(this)}return this.isIntent(e)&&this.isAssign(e)!==!0?this.node.build(...t):super.build(...t)}generate(t){const{node:e,name:n,readOnly:i}=this,{renderer:s}=t,o=s.backend.isWebGPUBackend===!0;let a=!1,l=!1;i&&(a=t.isDeterministic(e),l=o?i:a);const c=this.getNodeType(t);if(c=="void")return this.isIntent(t)!==!0&&Ne('TSL: ".toVar()" can not be used with void type.',this.stackTrace),e.build(t);const h=t.getVectorType(c),u=e.build(t,h),d=t.getVarFromNode(this,n,h,void 0,l),f=t.getPropertyName(d);let p=f;if(l)if(o)p=a?`const ${f}`:`let ${f}`;else{const x=e.getArrayCount(t);p=`const ${t.getVar(d.type,f,x)}`}return t.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(t){return t.getDataFromNode(this).stack!==void 0}}const vg=De(jI),KI=(r,t=null)=>vg(r,t).toStack(),QI=(r,t=null)=>vg(r,t,!0).toStack(),tP=r=>vg(r).setIntent(!0).toStack();q("toVar",KI);q("toConst",QI);q("toVarIntent",tP);class eP extends Bt{static get type(){return"SubBuild"}constructor(t,e,n=null){super(n),this.node=t,this.name=e,this.isSubBuildNode=!0}getNodeType(t){if(this.nodeType!==null)return this.nodeType;t.addSubBuild(this.name);const e=this.node.getNodeType(t);return t.removeSubBuild(),e}build(t,...e){t.addSubBuild(this.name);const n=this.node.build(t,...e);return t.removeSubBuild(),n}}const vl=(r,t,e=null)=>new eP(Ot(r),t,e);class nP extends Bt{static get type(){return"VaryingNode"}constructor(t,e=null){super(),this.node=vl(t,"VERTEX"),this.name=e,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(t,e=null){return this.interpolationType=t,this.interpolationSampling=e,this}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}setupVarying(t){const e=t.getNodeProperties(this);let n=e.varying;if(n===void 0){const i=this.name,s=this.getNodeType(t),o=this.interpolationType,a=this.interpolationSampling;e.varying=n=t.getVaryingFromNode(this,i,s,o,a),e.node=vl(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=t.shaderStage==="fragment"),n}setup(t){this.setupVarying(t),t.flowNodeFromShaderStage(Eh.VERTEX,this.node)}analyze(t){this.setupVarying(t),t.flowNodeFromShaderStage(Eh.VERTEX,this.node)}generate(t){const e=t.getSubBuildProperty("property",t.currentStack),n=t.getNodeProperties(this),i=this.setupVarying(t);if(n[e]===void 0){const s=this.getNodeType(t),o=t.getPropertyName(i,Eh.VERTEX);t.flowNodeFromShaderStage(Eh.VERTEX,n.node,s,o),n[e]=o}return t.getPropertyName(i)}}const La=De(nP).setParameterLength(1,2),iP=r=>La(r);q("toVarying",La);q("toVertexStage",iP);const sP=Mt(([r])=>{const t=r.mul(.9478672986).add(.0521327014).pow(2.4),e=r.mul(.0773993808),n=r.lessThanEqual(.04045);return Dn(t,e,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),rP=Mt(([r])=>{const t=r.pow(.41666).mul(1.055).sub(.055),e=r.mul(12.92),n=r.lessThanEqual(.0031308);return Dn(t,e,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Mg="WorkingColorSpace",oP="OutputColorSpace";class _M extends xn{static get type(){return"ColorSpaceNode"}constructor(t,e,n){super("vec4"),this.colorNode=t,this.source=e,this.target=n}resolveColorSpace(t,e){return e===Mg?Qe.workingColorSpace:e===oP?t.context.outputColorSpace||t.renderer.outputColorSpace:e}setup(t){const{colorNode:e}=this,n=this.resolveColorSpace(t,this.source),i=this.resolveColorSpace(t,this.target);let s=e;return Qe.enabled===!1||n===i||!n||!i||(Qe.getTransfer(n)===gl&&(s=zn(sP(s.rgb),s.a)),Qe.getPrimaries(n)!==Qe.getPrimaries(i)&&(s=zn(yi(Qe._getMatrix(new Mi,n,i)).mul(s.rgb),s.a)),Qe.getTransfer(i)===gl&&(s=zn(rP(s.rgb),s.a))),s}}const aP=(r,t)=>new _M(Ot(r),Mg,t),vM=(r,t)=>new _M(Ot(r),t,Mg);q("workingToColorSpace",aP);q("colorSpaceToWorking",vM);let lP=class extends Ia{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),n=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,n,i)}};class cP extends Bt{static get type(){return"ReferenceBaseNode"}constructor(t,e,n=null,i=null){super(),this.property=t,this.uniformType=e,this.object=n,this.count=i,this.properties=t.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=ue.OBJECT}setGroup(t){return this.group=t,this}element(t){return new lP(this,Ot(t))}setNodeType(t){const e=de(null,t);this.group!==null&&e.setGroup(this.group),this.node=e}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let n=t[e[0]];for(let i=1;i<e.length;i++)n=n[e[i]];return n}updateReference(t){return this.reference=this.object!==null?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}class hP extends cP{static get type(){return"RendererReferenceNode"}constructor(t,e,n=null){super(t,e,n),this.renderer=n,this.setGroup(te)}updateReference(t){return this.reference=this.renderer!==null?this.renderer:t.renderer,this.reference}}const uP=(r,t,e=null)=>new hP(r,t,e);class dP extends xn{static get type(){return"ToneMappingNode"}constructor(t,e=pP,n=null){super("vec3"),this._toneMapping=t,this.exposureNode=e,this.colorNode=n}customCacheKey(){return Jv(this._toneMapping)}setToneMapping(t){return this._toneMapping=t,this}getToneMapping(){return this._toneMapping}setup(t){const e=this.colorNode||t.context.color,n=this._toneMapping;if(n===Dp)return e;let i=null;const s=t.renderer.library.getToneMappingFunction(n);return s!==null?i=zn(s(e.rgb,this.exposureNode),e.a):(Ne("ToneMappingNode: Unsupported Tone Mapping configuration.",n),i=e),i}}const fP=(r,t,e)=>new dP(r,Ot(t),Ot(e)),pP=uP("toneMappingExposure","float");q("toneMapping",(r,t,e)=>fP(t,e,r));const Je=new H,Ph=new Ge;let mP=0;class sr{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:mP++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=xa,this.updateRanges=[],this.gpuType=Wv,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Ph.fromBufferAttribute(this,e),Ph.applyMatrix3(t),this.setXY(e,Ph.x,Ph.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Je.fromBufferAttribute(this,e),Je.applyMatrix3(t),this.setXYZ(e,Je.x,Je.y,Je.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Je.fromBufferAttribute(this,e),Je.applyMatrix4(t),this.setXYZ(e,Je.x,Je.y,Je.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Je.fromBufferAttribute(this,e),Je.applyNormalMatrix(t),this.setXYZ(e,Je.x,Je.y,Je.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Je.fromBufferAttribute(this,e),Je.transformDirection(t),this.setXYZ(e,Je.x,Je.y,Je.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ii(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=be(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ii(e,this.array)),e}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ii(e,this.array)),e}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ii(e,this.array)),e}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ii(e,this.array)),e}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array),i=be(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array),i=be(i,this.array),s=be(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==xa&&(t.usage=this.usage),t}}class gP extends sr{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class xP extends sr{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Hp extends sr{constructor(t,e,n){super(new Float32Array(t),e,n)}}const Pn=new H;class Sg{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Pn.fromBufferAttribute(this,e),Pn.applyMatrix4(t),this.setXYZ(e,Pn.x,Pn.y,Pn.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Pn.fromBufferAttribute(this,e),Pn.applyNormalMatrix(t),this.setXYZ(e,Pn.x,Pn.y,Pn.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Pn.fromBufferAttribute(this,e),Pn.transformDirection(t),this.setXYZ(e,Pn.x,Pn.y,Pn.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Ii(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=be(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ii(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ii(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ii(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ii(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),n=be(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),n=be(n,this.array),i=be(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),n=be(n,this.array),i=be(i,this.array),s=be(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){Bp("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new sr(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Sg(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Bp("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class MM{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=xa,this.updateRanges=[],this.version=0,this.uuid=Ps()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ps()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ps()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const $x=new WeakMap;function qx(r,t){let e=$x.get(r);return e===void 0&&(e=new MM(r,t),$x.set(r,e)),e}class qs extends cg{static get type(){return"BufferAttributeNode"}constructor(t,e=null,n=0,i=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferStride=n,this.bufferOffset=i,this.usage=xa,this.instanced=!1,this.attribute=null,this.global=!0,t&&t.isBufferAttribute===!0&&t.itemSize<=4&&(this.attribute=t,this.usage=t.usage,this.instanced=t.isInstancedBufferAttribute)}getHash(t){if(this.bufferStride===0&&this.bufferOffset===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getNodeType(t){return this.bufferType===null&&(this.bufferType=t.getTypeFromAttribute(this.attribute)),this.bufferType}setup(t){if(this.attribute!==null)return;const e=this.getNodeType(t),n=t.getTypeLength(e),i=this.value,s=this.bufferStride||n,o=this.bufferOffset;let a;i.isInterleavedBuffer===!0?a=i:i.isBufferAttribute===!0?a=qx(i.array,s):a=qx(i,s);const l=new Sg(a,n,o);a.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(t){const e=this.getNodeType(t),n=t.getBufferAttributeFromNode(this,e),i=t.getPropertyName(n);let s=null;return t.shaderStage==="vertex"||t.shaderStage==="compute"?(this.name=i,s=i):s=La(this).build(t,e),s}getInputType(){return"bufferAttribute"}setUsage(t){return this.usage=t,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=t),this}setInstanced(t){return this.instanced=t,this}}function bg(r,t=null,e=0,n=0,i=xa,s=!1){return t==="mat3"||t===null&&r.itemSize===9?yi(new qs(r,"vec3",9,0).setUsage(i).setInstanced(s),new qs(r,"vec3",9,3).setUsage(i).setInstanced(s),new qs(r,"vec3",9,6).setUsage(i).setInstanced(s)):t==="mat4"||t===null&&r.itemSize===16?Ud(new qs(r,"vec4",16,0).setUsage(i).setInstanced(s),new qs(r,"vec4",16,4).setUsage(i).setInstanced(s),new qs(r,"vec4",16,8).setUsage(i).setInstanced(s),new qs(r,"vec4",16,12).setUsage(i).setInstanced(s)):new qs(r,t,e,n).setUsage(i)}const SM=(r,t=null,e=0,n=0)=>bg(r,t,e,n),Yx=(r,t=null,e=0,n=0)=>bg(r,t,e,n,xa,!0),Zx=(r,t=null,e=0,n=0)=>bg(r,t,e,n,Op,!0);q("toAttribute",r=>SM(r.value));class yP extends Bt{static get type(){return"ComputeNode"}constructor(t,e){super("void"),this.isComputeNode=!0,this.computeNode=t,this.workgroupSize=e,this.count=null,this.version=1,this.name="",this.updateBeforeType=ue.OBJECT,this.onInitFunction=null}setCount(t){return this.count=t,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(t){return this.name=t,this}label(t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.',new xi),this.setName(t)}onInit(t){return this.onInitFunction=t,this}updateBefore({renderer:t}){t.compute(this)}setup(t){const e=this.computeNode.build(t);if(e){const n=t.getNodeProperties(this);n.outputComputeNode=e.outputNode,e.outputNode=null}return e}generate(t,e){const{shaderStage:n}=t;if(n==="compute"){const i=this.computeNode.build(t,"void");i!==""&&t.addLineFlowCode(i,this)}else{const s=t.getNodeProperties(this).outputComputeNode;if(s)return s.build(t,e)}}}const bM=(r,t=[64])=>{(t.length===0||t.length>3)&&Ne("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new xi);for(let e=0;e<t.length;e++){const n=t[e];(typeof n!="number"||n<=0||!Number.isInteger(n))&&Ne(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new xi)}for(;t.length<3;)t.push(1);return new yP(Ot(r),t)},_P=(r,t,e)=>bM(r,e).setCount(t);q("compute",_P);q("computeKernel",bM);class vP extends Bt{static get type(){return"IsolateNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isIsolateNode=!0}getNodeType(t){const e=t.getCache(),n=t.getCacheFromNode(this,this.parent);t.setCache(n);const i=this.node.getNodeType(t);return t.setCache(e),i}build(t,...e){const n=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);const s=this.node.build(t,...e);return t.setCache(n),s}setParent(t){return this.parent=t,this}getParent(){return this.parent}}const TM=r=>new vP(Ot(r));function MP(r,t=!0){return ne('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),TM(r).setParent(t)}q("cache",MP);q("isolate",TM);class SP extends Bt{static get type(){return"BypassNode"}constructor(t,e){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=e}getNodeType(t){return this.outputNode.getNodeType(t)}generate(t){const e=this.callNode.build(t,"void");return e!==""&&t.addLineFlowCode(e,this),this.outputNode.build(t)}}const bP=De(SP).setParameterLength(2);q("bypass",bP);class wM extends Bt{static get type(){return"RemapNode"}constructor(t,e,n,i=kt(0),s=kt(1)){super(),this.node=t,this.inLowNode=e,this.inHighNode=n,this.outLowNode=i,this.outHighNode=s,this.doClamp=!0}setup(){const{node:t,inLowNode:e,inHighNode:n,outLowNode:i,outHighNode:s,doClamp:o}=this;let a=t.sub(e).div(n.sub(e));return o===!0&&(a=a.clamp()),a.mul(s.sub(i)).add(i)}}const TP=De(wM,null,null,{doClamp:!1}).setParameterLength(3,5),wP=De(wM).setParameterLength(3,5);q("remap",TP);q("remapClamp",wP);class AP extends Bt{static get type(){return"ExpressionNode"}constructor(t="",e="void"){super(e),this.snippet=t}generate(t,e){const n=this.getNodeType(t),i=this.snippet;if(n==="void")t.addLineFlowCode(i,this);else return t.format(i,n,e)}}const Es=De(AP).setParameterLength(1,2),EP=r=>(r?_g(r,Es("discard")):Es("discard")).toStack();q("discard",EP);class CP extends xn{static get type(){return"RenderOutputNode"}constructor(t,e,n){super("vec4"),this.colorNode=t,this._toneMapping=e,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(t){return this._toneMapping=t,this}getToneMapping(){return this._toneMapping}setup({context:t}){let e=this.colorNode||t.color;const n=(this._toneMapping!==null?this._toneMapping:t.toneMapping)||Dp,i=(this.outputColorSpace!==null?this.outputColorSpace:t.outputColorSpace)||Uu;return n!==Dp&&(e=e.toneMapping(n)),i!==Uu&&i!==Qe.workingColorSpace&&(e=e.workingToColorSpace(i)),e}}const NP=(r,t=null,e=null)=>new CP(Ot(r),t,e);q("renderOutput",NP);class RP extends xn{static get type(){return"DebugNode"}constructor(t,e=null){super(),this.node=t,this.callback=e}getNodeType(t){return this.node.getNodeType(t)}setup(t){return this.node.build(t)}analyze(t){return this.node.build(t)}generate(t){const e=this.callback,n=this.node.build(t);if(e!==null)e(t,n);else{const i="--- TSL debug - "+t.shaderStage+" shader ---",s="-".repeat(i.length);let o="";o+="// #"+i+`#
|
|
4073
|
+
`);return t.format(h,n,e)}}const yg=De($I).setParameterLength(2,3);q("select",yg);class xM extends Bt{static get type(){return"ContextNode"}constructor(t=null,e={}){super(),this.isContextNode=!0,this.node=t,this.value=e}getScope(){return this.node.getScope()}getNodeType(t){return this.node.getNodeType(t)}getFlowContextData(){const t=[];return this.traverse(e=>{e.isContextNode===!0&&t.push(e.value)}),Object.assign({},...t)}getMemberType(t,e){return this.node.getMemberType(t,e)}analyze(t){const e=t.addContext(this.value);this.node.build(t),t.setContext(e)}setup(t){const e=t.addContext(this.value);this.node.build(t),t.setContext(e)}generate(t,e){const n=t.addContext(this.value),i=this.node.build(t,e);return t.setContext(n),i}}const La=(r=null,t={})=>{let e=r;return(e===null||e.isNode!==!0)&&(t=e||t,e=null),new xM(e,t)},qI=r=>La(r,{uniformFlow:!0}),yM=(r,t)=>La(r,{nodeName:t});function YI(r,t,e=null){return La(e,{getShadow:({light:n,shadowColorNode:i})=>t===n?i.mul(r):i})}function ZI(r,t=null){return La(t,{getAO:(e,{material:n})=>n.transparent===!0?e:e!==null?e.mul(r):r})}function JI(r,t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),yM(r,t)}q("context",La);q("label",JI);q("uniformFlow",qI);q("setName",yM);q("builtinShadowContext",(r,t,e)=>YI(t,e,r));q("builtinAOContext",(r,t)=>ZI(t,r));class jI extends Bt{static get type(){return"VarNode"}constructor(t,e=null,n=!1){super(),this.node=t,this.name=e,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(t){return this.intent=t,this}isIntent(t){return t.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(t,e){return this.node.getMemberType(t,e)}getElementType(t){return this.node.getElementType(t)}getNodeType(t){return this.node.getNodeType(t)}getArrayCount(t){return this.node.getArrayCount(t)}isAssign(t){return t.getDataFromNode(this).assign}build(...t){const e=t[0];if(this._hasStack(e)===!1&&e.buildStage==="setup"&&(e.context.nodeLoop||e.context.nodeBlock)){let n=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&e.fnCall&&e.fnCall.shaderNode&&e.getDataFromNode(this.node.shaderNode).hasLoop){const o=e.getDataFromNode(this);o.forceDeclaration=!0,n=!0}const i=e.getBaseStack();n?i.addToStackBefore(this):i.addToStack(this)}return this.isIntent(e)&&this.isAssign(e)!==!0?this.node.build(...t):super.build(...t)}generate(t){const{node:e,name:n,readOnly:i}=this,{renderer:s}=t,o=s.backend.isWebGPUBackend===!0;let a=!1,l=!1;i&&(a=t.isDeterministic(e),l=o?i:a);const c=this.getNodeType(t);if(c=="void")return this.isIntent(t)!==!0&&Ne('TSL: ".toVar()" can not be used with void type.',this.stackTrace),e.build(t);const h=t.getVectorType(c),u=e.build(t,h),d=t.getVarFromNode(this,n,h,void 0,l),f=t.getPropertyName(d);let p=f;if(l)if(o)p=a?`const ${f}`:`let ${f}`;else{const x=e.getArrayCount(t);p=`const ${t.getVar(d.type,f,x)}`}return t.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(t){return t.getDataFromNode(this).stack!==void 0}}const _g=De(jI),KI=(r,t=null)=>_g(r,t).toStack(),QI=(r,t=null)=>_g(r,t,!0).toStack(),tP=r=>_g(r).setIntent(!0).toStack();q("toVar",KI);q("toConst",QI);q("toVarIntent",tP);class eP extends Bt{static get type(){return"SubBuild"}constructor(t,e,n=null){super(n),this.node=t,this.name=e,this.isSubBuildNode=!0}getNodeType(t){if(this.nodeType!==null)return this.nodeType;t.addSubBuild(this.name);const e=this.node.getNodeType(t);return t.removeSubBuild(),e}build(t,...e){t.addSubBuild(this.name);const n=this.node.build(t,...e);return t.removeSubBuild(),n}}const vl=(r,t,e=null)=>new eP(Ot(r),t,e);class nP extends Bt{static get type(){return"VaryingNode"}constructor(t,e=null){super(),this.node=vl(t,"VERTEX"),this.name=e,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(t,e=null){return this.interpolationType=t,this.interpolationSampling=e,this}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}setupVarying(t){const e=t.getNodeProperties(this);let n=e.varying;if(n===void 0){const i=this.name,s=this.getNodeType(t),o=this.interpolationType,a=this.interpolationSampling;e.varying=n=t.getVaryingFromNode(this,i,s,o,a),e.node=vl(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=t.shaderStage==="fragment"),n}setup(t){this.setupVarying(t),t.flowNodeFromShaderStage(Eh.VERTEX,this.node)}analyze(t){this.setupVarying(t),t.flowNodeFromShaderStage(Eh.VERTEX,this.node)}generate(t){const e=t.getSubBuildProperty("property",t.currentStack),n=t.getNodeProperties(this),i=this.setupVarying(t);if(n[e]===void 0){const s=this.getNodeType(t),o=t.getPropertyName(i,Eh.VERTEX);t.flowNodeFromShaderStage(Eh.VERTEX,n.node,s,o),n[e]=o}return t.getPropertyName(i)}}const Fa=De(nP).setParameterLength(1,2),iP=r=>Fa(r);q("toVarying",Fa);q("toVertexStage",iP);const sP=Mt(([r])=>{const t=r.mul(.9478672986).add(.0521327014).pow(2.4),e=r.mul(.0773993808),n=r.lessThanEqual(.04045);return Dn(t,e,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),rP=Mt(([r])=>{const t=r.pow(.41666).mul(1.055).sub(.055),e=r.mul(12.92),n=r.lessThanEqual(.0031308);return Dn(t,e,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),vg="WorkingColorSpace",oP="OutputColorSpace";class _M extends xn{static get type(){return"ColorSpaceNode"}constructor(t,e,n){super("vec4"),this.colorNode=t,this.source=e,this.target=n}resolveColorSpace(t,e){return e===vg?Qe.workingColorSpace:e===oP?t.context.outputColorSpace||t.renderer.outputColorSpace:e}setup(t){const{colorNode:e}=this,n=this.resolveColorSpace(t,this.source),i=this.resolveColorSpace(t,this.target);let s=e;return Qe.enabled===!1||n===i||!n||!i||(Qe.getTransfer(n)===gl&&(s=zn(sP(s.rgb),s.a)),Qe.getPrimaries(n)!==Qe.getPrimaries(i)&&(s=zn(yi(Qe._getMatrix(new Mi,n,i)).mul(s.rgb),s.a)),Qe.getTransfer(i)===gl&&(s=zn(rP(s.rgb),s.a))),s}}const aP=(r,t)=>new _M(Ot(r),vg,t),vM=(r,t)=>new _M(Ot(r),t,vg);q("workingToColorSpace",aP);q("colorSpaceToWorking",vM);let lP=class extends Pa{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),n=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,n,i)}};class cP extends Bt{static get type(){return"ReferenceBaseNode"}constructor(t,e,n=null,i=null){super(),this.property=t,this.uniformType=e,this.object=n,this.count=i,this.properties=t.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=ue.OBJECT}setGroup(t){return this.group=t,this}element(t){return new lP(this,Ot(t))}setNodeType(t){const e=de(null,t);this.group!==null&&e.setGroup(this.group),this.node=e}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let n=t[e[0]];for(let i=1;i<e.length;i++)n=n[e[i]];return n}updateReference(t){return this.reference=this.object!==null?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}class hP extends cP{static get type(){return"RendererReferenceNode"}constructor(t,e,n=null){super(t,e,n),this.renderer=n,this.setGroup(te)}updateReference(t){return this.reference=this.renderer!==null?this.renderer:t.renderer,this.reference}}const uP=(r,t,e=null)=>new hP(r,t,e);class dP extends xn{static get type(){return"ToneMappingNode"}constructor(t,e=pP,n=null){super("vec3"),this._toneMapping=t,this.exposureNode=e,this.colorNode=n}customCacheKey(){return Jv(this._toneMapping)}setToneMapping(t){return this._toneMapping=t,this}getToneMapping(){return this._toneMapping}setup(t){const e=this.colorNode||t.context.color,n=this._toneMapping;if(n===Dp)return e;let i=null;const s=t.renderer.library.getToneMappingFunction(n);return s!==null?i=zn(s(e.rgb,this.exposureNode),e.a):(Ne("ToneMappingNode: Unsupported Tone Mapping configuration.",n),i=e),i}}const fP=(r,t,e)=>new dP(r,Ot(t),Ot(e)),pP=uP("toneMappingExposure","float");q("toneMapping",(r,t,e)=>fP(t,e,r));const Je=new H,Ph=new Ge;let mP=0;class sr{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:mP++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=ya,this.updateRanges=[],this.gpuType=Wv,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Ph.fromBufferAttribute(this,e),Ph.applyMatrix3(t),this.setXY(e,Ph.x,Ph.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Je.fromBufferAttribute(this,e),Je.applyMatrix3(t),this.setXYZ(e,Je.x,Je.y,Je.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Je.fromBufferAttribute(this,e),Je.applyMatrix4(t),this.setXYZ(e,Je.x,Je.y,Je.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Je.fromBufferAttribute(this,e),Je.applyNormalMatrix(t),this.setXYZ(e,Je.x,Je.y,Je.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Je.fromBufferAttribute(this,e),Je.transformDirection(t),this.setXYZ(e,Je.x,Je.y,Je.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ii(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=be(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ii(e,this.array)),e}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ii(e,this.array)),e}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ii(e,this.array)),e}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ii(e,this.array)),e}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array),i=be(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array),i=be(i,this.array),s=be(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==ya&&(t.usage=this.usage),t}}class gP extends sr{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class xP extends sr{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Hp extends sr{constructor(t,e,n){super(new Float32Array(t),e,n)}}const Pn=new H;class Mg{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Pn.fromBufferAttribute(this,e),Pn.applyMatrix4(t),this.setXYZ(e,Pn.x,Pn.y,Pn.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Pn.fromBufferAttribute(this,e),Pn.applyNormalMatrix(t),this.setXYZ(e,Pn.x,Pn.y,Pn.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Pn.fromBufferAttribute(this,e),Pn.transformDirection(t),this.setXYZ(e,Pn.x,Pn.y,Pn.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Ii(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=be(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ii(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ii(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ii(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ii(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),n=be(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),n=be(n,this.array),i=be(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=be(e,this.array),n=be(n,this.array),i=be(i,this.array),s=be(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){Bp("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new sr(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Mg(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Bp("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class MM{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=ya,this.updateRanges=[],this.version=0,this.uuid=Ps()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ps()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ps()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Xx=new WeakMap;function $x(r,t){let e=Xx.get(r);return e===void 0&&(e=new MM(r,t),Xx.set(r,e)),e}class qs extends lg{static get type(){return"BufferAttributeNode"}constructor(t,e=null,n=0,i=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferStride=n,this.bufferOffset=i,this.usage=ya,this.instanced=!1,this.attribute=null,this.global=!0,t&&t.isBufferAttribute===!0&&t.itemSize<=4&&(this.attribute=t,this.usage=t.usage,this.instanced=t.isInstancedBufferAttribute)}getHash(t){if(this.bufferStride===0&&this.bufferOffset===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getNodeType(t){return this.bufferType===null&&(this.bufferType=t.getTypeFromAttribute(this.attribute)),this.bufferType}setup(t){if(this.attribute!==null)return;const e=this.getNodeType(t),n=t.getTypeLength(e),i=this.value,s=this.bufferStride||n,o=this.bufferOffset;let a;i.isInterleavedBuffer===!0?a=i:i.isBufferAttribute===!0?a=$x(i.array,s):a=$x(i,s);const l=new Mg(a,n,o);a.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(t){const e=this.getNodeType(t),n=t.getBufferAttributeFromNode(this,e),i=t.getPropertyName(n);let s=null;return t.shaderStage==="vertex"||t.shaderStage==="compute"?(this.name=i,s=i):s=Fa(this).build(t,e),s}getInputType(){return"bufferAttribute"}setUsage(t){return this.usage=t,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=t),this}setInstanced(t){return this.instanced=t,this}}function Sg(r,t=null,e=0,n=0,i=ya,s=!1){return t==="mat3"||t===null&&r.itemSize===9?yi(new qs(r,"vec3",9,0).setUsage(i).setInstanced(s),new qs(r,"vec3",9,3).setUsage(i).setInstanced(s),new qs(r,"vec3",9,6).setUsage(i).setInstanced(s)):t==="mat4"||t===null&&r.itemSize===16?Ud(new qs(r,"vec4",16,0).setUsage(i).setInstanced(s),new qs(r,"vec4",16,4).setUsage(i).setInstanced(s),new qs(r,"vec4",16,8).setUsage(i).setInstanced(s),new qs(r,"vec4",16,12).setUsage(i).setInstanced(s)):new qs(r,t,e,n).setUsage(i)}const SM=(r,t=null,e=0,n=0)=>Sg(r,t,e,n),qx=(r,t=null,e=0,n=0)=>Sg(r,t,e,n,ya,!0),Yx=(r,t=null,e=0,n=0)=>Sg(r,t,e,n,Op,!0);q("toAttribute",r=>SM(r.value));class yP extends Bt{static get type(){return"ComputeNode"}constructor(t,e){super("void"),this.isComputeNode=!0,this.computeNode=t,this.workgroupSize=e,this.count=null,this.version=1,this.name="",this.updateBeforeType=ue.OBJECT,this.onInitFunction=null}setCount(t){return this.count=t,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(t){return this.name=t,this}label(t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.',new xi),this.setName(t)}onInit(t){return this.onInitFunction=t,this}updateBefore({renderer:t}){t.compute(this)}setup(t){const e=this.computeNode.build(t);if(e){const n=t.getNodeProperties(this);n.outputComputeNode=e.outputNode,e.outputNode=null}return e}generate(t,e){const{shaderStage:n}=t;if(n==="compute"){const i=this.computeNode.build(t,"void");i!==""&&t.addLineFlowCode(i,this)}else{const s=t.getNodeProperties(this).outputComputeNode;if(s)return s.build(t,e)}}}const bM=(r,t=[64])=>{(t.length===0||t.length>3)&&Ne("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new xi);for(let e=0;e<t.length;e++){const n=t[e];(typeof n!="number"||n<=0||!Number.isInteger(n))&&Ne(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new xi)}for(;t.length<3;)t.push(1);return new yP(Ot(r),t)},_P=(r,t,e)=>bM(r,e).setCount(t);q("compute",_P);q("computeKernel",bM);class vP extends Bt{static get type(){return"IsolateNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isIsolateNode=!0}getNodeType(t){const e=t.getCache(),n=t.getCacheFromNode(this,this.parent);t.setCache(n);const i=this.node.getNodeType(t);return t.setCache(e),i}build(t,...e){const n=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);const s=this.node.build(t,...e);return t.setCache(n),s}setParent(t){return this.parent=t,this}getParent(){return this.parent}}const TM=r=>new vP(Ot(r));function MP(r,t=!0){return ne('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),TM(r).setParent(t)}q("cache",MP);q("isolate",TM);class SP extends Bt{static get type(){return"BypassNode"}constructor(t,e){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=e}getNodeType(t){return this.outputNode.getNodeType(t)}generate(t){const e=this.callNode.build(t,"void");return e!==""&&t.addLineFlowCode(e,this),this.outputNode.build(t)}}const bP=De(SP).setParameterLength(2);q("bypass",bP);class wM extends Bt{static get type(){return"RemapNode"}constructor(t,e,n,i=kt(0),s=kt(1)){super(),this.node=t,this.inLowNode=e,this.inHighNode=n,this.outLowNode=i,this.outHighNode=s,this.doClamp=!0}setup(){const{node:t,inLowNode:e,inHighNode:n,outLowNode:i,outHighNode:s,doClamp:o}=this;let a=t.sub(e).div(n.sub(e));return o===!0&&(a=a.clamp()),a.mul(s.sub(i)).add(i)}}const TP=De(wM,null,null,{doClamp:!1}).setParameterLength(3,5),wP=De(wM).setParameterLength(3,5);q("remap",TP);q("remapClamp",wP);class AP extends Bt{static get type(){return"ExpressionNode"}constructor(t="",e="void"){super(e),this.snippet=t}generate(t,e){const n=this.getNodeType(t),i=this.snippet;if(n==="void")t.addLineFlowCode(i,this);else return t.format(i,n,e)}}const Es=De(AP).setParameterLength(1,2),EP=r=>(r?yg(r,Es("discard")):Es("discard")).toStack();q("discard",EP);class CP extends xn{static get type(){return"RenderOutputNode"}constructor(t,e,n){super("vec4"),this.colorNode=t,this._toneMapping=e,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(t){return this._toneMapping=t,this}getToneMapping(){return this._toneMapping}setup({context:t}){let e=this.colorNode||t.color;const n=(this._toneMapping!==null?this._toneMapping:t.toneMapping)||Dp,i=(this.outputColorSpace!==null?this.outputColorSpace:t.outputColorSpace)||Uu;return n!==Dp&&(e=e.toneMapping(n)),i!==Uu&&i!==Qe.workingColorSpace&&(e=e.workingToColorSpace(i)),e}}const NP=(r,t=null,e=null)=>new CP(Ot(r),t,e);q("renderOutput",NP);class RP extends xn{static get type(){return"DebugNode"}constructor(t,e=null){super(),this.node=t,this.callback=e}getNodeType(t){return this.node.getNodeType(t)}setup(t){return this.node.build(t)}analyze(t){return this.node.build(t)}generate(t){const e=this.callback,n=this.node.build(t);if(e!==null)e(t,n);else{const i="--- TSL debug - "+t.shaderStage+" shader ---",s="-".repeat(i.length);let o="";o+="// #"+i+`#
|
|
4074
4074
|
`,o+=t.flow.code.replace(/^\t/mg,"")+`
|
|
4075
4075
|
`,o+="/* ... */ "+n+` /* ... */
|
|
4076
4076
|
`,o+="// #"+s+`#
|
|
4077
|
-
`,Bp(o)}return n}}const IP=(r,t=null)=>new RP(Ot(r),t).toStack();q("debug",IP);class PP{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(t){return this._renderer=t,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class LP extends Bt{static get type(){return"InspectorNode"}constructor(t,e="",n=null){super(),this.node=t,this.name=e,this.callback=n,this.updateType=ue.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(t){t.renderer.inspector.inspect(this)}getNodeType(t){return this.node.getNodeType(t)}setup(t){let e=this.node;return t.context.inspector===!0&&this.callback!==null&&(e=this.callback(e)),t.renderer.backend.isWebGPUBackend!==!0&&t.renderer.inspector.constructor!==PP&&ya('TSL: ".toInspector()" is only available with WebGPU.'),e}}function FP(r,t="",e=null){return r=Ot(r),r.before(new LP(r,t,e))}q("toInspector",FP);class AM extends Bt{static get type(){return"AttributeNode"}constructor(t,e=null){super(e),this.global=!0,this._attributeName=t}getHash(t){return this.getAttributeName(t)}getNodeType(t){let e=this.nodeType;if(e===null){const n=this.getAttributeName(t);if(t.hasGeometryAttribute(n)){const i=t.geometry.getAttribute(n);e=t.getTypeFromAttribute(i)}else e="float"}return e}setAttributeName(t){return this._attributeName=t,this}getAttributeName(){return this._attributeName}generate(t){const e=this.getAttributeName(t),n=this.getNodeType(t);if(t.hasGeometryAttribute(e)===!0){const s=t.geometry.getAttribute(e),o=t.getTypeFromAttribute(s),a=t.getAttribute(e,o);return t.shaderStage==="vertex"?t.format(a.name,o,n):La(this).build(t,n)}else return ne(`AttributeNode: Vertex attribute "${e}" not found on geometry.`),t.generateConst(n)}serialize(t){super.serialize(t),t.global=this.global,t._attributeName=this._attributeName}deserialize(t){super.deserialize(t),this.global=t.global,this._attributeName=t._attributeName}}const va=(r,t=null)=>new AM(r,t);class Tg extends Ac{static get type(){return"BufferNode"}constructor(t,e,n=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(t){return this.getNodeType(t)}getInputType(){return"buffer"}}const EM=(r,t,e)=>new Tg(r,t,e);class DP extends Ia{static get type(){return"UniformArrayElementNode"}constructor(t,e){super(t,e),this.isArrayBufferElementNode=!0}generate(t){const e=super.generate(t),n=this.getNodeType(),i=this.node.getPaddedType();return t.format(e,i,n)}}class UP extends Tg{static get type(){return"UniformArrayNode"}constructor(t,e=null){super(null),this.array=t,this.elementType=e===null?Bu(t[0]):e,this.paddedType=this.getPaddedType(),this.updateType=ue.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const t=this.elementType;let e="vec4";return t==="mat2"?e="mat2":/mat/.test(t)===!0?e="mat4":t.charAt(0)==="i"?e="ivec4":t.charAt(0)==="u"&&(e="uvec4"),e}update(){const{array:t,value:e}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let i=0;i<t.length;i++){const s=i*4;e[s]=t[i]}else if(n==="color")for(let i=0;i<t.length;i++){const s=i*4,o=t[i];e[s]=o.r,e[s+1]=o.g,e[s+2]=o.b||0}else if(n==="mat2")for(let i=0;i<t.length;i++){const s=i*4,o=t[i];e[s]=o.elements[0],e[s+1]=o.elements[1],e[s+2]=o.elements[2],e[s+3]=o.elements[3]}else if(n==="mat3")for(let i=0;i<t.length;i++){const s=i*16,o=t[i];e[s]=o.elements[0],e[s+1]=o.elements[1],e[s+2]=o.elements[2],e[s+4]=o.elements[3],e[s+5]=o.elements[4],e[s+6]=o.elements[5],e[s+8]=o.elements[6],e[s+9]=o.elements[7],e[s+10]=o.elements[8],e[s+15]=1}else if(n==="mat4")for(let i=0;i<t.length;i++){const s=i*16,o=t[i];for(let a=0;a<o.elements.length;a++)e[s+a]=o.elements[a]}else for(let i=0;i<t.length;i++){const s=i*4,o=t[i];e[s]=o.x,e[s+1]=o.y,e[s+2]=o.z||0,e[s+3]=o.w||0}}setup(t){const e=this.array.length,n=this.elementType;let i=Float32Array;const s=this.paddedType,o=t.getTypeLength(s);return n.charAt(0)==="i"&&(i=Int32Array),n.charAt(0)==="u"&&(i=Uint32Array),this.value=new i(e*o),this.bufferCount=e,this.bufferType=s,this.update(),super.setup(t)}element(t){return new DP(this,Ot(t))}}const Qi=(r,t)=>new UP(r,t);class OP extends Bt{constructor(t){super("float"),this.name=t,this.isBuiltinNode=!0}generate(){return this.name}}const Bd=De(OP).setParameterLength(1);let Ja,ja;class Ue extends Bt{static get type(){return"ScreenNode"}constructor(t){super(),this.scope=t,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Ue.DPR?"float":this.scope===Ue.VIEWPORT?"vec4":"vec2"}getUpdateType(){let t=ue.NONE;return(this.scope===Ue.SIZE||this.scope===Ue.VIEWPORT||this.scope===Ue.DPR)&&(t=ue.RENDER),this.updateType=t,t}update({renderer:t}){const e=t.getRenderTarget();this.scope===Ue.VIEWPORT?e!==null?ja.copy(e.viewport):(t.getViewport(ja),ja.multiplyScalar(t.getPixelRatio())):this.scope===Ue.DPR?this._output.value=t.getPixelRatio():e!==null?(Ja.width=e.width,Ja.height=e.height):t.getDrawingBufferSize(Ja)}setup(){const t=this.scope;let e=null;return t===Ue.SIZE?e=de(Ja||(Ja=new Ge)):t===Ue.VIEWPORT?e=de(ja||(ja=new Nn)):t===Ue.DPR?e=de(1):e=xe(Fa.div(Jx)),this._output=e,e}generate(t){if(this.scope===Ue.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){const n=t.getNodeProperties(Jx).outputNode.build(t);e=`${t.getType("vec2")}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}}Ue.COORDINATE="coordinate";Ue.VIEWPORT="viewport";Ue.SIZE="size";Ue.UV="uv";Ue.DPR="dpr";const wg=Ke(Ue,Ue.UV),Jx=Ke(Ue,Ue.SIZE),Fa=Ke(Ue,Ue.COORDINATE),CM=Ke(Ue,Ue.VIEWPORT);CM.zw;CM.xy;let Xf=null,Lh=null,$f=null,Fh=null,qf=null,Dh=null;const Ag=de(0,"uint").setName("u_cameraIndex").setGroup(aM("cameraIndex")).toVarying("v_cameraIndex"),Or=de("float").setName("cameraNear").setGroup(te).onRenderUpdate(({camera:r})=>r.near),Br=de("float").setName("cameraFar").setGroup(te).onRenderUpdate(({camera:r})=>r.far),BP=Mt(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const n of r.cameras)e.push(n.projectionMatrix);Lh===null?Lh=Qi(e).setGroup(te).setName("cameraProjectionMatrices"):Lh.array=e,t=Lh.element(r.isMultiViewCamera?Bd("gl_ViewID_OVR"):Ag).toConst("cameraProjectionMatrix")}else Xf===null&&(Xf=de(r.projectionMatrix).setName("cameraProjectionMatrix").setGroup(te).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=Xf;return t}).once()(),zP=Mt(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const n of r.cameras)e.push(n.projectionMatrixInverse);Fh===null?Fh=Qi(e).setGroup(te).setName("cameraProjectionMatricesInverse"):Fh.array=e,t=Fh.element(r.isMultiViewCamera?Bd("gl_ViewID_OVR"):Ag).toConst("cameraProjectionMatrixInverse")}else $f===null&&($f=de(r.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(te).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=$f;return t}).once()(),Da=Mt(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const n of r.cameras)e.push(n.matrixWorldInverse);Dh===null?Dh=Qi(e).setGroup(te).setName("cameraViewMatrices"):Dh.array=e,t=Dh.element(r.isMultiViewCamera?Bd("gl_ViewID_OVR"):Ag).toConst("cameraViewMatrix")}else qf===null&&(qf=de(r.matrixWorldInverse).setName("cameraViewMatrix").setGroup(te).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=qf;return t}).once()();class Ic{constructor(t=new H(1/0,1/0,1/0),e=new H(-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,n=t.length;e<n;e+=3)this.expandByPoint(Ei.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Ei.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Ei.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Ei):Ei.fromBufferAttribute(s,o),Ei.applyMatrix4(t.matrixWorld),this.expandByPoint(Ei);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Uh.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Uh.copy(n.boundingBox)),Uh.applyMatrix4(t.matrixWorld),this.union(Uh)}const i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.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.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Ei),Ei.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ka),Oh.subVectors(this.max,Ka),Do.subVectors(t.a,Ka),Uo.subVectors(t.b,Ka),Oo.subVectors(t.c,Ka),Ys.subVectors(Uo,Do),Zs.subVectors(Oo,Uo),Ir.subVectors(Do,Oo);let e=[0,-Ys.z,Ys.y,0,-Zs.z,Zs.y,0,-Ir.z,Ir.y,Ys.z,0,-Ys.x,Zs.z,0,-Zs.x,Ir.z,0,-Ir.x,-Ys.y,Ys.x,0,-Zs.y,Zs.x,0,-Ir.y,Ir.x,0];return!Yf(e,Do,Uo,Oo,Oh)||(e=[1,0,0,0,1,0,0,0,1],!Yf(e,Do,Uo,Oo,Oh))?!1:(Bh.crossVectors(Ys,Zs),e=[Bh.x,Bh.y,Bh.z],Yf(e,Do,Uo,Oo,Oh))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ei).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ei).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:(_s[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),_s[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),_s[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),_s[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),_s[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),_s[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),_s[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),_s[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(_s),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const _s=[new H,new H,new H,new H,new H,new H,new H,new H],Ei=new H,Uh=new Ic,Do=new H,Uo=new H,Oo=new H,Ys=new H,Zs=new H,Ir=new H,Ka=new H,Oh=new H,Bh=new H,Pr=new H;function Yf(r,t,e,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Pr.fromArray(r,s);const a=i.x*Math.abs(Pr.x)+i.y*Math.abs(Pr.y)+i.z*Math.abs(Pr.z),l=t.dot(Pr),c=e.dot(Pr),h=n.dot(Pr);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const VP=new Ic,Qa=new H,Zf=new H;class zd{constructor(t=new H,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 n=this.center;e!==void 0?n.copy(e):VP.setFromPoints(t).getCenter(n);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.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;Qa.subVectors(t,this.center);const e=Qa.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Qa,i/n),this.radius+=i}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):(Zf.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Qa.copy(t.center).add(Zf)),this.expandByPoint(Qa.copy(t.center).sub(Zf))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const jx=new zd;class Pe extends Bt{static get type(){return"Object3DNode"}constructor(t,e=null){super(),this.scope=t,this.object3d=e,this.updateType=ue.OBJECT,this.uniformNode=new Ac(null)}getNodeType(){const t=this.scope;if(t===Pe.WORLD_MATRIX)return"mat4";if(t===Pe.POSITION||t===Pe.VIEW_POSITION||t===Pe.DIRECTION||t===Pe.SCALE)return"vec3";if(t===Pe.RADIUS)return"float"}update(t){const e=this.object3d,n=this.uniformNode,i=this.scope;if(i===Pe.WORLD_MATRIX)n.value=e.matrixWorld;else if(i===Pe.POSITION)n.value=n.value||new H,n.value.setFromMatrixPosition(e.matrixWorld);else if(i===Pe.SCALE)n.value=n.value||new H,n.value.setFromMatrixScale(e.matrixWorld);else if(i===Pe.DIRECTION)n.value=n.value||new H,e.getWorldDirection(n.value);else if(i===Pe.VIEW_POSITION){const s=t.camera;n.value=n.value||new H,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}else if(i===Pe.RADIUS){const s=t.object.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),jx.copy(s.boundingSphere).applyMatrix4(e.matrixWorld),n.value=jx.radius}}generate(t){const e=this.scope;return e===Pe.WORLD_MATRIX?this.uniformNode.nodeType="mat4":e===Pe.POSITION||e===Pe.VIEW_POSITION||e===Pe.DIRECTION||e===Pe.SCALE?this.uniformNode.nodeType="vec3":e===Pe.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(t)}serialize(t){super.serialize(t),t.scope=this.scope}deserialize(t){super.deserialize(t),this.scope=t.scope}}Pe.WORLD_MATRIX="worldMatrix";Pe.POSITION="position";Pe.SCALE="scale";Pe.VIEW_POSITION="viewPosition";Pe.DIRECTION="direction";Pe.RADIUS="radius";class Kx extends Pe{static get type(){return"ModelNode"}constructor(t){super(t)}update(t){this.object3d=t.object,super.update(t)}}const Eg=Ke(Kx,Kx.WORLD_MATRIX),kP=de(new Mi).onObjectUpdate(({object:r},t)=>t.value.getNormalMatrix(r.matrixWorld)),NM=Mt(r=>r.context.modelViewMatrix||GP).once()().toVar("modelViewMatrix_2"),GP=Da.mul(Eg),HP=Mt(r=>r.shaderStage!=="fragment"?(ya("TSL: `clipSpace` is only available in fragment stage."),zn()):r.context.clipSpace.toVarying("v_clipSpace")).once()(),RM=va("position","vec3"),Xn=RM.toVarying("positionLocal"),ku=RM.toVarying("positionPrevious"),Cg=Mt(r=>Eg.mul(Xn).xyz.toVarying(r.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),hn=Mt(r=>{if(r.shaderStage==="fragment"&&r.material.vertexNode){const t=zP.mul(HP);return t.xyz.div(t.w).toVar("positionView")}return r.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),IM=Mt(r=>{let t;return r.camera.isOrthographicCamera?t=Pt(0,0,1):t=hn.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class WP extends Bt{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(t){if(t.shaderStage!=="fragment")return"true";const{material:e}=t;return e.side===tg?"false":t.getFrontFacing()}}const XP=Ke(WP),PM=kt(XP).mul(2).sub(1),Vd=Mt(([r],{material:t})=>{const e=t.side;return e===tg?r=r.mul(-1):e===pN&&(r=r.mul(PM)),r}),$P=va("normal","vec3"),ls=Mt(r=>r.geometry.hasAttribute("normal")===!1?(ne('TSL: Vertex attribute "normal" not found on geometry.'),Pt(0,1,0)):$P,"vec3").once()().toVar("normalLocal"),qP=hn.dFdx().cross(hn.dFdy()).normalize().toVar("normalFlat"),YP=Mt(r=>{let t;return r.isFlatShading()?t=qP:t=LM(ls).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),_i=Mt(r=>{let t;return r.subBuildFn==="NORMAL"||r.subBuildFn==="VERTEX"?(t=YP,r.isFlatShading()!==!0&&(t=Vd(t))):t=r.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),kd=_i.transformDirection(Da).toVar("normalWorld"),ZP=Mt(({subBuildFn:r,context:t})=>{let e;return r==="NORMAL"||r==="VERTEX"?e=_i:e=t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),JP=Mt(([r,t=Eg])=>{const e=yi(t),n=r.div(Pt(e[0].dot(e[0]),e[1].dot(e[1]),e[2].dot(e[2])));return e.mul(n).xyz}),LM=Mt(([r],t)=>{const e=t.context.modelNormalViewMatrix;if(e)return e.transformDirection(r);const n=kP.mul(r);return Da.transformDirection(n)});Mt(()=>(ne('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),_i)).once(["NORMAL","VERTEX"])();Mt(()=>(ne('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),kd)).once(["NORMAL","VERTEX"])();Mt(()=>(ne('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),ZP)).once(["NORMAL","VERTEX"])();class jP{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(t,e){let n=t.get(e);return n===void 0&&(n={renderId:0,frameId:0},t.set(e,n)),n}updateBeforeNode(t){const e=t.getUpdateBeforeType(),n=t.updateReference(this);if(e===ue.FRAME){const i=this._getMaps(this.updateBeforeMap,n);if(i.frameId!==this.frameId){const s=i.frameId;i.frameId=this.frameId,t.updateBefore(this)===!1&&(i.frameId=s)}}else if(e===ue.RENDER){const i=this._getMaps(this.updateBeforeMap,n);if(i.renderId!==this.renderId){const s=i.renderId;i.renderId=this.renderId,t.updateBefore(this)===!1&&(i.renderId=s)}}else e===ue.OBJECT&&t.updateBefore(this)}updateAfterNode(t){const e=t.getUpdateAfterType(),n=t.updateReference(this);if(e===ue.FRAME){const i=this._getMaps(this.updateAfterMap,n);i.frameId!==this.frameId&&t.updateAfter(this)!==!1&&(i.frameId=this.frameId)}else if(e===ue.RENDER){const i=this._getMaps(this.updateAfterMap,n);i.renderId!==this.renderId&&t.updateAfter(this)!==!1&&(i.renderId=this.renderId)}else e===ue.OBJECT&&t.updateAfter(this)}updateNode(t){const e=t.getUpdateType(),n=t.updateReference(this);if(e===ue.FRAME){const i=this._getMaps(this.updateMap,n);i.frameId!==this.frameId&&t.update(this)!==!1&&(i.frameId=this.frameId)}else if(e===ue.RENDER){const i=this._getMaps(this.updateMap,n);i.renderId!==this.renderId&&t.update(this)!==!1&&(i.renderId=this.renderId)}else e===ue.OBJECT&&t.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}let KP=0;class Wp extends Ra{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:KP++}),this.uuid=Ps(),this.name="",this.type="Material",this.blending=Sx,this.side=Fp,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Tx,this.blendDst=wx,this.blendEquation=bx,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vi(0,0,0),this.blendAlpha=0,this.depthFunc=Ax,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ix,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lo,this.stencilZFail=Lo,this.stencilZPass=Lo,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){ne(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){ne(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Sx&&(n.blending=this.blending),this.side!==Fp&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Tx&&(n.blendSrc=this.blendSrc),this.blendDst!==wx&&(n.blendDst=this.blendDst),this.blendEquation!==bx&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ax&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ix&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Lo&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Lo&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Lo&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}const Gd=(r=0)=>va("uv"+(r>0?r:""),"vec2");class QP extends Bt{static get type(){return"TextureSizeNode"}constructor(t,e=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=t,this.levelNode=e}generate(t,e){const n=this.textureNode.build(t,"property"),i=this.levelNode===null?"0":this.levelNode.build(t,"int");return t.format(`${t.getMethod("textureDimensions")}( ${n}, ${i} )`,this.getNodeType(t),e)}}const ra=De(QP).setParameterLength(1,2);class t2 extends Ac{static get type(){return"MaxMipLevelNode"}constructor(t){super(0),this._textureNode=t,this.updateType=ue.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const t=this.texture,e=t.images,n=e&&e.length>0?e[0]&&e[0].image||e[0]:t.image;if(n&&n.width!==void 0){const{width:i,height:s}=n;this.value=Math.log2(Math.max(i,s))}}}const e2=De(t2).setParameterLength(1);let Bo;class n2{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Bo===void 0&&(Bo=Lx("canvas")),Bo.width=t.width,Bo.height=t.height;const i=Bo.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=Bo}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Lx("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Ls(s[o]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Ls(e[n]/255)*255):e[n]=Ls(e[n]);return{data:e,width:t.width,height:t.height}}else return ne("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let i2=0;class Ng{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:i2++}),this.uuid=Ps(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Jf(i[o].image)):s.push(Jf(i[o]))}else s=Jf(i);n.url=s}return e||(t.images[this.uuid]=n),n}}function Jf(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?n2.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(ne("Texture: Unable to serialize Texture."),{})}let s2=0;const jf=new H;class ni extends Ra{constructor(t=ni.DEFAULT_IMAGE,e=ni.DEFAULT_MAPPING,n=ll,i=ll,s=rc,o=Gv,a=wN,l=Hv,c=ni.DEFAULT_ANISOTROPY,h=Uu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:s2++}),this.uuid=Ps(),this.name="",this.source=new Ng(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ge(0,0),this.repeat=new Ge(1,1),this.center=new Ge(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Mi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(jf).x}get height(){return this.source.getSize(jf).y}get depth(){return this.source.getSize(jf).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){ne(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){ne(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==kv)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ex:t.x=t.x-Math.floor(t.x);break;case ll:t.x=t.x<0?0:1;break;case Cx: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 Ex:t.y=t.y-Math.floor(t.y);break;case ll:t.y=t.y<0?0:1;break;case Cx: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)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ni.DEFAULT_IMAGE=null;ni.DEFAULT_MAPPING=kv;ni.DEFAULT_ANISOTROPY=4;class r2 extends Error{constructor(t,e=null){super(t),this.name="NodeError",this.stackTrace=e}}const FM=new ni;class Hd extends Ac{static get type(){return"TextureNode"}constructor(t=FM,e=null,n=null,i=null){super(t),this.isTextureNode=!0,this.uvNode=e,this.levelNode=n,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ue.NONE,this.referenceNode=null,this._value=t,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(e===null)}set value(t){this.referenceNode?this.referenceNode.value=t:this._value=t}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===ng?"uvec4":this.value.type===TN?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Gd(this.value.channel)}updateReference(){return this.value}getTransformedUV(t){return this._matrixUniform===null&&(this._matrixUniform=de(this.value.matrix)),this._matrixUniform.mul(Pt(t,1)).xy}setUpdateMatrix(t){return this.updateMatrix=t,this}setupUV(t,e){return t.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=de(!1)),e=e.toVar(),this.sampler?e=this._flipYUniform.select(e.flipY(),e):e=this._flipYUniform.select(e.setY(Be(ra(this,this.levelNode).y).sub(e.y).sub(1)),e)),e}setup(t){const e=t.getNodeProperties(this);e.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new r2("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const i=Mt(()=>{let l=this.uvNode;return(l===null||t.context.forceUVContext===!0)&&t.context.getUV&&(l=t.context.getUV(this,t)),l||(l=this.getDefaultUV()),this.updateMatrix===!0&&(l=this.getTransformedUV(l)),l=this.setupUV(t,l),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?ue.OBJECT:ue.NONE,l})();let s=this.levelNode;s===null&&t.context.getTextureLevel&&(s=t.context.getTextureLevel(this));let o=null,a=null;if(this.compareNode!==null)if(t.renderer.hasCompatibility($v.TEXTURE_COMPARE))o=this.compareNode;else{const l=n.compareFunction;l===null||l===IN||l===ig||l===Px||l===Ou?a=this.compareNode:(o=this.compareNode,ya('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}e.uvNode=i,e.levelNode=s,e.biasNode=this.biasNode,e.compareNode=o,e.compareStepNode=a,e.gradNode=this.gradNode,e.depthNode=this.depthNode,e.offsetNode=this.offsetNode}generateUV(t,e){return e.build(t,this.sampler===!0?"vec2":"ivec2")}generateOffset(t,e){return e.build(t,"ivec2")}generateSnippet(t,e,n,i,s,o,a,l,c){const h=this.value;let u;return s?u=t.generateTextureBias(h,e,n,s,o,c):l?u=t.generateTextureGrad(h,e,n,l,o,c):a?u=t.generateTextureCompare(h,e,n,a,o,c):this.sampler===!1?u=t.generateTextureLoad(h,e,n,i,o,c):i?u=t.generateTextureLevel(h,e,n,i,o,c):u=t.generateTexture(h,e,n,o,c),u}generate(t,e){const n=this.value,i=t.getNodeProperties(this),s=super.generate(t,"property");if(/^sampler/.test(e))return s+"_sampler";if(t.isReference(e))return s;{const o=t.getDataFromNode(this),a=this.getNodeType(t);let l=o.propertyName;if(l===void 0){const{uvNode:h,levelNode:u,biasNode:d,compareNode:f,compareStepNode:p,depthNode:x,gradNode:g,offsetNode:m}=i,y=this.generateUV(t,h),v=u?u.build(t,"float"):null,_=d?d.build(t,"float"):null,w=x?x.build(t,"int"):null,T=f?f.build(t,"float"):null,E=p?p.build(t,"float"):null,M=g?[g[0].build(t,"vec2"),g[1].build(t,"vec2")]:null,b=m?this.generateOffset(t,m):null,P=t.getVarFromNode(this);l=t.getPropertyName(P);let N=this.generateSnippet(t,s,y,v,_,w,T,M,b);if(E!==null){const L=n.compareFunction;L===Px||L===Ou?N=cc(Es(N,a),Es(E,"float")).build(t,a):N=cc(Es(E,"float"),Es(N,a)).build(t,a)}t.addLineFlowCode(`${l} = ${N}`,this),o.snippet=N,o.propertyName=l}let c=l;return t.needsToWorkingColorSpace(n)&&(c=vM(Es(c,a),n.colorSpace).setup(t).build(t,a)),t.format(c,a,e)}}setSampler(t){return this.sampler=t,this}getSampler(){return this.sampler}sample(t){const e=this.clone();return e.uvNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}load(t){return this.sample(t).setSampler(!1)}blur(t){const e=this.clone();e.biasNode=Ot(t).mul(e2(e)),e.referenceNode=this.getBase();const n=e.value;return e.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===gi||n.magFilter===gi)&&(ne("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),e.biasNode=null),Ot(e)}level(t){const e=this.clone();return e.levelNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}size(t){return ra(this,t)}bias(t){const e=this.clone();return e.biasNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(t){const e=this.clone();return e.compareNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}grad(t,e){const n=this.clone();return n.gradNode=[Ot(t),Ot(e)],n.referenceNode=this.getBase(),Ot(n)}depth(t){const e=this.clone();return e.depthNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}offset(t){const e=this.clone();return e.offsetNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}serialize(t){super.serialize(t),t.value=this.value.toJSON(t.meta).uuid,t.sampler=this.sampler,t.updateMatrix=this.updateMatrix,t.updateType=this.updateType}deserialize(t){super.deserialize(t),this.value=t.meta.textures[t.value],this.sampler=t.sampler,this.updateMatrix=t.updateMatrix,this.updateType=t.updateType}update(){const t=this.value,e=this._matrixUniform;e!==null&&(e.value=t.matrix),t.matrixAutoUpdate===!0&&t.updateMatrix();const n=this._flipYUniform;n!==null&&(n.value=t.image instanceof ImageBitmap&&t.flipY===!0||t.isRenderTargetTexture===!0||t.isFramebufferTexture===!0||t.isDepthTexture===!0)}clone(){const t=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return t.sampler=this.sampler,t.depthNode=this.depthNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.offsetNode=this.offsetNode,t}}const o2=De(Hd).setParameterLength(1,4).setName("texture"),pn=(r=FM,t=null,e=null,n=null)=>{let i;return r&&r.isTextureNode===!0?(i=Ot(r.clone()),i.referenceNode=r.getBase(),t!==null&&(i.uvNode=Ot(t)),e!==null&&(i.levelNode=Ot(e)),n!==null&&(i.biasNode=Ot(n))):i=o2(r,t,e,n),i},li=(...r)=>pn(...r).setSampler(!1),Qx=new ke,ty=new Na;class Ua{constructor(t=0,e=0,n=0,i=Ua.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,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,n=!0){const i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(pe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-pe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(pe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-pe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(pe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-pe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:ne("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Qx.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Qx,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ty.setFromEuler(this),this.setFromQuaternion(ty,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}}Ua.DEFAULT_ORDER="XYZ";const ey=new Ua,Kf=new ke,a2=de(0).onReference(({material:r})=>r).onObjectUpdate(({material:r})=>r.refractionRatio),l2=de(new ke).onReference(function(r){return r.material}).onObjectUpdate(function({material:r,scene:t}){const e=t.environment!==null&&r.envMap===null?t.environmentRotation:r.envMapRotation;return e?(ey.copy(e),Kf.makeRotationFromEuler(ey)):Kf.identity(),Kf}),c2=IM.negate().reflect(_i),h2=IM.negate().refract(_i,a2),u2=c2.transformDirection(Da).toVar("reflectVector"),d2=h2.transformDirection(Da).toVar("reflectVector");class f2 extends ni{constructor(t=[],e=eg,n,i,s,o,a,l,c,h){super(t,e,n,i,s,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}const p2=new f2;class m2 extends Hd{static get type(){return"CubeTextureNode"}constructor(t,e=null,n=null,i=null){super(t,e,n,i),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const t=this.value;return t.mapping===eg?u2:t.mapping===bN?d2:(Ne('CubeTextureNode: Mapping "%s" not supported.',t.mapping),Pt(0,0,0))}setUpdateMatrix(){}setupUV(t,e){const n=this.value;return n.isDepthTexture===!0?t.renderer.coordinateSystem===hr?Pt(e.x,e.y.negate(),e.z):e:((t.renderer.coordinateSystem===hr||!n.isRenderTargetTexture)&&(e=Pt(e.x.negate(),e.yz)),l2.mul(e))}generateUV(t,e){return e.build(t,this.sampler===!0?"vec3":"ivec3")}}const g2=De(m2).setParameterLength(1,4).setName("cubeTexture"),ts=(r=p2,t=null,e=null,n=null)=>{let i;return r&&r.isCubeTextureNode===!0?(i=Ot(r.clone()),i.referenceNode=r,t!==null&&(i.uvNode=Ot(t)),e!==null&&(i.levelNode=Ot(e)),n!==null&&(i.biasNode=Ot(n))):i=g2(r,t,e,n),i};class x2 extends Ia{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),n=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,n,i)}}class Rg extends Bt{static get type(){return"ReferenceNode"}constructor(t,e,n=null,i=null){super(),this.property=t,this.uniformType=e,this.object=n,this.count=i,this.properties=t.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=ue.OBJECT}element(t){return new x2(this,Ot(t))}setGroup(t){return this.group=t,this}setName(t){return this.name=t,this}label(t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(t)}setNodeType(t){let e=null;this.count!==null?e=EM(null,t,this.count):Array.isArray(this.getValueFromReference())?e=Qi(null,t):t==="texture"?e=pn(null):t==="cubeTexture"?e=ts(null):e=de(null,t),this.group!==null&&e.setGroup(this.group),this.name!==null&&e.setName(this.name),this.node=e}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let n=t[e[0]];for(let i=1;i<e.length;i++)n=n[e[i]];return n}updateReference(t){return this.reference=this.object!==null?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}const tn=(r,t,e)=>new Rg(r,t,e),ny=(r,t,e,n)=>new Rg(r,t,n,e);class y2 extends Rg{static get type(){return"MaterialReferenceNode"}constructor(t,e,n=null){super(t,e,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(t){return this.reference=this.material!==null?this.material:t.material,this.reference}}const qo=(r,t,e=null)=>new y2(r,t,e),DM=Gd(),_2=hn.dFdx(),v2=hn.dFdy(),UM=DM.dFdx(),OM=DM.dFdy(),BM=_i,zM=v2.cross(BM),VM=BM.cross(_2),Xp=zM.mul(UM.x).add(VM.mul(OM.x)),$p=zM.mul(UM.y).add(VM.mul(OM.y)),iy=Xp.dot(Xp).max($p.dot($p)),kM=iy.equal(0).select(0,iy.inverseSqrt()),M2=Xp.mul(kM).toVar("tangentViewFrame"),S2=$p.mul(kM).toVar("bitangentViewFrame"),GM=va("tangent","vec4"),Gu=GM.xyz.toVar("tangentLocal"),HM=Mt(r=>{let t;return r.subBuildFn==="VERTEX"||r.geometry.hasAttribute("tangent")?t=NM.mul(zn(Gu,0)).xyz.toVarying("v_tangentView").normalize():t=M2,r.isFlatShading()!==!0&&(t=Vd(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),b2=Mt(([r,t],e)=>{let n=r.mul(GM.w).xyz;return e.subBuildFn==="NORMAL"&&e.isFlatShading()!==!0&&(n=n.toVarying(t)),n}).once(["NORMAL"]),T2=Mt(r=>{let t;return r.subBuildFn==="VERTEX"||r.geometry.hasAttribute("tangent")?t=b2(_i.cross(HM),"v_bitangentView").normalize():t=S2,r.isFlatShading()!==!0&&(t=Vd(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),w2=yi(HM,T2,_i).toVar("TBNViewMatrix"),sy=r=>Pt(r,Cc(yg(kt(1).sub(Rc(r,r)))));class A2 extends xn{static get type(){return"NormalMapNode"}constructor(t,e=null){super("vec3"),this.node=t,this.scaleNode=e,this.normalMapType=zf,this.unpackNormalMode=Vf}setup(t){const{normalMapType:e,scaleNode:n,unpackNormalMode:i}=this;let s=this.node.mul(2).sub(1);if(e===zf?i===Xv?s=sy(s.xy):i===RN?s=sy(s.yw):i!==Vf&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${i}`):i!==Vf&&console.error(`THREE.NodeMaterial: Normal map type '${e}' is not compatible with unpack normal mode '${i}'`),n!==null){let a=n;t.isFlatShading()===!0&&(a=Vd(a)),s=Pt(s.xy.mul(a),s.z)}let o=null;return e===NN?o=LM(s):e===zf?o=w2.mul(s).normalize():(Ne(`NodeMaterial: Unsupported normal map type: ${e}`),o=_i),o}}const ry=De(A2).setParameterLength(1,2),E2=Mt(({textureNode:r,bumpScale:t})=>{const e=i=>r.isolate().context({getUV:s=>i(s.uvNode||Gd()),forceUVContext:!0}),n=kt(e(i=>i));return xe(kt(e(i=>i.add(i.dFdx()))).sub(n),kt(e(i=>i.add(i.dFdy()))).sub(n)).mul(t)}),C2=Mt(r=>{const{surf_pos:t,surf_norm:e,dHdxy:n}=r,i=t.dFdx().normalize(),s=t.dFdy().normalize(),o=e,a=s.cross(o),l=o.cross(i),c=i.dot(a).mul(PM),h=c.sign().mul(n.x.mul(a).add(n.y.mul(l)));return c.abs().mul(e).sub(h).normalize()});class N2 extends xn{static get type(){return"BumpMapNode"}constructor(t,e=null){super("vec3"),this.textureNode=t,this.scaleNode=e}setup(){const t=this.scaleNode!==null?this.scaleNode:1,e=E2({textureNode:this.textureNode,bumpScale:t});return C2({surf_pos:hn,surf_norm:_i,dHdxy:e})}}const R2=De(N2).setParameterLength(1,2),oy=new Map;class vt extends Bt{static get type(){return"MaterialNode"}constructor(t){super(),this.scope=t}getCache(t,e){let n=oy.get(t);return n===void 0&&(n=qo(t,e),oy.set(t,n)),n}getFloat(t){return this.getCache(t,"float")}getColor(t){return this.getCache(t,"color")}getTexture(t){return this.getCache(t==="map"?"map":t+"Map","texture")}setup(t){const e=t.context.material,n=this.scope;let i=null;if(n===vt.COLOR){const s=e.color!==void 0?this.getColor(n):Pt();e.map&&e.map.isTexture===!0?i=s.mul(this.getTexture("map")):i=s}else if(n===vt.OPACITY){const s=this.getFloat(n);e.alphaMap&&e.alphaMap.isTexture===!0?i=s.mul(this.getTexture("alpha")):i=s}else if(n===vt.SPECULAR_STRENGTH)e.specularMap&&e.specularMap.isTexture===!0?i=this.getTexture("specular").r:i=kt(1);else if(n===vt.SPECULAR_INTENSITY){const s=this.getFloat(n);e.specularIntensityMap&&e.specularIntensityMap.isTexture===!0?i=s.mul(this.getTexture(n).a):i=s}else if(n===vt.SPECULAR_COLOR){const s=this.getColor(n);e.specularColorMap&&e.specularColorMap.isTexture===!0?i=s.mul(this.getTexture(n).rgb):i=s}else if(n===vt.ROUGHNESS){const s=this.getFloat(n);e.roughnessMap&&e.roughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).g):i=s}else if(n===vt.METALNESS){const s=this.getFloat(n);e.metalnessMap&&e.metalnessMap.isTexture===!0?i=s.mul(this.getTexture(n).b):i=s}else if(n===vt.EMISSIVE){const s=this.getFloat("emissiveIntensity"),o=this.getColor(n).mul(s);e.emissiveMap&&e.emissiveMap.isTexture===!0?i=o.mul(this.getTexture(n)):i=o}else if(n===vt.NORMAL)e.normalMap?(i=ry(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=e.normalMapType,(e.normalMap.format==hl||e.normalMap.format==CN||e.normalMap.format==EN)&&(i.unpackNormalMode=Xv)):e.bumpMap?i=R2(this.getTexture("bump").r,this.getFloat("bumpScale")):i=_i;else if(n===vt.CLEARCOAT){const s=this.getFloat(n);e.clearcoatMap&&e.clearcoatMap.isTexture===!0?i=s.mul(this.getTexture(n).r):i=s}else if(n===vt.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);e.clearcoatRoughnessMap&&e.clearcoatRoughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).r):i=s}else if(n===vt.CLEARCOAT_NORMAL)e.clearcoatNormalMap?i=ry(this.getTexture(n),this.getCache(n+"Scale","vec2")):i=_i;else if(n===vt.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));e.sheenColorMap&&e.sheenColorMap.isTexture===!0?i=s.mul(this.getTexture("sheenColor").rgb):i=s}else if(n===vt.SHEEN_ROUGHNESS){const s=this.getFloat(n);e.sheenRoughnessMap&&e.sheenRoughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).a):i=s,i=i.clamp(1e-4,1)}else if(n===vt.ANISOTROPY)if(e.anisotropyMap&&e.anisotropyMap.isTexture===!0){const s=this.getTexture(n);i=rM(tl.x,tl.y,tl.y.negate(),tl.x).mul(s.rg.mul(2).sub(xe(1)).normalize().mul(s.b))}else i=tl;else if(n===vt.IRIDESCENCE_THICKNESS){const s=tn("1","float",e.iridescenceThicknessRange);if(e.iridescenceThicknessMap){const o=tn("0","float",e.iridescenceThicknessRange);i=s.sub(o).mul(this.getTexture(n).g).add(o)}else i=s}else if(n===vt.TRANSMISSION){const s=this.getFloat(n);e.transmissionMap?i=s.mul(this.getTexture(n).r):i=s}else if(n===vt.THICKNESS){const s=this.getFloat(n);e.thicknessMap?i=s.mul(this.getTexture(n).g):i=s}else if(n===vt.IOR)i=this.getFloat(n);else if(n===vt.LIGHT_MAP)i=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===vt.AO)i=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===vt.LINE_DASH_OFFSET)i=e.dashOffset?this.getFloat(n):kt(0);else{const s=this.getNodeType(t);i=this.getCache(n,s)}return i}}vt.ALPHA_TEST="alphaTest";vt.COLOR="color";vt.OPACITY="opacity";vt.SHININESS="shininess";vt.SPECULAR="specular";vt.SPECULAR_STRENGTH="specularStrength";vt.SPECULAR_INTENSITY="specularIntensity";vt.SPECULAR_COLOR="specularColor";vt.REFLECTIVITY="reflectivity";vt.ROUGHNESS="roughness";vt.METALNESS="metalness";vt.NORMAL="normal";vt.CLEARCOAT="clearcoat";vt.CLEARCOAT_ROUGHNESS="clearcoatRoughness";vt.CLEARCOAT_NORMAL="clearcoatNormal";vt.EMISSIVE="emissive";vt.ROTATION="rotation";vt.SHEEN="sheen";vt.SHEEN_ROUGHNESS="sheenRoughness";vt.ANISOTROPY="anisotropy";vt.IRIDESCENCE="iridescence";vt.IRIDESCENCE_IOR="iridescenceIOR";vt.IRIDESCENCE_THICKNESS="iridescenceThickness";vt.IOR="ior";vt.TRANSMISSION="transmission";vt.THICKNESS="thickness";vt.ATTENUATION_DISTANCE="attenuationDistance";vt.ATTENUATION_COLOR="attenuationColor";vt.LINE_SCALE="scale";vt.LINE_DASH_SIZE="dashSize";vt.LINE_GAP_SIZE="gapSize";vt.LINE_WIDTH="linewidth";vt.LINE_DASH_OFFSET="dashOffset";vt.POINT_SIZE="size";vt.DISPERSION="dispersion";vt.LIGHT_MAP="light";vt.AO="ao";const I2=Ke(vt,vt.ALPHA_TEST),P2=Ke(vt,vt.COLOR),L2=Ke(vt,vt.EMISSIVE),F2=Ke(vt,vt.OPACITY),D2=Ke(vt,vt.NORMAL),U2=Ke(vt,vt.LIGHT_MAP),O2=Ke(vt,vt.AO),tl=de(new Ge).onReference(function(r){return r.material}).onRenderUpdate(function({material:r}){this.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation))}),B2=Mt(r=>r.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class z2 extends Ia{static get type(){return"StorageArrayElementNode"}constructor(t,e){super(t,e),this.isStorageArrayElementNode=!0}set storageBufferNode(t){this.node=t}get storageBufferNode(){return this.node}getMemberType(t,e){const n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(t,e):"void"}setup(t){return t.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&t.setupPBO(this.node),super.setup(t)}generate(t,e){let n;const i=t.context.assign;if(t.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&i!==!0&&(this.node.value.isInstancedBufferAttribute||t.shaderStage!=="compute")?n=t.generatePBO(this):n=this.node.build(t):n=super.generate(t),i!==!0){const s=this.getNodeType(t);n=t.format(n,s,e)}return n}}const V2=De(z2).setParameterLength(2);class k2 extends Tg{static get type(){return"StorageBufferNode"}constructor(t,e=null,n=0){let i,s=null;e&&e.isStruct?(i="struct",s=e.layout,(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(n=t.count)):e===null&&(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)?(i=nR(t.itemSize),n=t.count):i=e,super(t,i,n),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=Mx.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,t.isStorageBufferAttribute!==!0&&t.isStorageInstancedBufferAttribute!==!0&&(t.isInstancedBufferAttribute?t.isStorageInstancedBufferAttribute=!0:t.isStorageBufferAttribute=!0)}getHash(t){if(this.bufferCount===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(t){return V2(this,t)}setPBO(t){return this.isPBO=t,this}getPBO(){return this.isPBO}setAccess(t){return this.access=t,this}toReadOnly(){return this.setAccess(Mx.READ_ONLY)}setAtomic(t){return this.isAtomic=t,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=SM(this.value),this._varying=La(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(t){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(t);if(t.isAvailable("storageBuffer")||t.isAvailable("indirectStorageBuffer"))return super.getNodeType(t);const{attribute:e}=this.getAttributeData();return e.getNodeType(t)}getMemberType(t,e){return this.structTypeNode!==null?this.structTypeNode.getMemberType(t,e):"void"}generate(t){if(this.structTypeNode!==null&&this.structTypeNode.build(t),t.isAvailable("storageBuffer")||t.isAvailable("indirectStorageBuffer"))return super.generate(t);const{attribute:e,varying:n}=this.getAttributeData(),i=n.build(t);return t.registerTransform(i,e),i}}const ay=(r,t=null,e=0)=>new k2(r,t,e);class en extends Bt{static get type(){return"IndexNode"}constructor(t){super("uint"),this.scope=t,this.isIndexNode=!0}generate(t){const e=this.getNodeType(t),n=this.scope;let i;if(n===en.VERTEX)i=t.getVertexIndex();else if(n===en.INSTANCE)i=t.getInstanceIndex();else if(n===en.DRAW)i=t.getDrawIndex();else if(n===en.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(n===en.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(n===en.SUBGROUP)i=t.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return t.shaderStage==="vertex"||t.shaderStage==="compute"?s=i:s=La(this).build(t,e),s}}en.VERTEX="vertex";en.INSTANCE="instance";en.SUBGROUP="subgroup";en.INVOCATION_LOCAL="invocationLocal";en.INVOCATION_SUBGROUP="invocationSubgroup";en.DRAW="draw";const G2=Ke(en,en.VERTEX),Ml=Ke(en,en.INSTANCE),H2=Ke(en,en.DRAW);class W2 extends MM{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class X2 extends sr{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}class $2 extends Bt{static get type(){return"InstanceNode"}constructor(t,e,n=null){super("void"),this.count=t,this.instanceMatrix=e,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ue.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:t}=this;return t&&t.isStorageInstancedBufferAttribute===!0}get isStorageColor(){const{instanceColor:t}=this;return t&&t.isStorageInstancedBufferAttribute===!0}setup(t){let{instanceMatrixNode:e,instanceColorNode:n}=this;e===null&&(e=this._createInstanceMatrixNode(!0,t),this.instanceMatrixNode=e);const{instanceColor:i,isStorageColor:s}=this;if(i&&n===null){if(s)n=ay(i,"vec3",Math.max(i.count,1)).element(Ml);else{const a=new X2(i.array,3),l=i.usage===Op?Zx:Yx;this.bufferColor=a,n=Pt(l(a,"vec3",3,0))}this.instanceColorNode=n}const o=e.mul(Xn).xyz;if(Xn.assign(o),t.needsPreviousData()&&ku.assign(this.getPreviousInstancedPosition(t)),t.hasGeometryAttribute("normal")){const a=JP(ls,e);ls.assign(a)}this.instanceColorNode!==null&&zu("vec3","vInstanceColor").assign(this.instanceColorNode)}update(t){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)),this.previousInstanceMatrixNode!==null&&t.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(t){const e=t.object;return this.previousInstanceMatrixNode===null&&(e.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,t)),this.previousInstanceMatrixNode.mul(ku).xyz}_createInstanceMatrixNode(t,e){let n;const{instanceMatrix:i}=this,{count:s}=i;if(this.isStorageMatrix)n=ay(i,"mat4",Math.max(s,1)).element(Ml);else if(s*16*4<=e.getUniformBufferLimit())n=EM(i.array,"mat4",Math.max(s,1)).element(Ml);else{const a=new W2(i.array,16,1);t===!0&&(this.buffer=a);const l=i.usage===Op?Zx:Yx,c=[l(a,"vec4",16,0),l(a,"vec4",16,4),l(a,"vec4",16,8),l(a,"vec4",16,12)];n=Ud(...c)}return n}}class q2 extends $2{static get type(){return"InstancedMeshNode"}constructor(t){const{count:e,instanceMatrix:n,instanceColor:i}=t;super(e,n,i),this.instancedMesh=t}}const Y2=De(q2).setParameterLength(1);class Z2 extends Bt{static get type(){return"BatchNode"}constructor(t){super("void"),this.batchMesh=t,this.batchingIdNode=null}setup(t){this.batchingIdNode===null&&(t.getDrawIndex()===null?this.batchingIdNode=Ml:this.batchingIdNode=H2);const n=Mt(([p])=>{const x=Be(ra(li(this.batchMesh._indirectTexture),0).x).toConst(),g=Be(p).mod(x).toConst(),m=Be(p).div(x).toConst();return li(this.batchMesh._indirectTexture,ji(g,m)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Be(this.batchingIdNode)),i=this.batchMesh._matricesTexture,s=Be(ra(li(i),0).x).toConst(),o=kt(n).mul(4).toInt().toConst(),a=o.mod(s).toConst(),l=o.div(s).toConst(),c=Ud(li(i,ji(a,l)),li(i,ji(a.add(1),l)),li(i,ji(a.add(2),l)),li(i,ji(a.add(3),l))),h=this.batchMesh._colorsTexture;if(h!==null){const x=Mt(([g])=>{const m=Be(ra(li(h),0).x).toConst(),y=g,v=y.mod(m).toConst(),_=y.div(m).toConst();return li(h,ji(v,_)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);zu("vec3","vBatchColor").assign(x)}const u=yi(c);Xn.assign(c.mul(Xn));const d=ls.div(Pt(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;ls.assign(f),t.hasGeometryAttribute("tangent")&&Gu.mulAssign(u)}}const J2=De(Z2).setParameterLength(1),ly=new WeakMap;class j2 extends Bt{static get type(){return"SkinningNode"}constructor(t){super("void"),this.skinnedMesh=t,this.updateType=ue.OBJECT,this.skinIndexNode=va("skinIndex","uvec4"),this.skinWeightNode=va("skinWeight","vec4"),this.bindMatrixNode=tn("bindMatrix","mat4"),this.bindMatrixInverseNode=tn("bindMatrixInverse","mat4"),this.boneMatricesNode=ny("skeleton.boneMatrices","mat4",t.skeleton.bones.length),this.positionNode=Xn,this.toPositionNode=Xn,this.previousBoneMatricesNode=null}getSkinnedPosition(t=this.boneMatricesNode,e=this.positionNode){const{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:s,bindMatrixInverseNode:o}=this,a=t.element(n.x),l=t.element(n.y),c=t.element(n.z),h=t.element(n.w),u=s.mul(e),d=os(a.mul(i.x).mul(u),l.mul(i.y).mul(u),c.mul(i.z).mul(u),h.mul(i.w).mul(u));return o.mul(d).xyz}getSkinnedNormalAndTangent(t=this.boneMatricesNode,e=ls,n=Gu){const{skinIndexNode:i,skinWeightNode:s,bindMatrixNode:o,bindMatrixInverseNode:a}=this,l=t.element(i.x),c=t.element(i.y),h=t.element(i.z),u=t.element(i.w);let d=os(s.x.mul(l),s.y.mul(c),s.z.mul(h),s.w.mul(u));d=a.mul(d).mul(o);const f=d.transformDirection(e).xyz,p=d.transformDirection(n).xyz;return{skinNormal:f,skinTangent:p}}getPreviousSkinnedPosition(t){const e=t.object;return this.previousBoneMatricesNode===null&&(e.skeleton.previousBoneMatrices=new Float32Array(e.skeleton.boneMatrices),this.previousBoneMatricesNode=ny("skeleton.previousBoneMatrices","mat4",e.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,ku)}setup(t){t.needsPreviousData()&&ku.assign(this.getPreviousSkinnedPosition(t));const e=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(e),t.hasGeometryAttribute("normal")){const{skinNormal:n,skinTangent:i}=this.getSkinnedNormalAndTangent();ls.assign(n),t.hasGeometryAttribute("tangent")&&Gu.assign(i)}return e}generate(t,e){if(e!=="void")return super.generate(t,e)}update(t){const e=t.object&&t.object.skeleton?t.object.skeleton:this.skinnedMesh.skeleton;ly.get(e)!==t.frameId&&(ly.set(e,t.frameId),this.previousBoneMatricesNode!==null&&(e.previousBoneMatrices===null&&(e.previousBoneMatrices=new Float32Array(e.boneMatrices)),e.previousBoneMatrices.set(e.boneMatrices)),e.update())}}const K2=r=>new j2(r);class Q2 extends Bt{static get type(){return"LoopNode"}constructor(t=[]){super("void"),this.params=t}getVarName(t){return String.fromCharCode(105+t)}getProperties(t){const e=t.getNodeProperties(this);if(e.stackNode!==void 0)return e;const n={};for(let a=0,l=this.params.length-1;a<l;a++){const c=this.params[a],h=c.isNode!==!0&&c.name||this.getVarName(a),u=c.isNode!==!0&&c.type||"int";n[h]=Es(h,u)}const i=t.addStack(),s=this.params[this.params.length-1](n);e.returnsNode=s.context({nodeLoop:s}),e.stackNode=i;const o=this.params[0];if(o.isNode!==!0&&typeof o.update=="function"){const a=Mt(this.params[0].update)(n);e.updateNode=a.context({nodeLoop:a})}return t.removeStack(),e}setup(t){if(this.getProperties(t),t.fnCall){const e=t.getDataFromNode(t.fnCall.shaderNode);e.hasLoop=!0}}generate(t){const e=this.getProperties(t),n=this.params,i=e.stackNode;for(let o=0,a=n.length-1;o<a;o++){const l=n[o];let c=!1,h=null,u=null,d=null,f=null,p=null,x=null;l.isNode?l.getNodeType(t)==="bool"?(c=!0,f="bool",u=l.build(t,f)):(f="int",d=this.getVarName(o),h="0",u=l.build(t,f),p="<"):(f=l.type||"int",d=l.name||this.getVarName(o),h=l.start,u=l.end,p=l.condition,x=l.update,typeof h=="number"?h=t.generateConst(f,h):h&&h.isNode&&(h=h.build(t,f)),typeof u=="number"?u=t.generateConst(f,u):u&&u.isNode&&(u=u.build(t,f)),h!==void 0&&u===void 0?(h=h+" - 1",u="0",p=">="):u!==void 0&&h===void 0&&(h="0",p="<"),p===void 0&&(Number(h)>Number(u)?p=">=":p="<"));let g;if(c)g=`while ( ${u} )`;else{const m={start:h,end:u},y=m.start,v=m.end;let _;const w=()=>p.includes("<")?"+=":"-=";if(x!=null)switch(typeof x){case"function":_=t.flowStagesNode(e.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":_=d+" "+w()+" "+t.generateConst(f,x);break;case"string":_=d+" "+x;break;default:x.isNode?_=d+" "+w()+" "+x.build(t):(Ne("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),_="break /* invalid update */")}else f==="int"||f==="uint"?x=p.includes("<")?"++":"--":x=w()+" 1.",_=d+" "+x;const T=t.getVar(f,d)+" = "+y,E=d+" "+p+" "+v;g=`for ( ${T}; ${E}; ${_} )`}t.addFlowCode((o===0?`
|
|
4077
|
+
`,Bp(o)}return n}}const IP=(r,t=null)=>new RP(Ot(r),t).toStack();q("debug",IP);class PP{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(t){return this._renderer=t,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class LP extends Bt{static get type(){return"InspectorNode"}constructor(t,e="",n=null){super(),this.node=t,this.name=e,this.callback=n,this.updateType=ue.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(t){t.renderer.inspector.inspect(this)}getNodeType(t){return this.node.getNodeType(t)}setup(t){let e=this.node;return t.context.inspector===!0&&this.callback!==null&&(e=this.callback(e)),t.renderer.backend.isWebGPUBackend!==!0&&t.renderer.inspector.constructor!==PP&&_a('TSL: ".toInspector()" is only available with WebGPU.'),e}}function FP(r,t="",e=null){return r=Ot(r),r.before(new LP(r,t,e))}q("toInspector",FP);class AM extends Bt{static get type(){return"AttributeNode"}constructor(t,e=null){super(e),this.global=!0,this._attributeName=t}getHash(t){return this.getAttributeName(t)}getNodeType(t){let e=this.nodeType;if(e===null){const n=this.getAttributeName(t);if(t.hasGeometryAttribute(n)){const i=t.geometry.getAttribute(n);e=t.getTypeFromAttribute(i)}else e="float"}return e}setAttributeName(t){return this._attributeName=t,this}getAttributeName(){return this._attributeName}generate(t){const e=this.getAttributeName(t),n=this.getNodeType(t);if(t.hasGeometryAttribute(e)===!0){const s=t.geometry.getAttribute(e),o=t.getTypeFromAttribute(s),a=t.getAttribute(e,o);return t.shaderStage==="vertex"?t.format(a.name,o,n):Fa(this).build(t,n)}else return ne(`AttributeNode: Vertex attribute "${e}" not found on geometry.`),t.generateConst(n)}serialize(t){super.serialize(t),t.global=this.global,t._attributeName=this._attributeName}deserialize(t){super.deserialize(t),this.global=t.global,this._attributeName=t._attributeName}}const Ma=(r,t=null)=>new AM(r,t);class bg extends Ac{static get type(){return"BufferNode"}constructor(t,e,n=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(t){return this.getNodeType(t)}getInputType(){return"buffer"}}const EM=(r,t,e)=>new bg(r,t,e);class DP extends Pa{static get type(){return"UniformArrayElementNode"}constructor(t,e){super(t,e),this.isArrayBufferElementNode=!0}generate(t){const e=super.generate(t),n=this.getNodeType(),i=this.node.getPaddedType();return t.format(e,i,n)}}class UP extends bg{static get type(){return"UniformArrayNode"}constructor(t,e=null){super(null),this.array=t,this.elementType=e===null?Bu(t[0]):e,this.paddedType=this.getPaddedType(),this.updateType=ue.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const t=this.elementType;let e="vec4";return t==="mat2"?e="mat2":/mat/.test(t)===!0?e="mat4":t.charAt(0)==="i"?e="ivec4":t.charAt(0)==="u"&&(e="uvec4"),e}update(){const{array:t,value:e}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let i=0;i<t.length;i++){const s=i*4;e[s]=t[i]}else if(n==="color")for(let i=0;i<t.length;i++){const s=i*4,o=t[i];e[s]=o.r,e[s+1]=o.g,e[s+2]=o.b||0}else if(n==="mat2")for(let i=0;i<t.length;i++){const s=i*4,o=t[i];e[s]=o.elements[0],e[s+1]=o.elements[1],e[s+2]=o.elements[2],e[s+3]=o.elements[3]}else if(n==="mat3")for(let i=0;i<t.length;i++){const s=i*16,o=t[i];e[s]=o.elements[0],e[s+1]=o.elements[1],e[s+2]=o.elements[2],e[s+4]=o.elements[3],e[s+5]=o.elements[4],e[s+6]=o.elements[5],e[s+8]=o.elements[6],e[s+9]=o.elements[7],e[s+10]=o.elements[8],e[s+15]=1}else if(n==="mat4")for(let i=0;i<t.length;i++){const s=i*16,o=t[i];for(let a=0;a<o.elements.length;a++)e[s+a]=o.elements[a]}else for(let i=0;i<t.length;i++){const s=i*4,o=t[i];e[s]=o.x,e[s+1]=o.y,e[s+2]=o.z||0,e[s+3]=o.w||0}}setup(t){const e=this.array.length,n=this.elementType;let i=Float32Array;const s=this.paddedType,o=t.getTypeLength(s);return n.charAt(0)==="i"&&(i=Int32Array),n.charAt(0)==="u"&&(i=Uint32Array),this.value=new i(e*o),this.bufferCount=e,this.bufferType=s,this.update(),super.setup(t)}element(t){return new DP(this,Ot(t))}}const Qi=(r,t)=>new UP(r,t);class OP extends Bt{constructor(t){super("float"),this.name=t,this.isBuiltinNode=!0}generate(){return this.name}}const Bd=De(OP).setParameterLength(1);let ja,Ka;class Ue extends Bt{static get type(){return"ScreenNode"}constructor(t){super(),this.scope=t,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Ue.DPR?"float":this.scope===Ue.VIEWPORT?"vec4":"vec2"}getUpdateType(){let t=ue.NONE;return(this.scope===Ue.SIZE||this.scope===Ue.VIEWPORT||this.scope===Ue.DPR)&&(t=ue.RENDER),this.updateType=t,t}update({renderer:t}){const e=t.getRenderTarget();this.scope===Ue.VIEWPORT?e!==null?Ka.copy(e.viewport):(t.getViewport(Ka),Ka.multiplyScalar(t.getPixelRatio())):this.scope===Ue.DPR?this._output.value=t.getPixelRatio():e!==null?(ja.width=e.width,ja.height=e.height):t.getDrawingBufferSize(ja)}setup(){const t=this.scope;let e=null;return t===Ue.SIZE?e=de(ja||(ja=new Ge)):t===Ue.VIEWPORT?e=de(Ka||(Ka=new Nn)):t===Ue.DPR?e=de(1):e=xe(Da.div(Zx)),this._output=e,e}generate(t){if(this.scope===Ue.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){const n=t.getNodeProperties(Zx).outputNode.build(t);e=`${t.getType("vec2")}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}}Ue.COORDINATE="coordinate";Ue.VIEWPORT="viewport";Ue.SIZE="size";Ue.UV="uv";Ue.DPR="dpr";const Tg=Ke(Ue,Ue.UV),Zx=Ke(Ue,Ue.SIZE),Da=Ke(Ue,Ue.COORDINATE),CM=Ke(Ue,Ue.VIEWPORT);CM.zw;CM.xy;let Xf=null,Lh=null,$f=null,Fh=null,qf=null,Dh=null;const wg=de(0,"uint").setName("u_cameraIndex").setGroup(aM("cameraIndex")).toVarying("v_cameraIndex"),Or=de("float").setName("cameraNear").setGroup(te).onRenderUpdate(({camera:r})=>r.near),Br=de("float").setName("cameraFar").setGroup(te).onRenderUpdate(({camera:r})=>r.far),BP=Mt(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const n of r.cameras)e.push(n.projectionMatrix);Lh===null?Lh=Qi(e).setGroup(te).setName("cameraProjectionMatrices"):Lh.array=e,t=Lh.element(r.isMultiViewCamera?Bd("gl_ViewID_OVR"):wg).toConst("cameraProjectionMatrix")}else Xf===null&&(Xf=de(r.projectionMatrix).setName("cameraProjectionMatrix").setGroup(te).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=Xf;return t}).once()(),zP=Mt(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const n of r.cameras)e.push(n.projectionMatrixInverse);Fh===null?Fh=Qi(e).setGroup(te).setName("cameraProjectionMatricesInverse"):Fh.array=e,t=Fh.element(r.isMultiViewCamera?Bd("gl_ViewID_OVR"):wg).toConst("cameraProjectionMatrixInverse")}else $f===null&&($f=de(r.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(te).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=$f;return t}).once()(),Ua=Mt(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const n of r.cameras)e.push(n.matrixWorldInverse);Dh===null?Dh=Qi(e).setGroup(te).setName("cameraViewMatrices"):Dh.array=e,t=Dh.element(r.isMultiViewCamera?Bd("gl_ViewID_OVR"):wg).toConst("cameraViewMatrix")}else qf===null&&(qf=de(r.matrixWorldInverse).setName("cameraViewMatrix").setGroup(te).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=qf;return t}).once()();class Ic{constructor(t=new H(1/0,1/0,1/0),e=new H(-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,n=t.length;e<n;e+=3)this.expandByPoint(Ei.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Ei.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Ei.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Ei):Ei.fromBufferAttribute(s,o),Ei.applyMatrix4(t.matrixWorld),this.expandByPoint(Ei);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Uh.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Uh.copy(n.boundingBox)),Uh.applyMatrix4(t.matrixWorld),this.union(Uh)}const i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.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.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Ei),Ei.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Qa),Oh.subVectors(this.max,Qa),Do.subVectors(t.a,Qa),Uo.subVectors(t.b,Qa),Oo.subVectors(t.c,Qa),Ys.subVectors(Uo,Do),Zs.subVectors(Oo,Uo),Ir.subVectors(Do,Oo);let e=[0,-Ys.z,Ys.y,0,-Zs.z,Zs.y,0,-Ir.z,Ir.y,Ys.z,0,-Ys.x,Zs.z,0,-Zs.x,Ir.z,0,-Ir.x,-Ys.y,Ys.x,0,-Zs.y,Zs.x,0,-Ir.y,Ir.x,0];return!Yf(e,Do,Uo,Oo,Oh)||(e=[1,0,0,0,1,0,0,0,1],!Yf(e,Do,Uo,Oo,Oh))?!1:(Bh.crossVectors(Ys,Zs),e=[Bh.x,Bh.y,Bh.z],Yf(e,Do,Uo,Oo,Oh))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ei).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ei).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:(_s[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),_s[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),_s[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),_s[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),_s[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),_s[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),_s[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),_s[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(_s),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const _s=[new H,new H,new H,new H,new H,new H,new H,new H],Ei=new H,Uh=new Ic,Do=new H,Uo=new H,Oo=new H,Ys=new H,Zs=new H,Ir=new H,Qa=new H,Oh=new H,Bh=new H,Pr=new H;function Yf(r,t,e,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Pr.fromArray(r,s);const a=i.x*Math.abs(Pr.x)+i.y*Math.abs(Pr.y)+i.z*Math.abs(Pr.z),l=t.dot(Pr),c=e.dot(Pr),h=n.dot(Pr);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const VP=new Ic,tl=new H,Zf=new H;class zd{constructor(t=new H,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 n=this.center;e!==void 0?n.copy(e):VP.setFromPoints(t).getCenter(n);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.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;tl.subVectors(t,this.center);const e=tl.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(tl,i/n),this.radius+=i}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):(Zf.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(tl.copy(t.center).add(Zf)),this.expandByPoint(tl.copy(t.center).sub(Zf))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Jx=new zd;class Pe extends Bt{static get type(){return"Object3DNode"}constructor(t,e=null){super(),this.scope=t,this.object3d=e,this.updateType=ue.OBJECT,this.uniformNode=new Ac(null)}getNodeType(){const t=this.scope;if(t===Pe.WORLD_MATRIX)return"mat4";if(t===Pe.POSITION||t===Pe.VIEW_POSITION||t===Pe.DIRECTION||t===Pe.SCALE)return"vec3";if(t===Pe.RADIUS)return"float"}update(t){const e=this.object3d,n=this.uniformNode,i=this.scope;if(i===Pe.WORLD_MATRIX)n.value=e.matrixWorld;else if(i===Pe.POSITION)n.value=n.value||new H,n.value.setFromMatrixPosition(e.matrixWorld);else if(i===Pe.SCALE)n.value=n.value||new H,n.value.setFromMatrixScale(e.matrixWorld);else if(i===Pe.DIRECTION)n.value=n.value||new H,e.getWorldDirection(n.value);else if(i===Pe.VIEW_POSITION){const s=t.camera;n.value=n.value||new H,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}else if(i===Pe.RADIUS){const s=t.object.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),Jx.copy(s.boundingSphere).applyMatrix4(e.matrixWorld),n.value=Jx.radius}}generate(t){const e=this.scope;return e===Pe.WORLD_MATRIX?this.uniformNode.nodeType="mat4":e===Pe.POSITION||e===Pe.VIEW_POSITION||e===Pe.DIRECTION||e===Pe.SCALE?this.uniformNode.nodeType="vec3":e===Pe.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(t)}serialize(t){super.serialize(t),t.scope=this.scope}deserialize(t){super.deserialize(t),this.scope=t.scope}}Pe.WORLD_MATRIX="worldMatrix";Pe.POSITION="position";Pe.SCALE="scale";Pe.VIEW_POSITION="viewPosition";Pe.DIRECTION="direction";Pe.RADIUS="radius";class jx extends Pe{static get type(){return"ModelNode"}constructor(t){super(t)}update(t){this.object3d=t.object,super.update(t)}}const Ag=Ke(jx,jx.WORLD_MATRIX),kP=de(new Mi).onObjectUpdate(({object:r},t)=>t.value.getNormalMatrix(r.matrixWorld)),NM=Mt(r=>r.context.modelViewMatrix||GP).once()().toVar("modelViewMatrix_2"),GP=Ua.mul(Ag),HP=Mt(r=>r.shaderStage!=="fragment"?(_a("TSL: `clipSpace` is only available in fragment stage."),zn()):r.context.clipSpace.toVarying("v_clipSpace")).once()(),RM=Ma("position","vec3"),Xn=RM.toVarying("positionLocal"),ku=RM.toVarying("positionPrevious"),Eg=Mt(r=>Ag.mul(Xn).xyz.toVarying(r.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),hn=Mt(r=>{if(r.shaderStage==="fragment"&&r.material.vertexNode){const t=zP.mul(HP);return t.xyz.div(t.w).toVar("positionView")}return r.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),IM=Mt(r=>{let t;return r.camera.isOrthographicCamera?t=Pt(0,0,1):t=hn.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class WP extends Bt{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(t){if(t.shaderStage!=="fragment")return"true";const{material:e}=t;return e.side===Qm?"false":t.getFrontFacing()}}const XP=Ke(WP),PM=kt(XP).mul(2).sub(1),Vd=Mt(([r],{material:t})=>{const e=t.side;return e===Qm?r=r.mul(-1):e===pN&&(r=r.mul(PM)),r}),$P=Ma("normal","vec3"),ls=Mt(r=>r.geometry.hasAttribute("normal")===!1?(ne('TSL: Vertex attribute "normal" not found on geometry.'),Pt(0,1,0)):$P,"vec3").once()().toVar("normalLocal"),qP=hn.dFdx().cross(hn.dFdy()).normalize().toVar("normalFlat"),YP=Mt(r=>{let t;return r.isFlatShading()?t=qP:t=LM(ls).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),_i=Mt(r=>{let t;return r.subBuildFn==="NORMAL"||r.subBuildFn==="VERTEX"?(t=YP,r.isFlatShading()!==!0&&(t=Vd(t))):t=r.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),kd=_i.transformDirection(Ua).toVar("normalWorld"),ZP=Mt(({subBuildFn:r,context:t})=>{let e;return r==="NORMAL"||r==="VERTEX"?e=_i:e=t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),JP=Mt(([r,t=Ag])=>{const e=yi(t),n=r.div(Pt(e[0].dot(e[0]),e[1].dot(e[1]),e[2].dot(e[2])));return e.mul(n).xyz}),LM=Mt(([r],t)=>{const e=t.context.modelNormalViewMatrix;if(e)return e.transformDirection(r);const n=kP.mul(r);return Ua.transformDirection(n)});Mt(()=>(ne('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),_i)).once(["NORMAL","VERTEX"])();Mt(()=>(ne('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),kd)).once(["NORMAL","VERTEX"])();Mt(()=>(ne('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),ZP)).once(["NORMAL","VERTEX"])();class jP{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(t,e){let n=t.get(e);return n===void 0&&(n={renderId:0,frameId:0},t.set(e,n)),n}updateBeforeNode(t){const e=t.getUpdateBeforeType(),n=t.updateReference(this);if(e===ue.FRAME){const i=this._getMaps(this.updateBeforeMap,n);if(i.frameId!==this.frameId){const s=i.frameId;i.frameId=this.frameId,t.updateBefore(this)===!1&&(i.frameId=s)}}else if(e===ue.RENDER){const i=this._getMaps(this.updateBeforeMap,n);if(i.renderId!==this.renderId){const s=i.renderId;i.renderId=this.renderId,t.updateBefore(this)===!1&&(i.renderId=s)}}else e===ue.OBJECT&&t.updateBefore(this)}updateAfterNode(t){const e=t.getUpdateAfterType(),n=t.updateReference(this);if(e===ue.FRAME){const i=this._getMaps(this.updateAfterMap,n);i.frameId!==this.frameId&&t.updateAfter(this)!==!1&&(i.frameId=this.frameId)}else if(e===ue.RENDER){const i=this._getMaps(this.updateAfterMap,n);i.renderId!==this.renderId&&t.updateAfter(this)!==!1&&(i.renderId=this.renderId)}else e===ue.OBJECT&&t.updateAfter(this)}updateNode(t){const e=t.getUpdateType(),n=t.updateReference(this);if(e===ue.FRAME){const i=this._getMaps(this.updateMap,n);i.frameId!==this.frameId&&t.update(this)!==!1&&(i.frameId=this.frameId)}else if(e===ue.RENDER){const i=this._getMaps(this.updateMap,n);i.renderId!==this.renderId&&t.update(this)!==!1&&(i.renderId=this.renderId)}else e===ue.OBJECT&&t.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}let KP=0;class Wp extends Ia{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:KP++}),this.uuid=Ps(),this.name="",this.type="Material",this.blending=Mx,this.side=Fp,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bx,this.blendDst=Tx,this.blendEquation=Sx,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vi(0,0,0),this.blendAlpha=0,this.depthFunc=wx,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Rx,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lo,this.stencilZFail=Lo,this.stencilZPass=Lo,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){ne(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){ne(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Mx&&(n.blending=this.blending),this.side!==Fp&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==bx&&(n.blendSrc=this.blendSrc),this.blendDst!==Tx&&(n.blendDst=this.blendDst),this.blendEquation!==Sx&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==wx&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Rx&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Lo&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Lo&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Lo&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}const Gd=(r=0)=>Ma("uv"+(r>0?r:""),"vec2");class QP extends Bt{static get type(){return"TextureSizeNode"}constructor(t,e=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=t,this.levelNode=e}generate(t,e){const n=this.textureNode.build(t,"property"),i=this.levelNode===null?"0":this.levelNode.build(t,"int");return t.format(`${t.getMethod("textureDimensions")}( ${n}, ${i} )`,this.getNodeType(t),e)}}const oa=De(QP).setParameterLength(1,2);class t2 extends Ac{static get type(){return"MaxMipLevelNode"}constructor(t){super(0),this._textureNode=t,this.updateType=ue.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const t=this.texture,e=t.images,n=e&&e.length>0?e[0]&&e[0].image||e[0]:t.image;if(n&&n.width!==void 0){const{width:i,height:s}=n;this.value=Math.log2(Math.max(i,s))}}}const e2=De(t2).setParameterLength(1);let Bo;class n2{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Bo===void 0&&(Bo=Px("canvas")),Bo.width=t.width,Bo.height=t.height;const i=Bo.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=Bo}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Px("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Ls(s[o]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Ls(e[n]/255)*255):e[n]=Ls(e[n]);return{data:e,width:t.width,height:t.height}}else return ne("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let i2=0;class Cg{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:i2++}),this.uuid=Ps(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Jf(i[o].image)):s.push(Jf(i[o]))}else s=Jf(i);n.url=s}return e||(t.images[this.uuid]=n),n}}function Jf(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?n2.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(ne("Texture: Unable to serialize Texture."),{})}let s2=0;const jf=new H;class ni extends Ia{constructor(t=ni.DEFAULT_IMAGE,e=ni.DEFAULT_MAPPING,n=cl,i=cl,s=rc,o=Gv,a=wN,l=Hv,c=ni.DEFAULT_ANISOTROPY,h=Uu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:s2++}),this.uuid=Ps(),this.name="",this.source=new Cg(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ge(0,0),this.repeat=new Ge(1,1),this.center=new Ge(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Mi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(jf).x}get height(){return this.source.getSize(jf).y}get depth(){return this.source.getSize(jf).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){ne(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){ne(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==kv)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ax:t.x=t.x-Math.floor(t.x);break;case cl:t.x=t.x<0?0:1;break;case Ex: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 Ax:t.y=t.y-Math.floor(t.y);break;case cl:t.y=t.y<0?0:1;break;case Ex: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)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ni.DEFAULT_IMAGE=null;ni.DEFAULT_MAPPING=kv;ni.DEFAULT_ANISOTROPY=4;class r2 extends Error{constructor(t,e=null){super(t),this.name="NodeError",this.stackTrace=e}}const FM=new ni;class Hd extends Ac{static get type(){return"TextureNode"}constructor(t=FM,e=null,n=null,i=null){super(t),this.isTextureNode=!0,this.uvNode=e,this.levelNode=n,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ue.NONE,this.referenceNode=null,this._value=t,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(e===null)}set value(t){this.referenceNode?this.referenceNode.value=t:this._value=t}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===eg?"uvec4":this.value.type===TN?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Gd(this.value.channel)}updateReference(){return this.value}getTransformedUV(t){return this._matrixUniform===null&&(this._matrixUniform=de(this.value.matrix)),this._matrixUniform.mul(Pt(t,1)).xy}setUpdateMatrix(t){return this.updateMatrix=t,this}setupUV(t,e){return t.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=de(!1)),e=e.toVar(),this.sampler?e=this._flipYUniform.select(e.flipY(),e):e=this._flipYUniform.select(e.setY(Be(oa(this,this.levelNode).y).sub(e.y).sub(1)),e)),e}setup(t){const e=t.getNodeProperties(this);e.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new r2("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const i=Mt(()=>{let l=this.uvNode;return(l===null||t.context.forceUVContext===!0)&&t.context.getUV&&(l=t.context.getUV(this,t)),l||(l=this.getDefaultUV()),this.updateMatrix===!0&&(l=this.getTransformedUV(l)),l=this.setupUV(t,l),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?ue.OBJECT:ue.NONE,l})();let s=this.levelNode;s===null&&t.context.getTextureLevel&&(s=t.context.getTextureLevel(this));let o=null,a=null;if(this.compareNode!==null)if(t.renderer.hasCompatibility($v.TEXTURE_COMPARE))o=this.compareNode;else{const l=n.compareFunction;l===null||l===IN||l===ng||l===Ix||l===Ou?a=this.compareNode:(o=this.compareNode,_a('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}e.uvNode=i,e.levelNode=s,e.biasNode=this.biasNode,e.compareNode=o,e.compareStepNode=a,e.gradNode=this.gradNode,e.depthNode=this.depthNode,e.offsetNode=this.offsetNode}generateUV(t,e){return e.build(t,this.sampler===!0?"vec2":"ivec2")}generateOffset(t,e){return e.build(t,"ivec2")}generateSnippet(t,e,n,i,s,o,a,l,c){const h=this.value;let u;return s?u=t.generateTextureBias(h,e,n,s,o,c):l?u=t.generateTextureGrad(h,e,n,l,o,c):a?u=t.generateTextureCompare(h,e,n,a,o,c):this.sampler===!1?u=t.generateTextureLoad(h,e,n,i,o,c):i?u=t.generateTextureLevel(h,e,n,i,o,c):u=t.generateTexture(h,e,n,o,c),u}generate(t,e){const n=this.value,i=t.getNodeProperties(this),s=super.generate(t,"property");if(/^sampler/.test(e))return s+"_sampler";if(t.isReference(e))return s;{const o=t.getDataFromNode(this),a=this.getNodeType(t);let l=o.propertyName;if(l===void 0){const{uvNode:h,levelNode:u,biasNode:d,compareNode:f,compareStepNode:p,depthNode:x,gradNode:g,offsetNode:m}=i,y=this.generateUV(t,h),v=u?u.build(t,"float"):null,_=d?d.build(t,"float"):null,w=x?x.build(t,"int"):null,T=f?f.build(t,"float"):null,E=p?p.build(t,"float"):null,M=g?[g[0].build(t,"vec2"),g[1].build(t,"vec2")]:null,b=m?this.generateOffset(t,m):null,P=t.getVarFromNode(this);l=t.getPropertyName(P);let N=this.generateSnippet(t,s,y,v,_,w,T,M,b);if(E!==null){const L=n.compareFunction;L===Ix||L===Ou?N=cc(Es(N,a),Es(E,"float")).build(t,a):N=cc(Es(E,"float"),Es(N,a)).build(t,a)}t.addLineFlowCode(`${l} = ${N}`,this),o.snippet=N,o.propertyName=l}let c=l;return t.needsToWorkingColorSpace(n)&&(c=vM(Es(c,a),n.colorSpace).setup(t).build(t,a)),t.format(c,a,e)}}setSampler(t){return this.sampler=t,this}getSampler(){return this.sampler}sample(t){const e=this.clone();return e.uvNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}load(t){return this.sample(t).setSampler(!1)}blur(t){const e=this.clone();e.biasNode=Ot(t).mul(e2(e)),e.referenceNode=this.getBase();const n=e.value;return e.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===gi||n.magFilter===gi)&&(ne("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),e.biasNode=null),Ot(e)}level(t){const e=this.clone();return e.levelNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}size(t){return oa(this,t)}bias(t){const e=this.clone();return e.biasNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(t){const e=this.clone();return e.compareNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}grad(t,e){const n=this.clone();return n.gradNode=[Ot(t),Ot(e)],n.referenceNode=this.getBase(),Ot(n)}depth(t){const e=this.clone();return e.depthNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}offset(t){const e=this.clone();return e.offsetNode=Ot(t),e.referenceNode=this.getBase(),Ot(e)}serialize(t){super.serialize(t),t.value=this.value.toJSON(t.meta).uuid,t.sampler=this.sampler,t.updateMatrix=this.updateMatrix,t.updateType=this.updateType}deserialize(t){super.deserialize(t),this.value=t.meta.textures[t.value],this.sampler=t.sampler,this.updateMatrix=t.updateMatrix,this.updateType=t.updateType}update(){const t=this.value,e=this._matrixUniform;e!==null&&(e.value=t.matrix),t.matrixAutoUpdate===!0&&t.updateMatrix();const n=this._flipYUniform;n!==null&&(n.value=t.image instanceof ImageBitmap&&t.flipY===!0||t.isRenderTargetTexture===!0||t.isFramebufferTexture===!0||t.isDepthTexture===!0)}clone(){const t=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return t.sampler=this.sampler,t.depthNode=this.depthNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.offsetNode=this.offsetNode,t}}const o2=De(Hd).setParameterLength(1,4).setName("texture"),pn=(r=FM,t=null,e=null,n=null)=>{let i;return r&&r.isTextureNode===!0?(i=Ot(r.clone()),i.referenceNode=r.getBase(),t!==null&&(i.uvNode=Ot(t)),e!==null&&(i.levelNode=Ot(e)),n!==null&&(i.biasNode=Ot(n))):i=o2(r,t,e,n),i},li=(...r)=>pn(...r).setSampler(!1),Kx=new ke,Qx=new Ra;class Oa{constructor(t=0,e=0,n=0,i=Oa.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,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,n=!0){const i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(pe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-pe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(pe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-pe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(pe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-pe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:ne("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Kx.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Kx,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Qx.setFromEuler(this),this.setFromQuaternion(Qx,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}}Oa.DEFAULT_ORDER="XYZ";const ty=new Oa,Kf=new ke,a2=de(0).onReference(({material:r})=>r).onObjectUpdate(({material:r})=>r.refractionRatio),l2=de(new ke).onReference(function(r){return r.material}).onObjectUpdate(function({material:r,scene:t}){const e=t.environment!==null&&r.envMap===null?t.environmentRotation:r.envMapRotation;return e?(ty.copy(e),Kf.makeRotationFromEuler(ty)):Kf.identity(),Kf}),c2=IM.negate().reflect(_i),h2=IM.negate().refract(_i,a2),u2=c2.transformDirection(Ua).toVar("reflectVector"),d2=h2.transformDirection(Ua).toVar("reflectVector");class f2 extends ni{constructor(t=[],e=tg,n,i,s,o,a,l,c,h){super(t,e,n,i,s,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}const p2=new f2;class m2 extends Hd{static get type(){return"CubeTextureNode"}constructor(t,e=null,n=null,i=null){super(t,e,n,i),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const t=this.value;return t.mapping===tg?u2:t.mapping===bN?d2:(Ne('CubeTextureNode: Mapping "%s" not supported.',t.mapping),Pt(0,0,0))}setUpdateMatrix(){}setupUV(t,e){const n=this.value;return n.isDepthTexture===!0?t.renderer.coordinateSystem===hr?Pt(e.x,e.y.negate(),e.z):e:((t.renderer.coordinateSystem===hr||!n.isRenderTargetTexture)&&(e=Pt(e.x.negate(),e.yz)),l2.mul(e))}generateUV(t,e){return e.build(t,this.sampler===!0?"vec3":"ivec3")}}const g2=De(m2).setParameterLength(1,4).setName("cubeTexture"),ts=(r=p2,t=null,e=null,n=null)=>{let i;return r&&r.isCubeTextureNode===!0?(i=Ot(r.clone()),i.referenceNode=r,t!==null&&(i.uvNode=Ot(t)),e!==null&&(i.levelNode=Ot(e)),n!==null&&(i.biasNode=Ot(n))):i=g2(r,t,e,n),i};class x2 extends Pa{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),n=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,n,i)}}class Ng extends Bt{static get type(){return"ReferenceNode"}constructor(t,e,n=null,i=null){super(),this.property=t,this.uniformType=e,this.object=n,this.count=i,this.properties=t.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=ue.OBJECT}element(t){return new x2(this,Ot(t))}setGroup(t){return this.group=t,this}setName(t){return this.name=t,this}label(t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(t)}setNodeType(t){let e=null;this.count!==null?e=EM(null,t,this.count):Array.isArray(this.getValueFromReference())?e=Qi(null,t):t==="texture"?e=pn(null):t==="cubeTexture"?e=ts(null):e=de(null,t),this.group!==null&&e.setGroup(this.group),this.name!==null&&e.setName(this.name),this.node=e}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let n=t[e[0]];for(let i=1;i<e.length;i++)n=n[e[i]];return n}updateReference(t){return this.reference=this.object!==null?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}const tn=(r,t,e)=>new Ng(r,t,e),ey=(r,t,e,n)=>new Ng(r,t,n,e);class y2 extends Ng{static get type(){return"MaterialReferenceNode"}constructor(t,e,n=null){super(t,e,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(t){return this.reference=this.material!==null?this.material:t.material,this.reference}}const qo=(r,t,e=null)=>new y2(r,t,e),DM=Gd(),_2=hn.dFdx(),v2=hn.dFdy(),UM=DM.dFdx(),OM=DM.dFdy(),BM=_i,zM=v2.cross(BM),VM=BM.cross(_2),Xp=zM.mul(UM.x).add(VM.mul(OM.x)),$p=zM.mul(UM.y).add(VM.mul(OM.y)),ny=Xp.dot(Xp).max($p.dot($p)),kM=ny.equal(0).select(0,ny.inverseSqrt()),M2=Xp.mul(kM).toVar("tangentViewFrame"),S2=$p.mul(kM).toVar("bitangentViewFrame"),GM=Ma("tangent","vec4"),Gu=GM.xyz.toVar("tangentLocal"),HM=Mt(r=>{let t;return r.subBuildFn==="VERTEX"||r.geometry.hasAttribute("tangent")?t=NM.mul(zn(Gu,0)).xyz.toVarying("v_tangentView").normalize():t=M2,r.isFlatShading()!==!0&&(t=Vd(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),b2=Mt(([r,t],e)=>{let n=r.mul(GM.w).xyz;return e.subBuildFn==="NORMAL"&&e.isFlatShading()!==!0&&(n=n.toVarying(t)),n}).once(["NORMAL"]),T2=Mt(r=>{let t;return r.subBuildFn==="VERTEX"||r.geometry.hasAttribute("tangent")?t=b2(_i.cross(HM),"v_bitangentView").normalize():t=S2,r.isFlatShading()!==!0&&(t=Vd(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),w2=yi(HM,T2,_i).toVar("TBNViewMatrix"),iy=r=>Pt(r,Cc(xg(kt(1).sub(Rc(r,r)))));class A2 extends xn{static get type(){return"NormalMapNode"}constructor(t,e=null){super("vec3"),this.node=t,this.scaleNode=e,this.normalMapType=zf,this.unpackNormalMode=Vf}setup(t){const{normalMapType:e,scaleNode:n,unpackNormalMode:i}=this;let s=this.node.mul(2).sub(1);if(e===zf?i===Xv?s=iy(s.xy):i===RN?s=iy(s.yw):i!==Vf&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${i}`):i!==Vf&&console.error(`THREE.NodeMaterial: Normal map type '${e}' is not compatible with unpack normal mode '${i}'`),n!==null){let a=n;t.isFlatShading()===!0&&(a=Vd(a)),s=Pt(s.xy.mul(a),s.z)}let o=null;return e===NN?o=LM(s):e===zf?o=w2.mul(s).normalize():(Ne(`NodeMaterial: Unsupported normal map type: ${e}`),o=_i),o}}const sy=De(A2).setParameterLength(1,2),E2=Mt(({textureNode:r,bumpScale:t})=>{const e=i=>r.isolate().context({getUV:s=>i(s.uvNode||Gd()),forceUVContext:!0}),n=kt(e(i=>i));return xe(kt(e(i=>i.add(i.dFdx()))).sub(n),kt(e(i=>i.add(i.dFdy()))).sub(n)).mul(t)}),C2=Mt(r=>{const{surf_pos:t,surf_norm:e,dHdxy:n}=r,i=t.dFdx().normalize(),s=t.dFdy().normalize(),o=e,a=s.cross(o),l=o.cross(i),c=i.dot(a).mul(PM),h=c.sign().mul(n.x.mul(a).add(n.y.mul(l)));return c.abs().mul(e).sub(h).normalize()});class N2 extends xn{static get type(){return"BumpMapNode"}constructor(t,e=null){super("vec3"),this.textureNode=t,this.scaleNode=e}setup(){const t=this.scaleNode!==null?this.scaleNode:1,e=E2({textureNode:this.textureNode,bumpScale:t});return C2({surf_pos:hn,surf_norm:_i,dHdxy:e})}}const R2=De(N2).setParameterLength(1,2),ry=new Map;class vt extends Bt{static get type(){return"MaterialNode"}constructor(t){super(),this.scope=t}getCache(t,e){let n=ry.get(t);return n===void 0&&(n=qo(t,e),ry.set(t,n)),n}getFloat(t){return this.getCache(t,"float")}getColor(t){return this.getCache(t,"color")}getTexture(t){return this.getCache(t==="map"?"map":t+"Map","texture")}setup(t){const e=t.context.material,n=this.scope;let i=null;if(n===vt.COLOR){const s=e.color!==void 0?this.getColor(n):Pt();e.map&&e.map.isTexture===!0?i=s.mul(this.getTexture("map")):i=s}else if(n===vt.OPACITY){const s=this.getFloat(n);e.alphaMap&&e.alphaMap.isTexture===!0?i=s.mul(this.getTexture("alpha")):i=s}else if(n===vt.SPECULAR_STRENGTH)e.specularMap&&e.specularMap.isTexture===!0?i=this.getTexture("specular").r:i=kt(1);else if(n===vt.SPECULAR_INTENSITY){const s=this.getFloat(n);e.specularIntensityMap&&e.specularIntensityMap.isTexture===!0?i=s.mul(this.getTexture(n).a):i=s}else if(n===vt.SPECULAR_COLOR){const s=this.getColor(n);e.specularColorMap&&e.specularColorMap.isTexture===!0?i=s.mul(this.getTexture(n).rgb):i=s}else if(n===vt.ROUGHNESS){const s=this.getFloat(n);e.roughnessMap&&e.roughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).g):i=s}else if(n===vt.METALNESS){const s=this.getFloat(n);e.metalnessMap&&e.metalnessMap.isTexture===!0?i=s.mul(this.getTexture(n).b):i=s}else if(n===vt.EMISSIVE){const s=this.getFloat("emissiveIntensity"),o=this.getColor(n).mul(s);e.emissiveMap&&e.emissiveMap.isTexture===!0?i=o.mul(this.getTexture(n)):i=o}else if(n===vt.NORMAL)e.normalMap?(i=sy(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=e.normalMapType,(e.normalMap.format==ul||e.normalMap.format==CN||e.normalMap.format==EN)&&(i.unpackNormalMode=Xv)):e.bumpMap?i=R2(this.getTexture("bump").r,this.getFloat("bumpScale")):i=_i;else if(n===vt.CLEARCOAT){const s=this.getFloat(n);e.clearcoatMap&&e.clearcoatMap.isTexture===!0?i=s.mul(this.getTexture(n).r):i=s}else if(n===vt.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);e.clearcoatRoughnessMap&&e.clearcoatRoughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).r):i=s}else if(n===vt.CLEARCOAT_NORMAL)e.clearcoatNormalMap?i=sy(this.getTexture(n),this.getCache(n+"Scale","vec2")):i=_i;else if(n===vt.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));e.sheenColorMap&&e.sheenColorMap.isTexture===!0?i=s.mul(this.getTexture("sheenColor").rgb):i=s}else if(n===vt.SHEEN_ROUGHNESS){const s=this.getFloat(n);e.sheenRoughnessMap&&e.sheenRoughnessMap.isTexture===!0?i=s.mul(this.getTexture(n).a):i=s,i=i.clamp(1e-4,1)}else if(n===vt.ANISOTROPY)if(e.anisotropyMap&&e.anisotropyMap.isTexture===!0){const s=this.getTexture(n);i=rM(el.x,el.y,el.y.negate(),el.x).mul(s.rg.mul(2).sub(xe(1)).normalize().mul(s.b))}else i=el;else if(n===vt.IRIDESCENCE_THICKNESS){const s=tn("1","float",e.iridescenceThicknessRange);if(e.iridescenceThicknessMap){const o=tn("0","float",e.iridescenceThicknessRange);i=s.sub(o).mul(this.getTexture(n).g).add(o)}else i=s}else if(n===vt.TRANSMISSION){const s=this.getFloat(n);e.transmissionMap?i=s.mul(this.getTexture(n).r):i=s}else if(n===vt.THICKNESS){const s=this.getFloat(n);e.thicknessMap?i=s.mul(this.getTexture(n).g):i=s}else if(n===vt.IOR)i=this.getFloat(n);else if(n===vt.LIGHT_MAP)i=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===vt.AO)i=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===vt.LINE_DASH_OFFSET)i=e.dashOffset?this.getFloat(n):kt(0);else{const s=this.getNodeType(t);i=this.getCache(n,s)}return i}}vt.ALPHA_TEST="alphaTest";vt.COLOR="color";vt.OPACITY="opacity";vt.SHININESS="shininess";vt.SPECULAR="specular";vt.SPECULAR_STRENGTH="specularStrength";vt.SPECULAR_INTENSITY="specularIntensity";vt.SPECULAR_COLOR="specularColor";vt.REFLECTIVITY="reflectivity";vt.ROUGHNESS="roughness";vt.METALNESS="metalness";vt.NORMAL="normal";vt.CLEARCOAT="clearcoat";vt.CLEARCOAT_ROUGHNESS="clearcoatRoughness";vt.CLEARCOAT_NORMAL="clearcoatNormal";vt.EMISSIVE="emissive";vt.ROTATION="rotation";vt.SHEEN="sheen";vt.SHEEN_ROUGHNESS="sheenRoughness";vt.ANISOTROPY="anisotropy";vt.IRIDESCENCE="iridescence";vt.IRIDESCENCE_IOR="iridescenceIOR";vt.IRIDESCENCE_THICKNESS="iridescenceThickness";vt.IOR="ior";vt.TRANSMISSION="transmission";vt.THICKNESS="thickness";vt.ATTENUATION_DISTANCE="attenuationDistance";vt.ATTENUATION_COLOR="attenuationColor";vt.LINE_SCALE="scale";vt.LINE_DASH_SIZE="dashSize";vt.LINE_GAP_SIZE="gapSize";vt.LINE_WIDTH="linewidth";vt.LINE_DASH_OFFSET="dashOffset";vt.POINT_SIZE="size";vt.DISPERSION="dispersion";vt.LIGHT_MAP="light";vt.AO="ao";const I2=Ke(vt,vt.ALPHA_TEST),P2=Ke(vt,vt.COLOR),L2=Ke(vt,vt.EMISSIVE),F2=Ke(vt,vt.OPACITY),D2=Ke(vt,vt.NORMAL),U2=Ke(vt,vt.LIGHT_MAP),O2=Ke(vt,vt.AO),el=de(new Ge).onReference(function(r){return r.material}).onRenderUpdate(function({material:r}){this.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation))}),B2=Mt(r=>r.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class z2 extends Pa{static get type(){return"StorageArrayElementNode"}constructor(t,e){super(t,e),this.isStorageArrayElementNode=!0}set storageBufferNode(t){this.node=t}get storageBufferNode(){return this.node}getMemberType(t,e){const n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(t,e):"void"}setup(t){return t.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&t.setupPBO(this.node),super.setup(t)}generate(t,e){let n;const i=t.context.assign;if(t.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&i!==!0&&(this.node.value.isInstancedBufferAttribute||t.shaderStage!=="compute")?n=t.generatePBO(this):n=this.node.build(t):n=super.generate(t),i!==!0){const s=this.getNodeType(t);n=t.format(n,s,e)}return n}}const V2=De(z2).setParameterLength(2);class k2 extends bg{static get type(){return"StorageBufferNode"}constructor(t,e=null,n=0){let i,s=null;e&&e.isStruct?(i="struct",s=e.layout,(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(n=t.count)):e===null&&(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)?(i=nR(t.itemSize),n=t.count):i=e,super(t,i,n),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=vx.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,t.isStorageBufferAttribute!==!0&&t.isStorageInstancedBufferAttribute!==!0&&(t.isInstancedBufferAttribute?t.isStorageInstancedBufferAttribute=!0:t.isStorageBufferAttribute=!0)}getHash(t){if(this.bufferCount===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(t){return V2(this,t)}setPBO(t){return this.isPBO=t,this}getPBO(){return this.isPBO}setAccess(t){return this.access=t,this}toReadOnly(){return this.setAccess(vx.READ_ONLY)}setAtomic(t){return this.isAtomic=t,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=SM(this.value),this._varying=Fa(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(t){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(t);if(t.isAvailable("storageBuffer")||t.isAvailable("indirectStorageBuffer"))return super.getNodeType(t);const{attribute:e}=this.getAttributeData();return e.getNodeType(t)}getMemberType(t,e){return this.structTypeNode!==null?this.structTypeNode.getMemberType(t,e):"void"}generate(t){if(this.structTypeNode!==null&&this.structTypeNode.build(t),t.isAvailable("storageBuffer")||t.isAvailable("indirectStorageBuffer"))return super.generate(t);const{attribute:e,varying:n}=this.getAttributeData(),i=n.build(t);return t.registerTransform(i,e),i}}const oy=(r,t=null,e=0)=>new k2(r,t,e);class en extends Bt{static get type(){return"IndexNode"}constructor(t){super("uint"),this.scope=t,this.isIndexNode=!0}generate(t){const e=this.getNodeType(t),n=this.scope;let i;if(n===en.VERTEX)i=t.getVertexIndex();else if(n===en.INSTANCE)i=t.getInstanceIndex();else if(n===en.DRAW)i=t.getDrawIndex();else if(n===en.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(n===en.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(n===en.SUBGROUP)i=t.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return t.shaderStage==="vertex"||t.shaderStage==="compute"?s=i:s=Fa(this).build(t,e),s}}en.VERTEX="vertex";en.INSTANCE="instance";en.SUBGROUP="subgroup";en.INVOCATION_LOCAL="invocationLocal";en.INVOCATION_SUBGROUP="invocationSubgroup";en.DRAW="draw";const G2=Ke(en,en.VERTEX),Ml=Ke(en,en.INSTANCE),H2=Ke(en,en.DRAW);class W2 extends MM{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class X2 extends sr{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}class $2 extends Bt{static get type(){return"InstanceNode"}constructor(t,e,n=null){super("void"),this.count=t,this.instanceMatrix=e,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ue.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:t}=this;return t&&t.isStorageInstancedBufferAttribute===!0}get isStorageColor(){const{instanceColor:t}=this;return t&&t.isStorageInstancedBufferAttribute===!0}setup(t){let{instanceMatrixNode:e,instanceColorNode:n}=this;e===null&&(e=this._createInstanceMatrixNode(!0,t),this.instanceMatrixNode=e);const{instanceColor:i,isStorageColor:s}=this;if(i&&n===null){if(s)n=oy(i,"vec3",Math.max(i.count,1)).element(Ml);else{const a=new X2(i.array,3),l=i.usage===Op?Yx:qx;this.bufferColor=a,n=Pt(l(a,"vec3",3,0))}this.instanceColorNode=n}const o=e.mul(Xn).xyz;if(Xn.assign(o),t.needsPreviousData()&&ku.assign(this.getPreviousInstancedPosition(t)),t.hasGeometryAttribute("normal")){const a=JP(ls,e);ls.assign(a)}this.instanceColorNode!==null&&zu("vec3","vInstanceColor").assign(this.instanceColorNode)}update(t){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)),this.previousInstanceMatrixNode!==null&&t.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(t){const e=t.object;return this.previousInstanceMatrixNode===null&&(e.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,t)),this.previousInstanceMatrixNode.mul(ku).xyz}_createInstanceMatrixNode(t,e){let n;const{instanceMatrix:i}=this,{count:s}=i;if(this.isStorageMatrix)n=oy(i,"mat4",Math.max(s,1)).element(Ml);else if(s*16*4<=e.getUniformBufferLimit())n=EM(i.array,"mat4",Math.max(s,1)).element(Ml);else{const a=new W2(i.array,16,1);t===!0&&(this.buffer=a);const l=i.usage===Op?Yx:qx,c=[l(a,"vec4",16,0),l(a,"vec4",16,4),l(a,"vec4",16,8),l(a,"vec4",16,12)];n=Ud(...c)}return n}}class q2 extends $2{static get type(){return"InstancedMeshNode"}constructor(t){const{count:e,instanceMatrix:n,instanceColor:i}=t;super(e,n,i),this.instancedMesh=t}}const Y2=De(q2).setParameterLength(1);class Z2 extends Bt{static get type(){return"BatchNode"}constructor(t){super("void"),this.batchMesh=t,this.batchingIdNode=null}setup(t){this.batchingIdNode===null&&(t.getDrawIndex()===null?this.batchingIdNode=Ml:this.batchingIdNode=H2);const n=Mt(([p])=>{const x=Be(oa(li(this.batchMesh._indirectTexture),0).x).toConst(),g=Be(p).mod(x).toConst(),m=Be(p).div(x).toConst();return li(this.batchMesh._indirectTexture,ji(g,m)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Be(this.batchingIdNode)),i=this.batchMesh._matricesTexture,s=Be(oa(li(i),0).x).toConst(),o=kt(n).mul(4).toInt().toConst(),a=o.mod(s).toConst(),l=o.div(s).toConst(),c=Ud(li(i,ji(a,l)),li(i,ji(a.add(1),l)),li(i,ji(a.add(2),l)),li(i,ji(a.add(3),l))),h=this.batchMesh._colorsTexture;if(h!==null){const x=Mt(([g])=>{const m=Be(oa(li(h),0).x).toConst(),y=g,v=y.mod(m).toConst(),_=y.div(m).toConst();return li(h,ji(v,_)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);zu("vec3","vBatchColor").assign(x)}const u=yi(c);Xn.assign(c.mul(Xn));const d=ls.div(Pt(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;ls.assign(f),t.hasGeometryAttribute("tangent")&&Gu.mulAssign(u)}}const J2=De(Z2).setParameterLength(1),ay=new WeakMap;class j2 extends Bt{static get type(){return"SkinningNode"}constructor(t){super("void"),this.skinnedMesh=t,this.updateType=ue.OBJECT,this.skinIndexNode=Ma("skinIndex","uvec4"),this.skinWeightNode=Ma("skinWeight","vec4"),this.bindMatrixNode=tn("bindMatrix","mat4"),this.bindMatrixInverseNode=tn("bindMatrixInverse","mat4"),this.boneMatricesNode=ey("skeleton.boneMatrices","mat4",t.skeleton.bones.length),this.positionNode=Xn,this.toPositionNode=Xn,this.previousBoneMatricesNode=null}getSkinnedPosition(t=this.boneMatricesNode,e=this.positionNode){const{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:s,bindMatrixInverseNode:o}=this,a=t.element(n.x),l=t.element(n.y),c=t.element(n.z),h=t.element(n.w),u=s.mul(e),d=os(a.mul(i.x).mul(u),l.mul(i.y).mul(u),c.mul(i.z).mul(u),h.mul(i.w).mul(u));return o.mul(d).xyz}getSkinnedNormalAndTangent(t=this.boneMatricesNode,e=ls,n=Gu){const{skinIndexNode:i,skinWeightNode:s,bindMatrixNode:o,bindMatrixInverseNode:a}=this,l=t.element(i.x),c=t.element(i.y),h=t.element(i.z),u=t.element(i.w);let d=os(s.x.mul(l),s.y.mul(c),s.z.mul(h),s.w.mul(u));d=a.mul(d).mul(o);const f=d.transformDirection(e).xyz,p=d.transformDirection(n).xyz;return{skinNormal:f,skinTangent:p}}getPreviousSkinnedPosition(t){const e=t.object;return this.previousBoneMatricesNode===null&&(e.skeleton.previousBoneMatrices=new Float32Array(e.skeleton.boneMatrices),this.previousBoneMatricesNode=ey("skeleton.previousBoneMatrices","mat4",e.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,ku)}setup(t){t.needsPreviousData()&&ku.assign(this.getPreviousSkinnedPosition(t));const e=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(e),t.hasGeometryAttribute("normal")){const{skinNormal:n,skinTangent:i}=this.getSkinnedNormalAndTangent();ls.assign(n),t.hasGeometryAttribute("tangent")&&Gu.assign(i)}return e}generate(t,e){if(e!=="void")return super.generate(t,e)}update(t){const e=t.object&&t.object.skeleton?t.object.skeleton:this.skinnedMesh.skeleton;ay.get(e)!==t.frameId&&(ay.set(e,t.frameId),this.previousBoneMatricesNode!==null&&(e.previousBoneMatrices===null&&(e.previousBoneMatrices=new Float32Array(e.boneMatrices)),e.previousBoneMatrices.set(e.boneMatrices)),e.update())}}const K2=r=>new j2(r);class Q2 extends Bt{static get type(){return"LoopNode"}constructor(t=[]){super("void"),this.params=t}getVarName(t){return String.fromCharCode(105+t)}getProperties(t){const e=t.getNodeProperties(this);if(e.stackNode!==void 0)return e;const n={};for(let a=0,l=this.params.length-1;a<l;a++){const c=this.params[a],h=c.isNode!==!0&&c.name||this.getVarName(a),u=c.isNode!==!0&&c.type||"int";n[h]=Es(h,u)}const i=t.addStack(),s=this.params[this.params.length-1](n);e.returnsNode=s.context({nodeLoop:s}),e.stackNode=i;const o=this.params[0];if(o.isNode!==!0&&typeof o.update=="function"){const a=Mt(this.params[0].update)(n);e.updateNode=a.context({nodeLoop:a})}return t.removeStack(),e}setup(t){if(this.getProperties(t),t.fnCall){const e=t.getDataFromNode(t.fnCall.shaderNode);e.hasLoop=!0}}generate(t){const e=this.getProperties(t),n=this.params,i=e.stackNode;for(let o=0,a=n.length-1;o<a;o++){const l=n[o];let c=!1,h=null,u=null,d=null,f=null,p=null,x=null;l.isNode?l.getNodeType(t)==="bool"?(c=!0,f="bool",u=l.build(t,f)):(f="int",d=this.getVarName(o),h="0",u=l.build(t,f),p="<"):(f=l.type||"int",d=l.name||this.getVarName(o),h=l.start,u=l.end,p=l.condition,x=l.update,typeof h=="number"?h=t.generateConst(f,h):h&&h.isNode&&(h=h.build(t,f)),typeof u=="number"?u=t.generateConst(f,u):u&&u.isNode&&(u=u.build(t,f)),h!==void 0&&u===void 0?(h=h+" - 1",u="0",p=">="):u!==void 0&&h===void 0&&(h="0",p="<"),p===void 0&&(Number(h)>Number(u)?p=">=":p="<"));let g;if(c)g=`while ( ${u} )`;else{const m={start:h,end:u},y=m.start,v=m.end;let _;const w=()=>p.includes("<")?"+=":"-=";if(x!=null)switch(typeof x){case"function":_=t.flowStagesNode(e.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":_=d+" "+w()+" "+t.generateConst(f,x);break;case"string":_=d+" "+x;break;default:x.isNode?_=d+" "+w()+" "+x.build(t):(Ne("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),_="break /* invalid update */")}else f==="int"||f==="uint"?x=p.includes("<")?"++":"--":x=w()+" 1.",_=d+" "+x;const T=t.getVar(f,d)+" = "+y,E=d+" "+p+" "+v;g=`for ( ${T}; ${E}; ${_} )`}t.addFlowCode((o===0?`
|
|
4078
4078
|
`:"")+t.tab+g+` {
|
|
4079
4079
|
|
|
4080
4080
|
`).addFlowTab()}const s=i.build(t,"void");e.returnsNode.build(t,"void"),t.removeFlowTab().addFlowCode(`
|
|
4081
4081
|
`+t.tab+s);for(let o=0,a=this.params.length-1;o<a;o++)t.addFlowCode((o===0?"":t.tab)+`}
|
|
4082
4082
|
|
|
4083
|
-
`).removeFlowTab();t.addFlowTab()}}const tr=(...r)=>new Q2(sa(r,"int")).toStack();class t3 extends ni{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=gi,this.minFilter=gi,this.wrapR=ll,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}const Qf=new WeakMap,Kn=new Nn,cy=Mt(({bufferMap:r,influence:t,stride:e,width:n,depth:i,offset:s})=>{const o=Be(G2).mul(e).add(s),a=o.div(n),l=o.sub(a.mul(n));return li(r,ji(l,a)).depth(i).xyz.mul(t)});function e3(r){const t=r.morphAttributes.position!==void 0,e=r.morphAttributes.normal!==void 0,n=r.morphAttributes.color!==void 0,i=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,s=i!==void 0?i.length:0;let o=Qf.get(r);if(o===void 0||o.count!==s){let m=function(){x.dispose(),Qf.delete(r),r.removeEventListener("dispose",m)};o!==void 0&&o.texture.dispose();const a=r.morphAttributes.position||[],l=r.morphAttributes.normal||[],c=r.morphAttributes.color||[];let h=0;t===!0&&(h=1),e===!0&&(h=2),n===!0&&(h=3);let u=r.attributes.position.count*h,d=1;const f=4096;u>f&&(d=Math.ceil(u/f),u=f);const p=new Float32Array(u*d*4*s),x=new t3(p,u,d,s);x.type=Wv,x.needsUpdate=!0;const g=h*4;for(let y=0;y<s;y++){const v=a[y],_=l[y],w=c[y],T=u*d*4*y;for(let E=0;E<v.count;E++){const M=E*g;t===!0&&(Kn.fromBufferAttribute(v,E),p[T+M+0]=Kn.x,p[T+M+1]=Kn.y,p[T+M+2]=Kn.z,p[T+M+3]=0),e===!0&&(Kn.fromBufferAttribute(_,E),p[T+M+4]=Kn.x,p[T+M+5]=Kn.y,p[T+M+6]=Kn.z,p[T+M+7]=0),n===!0&&(Kn.fromBufferAttribute(w,E),p[T+M+8]=Kn.x,p[T+M+9]=Kn.y,p[T+M+10]=Kn.z,p[T+M+11]=w.itemSize===4?Kn.w:1)}}o={count:s,texture:x,stride:h,size:new Ge(u,d)},Qf.set(r,o),r.addEventListener("dispose",m)}return o}class n3 extends Bt{static get type(){return"MorphNode"}constructor(t){super("void"),this.mesh=t,this.morphBaseInfluence=de(1),this.updateType=ue.OBJECT}setup(t){const{geometry:e}=t,n=e.morphAttributes.position!==void 0,i=e.hasAttribute("normal")&&e.morphAttributes.normal!==void 0,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,o=s!==void 0?s.length:0,{texture:a,stride:l,size:c}=e3(e);n===!0&&Xn.mulAssign(this.morphBaseInfluence),i===!0&&ls.mulAssign(this.morphBaseInfluence);const h=Be(c.width);tr(o,({i:u})=>{const d=kt(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(li(this.mesh.morphTexture,ji(Be(u).add(1),Be(Ml))).r):d.assign(tn("morphTargetInfluences","float").element(u).toVar()),hi(d.notEqual(0),()=>{n===!0&&Xn.addAssign(cy({bufferMap:a,influence:d,stride:l,width:h,depth:u,offset:Be(0)})),i===!0&&ls.addAssign(cy({bufferMap:a,influence:d,stride:l,width:h,depth:u,offset:Be(1)}))})})}update(){const t=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?t.value=1:t.value=1-this.mesh.morphTargetInfluences.reduce((e,n)=>e+n,0)}}const i3=De(n3).setParameterLength(1);class Ig extends Bt{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class s3 extends Ig{static get type(){return"AONode"}constructor(t=null){super(),this.aoNode=t}setup(t){t.context.ambientOcclusion.mulAssign(this.aoNode)}}class r3 extends xM{static get type(){return"LightingContextNode"}constructor(t,e=null,n=null,i=null){super(t),this.lightingModel=e,this.backdropNode=n,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:t,backdropAlphaNode:e}=this,n=Pt().toVar("directDiffuse"),i=Pt().toVar("directSpecular"),s=Pt().toVar("indirectDiffuse"),o=Pt().toVar("indirectSpecular"),a={directDiffuse:n,directSpecular:i,indirectDiffuse:s,indirectSpecular:o};return{radiance:Pt().toVar("radiance"),irradiance:Pt().toVar("irradiance"),iblIrradiance:Pt().toVar("iblIrradiance"),ambientOcclusion:kt(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:t,backdropAlpha:e}}setup(t){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||t.context.lightingModel,super.setup(t)}}const o3=De(r3);class a3 extends Ig{static get type(){return"IrradianceNode"}constructor(t){super(),this.node=t}setup(t){t.context.irradiance.addAssign(this.node)}}class l3 extends ni{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=gi,this.minFilter=gi,this.generateMipmaps=!1,this.needsUpdate=!0}}const zo=new Ge;class c3 extends Hd{static get type(){return"ViewportTextureNode"}constructor(t=wg,e=null,n=null){let i=null;n===null?(i=new l3,i.minFilter=Gv,n=i):i=n,super(n,t,e),this.generateMipmaps=!1,this.defaultFramebuffer=i,this.isOutputTextureNode=!0,this.updateBeforeType=ue.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(t=null){let e,n;if(this.referenceNode?(e=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(e=this.defaultFramebuffer,n=this._cacheTextures),t===null)return e;if(n.has(t)===!1){const i=e.clone();n.set(t,i)}return n.get(t)}updateReference(t){const e=t.renderer.getRenderTarget();return this.value=this.getTextureForReference(e),this.value}updateBefore(t){const e=t.renderer,n=e.getRenderTarget();n===null?e.getDrawingBufferSize(zo):zo.set(n.width,n.height);const i=this.getTextureForReference(n);(i.image.width!==zo.width||i.image.height!==zo.height)&&(i.image.width=zo.width,i.image.height=zo.height,i.needsUpdate=!0);const s=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,e.copyFramebufferToTexture(i),i.generateMipmaps=s}clone(){const t=new this.constructor(this.uvNode,this.levelNode,this.value);return t.generateMipmaps=this.generateMipmaps,t}}class Pc extends ni{constructor(t,e,n=ng,i,s,o,a=gi,l=gi,c,h=Up,u=1){if(h!==Up&&h!==AN)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,i,s,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ng(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}let zh=null;class h3 extends c3{static get type(){return"ViewportDepthTextureNode"}constructor(t=wg,e=null){zh===null&&(zh=new Pc),super(t,e,zh)}getTextureForReference(){return zh}}const u3=De(h3).setParameterLength(0,2);class $n extends Bt{static get type(){return"ViewportDepthNode"}constructor(t,e=null){super("float"),this.scope=t,this.valueNode=e,this.isViewportDepthNode=!0}generate(t){const{scope:e}=this;return e===$n.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){const{scope:e}=this,n=this.valueNode;let i=null;if(e===$n.DEPTH_BASE)n!==null&&(i=qM().assign(n));else if(e===$n.DEPTH)t.isPerspectiveCamera?i=WM(hn.z,Or,Br):i=Sl(hn.z,Or,Br);else if(e===$n.LINEAR_DEPTH)if(n!==null)if(t.isPerspectiveCamera){const s=XM(n,Or,Br);i=Sl(s,Or,Br)}else i=n;else i=Sl(hn.z,Or,Br);return i}}$n.DEPTH_BASE="depthBase";$n.DEPTH="depth";$n.LINEAR_DEPTH="linearDepth";const Sl=(r,t,e)=>r.add(t).div(t.sub(e)),WM=(r,t,e)=>t.add(r).mul(e).div(e.sub(t).mul(r)),d3=(r,t,e)=>t.mul(r.add(e)).div(r.mul(t.sub(e))),XM=Mt(([r,t,e],n)=>n.renderer.reversedDepthBuffer===!0?t.mul(e).div(t.sub(e).mul(r).sub(t)):t.mul(e).div(e.sub(t).mul(r).sub(e))),$M=(r,t,e)=>{t=t.max(1e-6).toVar();const n=$r(r.negate().div(t)),i=$r(e.div(t));return n.div(i)},qM=De($n,$n.DEPTH_BASE),YM=Ke($n,$n.DEPTH),f3=De($n,$n.LINEAR_DEPTH).setParameterLength(0,1);u3();YM.assign=r=>qM(r);class pi extends Bt{static get type(){return"ClippingNode"}constructor(t=pi.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);const e=t.clippingContext,{intersectionPlanes:n,unionPlanes:i}=e;return this.hardwareClipping=t.material.hardwareClipping,this.scope===pi.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,i):this.scope===pi.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(n,i)}setupAlphaToCoverage(t,e){return Mt(()=>{const n=kt().toVar("distanceToPlane"),i=kt().toVar("distanceToGradient"),s=kt(1).toVar("clipOpacity"),o=e.length;if(this.hardwareClipping===!1&&o>0){const l=Qi(e).setGroup(te);tr(o,({i:c})=>{const h=l.element(c);n.assign(hn.dot(h.xyz).negate().add(h.w)),i.assign(n.fwidth().div(2)),s.mulAssign(hc(i.negate(),i,n))})}const a=t.length;if(a>0){const l=Qi(t).setGroup(te),c=kt(1).toVar("intersectionClipOpacity");tr(a,({i:h})=>{const u=l.element(h);n.assign(hn.dot(u.xyz).negate().add(u.w)),i.assign(n.fwidth().div(2)),c.mulAssign(hc(i.negate(),i,n).oneMinus())}),s.mulAssign(c.oneMinus())}Hn.a.mulAssign(s),Hn.a.equal(0).discard()})()}setupDefault(t,e){return Mt(()=>{const n=e.length;if(this.hardwareClipping===!1&&n>0){const s=Qi(e).setGroup(te);tr(n,({i:o})=>{const a=s.element(o);hn.dot(a.xyz).greaterThan(a.w).discard()})}const i=t.length;if(i>0){const s=Qi(t).setGroup(te),o=pg(!0).toVar("clipped");tr(i,({i:a})=>{const l=s.element(a);o.assign(hn.dot(l.xyz).greaterThan(l.w).and(o))}),o.discard()}})()}setupHardwareClipping(t,e){const n=t.length;return e.enableHardwareClipping(n),Mt(()=>{const i=Qi(t).setGroup(te),s=Bd(e.getClipDistance());tr(n,({i:o})=>{const a=i.element(o),l=hn.dot(a.xyz).sub(a.w).negate();s.element(o).assign(l)})})()}}pi.ALPHA_TO_COVERAGE="alphaToCoverage";pi.DEFAULT="default";pi.HARDWARE="hardware";const p3=()=>new pi,m3=()=>new pi(pi.ALPHA_TO_COVERAGE),g3=()=>new pi(pi.HARDWARE),x3=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],tp=new WeakMap;class y3{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=x3,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1?(this.getRenderObjectData(t),!0):!1}needsVelocity(t){const e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){const{geometry:n,material:i,object:s}=t;if(e={material:this.getMaterialData(i),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexId:n.index?n.index.id:null,indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:s.matrixWorld.clone()},s.center&&(e.center=s.center.clone()),s.morphTargetInfluences&&(e.morphTargetInfluences=s.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),e.material.transmission>0){const{width:o,height:a}=t.context;e.bufferWidth=o,e.bufferHeight=a}e.lights=this.getLightsData(t.lightsNode.getLights()),this.renderObjects.set(t,e)}return e}getAttributesData(t){const e={};for(const n in t){const i=t[n];e[n]={id:i.id,version:i.version}}return e}containsNode(t){const e=t.material;for(const n in e)if(e[n]&&e[n].isNode)return!0;return!!(t.context.modelViewMatrix||t.context.modelNormalViewMatrix||t.context.getAO||t.context.getShadow)}getMaterialData(t){const e={};for(const n of this.refreshUniforms){const i=t[n];i!=null&&(typeof i=="object"&&i.clone!==void 0?i.isTexture===!0?e[n]={id:i.id,version:i.version}:e[n]=i.clone():e[n]=i)}return e}equals(t,e){const{object:n,material:i,geometry:s}=t,o=this.getRenderObjectData(t);if(o.worldMatrix.equals(n.matrixWorld)!==!0)return o.worldMatrix.copy(n.matrixWorld),!1;const a=o.material;for(const y in a){const v=a[y],_=i[y];if(v.equals!==void 0){if(v.equals(_)===!1)return v.copy(_),!1}else if(_.isTexture===!0){if(v.id!==_.id||v.version!==_.version)return v.id=_.id,v.version=_.version,!1}else if(v!==_)return a[y]=_,!1}if(a.transmission>0){const{width:y,height:v}=t.context;if(o.bufferWidth!==y||o.bufferHeight!==v)return o.bufferWidth=y,o.bufferHeight=v,!1}const l=o.geometry,c=s.attributes,h=l.attributes,u=Object.keys(h),d=Object.keys(c);if(l.id!==s.id)return l.id=s.id,!1;if(u.length!==d.length)return o.geometry.attributes=this.getAttributesData(c),!1;for(const y of u){const v=h[y],_=c[y];if(_===void 0)return delete h[y],!1;if(v.id!==_.id||v.version!==_.version)return v.id=_.id,v.version=_.version,!1}const f=s.index,p=l.indexId,x=l.indexVersion,g=f?f.id:null,m=f?f.version:null;if(p!==g||x!==m)return l.indexId=g,l.indexVersion=m,!1;if(l.drawRange.start!==s.drawRange.start||l.drawRange.count!==s.drawRange.count)return l.drawRange.start=s.drawRange.start,l.drawRange.count=s.drawRange.count,!1;if(o.morphTargetInfluences){let y=!1;for(let v=0;v<o.morphTargetInfluences.length;v++)o.morphTargetInfluences[v]!==n.morphTargetInfluences[v]&&(o.morphTargetInfluences[v]=n.morphTargetInfluences[v],y=!0);if(y)return!1}if(o.lights){for(let y=0;y<e.length;y++)if(o.lights[y].map!==e[y].map)return!1}return o.center&&o.center.equals(n.center)===!1?(o.center.copy(n.center),!0):(t.bundle!==null&&(o.version=t.bundle.version),!0)}getLightsData(t){const e=[];for(const n of t)n.isSpotLight===!0&&n.map!==null&&e.push({map:n.map.version});return e}getLights(t,e){if(tp.has(t)){const i=tp.get(t);if(i.renderId===e)return i.lightsData}const n=this.getLightsData(t.getLights());return tp.set(t,{renderId:e,lightsData:n}),n}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;const{renderId:n}=e;if(this.renderId!==n)return this.renderId=n,!0;const i=t.object.static===!0,s=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;if(i||s)return!1;const o=this.getLights(t.lightsNode,n);return this.equals(t,o)!==!0}}const _3=.05,hy=Mt(([r])=>Qr(Ve(1e4,ac(Ve(17,r.x).add(Ve(.1,r.y)))).mul(os(.1,Nc(ac(Ve(13,r.y).add(r.x))))))),uy=Mt(([r])=>hy(xe(hy(r.xy),r.z))),v3=Mt(([r])=>{const t=as(Vu(pM(r.xyz)),Vu(mM(r.xyz))),e=kt(1).div(kt(_3).mul(t)).toVar("pixScale"),n=xe(kp(hu($r(e))),kp(cM($r(e)))),i=xe(uy(hu(n.x.mul(r.xyz))),uy(hu(n.y.mul(r.xyz)))),s=Qr($r(e)),o=os(Ve(s.oneMinus(),i.x),Ve(s,i.y)),a=lc(s,s.oneMinus()),l=Pt(o.mul(o).div(Ve(2,a).mul(Wn(1,a))),o.sub(Ve(.5,a)).div(Wn(1,a)),Wn(1,Wn(1,o).mul(Wn(1,o)).div(Ve(2,a).mul(Wn(1,a))))),c=o.lessThan(a.oneMinus()).select(o.lessThan(a).select(l.x,l.y),l.z);return _a(c,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class M3 extends AM{static get type(){return"VertexColorNode"}constructor(t){super(null,"vec4"),this.isVertexColorNode=!0,this.index=t}getAttributeName(){const t=this.index;return"color"+(t>0?t:"")}generate(t){const e=this.getAttributeName(t),n=t.hasGeometryAttribute(e);let i;return n===!0?i=super.generate(t):i=t.generateConst(this.nodeType,new Nn(1,1,1,1)),i}serialize(t){super.serialize(t),t.index=this.index}deserialize(t){super.deserialize(t),this.index=t.index}}const S3=(r=0)=>new M3(r),b3=Mt(([r])=>zn(r.rgb.mul(r.a),r.a),{color:"vec4",return:"vec4"});class qp extends Wp{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(t){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const t=[];for(const e of Object.getOwnPropertyNames(this)){if(e.startsWith("_")===!0)continue;const n=this[e];n&&n.isNode===!0&&t.push({property:e,childNode:n})}return t}customProgramCacheKey(){const t=[];for(const{property:e,childNode:n}of this._getNodeChildren())t.push(ag(e.slice(0,-4)),n.getCacheKey());return this.type+Zv(t)}build(t){this.setup(t)}setupObserver(t){return new y3(t)}setup(t){t.context.setupNormal=()=>vl(this.setupNormal(t),"NORMAL","vec3"),t.context.setupPositionView=()=>this.setupPositionView(t),t.context.setupModelViewProjection=()=>this.setupModelViewProjection(t);const e=t.renderer,n=e.getRenderTarget();e.contextNode.isContextNode===!0?t.context={...t.context,...e.contextNode.getFlowContextData()}:Ne('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?t.context={...t.context,...this.contextNode.getFlowContextData()}:Ne('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),t.addStack();const i=this.setupVertex(t),s=vl(this.vertexNode||i,"VERTEX");t.context.clipSpace=s,t.stack.outputNode=s,this.setupHardwareClipping(t),this.geometryNode!==null&&(t.stack.outputNode=t.stack.outputNode.bypass(this.geometryNode)),t.addFlow("vertex",t.removeStack()),t.addStack();let o;const a=this.setupClipping(t);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(t):e.depth===!0&&this.setupDepth(t)),this.fragmentNode===null){this.setupDiffuseColor(t),this.setupVariants(t);const l=this.setupLighting(t);a!==null&&t.stack.addToStack(a);const c=zn(l,Hn.a).max(0);o=this.setupOutput(t,c),Wf.assign(o);const h=this.outputNode!==null;if(h&&(o=this.outputNode),t.context.getOutput&&(o=t.context.getOutput(o,t)),n!==null){const u=e.getMRT(),d=this.mrtNode;u!==null?(h&&Wf.assign(o),o=u,d!==null&&(o=u.merge(d))):d!==null&&(o=d)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=zn(l)),o=this.setupOutput(t,l)}t.stack.outputNode=o,t.addFlow("fragment",t.removeStack()),t.observer=this.setupObserver(t)}setupClipping(t){if(t.clippingContext===null)return null;const{unionPlanes:e,intersectionPlanes:n}=t.clippingContext;let i=null;if(e.length>0||n.length>0){const s=t.renderer.currentSamples;this.alphaToCoverage&&s>1?i=m3():t.stack.addToStack(p3())}return i}setupHardwareClipping(t){if(this.hardwareClipping=!1,t.clippingContext===null)return;const e=t.clippingContext.unionPlanes.length;e>0&&e<=8&&t.isAvailable("clipDistance")&&(t.stack.addToStack(g3()),this.hardwareClipping=!0)}setupDepth(t){const{renderer:e,camera:n}=t;let i=this.depthNode;if(i===null){const s="getMRT"in e&&e.getMRT();s&&s.has("depth")?i=s.get("depth"):e.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?i=$M(hn.z,Or,Br):i=Sl(hn.z,Or,Br))}i!==null&&YM.assign(i).toStack()}setupPositionView(){return NM.mul(Xn).xyz}setupModelViewProjection(){return BP.mul(hn)}setupVertex(t){return t.addStack(),this.setupPosition(t),t.context.position=t.removeStack(),B2}setupPosition(t){const{object:e,geometry:n}=t;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&i3(e).toStack(),e.isSkinnedMesh===!0&&K2(e).toStack(),this.displacementMap){const i=qo("displacementMap","texture"),s=qo("displacementScale","float"),o=qo("displacementBias","float");Xn.addAssign(ls.normalize().mul(i.x.mul(s).add(o)))}return e.isBatchedMesh&&J2(e).toStack(),e.isInstancedMesh&&e.instanceMatrix&&e.instanceMatrix.isInstancedBufferAttribute===!0&&Y2(e).toStack(),this.positionNode!==null&&Xn.assign(vl(this.positionNode,"POSITION","vec3")),Xn}setupDiffuseColor(t){const{object:e,geometry:n}=t;this.maskNode!==null&&pg(this.maskNode).not().discard();let i=this.colorNode?zn(this.colorNode):P2;this.vertexColors===!0&&n.hasAttribute("color")&&(i=i.mul(S3())),e.instanceColor&&(i=zu("vec3","vInstanceColor").mul(i)),e.isBatchedMesh&&e._colorsTexture&&(i=zu("vec3","vBatchColor").mul(i)),Hn.assign(i);const s=this.opacityNode?kt(this.opacityNode):F2;Hn.a.assign(Hn.a.mul(s));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?kt(this.alphaTestNode):I2,this.alphaToCoverage===!0?(Hn.a=hc(o,o.add(gM(Hn.a)),Hn.a),Hn.a.lessThanEqual(0).discard()):Hn.a.lessThanEqual(o).discard()),this.alphaHash===!0&&Hn.a.lessThan(v3(Xn)).discard(),t.isOpaque()&&Hn.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Pt(0):Hn.rgb}setupNormal(){return this.normalNode?Pt(this.normalNode):D2}setupEnvironment(){let t=null;return this.envNode?t=this.envNode:this.envMap&&(t=this.envMap.isCubeTexture?qo("envMap","cubeTexture"):qo("envMap","texture")),t}setupLightMap(t){let e=null;return t.material.lightMap&&(e=new a3(U2)),e}setupLights(t){const e=[],n=this.setupEnvironment(t);n&&n.isLightingNode&&e.push(n);const i=this.setupLightMap(t);i&&i.isLightingNode&&e.push(i);let s=this.aoNode;s===null&&t.material.aoMap&&(s=O2),t.context.getAO&&(s=t.context.getAO(s,t)),s&&e.push(new s3(s));let o=this.lightsNode||t.lightsNode;return e.length>0&&(o=t.renderer.lighting.createNode([...o.getLights(),...e])),o}setupLightingModel(){}setupLighting(t){const{material:e}=t,{backdropNode:n,backdropAlphaNode:i,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(t):null;let l=this.setupOutgoingLight(t);if(a&&a.getScope().hasLights){const c=this.setupLightingModel(t)||null;l=o3(a,c,n,i)}else n!==null&&(l=Pt(i!==null?Dn(l,n,i):n));return(s&&s.isNode===!0||e.emissive&&e.emissive.isColor===!0)&&(Xx.assign(Pt(s||L2)),l=l.add(Xx)),l}setupFog(t,e){const n=t.fogNode;return n&&(Wf.assign(e),e=zn(n.toVar())),e}setupPremultipliedAlpha(t,e){return b3(e)}setupOutput(t,e){return this.fog===!0&&(e=this.setupFog(t,e)),this.premultipliedAlpha===!0&&(e=this.setupPremultipliedAlpha(t,e)),e}setDefaultValues(t){for(const n in t){const i=t[n];this[n]===void 0&&(this[n]=i,i&&i.clone&&(this[n]=i.clone()))}const e=Object.getOwnPropertyDescriptors(t.constructor.prototype);for(const n in e)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&e[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,e[n])}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{},nodes:{}});const n=Wp.prototype.toJSON.call(this,t);n.inputNodes={};for(const{property:s,childNode:o}of this._getNodeChildren())n.inputNodes[s]=o.toJSON(t).uuid;function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images),a=i(t.nodes);s.length>0&&(n.textures=s),o.length>0&&(n.images=o),a.length>0&&(n.nodes=a)}return n}copy(t){return this.lightsNode=t.lightsNode,this.envNode=t.envNode,this.aoNode=t.aoNode,this.colorNode=t.colorNode,this.normalNode=t.normalNode,this.opacityNode=t.opacityNode,this.backdropNode=t.backdropNode,this.backdropAlphaNode=t.backdropAlphaNode,this.alphaTestNode=t.alphaTestNode,this.maskNode=t.maskNode,this.maskShadowNode=t.maskShadowNode,this.positionNode=t.positionNode,this.geometryNode=t.geometryNode,this.depthNode=t.depthNode,this.receivedShadowPositionNode=t.receivedShadowPositionNode,this.castShadowPositionNode=t.castShadowPositionNode,this.receivedShadowNode=t.receivedShadowNode,this.castShadowNode=t.castShadowNode,this.outputNode=t.outputNode,this.mrtNode=t.mrtNode,this.fragmentNode=t.fragmentNode,this.vertexNode=t.vertexNode,this.contextNode=t.contextNode,super.copy(t)}}class ZM extends Ra{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rc,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Nn(0,0,t,e),this.scissorTest=!1,this.viewport=new Nn(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},s=new ni(i),o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){const e={minFilter:rc,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new Ng(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class T3{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let w3=0;const dy=new H,Vo=new Na,vs=new ke,Vh=new H,el=new H,A3=new H,E3=new Na,fy=new H(1,0,0),py=new H(0,1,0),my=new H(0,0,1),gy={type:"added"},C3={type:"removed"},ko={type:"childadded",child:null},ep={type:"childremoved",child:null};class Cn extends Ra{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:w3++}),this.uuid=Ps(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Cn.DEFAULT_UP.clone();const t=new H,e=new Ua,n=new Na,i=new H(1,1,1);function s(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ke},normalMatrix:{value:new Mi}}),this.matrix=new ke,this.matrixWorld=new ke,this.matrixAutoUpdate=Cn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Cn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new T3,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Vo.setFromAxisAngle(t,e),this.quaternion.multiply(Vo),this}rotateOnWorldAxis(t,e){return Vo.setFromAxisAngle(t,e),this.quaternion.premultiply(Vo),this}rotateX(t){return this.rotateOnAxis(fy,t)}rotateY(t){return this.rotateOnAxis(py,t)}rotateZ(t){return this.rotateOnAxis(my,t)}translateOnAxis(t,e){return dy.copy(t).applyQuaternion(this.quaternion),this.position.add(dy.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(fy,t)}translateY(t){return this.translateOnAxis(py,t)}translateZ(t){return this.translateOnAxis(my,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(vs.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Vh.copy(t):Vh.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),el.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vs.lookAt(el,Vh,this.up):vs.lookAt(Vh,el,this.up),this.quaternion.setFromRotationMatrix(vs),i&&(vs.extractRotation(i.matrixWorld),Vo.setFromRotationMatrix(vs),this.quaternion.premultiply(Vo.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Ne("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(gy),ko.child=t,this.dispatchEvent(ko),ko.child=null):Ne("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(C3),ep.child=t,this.dispatchEvent(ep),ep.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),vs.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),vs.multiply(t.parent.matrixWorld)),t.applyMatrix4(vs),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(gy),ko.child=t,this.dispatchEvent(ko),ko.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(el,t,A3),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(el,E3,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,i=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*i,s[13]+=n-s[1]*e-s[5]*n-s[9]*i,s[14]+=i-s[2]*e-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(t.shapes,u)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),h=o(t.images),u=o(t.shapes),d=o(t.skeletons),f=o(t.animations),p=o(t.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}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),t.pivot!==null&&(this.pivot=t.pivot.clone()),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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}}Cn.DEFAULT_UP=new H(0,1,0);Cn.DEFAULT_MATRIX_AUTO_UPDATE=!0;Cn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const kh=new H,Gh=new Na,Ji=new H;class JM extends Cn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ke,this.projectionMatrix=new ke,this.projectionMatrixInverse=new ke,this.coordinateSystem=ns,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(kh,Gh,Ji),Ji.x===1&&Ji.y===1&&Ji.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(kh,Gh,Ji.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose(kh,Gh,Ji),Ji.x===1&&Ji.y===1&&Ji.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(kh,Gh,Ji.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Js=new H,xy=new Ge,yy=new Ge;class jM extends JM{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=oc*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(xl*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return oc*2*Math.atan(Math.tan(xl*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Js.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Js.x,Js.y).multiplyScalar(-t/Js.z),Js.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Js.x,Js.y).multiplyScalar(-t/Js.z)}getViewSize(t,e){return this.getViewBounds(t,xy,yy),e.subVectors(yy,xy)}setViewOffset(t,e,n,i,s,o){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(xl*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,e-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}let N3=0;const ai=new ke,np=new Cn,Go=new H,Qn=new Ic,nl=new Ic,ln=new H;class Wd extends Ra{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:N3++}),this.uuid=Ps(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(PN(t)?xP:gP)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Mi().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return ai.makeRotationFromQuaternion(t),this.applyMatrix4(ai),this}rotateX(t){return ai.makeRotationX(t),this.applyMatrix4(ai),this}rotateY(t){return ai.makeRotationY(t),this.applyMatrix4(ai),this}rotateZ(t){return ai.makeRotationZ(t),this.applyMatrix4(ai),this}translate(t,e,n){return ai.makeTranslation(t,e,n),this.applyMatrix4(ai),this}scale(t,e,n){return ai.makeScale(t,e,n),this.applyMatrix4(ai),this}lookAt(t){return np.lookAt(t),np.updateMatrix(),this.applyMatrix4(np.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Go).negate(),this.translate(Go.x,Go.y,Go.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let i=0,s=t.length;i<s;i++){const o=t[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Hp(n,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&ne("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ic);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ne("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const s=e[n];Qn.setFromBufferAttribute(s),this.morphTargetsRelative?(ln.addVectors(this.boundingBox.min,Qn.min),this.boundingBox.expandByPoint(ln),ln.addVectors(this.boundingBox.max,Qn.max),this.boundingBox.expandByPoint(ln)):(this.boundingBox.expandByPoint(Qn.min),this.boundingBox.expandByPoint(Qn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ne('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zd);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ne("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new H,1/0);return}if(t){const n=this.boundingSphere.center;if(Qn.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];nl.setFromBufferAttribute(a),this.morphTargetsRelative?(ln.addVectors(Qn.min,nl.min),Qn.expandByPoint(ln),ln.addVectors(Qn.max,nl.max),Qn.expandByPoint(ln)):(Qn.expandByPoint(nl.min),Qn.expandByPoint(nl.max))}Qn.getCenter(n);let i=0;for(let s=0,o=t.count;s<o;s++)ln.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(ln));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)ln.fromBufferAttribute(a,c),l&&(Go.fromBufferAttribute(t,c),ln.add(Go)),i=Math.max(i,n.distanceToSquared(ln))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ne('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Ne("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new sr(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let M=0;M<n.count;M++)a[M]=new H,l[M]=new H;const c=new H,h=new H,u=new H,d=new Ge,f=new Ge,p=new Ge,x=new H,g=new H;function m(M,b,P){c.fromBufferAttribute(n,M),h.fromBufferAttribute(n,b),u.fromBufferAttribute(n,P),d.fromBufferAttribute(s,M),f.fromBufferAttribute(s,b),p.fromBufferAttribute(s,P),h.sub(c),u.sub(c),f.sub(d),p.sub(d);const N=1/(f.x*p.y-p.x*f.y);isFinite(N)&&(x.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(N),g.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(N),a[M].add(x),a[b].add(x),a[P].add(x),l[M].add(g),l[b].add(g),l[P].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let M=0,b=y.length;M<b;++M){const P=y[M],N=P.start,L=P.count;for(let U=N,V=N+L;U<V;U+=3)m(t.getX(U+0),t.getX(U+1),t.getX(U+2))}const v=new H,_=new H,w=new H,T=new H;function E(M){w.fromBufferAttribute(i,M),T.copy(w);const b=a[M];v.copy(b),v.sub(w.multiplyScalar(w.dot(b))).normalize(),_.crossVectors(T,b);const N=_.dot(l[M])<0?-1:1;o.setXYZW(M,v.x,v.y,v.z,N)}for(let M=0,b=y.length;M<b;++M){const P=y[M],N=P.start,L=P.count;for(let U=N,V=N+L;U<V;U+=3)E(t.getX(U+0)),E(t.getX(U+1)),E(t.getX(U+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new sr(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new H,s=new H,o=new H,a=new H,l=new H,c=new H,h=new H,u=new H;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),x=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,x),o.fromBufferAttribute(e,g),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),a.fromBufferAttribute(n,p),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,g),a.add(h),l.add(h),c.add(h),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ln.fromBufferAttribute(t,e),ln.normalize(),t.setXYZ(e,ln.x,ln.y,ln.z)}toNonIndexed(){function t(a,l){const c=a.array,h=a.itemSize,u=a.normalized,d=new c.constructor(l.length*h);let f=0,p=0;for(let x=0,g=l.length;x<g;x++){a.isInterleavedBufferAttribute?f=l[x]*a.data.stride+a.offset:f=l[x]*h;for(let m=0;m<h;m++)d[p++]=c[f++]}return new sr(d,h,u)}if(this.index===null)return ne("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Wd,n=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=t(l,n);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);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 n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),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 n=t.index;n!==null&&this.setIndex(n.clone());const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ms=new H,ip=new H,Hh=new H,js=new H,sp=new H,Wh=new H,rp=new H;class R3{constructor(t=new H,e=new H(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Ms)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ms.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ms.copy(this.origin).addScaledVector(this.direction,e),Ms.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ip.copy(t).add(e).multiplyScalar(.5),Hh.copy(e).sub(t).normalize(),js.copy(this.origin).sub(ip);const s=t.distanceTo(e)*.5,o=-this.direction.dot(Hh),a=js.dot(this.direction),l=-js.dot(Hh),c=js.lengthSq(),h=Math.abs(1-o*o);let u,d,f,p;if(h>0)if(u=o*l-a,d=o*a-l,p=s*h,u>=0)if(d>=-p)if(d<=p){const x=1/h;u*=x,d*=x,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-p?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=p?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(ip).addScaledVector(Hh,d),f}intersectSphere(t,e){Ms.subVectors(t.center,this.origin);const n=Ms.dot(this.direction),i=Ms.dot(Ms)-n*n,s=t.radius*t.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(s=(t.min.y-d.y)*h,o=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,o=(t.min.y-d.y)*h),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),u>=0?(a=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Ms)!==null}intersectTriangle(t,e,n,i,s){sp.subVectors(e,t),Wh.subVectors(n,t),rp.crossVectors(sp,Wh);let o=this.direction.dot(rp),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;js.subVectors(this.origin,t);const l=a*this.direction.dot(Wh.crossVectors(js,Wh));if(l<0)return null;const c=a*this.direction.dot(sp.cross(js));if(c<0||l+c>o)return null;const h=-a*js.dot(rp);return h<0?null:this.at(h/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}const Ci=new H,Ss=new H,op=new H,bs=new H,Ho=new H,Wo=new H,_y=new H,ap=new H,lp=new H,cp=new H,hp=new Nn,up=new Nn,dp=new Nn;class Pi{constructor(t=new H,e=new H,n=new H){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Ci.subVectors(t,e),i.cross(Ci);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){Ci.subVectors(i,e),Ss.subVectors(n,e),op.subVectors(t,e);const o=Ci.dot(Ci),a=Ci.dot(Ss),l=Ci.dot(op),c=Ss.dot(Ss),h=Ss.dot(op),u=o*c-a*a;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(c*l-a*h)*d,p=(o*h-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,bs)===null?!1:bs.x>=0&&bs.y>=0&&bs.x+bs.y<=1}static getInterpolation(t,e,n,i,s,o,a,l){return this.getBarycoord(t,e,n,i,bs)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,bs.x),l.addScaledVector(o,bs.y),l.addScaledVector(a,bs.z),l)}static getInterpolatedAttribute(t,e,n,i,s,o){return hp.setScalar(0),up.setScalar(0),dp.setScalar(0),hp.fromBufferAttribute(t,e),up.fromBufferAttribute(t,n),dp.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(hp,s.x),o.addScaledVector(up,s.y),o.addScaledVector(dp,s.z),o}static isFrontFacing(t,e,n,i){return Ci.subVectors(n,e),Ss.subVectors(t,e),Ci.cross(Ss).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ci.subVectors(this.c,this.b),Ss.subVectors(this.a,this.b),Ci.cross(Ss).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Pi.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Pi.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return Pi.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return Pi.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Pi.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,s=this.c;let o,a;Ho.subVectors(i,n),Wo.subVectors(s,n),ap.subVectors(t,n);const l=Ho.dot(ap),c=Wo.dot(ap);if(l<=0&&c<=0)return e.copy(n);lp.subVectors(t,i);const h=Ho.dot(lp),u=Wo.dot(lp);if(h>=0&&u<=h)return e.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(n).addScaledVector(Ho,o);cp.subVectors(t,s);const f=Ho.dot(cp),p=Wo.dot(cp);if(p>=0&&f<=p)return e.copy(s);const x=f*c-l*p;if(x<=0&&c>=0&&p<=0)return a=c/(c-p),e.copy(n).addScaledVector(Wo,a);const g=h*p-f*u;if(g<=0&&u-h>=0&&f-p>=0)return _y.subVectors(s,i),a=(u-h)/(u-h+(f-p)),e.copy(i).addScaledVector(_y,a);const m=1/(g+x+d);return o=x*m,a=d*m,e.copy(n).addScaledVector(Ho,o).addScaledVector(Wo,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class I3 extends Wp{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ua,this.combine=gN,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const vy=new ke,Lr=new R3,Xh=new zd,My=new H,$h=new H,qh=new H,Yh=new H,fp=new H,Zh=new H,Sy=new H,Jh=new H;class P3 extends Cn{constructor(t=new Wd,e=new I3){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){Zh.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],u=s[l];h!==0&&(fp.fromBufferAttribute(u,t),o?Zh.addScaledVector(fp,h):Zh.addScaledVector(fp.sub(e),h))}e.add(Zh)}return e}raycast(t,e){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Xh.copy(n.boundingSphere),Xh.applyMatrix4(s),Lr.copy(t.ray).recast(t.near),!(Xh.containsPoint(Lr.origin)===!1&&(Lr.intersectSphere(Xh,My)===null||Lr.origin.distanceToSquared(My)>(t.far-t.near)**2))&&(vy.copy(s).invert(),Lr.copy(t.ray).applyMatrix4(vy),!(n.boundingBox!==null&&Lr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Lr)))}_computeIntersections(t,e,n){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,x=d.length;p<x;p++){const g=d[p],m=o[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,w=v;_<w;_+=3){const T=a.getX(_),E=a.getX(_+1),M=a.getX(_+2);i=jh(this,m,t,n,c,h,u,T,E,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let g=p,m=x;g<m;g+=3){const y=a.getX(g),v=a.getX(g+1),_=a.getX(g+2);i=jh(this,o,t,n,c,h,u,y,v,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let p=0,x=d.length;p<x;p++){const g=d[p],m=o[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,w=v;_<w;_+=3){const T=_,E=_+1,M=_+2;i=jh(this,m,t,n,c,h,u,T,E,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),x=Math.min(l.count,f.start+f.count);for(let g=p,m=x;g<m;g+=3){const y=g,v=g+1,_=g+2;i=jh(this,o,t,n,c,h,u,y,v,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}}}function L3(r,t,e,n,i,s,o,a){let l;if(t.side===tg?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,t.side===Fp,a),l===null)return null;Jh.copy(a),Jh.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(Jh);return c<e.near||c>e.far?null:{distance:c,point:Jh.clone(),object:r}}function jh(r,t,e,n,i,s,o,a,l,c){r.getVertexPosition(a,$h),r.getVertexPosition(l,qh),r.getVertexPosition(c,Yh);const h=L3(r,t,e,n,$h,qh,Yh,Sy);if(h){const u=new H;Pi.getBarycoord(Sy,$h,qh,Yh,u),i&&(h.uv=Pi.getInterpolatedAttribute(i,a,l,c,u,new Ge)),s&&(h.uv1=Pi.getInterpolatedAttribute(s,a,l,c,u,new Ge)),o&&(h.normal=Pi.getInterpolatedAttribute(o,a,l,c,u,new H),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new H,materialIndex:0};Pi.getNormal($h,qh,Yh,d.normal),h.face=d,h.barycoord=u}return h}class F3{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(t){if(t.isNodeMaterial)return t;let e=null;const n=this.getMaterialNodeClass(t.type);if(n!==null){e=new n;for(const i in t)e[i]=t[i]}return e}addToneMapping(t,e){this.addType(t,e,this.toneMappingNodes)}getToneMappingFunction(t){return this.toneMappingNodes.get(t)||null}getMaterialNodeClass(t){return this.materialNodes.get(t)||null}addMaterial(t,e){this.addType(t,e,this.materialNodes)}getLightNodeClass(t){return this.lightNodes.get(t)||null}addLight(t,e){this.addClass(t,e,this.lightNodes)}addType(t,e,n){if(n.has(e)){ne(`Redefinition of node ${e}`);return}if(typeof t!="function")throw new Error(`Node class ${t.name} is not a class.`);if(typeof e=="function"||typeof e=="object")throw new Error(`Base class ${e} is not a class.`);n.set(e,t)}addClass(t,e,n){if(n.has(e)){ne(`Redefinition of node ${e.name}`);return}if(typeof t!="function")throw new Error(`Node class ${t.name} is not a class.`);if(typeof e!="function")throw new Error(`Base class ${e.name} is not a class.`);n.set(e,t)}}class oo extends Cn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Vi(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}const pp=new H,D3=new H,U3=new Mi;class Dr{constructor(t=new H(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=pp.subVectors(n,e).cross(D3.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(pp),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||U3.getNormalMatrix(t),i=this.coplanarPoint(pp).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Fr=new zd,O3=new Ge(.5,.5),Kh=new H;class B3{constructor(t=new Dr,e=new Dr,n=new Dr,i=new Dr,s=new Dr,o=new Dr){this.planes=[t,e,n,i,s,o]}set(t,e,n,i,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=ns,n=!1){const i=this.planes,s=t.elements,o=s[0],a=s[1],l=s[2],c=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],x=s[9],g=s[10],m=s[11],y=s[12],v=s[13],_=s[14],w=s[15];if(i[0].setComponents(c-o,f-h,m-p,w-y).normalize(),i[1].setComponents(c+o,f+h,m+p,w+y).normalize(),i[2].setComponents(c+a,f+u,m+x,w+v).normalize(),i[3].setComponents(c-a,f-u,m-x,w-v).normalize(),n)i[4].setComponents(l,d,g,_).normalize(),i[5].setComponents(c-l,f-d,m-g,w-_).normalize();else if(i[4].setComponents(c-l,f-d,m-g,w-_).normalize(),e===ns)i[5].setComponents(c+l,f+d,m+g,w+_).normalize();else if(e===hr)i[5].setComponents(l,d,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Fr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Fr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Fr)}intersectsSprite(t){Fr.center.set(0,0,0);const e=O3.distanceTo(t.center);return Fr.radius=.7071067811865476+e,Fr.applyMatrix4(t.matrixWorld),this.intersectsSphere(Fr)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(Kh.x=i.normal.x>0?t.max.x:t.min.x,Kh.y=i.normal.y>0?t.max.y:t.min.y,Kh.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Kh)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const mp=new ke,by=new H,Ty=new H;class Pg{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ge(512,512),this.mapType=Hv,this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new B3,this._frameExtents=new Ge(1,1),this._viewportCount=1,this._viewports=[new Nn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;by.setFromMatrixPosition(t.matrixWorld),e.position.copy(by),Ty.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Ty),e.updateMatrixWorld(),mp.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mp,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===hr||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(mp)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class z3 extends Pg{constructor(){super(new jM(90,1,.5,500)),this.isPointLightShadow=!0}}class V3 extends oo{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new z3}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class KM extends JM{constructor(t=-1,e=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-t,o=n+t,a=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class k3 extends Pg{constructor(){super(new KM(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class G3 extends oo{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.shadow=new k3}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class H3 extends oo{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class W3 extends Pg{constructor(){super(new jM(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=oc*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Lg extends oo{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new W3}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class X3 extends oo{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class $3 extends oo{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Vi(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}class q3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new H)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*i),e.addScaledVector(o[2],.488603*s),e.addScaledVector(o[3],.488603*n),e.addScaledVector(o[4],1.092548*(n*i)),e.addScaledVector(o[5],1.092548*(i*s)),e.addScaledVector(o[6],.315392*(3*s*s-1)),e.addScaledVector(o[7],1.092548*(n*s)),e.addScaledVector(o[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],2*.511664*i),e.addScaledVector(o[2],2*.511664*s),e.addScaledVector(o[3],2*.511664*n),e.addScaledVector(o[4],2*.429043*n*i),e.addScaledVector(o[5],2*.429043*i*s),e.addScaledVector(o[6],.743125*s*s-.247708),e.addScaledVector(o[7],2*.429043*n*s),e.addScaledVector(o[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+i*3);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+i*3);return t}static getBasisAt(t,e){const n=t.x,i=t.y,s=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*s,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*n*s,e[8]=.546274*(n*n-i*i)}}class Y3 extends oo{constructor(t=new q3,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Z3 extends Lg{constructor(t,e,n,i,s,o){super(t,e,n,i,s,o),this.iesMap=null}copy(t,e){return super.copy(t,e),this.iesMap=t.iesMap,this}}class J3 extends Lg{constructor(t,e,n,i,s,o){super(t,e,n,i,s,o),this.aspect=null}copy(t,e){return super.copy(t,e),this.aspect=t.aspect,this}}Mt(({texture:r,uv:t})=>{const n=Pt().toVar();return hi(t.x.lessThan(1e-4),()=>{n.assign(Pt(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{n.assign(Pt(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{n.assign(Pt(0,0,1))}).ElseIf(t.x.greaterThan(1-1e-4),()=>{n.assign(Pt(-1,0,0))}).ElseIf(t.y.greaterThan(1-1e-4),()=>{n.assign(Pt(0,-1,0))}).ElseIf(t.z.greaterThan(1-1e-4),()=>{n.assign(Pt(0,0,-1))}).Else(()=>{const s=r.sample(t.add(Pt(-.01,0,0))).r.sub(r.sample(t.add(Pt(.01,0,0))).r),o=r.sample(t.add(Pt(0,-.01,0))).r.sub(r.sample(t.add(Pt(0,.01,0))).r),a=r.sample(t.add(Pt(0,0,-.01))).r.sub(r.sample(t.add(Pt(0,0,.01))).r);n.assign(Pt(s,o,a))}),n.normalize()});const Qh=new Ge;class j3 extends Hd{static get type(){return"PassTextureNode"}constructor(t,e){super(e),this.passNode=t,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(t){const e=t.getNodeProperties(this);return e.passNode=this.passNode,super.setup(t)}clone(){return new this.constructor(this.passNode,this.value)}}class wy extends j3{static get type(){return"PassMultipleTextureNode"}constructor(t,e,n=!1){super(t,null),this.textureName=e,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(t){return this.updateTexture(),super.setup(t)}clone(){const t=new this.constructor(this.passNode,this.textureName,this.previousTexture);return t.uvNode=this.uvNode,t.levelNode=this.levelNode,t.biasNode=this.biasNode,t.sampler=this.sampler,t.depthNode=this.depthNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.offsetNode=this.offsetNode,t}}class Xd extends xn{static get type(){return"PassNode"}constructor(t,e,n,i={}){super("vec4"),this.scope=t,this.scene=e,this.camera=n,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const s=new Pc;s.isRenderTargetTexture=!0,s.name="depth";const o=new ZM(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:cl,...i});o.texture.name="output",o.depthTexture=s,this.renderTarget=o,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:o.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=de(0),this._cameraFar=de(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ue.FRAME,this.global=!0}setResolutionScale(t){return this._resolutionScale=t,this}getResolutionScale(){return this._resolutionScale}setResolution(t){return ne("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(t)}getResolution(){return ne("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(t){return this._layers=t,this}getLayers(){return this._layers}setMRT(t){return this._mrt=t,this}getMRT(){return this._mrt}getTexture(t){let e=this._textures[t];return e===void 0&&(e=this.renderTarget.texture.clone(),e.name=t,this._textures[t]=e,this.renderTarget.textures.push(e)),e}getPreviousTexture(t){let e=this._previousTextures[t];return e===void 0&&(e=this.getTexture(t).clone(),this._previousTextures[t]=e),e}toggleTexture(t){const e=this._previousTextures[t];if(e!==void 0){const n=this._textures[t],i=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[i]=e,this._textures[t]=e,this._previousTextures[t]=n,this._textureNodes[t].updateTexture(),this._previousTextureNodes[t].updateTexture()}}getTextureNode(t="output"){let e=this._textureNodes[t];return e===void 0&&(e=new wy(this,t),e.updateTexture(),this._textureNodes[t]=e),e}getPreviousTextureNode(t="output"){let e=this._previousTextureNodes[t];return e===void 0&&(this._textureNodes[t]===void 0&&this.getTextureNode(t),e=new wy(this,t,!0),e.updateTexture(),this._previousTextureNodes[t]=e),e}getViewZNode(t="depth"){let e=this._viewZNodes[t];if(e===void 0){const n=this._cameraNear,i=this._cameraFar;this._viewZNodes[t]=e=XM(this.getTextureNode(t),n,i)}return e}getLinearDepthNode(t="depth"){let e=this._linearDepthNodes[t];if(e===void 0){const n=this._cameraNear,i=this._cameraFar,s=this.getViewZNode(t);this._linearDepthNodes[t]=e=Sl(s,n,i)}return e}async compileAsync(t){const e=t.getRenderTarget(),n=t.getMRT();t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),await t.compileAsync(this.scene,this.camera),t.setRenderTarget(e),t.setMRT(n)}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),this.scope===Xd.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(t){const{renderer:e}=t,{scene:n}=this;let i,s;const o=e.getOutputRenderTarget();o&&o.isXRRenderTarget===!0?(s=1,i=e.xr.getCamera(),e.xr.updateCamera(i),Qh.set(o.width,o.height)):(i=this.camera,s=e.getPixelRatio(),e.getSize(Qh)),this._pixelRatio=s,this.setSize(Qh.width,Qh.height);const a=e.getRenderTarget(),l=e.getMRT(),c=e.autoClear,h=e.transparent,u=e.opaque,d=i.layers.mask,f=e.contextNode,p=n.overrideMaterial;this._cameraNear.value=i.near,this._cameraFar.value=i.far,this._layers!==null&&(i.layers.mask=this._layers.mask);for(const g in this._previousTextures)this.toggleTexture(g);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),e.autoClear=!0,e.transparent=this.transparent,e.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:Pa({...e.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),e.contextNode=this._contextNodeCache.context);const x=n.name;n.name=this.name?this.name:n.name,e.render(n,i),n.name=x,n.overrideMaterial=p,e.setRenderTarget(a),e.setMRT(l),e.autoClear=c,e.transparent=h,e.opaque=u,e.contextNode=f,i.layers.mask=d}setSize(t,e){this._width=t,this._height=e;const n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),i=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,i),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(t,e,n,i){t===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Nn),t.isVector4?this._scissor.copy(t):this._scissor.set(t,e,n,i),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(t,e,n,i){t===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Nn),t.isVector4?this._viewport.copy(t):this._viewport.set(t,e,n,i),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Xd.COLOR="color";Xd.DEPTH="depth";class hs extends Bt{static get type(){return"AtomicFunctionNode"}constructor(t,e,n){super("uint"),this.method=t,this.pointerNode=e,this.valueNode=n,this.parents=!0}getInputType(t){return this.pointerNode.getNodeType(t)}getNodeType(t){return this.getInputType(t)}generate(t){const e=t.getNodeProperties(this),n=e.parents,i=this.method,s=this.getNodeType(t),o=this.getInputType(t),a=this.pointerNode,l=this.valueNode,c=[];c.push(`&${a.build(t,o)}`),l!==null&&c.push(l.build(t,o));const h=`${t.getMethod(i,s)}( ${c.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)t.addLineFlowCode(h,this);else return e.constNode===void 0&&(e.constNode=Es(h,s).toConst()),e.constNode.build(t)}}hs.ATOMIC_LOAD="atomicLoad";hs.ATOMIC_STORE="atomicStore";hs.ATOMIC_ADD="atomicAdd";hs.ATOMIC_SUB="atomicSub";hs.ATOMIC_MAX="atomicMax";hs.ATOMIC_MIN="atomicMin";hs.ATOMIC_AND="atomicAnd";hs.ATOMIC_OR="atomicOr";hs.ATOMIC_XOR="atomicXor";De(hs);class K3 extends Bt{constructor(t){super(),this.scope=t}generate(t){const{scope:e}=this,{renderer:n}=t;n.backend.isWebGLBackend===!0?t.addFlowCode(` // ${e}Barrier
|
|
4084
|
-
`):t.addLineFlowCode(`${e}Barrier()`,this)}}De(K3);class ge extends xn{static get type(){return"SubgroupFunctionNode"}constructor(t,e=null,n=null){super(),this.method=t,this.aNode=e,this.bNode=n}getInputType(t){const e=this.aNode?this.aNode.getNodeType(t):null,n=this.bNode?this.bNode.getNodeType(t):null,i=t.isMatrix(e)?0:t.getTypeLength(e),s=t.isMatrix(n)?0:t.getTypeLength(n);return i>s?e:n}getNodeType(t){const e=this.method;return e===ge.SUBGROUP_ELECT?"bool":e===ge.SUBGROUP_BALLOT?"uvec4":this.getInputType(t)}generate(t,e){const n=this.method,i=this.getNodeType(t),s=this.getInputType(t),o=this.aNode,a=this.bNode,l=[];if(n===ge.SUBGROUP_BROADCAST||n===ge.SUBGROUP_SHUFFLE||n===ge.QUAD_BROADCAST){const h=a.getNodeType(t);l.push(o.build(t,i),a.build(t,h==="float"?"int":i))}else n===ge.SUBGROUP_SHUFFLE_XOR||n===ge.SUBGROUP_SHUFFLE_DOWN||n===ge.SUBGROUP_SHUFFLE_UP?l.push(o.build(t,i),a.build(t,"uint")):(o!==null&&l.push(o.build(t,s)),a!==null&&l.push(a.build(t,s)));const c=l.length===0?"()":`( ${l.join(", ")} )`;return t.format(`${t.getMethod(n,i)}${c}`,i,e)}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}ge.SUBGROUP_ELECT="subgroupElect";ge.SUBGROUP_BALLOT="subgroupBallot";ge.SUBGROUP_ADD="subgroupAdd";ge.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";ge.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";ge.SUBGROUP_MUL="subgroupMul";ge.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";ge.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";ge.SUBGROUP_AND="subgroupAnd";ge.SUBGROUP_OR="subgroupOr";ge.SUBGROUP_XOR="subgroupXor";ge.SUBGROUP_MIN="subgroupMin";ge.SUBGROUP_MAX="subgroupMax";ge.SUBGROUP_ALL="subgroupAll";ge.SUBGROUP_ANY="subgroupAny";ge.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";ge.QUAD_SWAP_X="quadSwapX";ge.QUAD_SWAP_Y="quadSwapY";ge.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";ge.SUBGROUP_BROADCAST="subgroupBroadcast";ge.SUBGROUP_SHUFFLE="subgroupShuffle";ge.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor";ge.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp";ge.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown";ge.QUAD_BROADCAST="quadBroadcast";class Q3 extends Bt{static get type(){return"ShadowBaseNode"}constructor(t){super(),this.light=t,this.updateBeforeType=ue.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:t,material:e}){QM.assign(e.receivedShadowPositionNode||t.shadowPositionWorld||Cg)}}const QM=lM("vec3","shadowPositionWorld"),gp=new KM(-1,1,1,-1,0,1);class tL extends Wd{constructor(t=!1){super();const e=t===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Hp([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Hp(e,2))}}const eL=new tL;class nL extends P3{constructor(t=null){super(eL,t),this.camera=gp,this.isQuadMesh=!0}async renderAsync(t){ya('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await t.init(),t.render(this,gp)}render(t){t.render(this,gp)}}let tu;function $d(r){tu=tu||new WeakMap;let t=tu.get(r);return t===void 0&&tu.set(r,t={}),t}function Fg(r){const t=$d(r);return t.shadowMatrix||(t.shadowMatrix=de("mat4").setGroup(te).onRenderUpdate(e=>((r.castShadow!==!0||e.renderer.shadowMap.enabled===!1)&&(r.shadow.camera.coordinateSystem!==e.camera.coordinateSystem&&(r.shadow.camera.coordinateSystem=e.camera.coordinateSystem,r.shadow.camera.updateProjectionMatrix()),r.shadow.updateMatrices(r)),r.shadow.matrix)))}function iL(r,t=Cg){const e=Fg(r).mul(t);return e.xyz.div(e.w)}function tS(r){const t=$d(r);return t.position||(t.position=de(new H).setGroup(te).onRenderUpdate((e,n)=>n.value.setFromMatrixPosition(r.matrixWorld)))}function sL(r){const t=$d(r);return t.targetPosition||(t.targetPosition=de(new H).setGroup(te).onRenderUpdate((e,n)=>n.value.setFromMatrixPosition(r.target.matrixWorld)))}function eS(r){const t=$d(r);return t.viewPosition||(t.viewPosition=de(new H).setGroup(te).onRenderUpdate(({camera:e},n)=>{n.value=n.value||new H,n.value.setFromMatrixPosition(r.matrixWorld),n.value.applyMatrix4(e.matrixWorldInverse)}))}const nS=r=>Da.transformDirection(tS(r).sub(sL(r)));function rL(r,t={}){return t.toneMapping=r.toneMapping,t.toneMappingExposure=r.toneMappingExposure,t.outputColorSpace=r.outputColorSpace,t.renderTarget=r.getRenderTarget(),t.activeCubeFace=r.getActiveCubeFace(),t.activeMipmapLevel=r.getActiveMipmapLevel(),t.renderObjectFunction=r.getRenderObjectFunction(),t.pixelRatio=r.getPixelRatio(),t.mrt=r.getMRT(),t.clearColor=r.getClearColor(t.clearColor||new Vi),t.clearAlpha=r.getClearAlpha(),t.autoClear=r.autoClear,t.scissorTest=r.getScissorTest(),t}function oL(r,t){return t=rL(r,t),r.setMRT(null),r.setRenderObjectFunction(null),r.setClearColor(0,1),r.autoClear=!0,t}function aL(r,t){r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),r.setRenderObjectFunction(t.renderObjectFunction),r.setPixelRatio(t.pixelRatio),r.setMRT(t.mrt),r.setClearColor(t.clearColor,t.clearAlpha),r.autoClear=t.autoClear,r.setScissorTest(t.scissorTest)}function lL(r,t={}){return t.background=r.background,t.backgroundNode=r.backgroundNode,t.overrideMaterial=r.overrideMaterial,t}function cL(r,t){return t=lL(r,t),r.background=null,r.backgroundNode=null,r.overrideMaterial=null,t}function hL(r,t){r.background=t.background,r.backgroundNode=t.backgroundNode,r.overrideMaterial=t.overrideMaterial}function uL(r,t,e){return e=oL(r,e),e=cL(t,e),e}function dL(r,t,e){aL(r,e),hL(t,e)}const iS=Mt(([r])=>Qr(kt(52.9829189).mul(Qr(Rc(r,xe(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),es=Mt(([r,t,e])=>{const n=kt(2.399963229728653),i=Cc(kt(r).add(.5).div(kt(t))),s=kt(r).mul(n).add(e);return xe(hM(s),ac(s)).mul(i)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),Hu=new WeakMap,fL=Mt(({depthTexture:r,shadowCoord:t,depthLayer:e})=>{let n=pn(r,t.xy).setName("t_basic");return r.isArrayTexture&&(n=n.depth(e)),n.compare(t.z)}),pL=Mt(({depthTexture:r,shadowCoord:t,shadow:e,depthLayer:n})=>{const i=(h,u)=>{let d=pn(r,h);return r.isArrayTexture&&(d=d.depth(n)),d.compare(u)},s=tn("mapSize","vec2",e).setGroup(te),o=tn("radius","float",e).setGroup(te),a=xe(1).div(s),l=o.mul(a.x),c=iS(Fa.xy).mul(6.28318530718);return os(i(t.xy.add(es(0,5,c).mul(l)),t.z),i(t.xy.add(es(1,5,c).mul(l)),t.z),i(t.xy.add(es(2,5,c).mul(l)),t.z),i(t.xy.add(es(3,5,c).mul(l)),t.z),i(t.xy.add(es(4,5,c).mul(l)),t.z)).mul(1/5)}),mL=Mt(({depthTexture:r,shadowCoord:t,shadow:e,depthLayer:n})=>{const i=(u,d)=>{let f=pn(r,u);return r.isArrayTexture&&(f=f.depth(n)),f.compare(d)},s=tn("mapSize","vec2",e).setGroup(te),o=xe(1).div(s),a=o.x,l=o.y,c=t.xy,h=Qr(c.mul(s).add(.5));return c.subAssign(h.mul(o)),os(i(c,t.z),i(c.add(xe(a,0)),t.z),i(c.add(xe(0,l)),t.z),i(c.add(o),t.z),Dn(i(c.add(xe(a.negate(),0)),t.z),i(c.add(xe(a.mul(2),0)),t.z),h.x),Dn(i(c.add(xe(a.negate(),l)),t.z),i(c.add(xe(a.mul(2),l)),t.z),h.x),Dn(i(c.add(xe(0,l.negate())),t.z),i(c.add(xe(0,l.mul(2))),t.z),h.y),Dn(i(c.add(xe(a,l.negate())),t.z),i(c.add(xe(a,l.mul(2))),t.z),h.y),Dn(Dn(i(c.add(xe(a.negate(),l.negate())),t.z),i(c.add(xe(a.mul(2),l.negate())),t.z),h.x),Dn(i(c.add(xe(a.negate(),l.mul(2))),t.z),i(c.add(xe(a.mul(2),l.mul(2))),t.z),h.x),h.y)).mul(1/9)}),gL=Mt(({depthTexture:r,shadowCoord:t,depthLayer:e},n)=>{let i=pn(r).sample(t.xy);r.isArrayTexture&&(i=i.depth(e)),i=i.rg;const s=i.x,o=as(1e-7,i.y.mul(i.y)),a=n.renderer.reversedDepthBuffer?cc(s,t.z):cc(t.z,s),l=kt(1).toVar();return hi(a.notEqual(1),()=>{const c=t.z.sub(s);let h=o.div(o.add(c.mul(c)));h=_a(Wn(h,.3).div(.65)),l.assign(as(a,h))}),l}),xL=r=>{let t=Hu.get(r);return t===void 0&&(t=new qp,t.colorNode=zn(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=mN,t.fog=!1,Hu.set(r,t)),t},yL=r=>{const t=Hu.get(r);t!==void 0&&(t.dispose(),Hu.delete(r))};class _L{constructor(){this.weakMaps={}}_getWeakMap(t){const e=t.length;let n=this.weakMaps[e];return n===void 0&&(n=new WeakMap,this.weakMaps[e]=n),n}get(t){let e=this._getWeakMap(t);for(let n=0;n<t.length-1;n++)if(e=e.get(t[n]),e===void 0)return;return e.get(t[t.length-1])}set(t,e){let n=this._getWeakMap(t);for(let i=0;i<t.length-1;i++){const s=t[i];n.has(s)===!1&&n.set(s,new WeakMap),n=n.get(s)}return n.set(t[t.length-1],e),this}delete(t){let e=this._getWeakMap(t);for(let n=0;n<t.length-1;n++)if(e=e.get(t[n]),e===void 0)return!1;return e.delete(t[t.length-1])}}const Ay=new _L,Xo=[],vL=(r,t,e,n)=>{Xo[0]=r,Xo[1]=t;let i=Ay.get(Xo);return(i===void 0||i.shadowType!==e||i.useVelocity!==n)&&(i=(s,o,a,l,c,h,...u)=>{(s.castShadow===!0||s.receiveShadow&&e===cu)&&(n&&(iR(s).useVelocity=!0),s.onBeforeShadow(r,s,a,t.camera,l,o.overrideMaterial,h),r.renderObject(s,o,a,l,c,h,...u),s.onAfterShadow(r,s,a,t.camera,l,o.overrideMaterial,h))},i.shadowType=e,i.useVelocity=n,Ay.set(Xo,i)),Xo[0]=null,Xo[1]=null,i},ML=Mt(({samples:r,radius:t,size:e,shadowPass:n,depthLayer:i})=>{const s=kt(0).toVar("meanVertical"),o=kt(0).toVar("squareMeanVertical"),a=r.lessThanEqual(kt(1)).select(kt(0),kt(2).div(r.sub(1))),l=r.lessThanEqual(kt(1)).select(kt(0),kt(-1));tr({start:Be(0),end:Be(r),type:"int",condition:"<"},({i:h})=>{const u=l.add(kt(h).mul(a));let d=n.sample(os(Fa.xy,xe(0,u).mul(t)).div(e));n.value.isArrayTexture&&(d=d.depth(i)),d=d.x,s.addAssign(d),o.addAssign(d.mul(d))}),s.divAssign(r),o.divAssign(r);const c=Cc(o.sub(s.mul(s)).max(0));return xe(s,c)}),SL=Mt(({samples:r,radius:t,size:e,shadowPass:n,depthLayer:i})=>{const s=kt(0).toVar("meanHorizontal"),o=kt(0).toVar("squareMeanHorizontal"),a=r.lessThanEqual(kt(1)).select(kt(0),kt(2).div(r.sub(1))),l=r.lessThanEqual(kt(1)).select(kt(0),kt(-1));tr({start:Be(0),end:Be(r),type:"int",condition:"<"},({i:h})=>{const u=l.add(kt(h).mul(a));let d=n.sample(os(Fa.xy,xe(u,0).mul(t)).div(e));n.value.isArrayTexture&&(d=d.depth(i)),s.addAssign(d.x),o.addAssign(os(d.y.mul(d.y),d.x.mul(d.x)))}),s.divAssign(r),o.divAssign(r);const c=Cc(o.sub(s.mul(s)).max(0));return xe(s,c)}),bL=[fL,pL,mL,gL];let xp;const eu=new nL;class sS extends Q3{static get type(){return"ShadowNode"}constructor(t,e=null){super(t),this.shadow=e||t.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(t,{filterFn:e,depthTexture:n,shadowCoord:i,shadow:s,depthLayer:o}){const a=i.x.greaterThanEqual(0).and(i.x.lessThanEqual(1)).and(i.y.greaterThanEqual(0)).and(i.y.lessThanEqual(1)).and(i.z.lessThanEqual(1)),l=e({depthTexture:n,shadowCoord:i,shadow:s,depthLayer:o});return a.select(l,kt(1))}setupShadowCoord(t,e){const{shadow:n}=this,{renderer:i}=t,s=n.biasNode||tn("bias","float",n).setGroup(te);let o=e,a;if(n.camera.isOrthographicCamera||i.logarithmicDepthBuffer!==!0)o=o.xyz.div(o.w),a=o.z;else{const l=o.w;o=o.xy.div(l);const c=tn("near","float",n.camera).setGroup(te),h=tn("far","float",n.camera).setGroup(te);a=$M(l.negate(),c,h)}return o=Pt(o.x,o.y.oneMinus(),i.reversedDepthBuffer?a.sub(s):a.add(s)),o}getShadowFilterFn(t){return bL[t]}setupRenderTarget(t,e){const n=new Pc(t.mapSize.width,t.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=e.renderer.reversedDepthBuffer?Ou:ig;const i=e.createRenderTarget(t.mapSize.width,t.mapSize.height);return i.texture.name="ShadowMap",i.texture.type=t.mapType,i.depthTexture=n,{shadowMap:i,depthTexture:n}}setupShadow(t){const{renderer:e,camera:n}=t,{light:i,shadow:s}=this,{depthTexture:o,shadowMap:a}=this.setupRenderTarget(s,t),l=e.shadowMap.type,c=e.hasCompatibility($v.TEXTURE_COMPARE);if((l===dN||l===fN)&&c?(o.minFilter=rc,o.magFilter=rc):(o.minFilter=gi,o.magFilter=gi),s.camera.coordinateSystem=n.coordinateSystem,s.camera.updateProjectionMatrix(),l===cu&&s.isPointLightShadow!==!0){o.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=t.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:hl,type:cl,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=t.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:hl,type:cl,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=t.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:hl,type:cl,depthBuffer:!1}),this.vsmShadowMapHorizontal=t.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:hl,type:cl,depthBuffer:!1}));let _=pn(o);o.isArrayTexture&&(_=_.depth(this.depthLayer));let w=pn(this.vsmShadowMapVertical.texture);o.isArrayTexture&&(w=w.depth(this.depthLayer));const T=tn("blurSamples","float",s).setGroup(te),E=tn("radius","float",s).setGroup(te),M=tn("mapSize","vec2",s).setGroup(te);let b=this.vsmMaterialVertical||(this.vsmMaterialVertical=new qp);b.fragmentNode=ML({samples:T,radius:E,size:M,shadowPass:_,depthLayer:this.depthLayer}).context(t.getSharedContext()),b.name="VSMVertical",b=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new qp),b.fragmentNode=SL({samples:T,radius:E,size:M,shadowPass:w,depthLayer:this.depthLayer}).context(t.getSharedContext()),b.name="VSMHorizontal"}const h=tn("intensity","float",s).setGroup(te),u=tn("normalBias","float",s).setGroup(te),d=Fg(i).mul(QM.add(kd.mul(u))),f=this.setupShadowCoord(t,d),p=s.filterNode||this.getShadowFilterFn(e.shadowMap.type)||null;if(p===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const x=l===cu&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:o,g=this.setupShadowFilter(t,{filterFn:p,shadowTexture:a.texture,depthTexture:x,shadowCoord:f,shadow:s,depthLayer:this.depthLayer});let m;e.shadowMap.transmitted===!0&&(a.texture.isCubeTexture?m=ts(a.texture,f.xyz):(m=pn(a.texture,f),o.isArrayTexture&&(m=m.depth(this.depthLayer))));let y;m?y=Dn(1,g.rgb.mix(m,1),h.mul(m.a)).toVar():y=Dn(1,g,h).toVar(),this.shadowMap=a,this.shadow.map=a;const v=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return m&&y.toInspector(`${v} / Color`,()=>this.shadowMap.texture.isCubeTexture?ts(this.shadowMap.texture):pn(this.shadowMap.texture)),y.toInspector(`${v} / Depth`,()=>this.shadowMap.texture.isCubeTexture?ts(this.shadowMap.texture).r.oneMinus():li(this.shadowMap.depthTexture,Gd().mul(ra(pn(this.shadowMap.depthTexture)))).r.oneMinus())}setup(t){if(t.renderer.shadowMap.enabled!==!1)return Mt(()=>{const e=t.renderer.shadowMap.type;this._currentShadowType!==e&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(t),n===null&&(this._node=n=this.setupShadow(t),this._currentShadowType=e),t.material.receivedShadowNode&&(n=t.material.receivedShadowNode(n)),n})()}renderShadow(t){const{shadow:e,shadowMap:n,light:i}=this,{renderer:s,scene:o}=t;e.updateMatrices(i),n.setSize(e.mapSize.width,e.mapSize.height,n.depth);const a=o.name;o.name=`Shadow Map [ ${i.name||"ID: "+i.id} ]`,s.render(o,e.camera),o.name=a}updateShadow(t){const{shadowMap:e,light:n,shadow:i}=this,{renderer:s,scene:o,camera:a}=t,l=s.shadowMap.type,c=e.depthTexture.version;this._depthVersionCached=c;const h=i.camera.layers.mask;(i.camera.layers.mask&4294967294)===0&&(i.camera.layers.mask=a.layers.mask);const u=s.getRenderObjectFunction(),d=s.getMRT(),f=d?d.has("velocity"):!1;xp=uL(s,o,xp),o.overrideMaterial=xL(n),s.setRenderObjectFunction(vL(s,i,l,f)),s.setClearColor(0,0),s.setRenderTarget(e),this.renderShadow(t),s.setRenderObjectFunction(u),l===cu&&i.isPointLightShadow!==!0&&this.vsmPass(s),i.camera.layers.mask=h,dL(s,o,xp)}vsmPass(t){const{shadow:e}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(e.mapSize.width,e.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(e.mapSize.width,e.mapSize.height,n),t.setRenderTarget(this.vsmShadowMapVertical),eu.material=this.vsmMaterialVertical,eu.render(t),t.setRenderTarget(this.vsmShadowMapHorizontal),eu.material=this.vsmMaterialHorizontal,eu.render(t)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,yL(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(t){const{shadow:e}=this;let n=e.needsUpdate||e.autoUpdate;n&&(this._cameraFrameId[t.camera]===t.frameId&&(n=!1),this._cameraFrameId[t.camera]=t.frameId),n&&(this.updateShadow(t),this.shadowMap.depthTexture.version===this._depthVersionCached&&(e.needsUpdate=!1))}}const TL=(r,t)=>new sS(r,t);class ao extends Ig{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new Vi,this.colorNode=t&&t.colorNode||de(this.color).setGroup(te),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ue.FRAME,t&&t.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},t.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(t){return eS(this.light).sub(t.context.positionView||hn)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return TL(this.light)}setupShadow(t){const{renderer:e}=t;if(e.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const i=this.light.shadow.shadowNode;let s;i!==void 0?s=Ot(i):s=this.setupShadowNode(),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}t.context.getShadow&&(n=t.context.getShadow(this,t)),this.colorNode=n}setup(t){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?t.object.receiveShadow&&this.setupShadow(t):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const e=this.setupDirect(t),n=this.setupDirectRectArea(t);e&&t.lightsNode.setupDirectLight(t,this,e),n&&t.lightsNode.setupDirectRectAreaLight(t,this,n)}update(){const{light:t}=this;this.color.copy(t.color).multiplyScalar(t.intensity)}}class wL extends ao{static get type(){return"AmbientLightNode"}constructor(t=null){super(t)}setup({context:t}){t.irradiance.addAssign(this.colorNode)}}class AL extends ao{static get type(){return"DirectionalLightNode"}constructor(t=null){super(t)}setupDirect(){const t=this.colorNode;return{lightDirection:nS(this.light),lightColor:t}}}class EL extends ao{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=tS(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=de(new Vi).setGroup(te)}update(t){const{light:e}=this;super.update(t),this.lightPositionNode.object3d=e,this.groundColorNode.value.copy(e.groundColor).multiplyScalar(e.intensity)}setup(t){const{colorNode:e,groundColorNode:n,lightDirectionNode:i}=this,o=kd.dot(i).mul(.5).add(.5),a=Dn(n,e,o);t.context.irradiance.addAssign(a)}}const rS=Mt(({lightDistance:r,cutoffDistance:t,decayExponent:e})=>{const n=r.pow(e).max(.01).reciprocal();return t.greaterThan(0).select(n.mul(r.div(t).pow4().oneMinus().clamp().pow2()),n)});class Dg extends ao{static get type(){return"SpotLightNode"}constructor(t=null){super(t),this.coneCosNode=de(0).setGroup(te),this.penumbraCosNode=de(0).setGroup(te),this.cutoffDistanceNode=de(0).setGroup(te),this.decayExponentNode=de(0).setGroup(te),this.colorNode=de(this.color).setGroup(te)}update(t){super.update(t);const{light:e}=this;this.coneCosNode.value=Math.cos(e.angle),this.penumbraCosNode.value=Math.cos(e.angle*(1-e.penumbra)),this.cutoffDistanceNode.value=e.distance,this.decayExponentNode.value=e.decay}getSpotAttenuation(t,e){const{coneCosNode:n,penumbraCosNode:i}=this;return hc(n,i,e)}getLightCoord(t){const e=t.getNodeProperties(this);let n=e.projectionUV;return n===void 0&&(n=iL(this.light,t.context.positionWorld),e.projectionUV=n),n}setupDirect(t){const{colorNode:e,cutoffDistanceNode:n,decayExponentNode:i,light:s}=this,o=this.getLightVector(t),a=o.normalize(),l=a.dot(nS(s)),c=this.getSpotAttenuation(t,l),h=o.length(),u=rS({lightDistance:h,cutoffDistance:n,decayExponent:i});let d=e.mul(c).mul(u),f,p;return s.colorNode?(p=this.getLightCoord(t),f=s.colorNode(p)):s.map&&(p=this.getLightCoord(t),f=pn(s.map,p.xy).onRenderUpdate(()=>s.map)),f&&(d=p.mul(2).sub(1).abs().lessThan(1).all().select(d.mul(f),d)),{lightColor:d,lightDirection:a}}}class CL extends Dg{static get type(){return"IESSpotLightNode"}getSpotAttenuation(t,e){const n=this.light.iesMap;let i=null;if(n&&n.isTexture===!0){const s=e.acos().mul(1/Math.PI);i=pn(n,xe(s,0),0).r}else i=super.getSpotAttenuation(e);return i}}const NL=Mt(([r,t])=>{const e=r.x,n=r.y,i=r.z;let s=t.element(0).mul(.886227);return s=s.add(t.element(1).mul(2*.511664).mul(n)),s=s.add(t.element(2).mul(2*.511664).mul(i)),s=s.add(t.element(3).mul(2*.511664).mul(e)),s=s.add(t.element(4).mul(2*.429043).mul(e).mul(n)),s=s.add(t.element(5).mul(2*.429043).mul(n).mul(i)),s=s.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),s=s.add(t.element(7).mul(2*.429043).mul(e).mul(i)),s=s.add(t.element(8).mul(.429043).mul(Ve(e,e).sub(Ve(n,n)))),s});class RL extends ao{static get type(){return"LightProbeNode"}constructor(t=null){super(t);const e=[];for(let n=0;n<9;n++)e.push(new H);this.lightProbe=Qi(e)}update(t){const{light:e}=this;super.update(t);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(e.sh.coefficients[n]).multiplyScalar(e.intensity)}setup(t){const e=NL(kd,this.lightProbe);t.context.irradiance.addAssign(e)}}class IL extends Pc{constructor(t,e=ng,n=eg,i,s,o=gi,a=gi,l,c=Up){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,i,s,o,a,l,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}const PL=new Vi,Ey=new ke,il=new H,yp=new H,LL=[new H(1,0,0),new H(-1,0,0),new H(0,-1,0),new H(0,1,0),new H(0,0,1),new H(0,0,-1)],FL=[new H(0,-1,0),new H(0,-1,0),new H(0,0,-1),new H(0,0,1),new H(0,-1,0),new H(0,-1,0)],DL=[new H(1,0,0),new H(-1,0,0),new H(0,1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1)],UL=[new H(0,-1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1),new H(0,-1,0),new H(0,-1,0)],OL=Mt(({depthTexture:r,bd3D:t,dp:e})=>ts(r,t).compare(e)),BL=Mt(({depthTexture:r,bd3D:t,dp:e,shadow:n})=>{const i=tn("radius","float",n).setGroup(te),s=tn("mapSize","vec2",n).setGroup(te),o=i.div(s.x),a=Nc(t),l=gg(Gp(t,a.x.greaterThan(a.z).select(Pt(0,1,0),Pt(1,0,0)))),c=Gp(t,l),h=iS(Fa.xy).mul(6.28318530718),u=es(0,5,h),d=es(1,5,h),f=es(2,5,h),p=es(3,5,h),x=es(4,5,h);return ts(r,t.add(l.mul(u.x).add(c.mul(u.y)).mul(o))).compare(e).add(ts(r,t.add(l.mul(d.x).add(c.mul(d.y)).mul(o))).compare(e)).add(ts(r,t.add(l.mul(f.x).add(c.mul(f.y)).mul(o))).compare(e)).add(ts(r,t.add(l.mul(p.x).add(c.mul(p.y)).mul(o))).compare(e)).add(ts(r,t.add(l.mul(x.x).add(c.mul(x.y)).mul(o))).compare(e)).mul(1/5)}),zL=Mt(({filterFn:r,depthTexture:t,shadowCoord:e,shadow:n},i)=>{const s=e.xyz.toConst(),o=s.abs().toConst(),a=o.x.max(o.y).max(o.z),l=de("float").setGroup(te).onRenderUpdate(()=>n.camera.near),c=de("float").setGroup(te).onRenderUpdate(()=>n.camera.far),h=tn("bias","float",n).setGroup(te),u=kt(1).toVar();return hi(a.sub(c).lessThanEqual(0).and(a.sub(l).greaterThanEqual(0)),()=>{let d;i.renderer.reversedDepthBuffer?(d=d3(a.negate(),l,c),d.subAssign(h)):(d=WM(a.negate(),l,c),d.addAssign(h));const f=s.normalize();u.assign(r({depthTexture:t,bd3D:f,dp:d,shadow:n}))}),u});class VL extends sS{static get type(){return"PointShadowNode"}constructor(t,e=null){super(t,e)}getShadowFilterFn(t){return t===uN?OL:BL}setupShadowCoord(t,e){return e}setupShadowFilter(t,{filterFn:e,depthTexture:n,shadowCoord:i,shadow:s}){return zL({filterFn:e,depthTexture:n,shadowCoord:i,shadow:s})}setupRenderTarget(t,e){const n=new IL(t.mapSize.width);n.name="PointShadowDepthTexture",n.compareFunction=e.renderer.reversedDepthBuffer?Ou:ig;const i=e.createCubeRenderTarget(t.mapSize.width);return i.texture.name="PointShadowMap",i.depthTexture=n,{shadowMap:i,depthTexture:n}}renderShadow(t){const{shadow:e,shadowMap:n,light:i}=this,{renderer:s,scene:o}=t,a=e.camera,l=e.matrix,c=s.coordinateSystem===hr,h=c?LL:DL,u=c?FL:UL;n.setSize(e.mapSize.width,e.mapSize.width);const d=s.autoClear,f=s.getClearColor(PL),p=s.getClearAlpha();s.autoClear=!1,s.setClearColor(e.clearColor,e.clearAlpha);for(let x=0;x<6;x++){s.setRenderTarget(n,x),s.clear();const g=i.distance||a.far;g!==a.far&&(a.far=g,a.updateProjectionMatrix()),il.setFromMatrixPosition(i.matrixWorld),a.position.copy(il),yp.copy(a.position),yp.add(h[x]),a.up.copy(u[x]),a.lookAt(yp),a.updateMatrixWorld(),l.makeTranslation(-il.x,-il.y,-il.z),Ey.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),e._frustum.setFromProjectionMatrix(Ey,a.coordinateSystem,a.reversedDepth);const m=o.name;o.name=`Point Light Shadow [ ${i.name||"ID: "+i.id} ] - Face ${x+1}`,s.render(o,a),o.name=m}s.autoClear=d,s.setClearColor(f,p)}}const kL=(r,t)=>new VL(r,t),GL=({color:r,lightVector:t,cutoffDistance:e,decayExponent:n})=>{const i=t.normalize(),s=t.length(),o=rS({lightDistance:s,cutoffDistance:e,decayExponent:n}),a=r.mul(o);return{lightDirection:i,lightColor:a}};class HL extends ao{static get type(){return"PointLightNode"}constructor(t=null){super(t),this.cutoffDistanceNode=de(0).setGroup(te),this.decayExponentNode=de(2).setGroup(te)}update(t){const{light:e}=this;super.update(t),this.cutoffDistanceNode.value=e.distance,this.decayExponentNode.value=e.decay}setupShadowNode(){return kL(this.light)}setupDirect(t){return GL({color:this.colorNode,lightVector:this.getLightVector(t),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const WL=Mt(([r,t])=>{const e=r.abs().sub(t);return Vu(as(e,0)).add(lc(as(e.x,e.y),0))});class XL extends Dg{static get type(){return"ProjectorLightNode"}update(t){super.update(t);const e=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(e.angle*(1-e.penumbra)),.99999),e.aspect===null){let n=1;e.map!==null&&(n=e.map.width/e.map.height),e.shadow.aspect=n}else e.shadow.aspect=e.aspect}getSpotAttenuation(t){const e=kt(0),n=this.penumbraCosNode,i=Fg(this.light).mul(t.context.positionWorld||Cg);return hi(i.w.greaterThan(0),()=>{const s=i.xyz.div(i.w),o=WL(s.xy.sub(xe(.5)),xe(.5)),a=Od(-1,Wn(1,uM(n)).sub(1));e.assign(yg(o.mul(-2).mul(a)))}),e}}const _p=new ke,nu=new ke;let sl=null;class $L extends ao{static get type(){return"RectAreaLightNode"}constructor(t=null){super(t),this.halfHeight=de(new H).setGroup(te),this.halfWidth=de(new H).setGroup(te),this.updateType=ue.RENDER}update(t){super.update(t);const{light:e}=this,n=t.camera.matrixWorldInverse;nu.identity(),_p.copy(e.matrixWorld),_p.premultiply(n),nu.extractRotation(_p),this.halfWidth.value.set(e.width*.5,0,0),this.halfHeight.value.set(0,e.height*.5,0),this.halfWidth.value.applyMatrix4(nu),this.halfHeight.value.applyMatrix4(nu)}setupDirectRectArea(t){let e,n;t.isAvailable("float32Filterable")?(e=pn(sl.LTC_FLOAT_1),n=pn(sl.LTC_FLOAT_2)):(e=pn(sl.LTC_HALF_1),n=pn(sl.LTC_HALF_2));const{colorNode:i,light:s}=this,o=eS(s);return{lightColor:i,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:e,ltc_2:n}}static setLTC(t){sl=t}}class oS extends xn{static get type(){return"BitcastNode"}constructor(t,e,n=null){super(),this.valueNode=t,this.conversionType=e,this.inputType=n,this.isBitcastNode=!0}getNodeType(t){if(this.inputType!==null){const e=this.valueNode.getNodeType(t),n=t.getTypeLength(e);return t.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(t){const e=this.getNodeType(t);let n="";if(this.inputType!==null){const i=this.valueNode.getNodeType(t);n=t.getTypeLength(i)===1?this.inputType:t.changeComponentType(i,this.inputType)}else n=this.valueNode.getNodeType(t);return`${t.getBitcastMethod(e,n)}( ${this.valueNode.build(t,n)} )`}}const qL=At(oS).setParameterLength(2),YL=r=>new oS(r,"uint","float"),iu={};class qr extends z{static get type(){return"BitcountNode"}constructor(t,e){super(t,e),this.isBitcountNode=!0}_resolveElementType(t,e,n){n==="int"?e.assign(qL(t,"uint")):e.assign(t)}_returnDataNode(t){switch(t){case"uint":return fn;case"int":return Be;case"uvec2":return tM;case"uvec3":return nM;case"uvec4":return sM;case"ivec2":return ji;case"ivec3":return eM;case"ivec4":return iM}}_createTrailingZerosBaseLayout(t,e){const n=this._returnDataNode(e);return Mt(([s])=>{const o=fn(0);this._resolveElementType(s,o,e);const a=kt(o.bitAnd(fM(o))),c=YL(a).shiftRight(23).sub(127);return n(c)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createLeadingZerosBaseLayout(t,e){const n=this._returnDataNode(e);return Mt(([s])=>{hi(s.equal(fn(0)),()=>fn(32));const o=fn(0),a=fn(0);return this._resolveElementType(s,o,e),hi(o.shiftRight(16).equal(0),()=>{a.addAssign(16),o.shiftLeftAssign(16)}),hi(o.shiftRight(24).equal(0),()=>{a.addAssign(8),o.shiftLeftAssign(8)}),hi(o.shiftRight(28).equal(0),()=>{a.addAssign(4),o.shiftLeftAssign(4)}),hi(o.shiftRight(30).equal(0),()=>{a.addAssign(2),o.shiftLeftAssign(2)}),hi(o.shiftRight(31).equal(0),()=>{a.addAssign(1)}),n(a)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createOneBitsBaseLayout(t,e){const n=this._returnDataNode(e);return Mt(([s])=>{const o=fn(0);this._resolveElementType(s,o,e),o.assign(o.sub(o.shiftRight(fn(1)).bitAnd(fn(1431655765)))),o.assign(o.bitAnd(fn(858993459)).add(o.shiftRight(fn(2)).bitAnd(fn(858993459))));const a=o.add(o.shiftRight(fn(4))).bitAnd(fn(252645135)).mul(fn(16843009)).shiftRight(fn(24));return n(a)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createMainLayout(t,e,n,i){const s=this._returnDataNode(e);return Mt(([a])=>{if(n===1)return s(i(a));{const l=s(0),c=["x","y","z","w"];for(let h=0;h<n;h++){const u=c[h];l[u].assign(i(a[u]))}return l}}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}setup(t){const{method:e,aNode:n}=this,{renderer:i}=t;if(i.backend.isWebGPUBackend)return super.setup(t);const s=this.getInputType(t),o=t.getElementType(s),a=t.getTypeLength(s),l=`${e}_base_${o}`,c=`${e}_${s}`;let h=iu[l];if(h===void 0){switch(e){case qr.COUNT_LEADING_ZEROS:{h=this._createLeadingZerosBaseLayout(l,o);break}case qr.COUNT_TRAILING_ZEROS:{h=this._createTrailingZerosBaseLayout(l,o);break}case qr.COUNT_ONE_BITS:{h=this._createOneBitsBaseLayout(l,o);break}}iu[l]=h}let u=iu[c];return u===void 0&&(u=this._createMainLayout(c,s,a,h),iu[c]=u),Mt(()=>u(n))()}}qr.COUNT_TRAILING_ZEROS="countTrailingZeros";qr.COUNT_LEADING_ZEROS="countLeadingZeros";qr.COUNT_ONE_BITS="countOneBits";class Rs extends Bt{static get type(){return"EventNode"}constructor(t,e){super("void"),this.eventType=t,this.callback=e,t===Rs.OBJECT?this.updateType=ue.OBJECT:t===Rs.MATERIAL?this.updateType=ue.RENDER:t===Rs.BEFORE_OBJECT?this.updateBeforeType=ue.OBJECT:t===Rs.BEFORE_MATERIAL&&(this.updateBeforeType=ue.RENDER)}update(t){this.callback(t)}updateBefore(t){this.callback(t)}}Rs.OBJECT="object";Rs.MATERIAL="material";Rs.BEFORE_OBJECT="beforeObject";Rs.BEFORE_MATERIAL="beforeMaterial";new Dr;new H;new H;new H;new ke;new H(0,0,-1);new Nn;new H;new H;new Nn;new Ge;const ZL=new ZM;wg.flipX();ZL.depthTexture=new Pc(1,1);Pt(.04);kt(1);const JL=Mt(([r,t])=>r.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),jL=Mt(([r,t])=>(r=r.mul(t),r.div(r.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),KL=Mt(([r,t])=>{r=r.mul(t),r=r.sub(.004).max(0);const e=r.mul(r.mul(6.2).add(.5)),n=r.mul(r.mul(6.2).add(1.7)).add(.06);return e.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),QL=Mt(([r])=>{const t=r.mul(r.add(.0245786)).sub(90537e-9),e=r.mul(r.add(.432951).mul(.983729)).add(.238081);return t.div(e)}),tF=Mt(([r,t])=>{const e=yi(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=yi(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return r=r.mul(t).div(.6),r=e.mul(r),r=QL(r),r=n.mul(r),r.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),eF=yi(Pt(1.6605,-.1246,-.0182),Pt(-.5876,1.1329,-.1006),Pt(-.0728,-.0083,1.1187)),nF=yi(Pt(.6274,.0691,.0164),Pt(.3293,.9195,.088),Pt(.0433,.0113,.8956)),iF=Mt(([r])=>{const t=Pt(r).toVar(),e=Pt(t.mul(t)).toVar(),n=Pt(e.mul(e)).toVar();return kt(15.5).mul(n.mul(e)).sub(Ve(40.14,n.mul(t))).add(Ve(31.96,n).sub(Ve(6.868,e.mul(t))).add(Ve(.4298,e).add(Ve(.1191,t).sub(.00232))))}),sF=Mt(([r,t])=>{const e=Pt(r).toVar(),n=yi(Pt(.856627153315983,.137318972929847,.11189821299995),Pt(.0951212405381588,.761241990602591,.0767994186031903),Pt(.0482516061458583,.101439036467562,.811302368396859)),i=yi(Pt(1.1271005818144368,-.1413297634984383,-.14132976349843826),Pt(-.11060664309660323,1.157823702216272,-.11060664309660294),Pt(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=kt(-12.47393),o=kt(4.026069);return e.mulAssign(t),e.assign(nF.mul(e)),e.assign(n.mul(e)),e.assign(as(e,1e-10)),e.assign($r(e)),e.assign(e.sub(s).div(o.sub(s))),e.assign(_a(e,0,1)),e.assign(iF(e)),e.assign(i.mul(e)),e.assign(xg(as(Pt(0),e),Pt(2.2))),e.assign(eF.mul(e)),e.assign(_a(e,0,1)),e}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),rF=Mt(([r,t])=>{const e=kt(.76),n=kt(.15);r=r.mul(t);const i=lc(r.r,lc(r.g,r.b)),s=_g(i.lessThan(.08),i.sub(Ve(6.25,i.mul(i))),.04);r.subAssign(s);const o=as(r.r,as(r.g,r.b));hi(o.lessThan(e),()=>r);const a=Wn(1,e),l=Wn(1,a.mul(a).div(o.add(a.sub(e))));r.mulAssign(l.div(o));const c=Wn(1,Od(1,n.mul(o.sub(l)).add(1)));return Dn(r,Pt(l),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class oF extends F3{constructor(){super(),this.addLight(HL,V3),this.addLight(AL,G3),this.addLight($L,H3),this.addLight(Dg,Lg),this.addLight(wL,X3),this.addLight(EL,$3),this.addLight(RL,Y3),this.addLight(CL,Z3),this.addLight(XL,J3),this.addToneMapping(JL,xN),this.addToneMapping(jL,yN),this.addToneMapping(KL,_N),this.addToneMapping(tF,vN),this.addToneMapping(sF,MN),this.addToneMapping(rF,SN)}}function aF(r){const t={};for(const e in r){t[e]={};for(const n in r[e]){const i=r[e][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(ne("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}function lF(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}exports.ACESFilmicToneMapping=$u;exports.AdditiveBlending=uu;exports.AgXToneMapping=qu;exports.AlwaysDepth=Tl;exports.AlwaysStencilFunc=Cu;exports.AmbientLight=Xm;exports.AnimationClip=ga;exports.AnimationMixer=_v;exports.ArrayCamera=Zm;exports.Audio=jm;exports.AudioContext=Nd;exports.AudioListener=mv;exports.AudioLoader=pv;exports.AxesHelper=Iv;exports.BackSide=An;exports.BasicDepthPacking=rm;exports.BasicNodeLibrary=oF;exports.BatchedMesh=gm;exports.Bone=hd;exports.BooleanKeyframeTrack=pr;exports.Box3=mn;exports.Box3Helper=Rv;exports.BoxGeometry=dr;exports.BoxHelper=Nv;exports.BufferAttribute=Te;exports.BufferGeometry=se;exports.Cache=Fi;exports.Camera=Tc;exports.CameraHelper=Cv;exports.CanvasTexture=H_;exports.CatmullRomCurve3=bm;exports.ClampToEdgeWrapping=Bn;exports.Color=wt;exports.ColorKeyframeTrack=Ad;exports.ColorManagement=fe;exports.CompressedArrayTexture=k_;exports.CompressedCubeTexture=G_;exports.CompressedTexture=_c;exports.Controls=Lv;exports.CubeCamera=Ym;exports.CubeTexture=Sa;exports.CubeUVReflectionMapping=to;exports.Curve=vi;exports.CustomBlending=Zp;exports.CylinderGeometry=ba;exports.Data3DTexture=mc;exports.DataTexture=fi;exports.DataTextureLoader=lv;exports.DataUtils=O_;exports.DecrementStencilOp=l_;exports.DecrementWrapStencilOp=h_;exports.DefaultLoadingManager=zm;exports.DepthFormat=Oi;exports.DepthStencilFormat=Cs;exports.DepthTexture=jr;exports.DirectionalLight=Wm;exports.DirectionalLightHelper=Ev;exports.DoubleSide=Ri;exports.DynamicDrawUsage=w_;exports.EdgesGeometry=Mm;exports.EqualDepth=Al;exports.EqualStencilFunc=p_;exports.EquirectangularReflectionMapping=Jo;exports.EquirectangularRefractionMapping=jo;exports.Euler=mi;exports.EventDispatcher=Bi;exports.ExtrudeGeometry=Mc;exports.FileLoader=rs;exports.Float32BufferAttribute=Ct;exports.FloatType=Tn;exports.Fog=cm;exports.FrontSide=is;exports.Frustum=no;exports.GLSL3=Nu;exports.GreaterDepth=Cl;exports.GreaterEqualDepth=El;exports.GreaterEqualStencilFunc=y_;exports.GreaterStencilFunc=g_;exports.GridHelper=Av;exports.Group=Gr;exports.HalfFloatType=Ui;exports.HemisphereLight=Vm;exports.ImageBitmapLoader=fv;exports.ImageUtils=am;exports.IncrementStencilOp=a_;exports.IncrementWrapStencilOp=c_;exports.InstancedBufferAttribute=Jr;exports.InstancedBufferGeometry=qm;exports.InstancedInterleavedBuffer=vv;exports.InstancedMesh=mm;exports.InterleavedBuffer=xc;exports.InterleavedBufferAttribute=ua;exports.Interpolant=so;exports.InterpolateDiscrete=ca;exports.InterpolateLinear=Yl;exports.InvertStencilOp=u_;exports.KeepStencilOp=Ks;exports.KeyframeTrack=ri;exports.LOD=fm;exports.Layers=gc;exports.LessDepth=wl;exports.LessEqualDepth=rr;exports.LessEqualStencilFunc=m_;exports.LessStencilFunc=f_;exports.Line=Fs;exports.Line3=Tv;exports.LineBasicMaterial=Rn;exports.LineLoop=xm;exports.LineSegments=zi;exports.LinearFilter=Fe;exports.LinearMipMapLinearFilter=Ky;exports.LinearMipmapLinearFilter=Li;exports.LinearMipmapNearestFilter=Ko;exports.LinearSRGBColorSpace=lr;exports.LinearToneMapping=Wu;exports.Loader=Vn;exports.LoaderUtils=Fu;exports.LoadingManager=Ed;exports.LoopOnce=nm;exports.LoopRepeat=im;exports.MOUSE=Cy;exports.Material=gn;exports.MathUtils=N_;exports.Matrix3=ae;exports.Matrix4=Qt;exports.MaxEquation=Jp;exports.Mesh=Ye;exports.MeshBasicMaterial=Ds;exports.MeshDepthMaterial=wd;exports.MeshLambertMaterial=Dm;exports.MeshNormalMaterial=Fm;exports.MeshPhongMaterial=Lm;exports.MeshPhysicalMaterial=Pm;exports.MeshStandardMaterial=Td;exports.MirroredRepeatWrapping=aa;exports.NearestFilter=Xe;exports.NearestMipMapNearestFilter=jy;exports.NearestMipmapLinearFilter=zr;exports.NearestMipmapNearestFilter=Ju;exports.NeutralToneMapping=Yu;exports.NeverDepth=bl;exports.NeverStencilFunc=d_;exports.NoBlending=Di;exports.NoColorSpace=Ki;exports.NoToneMapping=di;exports.NodeFrame=jP;exports.NormalBlending=nr;exports.NotEqualDepth=Nl;exports.NotEqualStencilFunc=x_;exports.NumberKeyframeTrack=pa;exports.Object3D=ve;exports.OctahedronGeometry=Ta;exports.OrthographicCamera=Ea;exports.PCFSoftShadowMap=Yp;exports.PMREMGenerator=Du;exports.PerspectiveCamera=cn;exports.Plane=Ts;exports.PlaneGeometry=io;exports.PointLight=Hm;exports.Points=ym;exports.PointsMaterial=dd;exports.PositionalAudio=gv;exports.PropertyBinding=me;exports.Quaternion=En;exports.QuaternionKeyframeTrack=Aa;exports.R11_EAC_Format=Ul;exports.RED_GREEN_RGTC2_Format=$l;exports.RED_RGTC1_Format=Wl;exports.REVISION=Wr;exports.RG11_EAC_Format=Bl;exports.RGBADepthPacking=i_;exports.RGBAFormat=wn;exports.RGBAIntegerFormat=pc;exports.RGBA_ASTC_4x4_Format=Vl;exports.RGBA_ASTC_6x6_Format=kl;exports.RGBA_BPTC_Format=Gl;exports.RGBA_ETC2_EAC_Format=Dl;exports.RGBA_PVRTC_2BPPV1_Format=Pl;exports.RGBA_PVRTC_4BPPV1_Format=Il;exports.RGBA_S3TC_DXT1_Format=ta;exports.RGBA_S3TC_DXT5_Format=ea;exports.RGBFormat=nd;exports.RGB_BPTC_UNSIGNED_Format=Hl;exports.RGB_ETC1_Format=Ll;exports.RGB_ETC2_Format=Fl;exports.RGB_PVRTC_4BPPV1_Format=Rl;exports.RGB_S3TC_DXT1_Format=Qo;exports.RGFormat=ar;exports.RGIntegerFormat=fc;exports.RawShaderMaterial=bd;exports.Ray=eo;exports.Raycaster=Mv;exports.RedFormat=dc;exports.RedIntegerFormat=Ma;exports.ReinhardToneMapping=Xu;exports.RepeatWrapping=oa;exports.ReplaceStencilOp=o_;exports.RingGeometry=Sc;exports.SIGNED_R11_EAC_Format=Ol;exports.SIGNED_RED_GREEN_RGTC2_Format=ql;exports.SIGNED_RED_RGTC1_Format=Xl;exports.SIGNED_RG11_EAC_Format=zl;exports.SRGBColorSpace=Fn;exports.Scene=hm;exports.ShaderChunk=oe;exports.ShaderLib=ci;exports.ShaderMaterial=si;exports.ShadowMaterial=Rm;exports.Shape=ir;exports.ShapePath=Pv;exports.ShapeUtils=ui;exports.Skeleton=yc;exports.SkinnedMesh=pm;exports.Source=Ns;exports.Sphere=un;exports.SphereGeometry=wa;exports.Spherical=Sv;exports.SpotLight=Gm;exports.Sprite=dm;exports.SpriteMaterial=cd;exports.THREE=hN;exports.TOUCH=Ny;exports.Texture=rn;exports.TextureLoader=cv;exports.Timer=Jm;exports.TorusGeometry=bc;exports.Triangle=ws;exports.TriangleFanDrawMode=n_;exports.TriangleStripDrawMode=e_;exports.TrianglesDrawMode=t_;exports.Uint16BufferAttribute=ld;exports.Uniform=Rd;exports.UniformsLib=gt;exports.UniformsUtils=Im;exports.UnsignedByteType=Un;exports.UnsignedInt101111Type=ed;exports.UnsignedInt248Type=Yr;exports.UnsignedInt5999Type=td;exports.UnsignedIntType=ii;exports.Vector2=tt;exports.Vector3=R;exports.Vector4=Le;exports.VectorKeyframeTrack=ma;exports.VideoTexture=_m;exports.WebGLCubeRenderTarget=Pd;exports.WebGLRenderTarget=qn;exports.WebGLRenderer=Vv;exports.WireframeGeometry=Nm;exports.ZeroStencilOp=r_;exports.cloneUniforms=aF;exports.cloneUniformsGroups=lF;
|
|
4083
|
+
`).removeFlowTab();t.addFlowTab()}}const tr=(...r)=>new Q2(ra(r,"int")).toStack();class t3 extends ni{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=gi,this.minFilter=gi,this.wrapR=cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}const Qf=new WeakMap,Kn=new Nn,ly=Mt(({bufferMap:r,influence:t,stride:e,width:n,depth:i,offset:s})=>{const o=Be(G2).mul(e).add(s),a=o.div(n),l=o.sub(a.mul(n));return li(r,ji(l,a)).depth(i).xyz.mul(t)});function e3(r){const t=r.morphAttributes.position!==void 0,e=r.morphAttributes.normal!==void 0,n=r.morphAttributes.color!==void 0,i=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,s=i!==void 0?i.length:0;let o=Qf.get(r);if(o===void 0||o.count!==s){let m=function(){x.dispose(),Qf.delete(r),r.removeEventListener("dispose",m)};o!==void 0&&o.texture.dispose();const a=r.morphAttributes.position||[],l=r.morphAttributes.normal||[],c=r.morphAttributes.color||[];let h=0;t===!0&&(h=1),e===!0&&(h=2),n===!0&&(h=3);let u=r.attributes.position.count*h,d=1;const f=4096;u>f&&(d=Math.ceil(u/f),u=f);const p=new Float32Array(u*d*4*s),x=new t3(p,u,d,s);x.type=Wv,x.needsUpdate=!0;const g=h*4;for(let y=0;y<s;y++){const v=a[y],_=l[y],w=c[y],T=u*d*4*y;for(let E=0;E<v.count;E++){const M=E*g;t===!0&&(Kn.fromBufferAttribute(v,E),p[T+M+0]=Kn.x,p[T+M+1]=Kn.y,p[T+M+2]=Kn.z,p[T+M+3]=0),e===!0&&(Kn.fromBufferAttribute(_,E),p[T+M+4]=Kn.x,p[T+M+5]=Kn.y,p[T+M+6]=Kn.z,p[T+M+7]=0),n===!0&&(Kn.fromBufferAttribute(w,E),p[T+M+8]=Kn.x,p[T+M+9]=Kn.y,p[T+M+10]=Kn.z,p[T+M+11]=w.itemSize===4?Kn.w:1)}}o={count:s,texture:x,stride:h,size:new Ge(u,d)},Qf.set(r,o),r.addEventListener("dispose",m)}return o}class n3 extends Bt{static get type(){return"MorphNode"}constructor(t){super("void"),this.mesh=t,this.morphBaseInfluence=de(1),this.updateType=ue.OBJECT}setup(t){const{geometry:e}=t,n=e.morphAttributes.position!==void 0,i=e.hasAttribute("normal")&&e.morphAttributes.normal!==void 0,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,o=s!==void 0?s.length:0,{texture:a,stride:l,size:c}=e3(e);n===!0&&Xn.mulAssign(this.morphBaseInfluence),i===!0&&ls.mulAssign(this.morphBaseInfluence);const h=Be(c.width);tr(o,({i:u})=>{const d=kt(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(li(this.mesh.morphTexture,ji(Be(u).add(1),Be(Ml))).r):d.assign(tn("morphTargetInfluences","float").element(u).toVar()),hi(d.notEqual(0),()=>{n===!0&&Xn.addAssign(ly({bufferMap:a,influence:d,stride:l,width:h,depth:u,offset:Be(0)})),i===!0&&ls.addAssign(ly({bufferMap:a,influence:d,stride:l,width:h,depth:u,offset:Be(1)}))})})}update(){const t=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?t.value=1:t.value=1-this.mesh.morphTargetInfluences.reduce((e,n)=>e+n,0)}}const i3=De(n3).setParameterLength(1);class Rg extends Bt{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class s3 extends Rg{static get type(){return"AONode"}constructor(t=null){super(),this.aoNode=t}setup(t){t.context.ambientOcclusion.mulAssign(this.aoNode)}}class r3 extends xM{static get type(){return"LightingContextNode"}constructor(t,e=null,n=null,i=null){super(t),this.lightingModel=e,this.backdropNode=n,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:t,backdropAlphaNode:e}=this,n=Pt().toVar("directDiffuse"),i=Pt().toVar("directSpecular"),s=Pt().toVar("indirectDiffuse"),o=Pt().toVar("indirectSpecular"),a={directDiffuse:n,directSpecular:i,indirectDiffuse:s,indirectSpecular:o};return{radiance:Pt().toVar("radiance"),irradiance:Pt().toVar("irradiance"),iblIrradiance:Pt().toVar("iblIrradiance"),ambientOcclusion:kt(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:t,backdropAlpha:e}}setup(t){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||t.context.lightingModel,super.setup(t)}}const o3=De(r3);class a3 extends Rg{static get type(){return"IrradianceNode"}constructor(t){super(),this.node=t}setup(t){t.context.irradiance.addAssign(this.node)}}class l3 extends ni{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=gi,this.minFilter=gi,this.generateMipmaps=!1,this.needsUpdate=!0}}const zo=new Ge;class c3 extends Hd{static get type(){return"ViewportTextureNode"}constructor(t=Tg,e=null,n=null){let i=null;n===null?(i=new l3,i.minFilter=Gv,n=i):i=n,super(n,t,e),this.generateMipmaps=!1,this.defaultFramebuffer=i,this.isOutputTextureNode=!0,this.updateBeforeType=ue.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(t=null){let e,n;if(this.referenceNode?(e=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(e=this.defaultFramebuffer,n=this._cacheTextures),t===null)return e;if(n.has(t)===!1){const i=e.clone();n.set(t,i)}return n.get(t)}updateReference(t){const e=t.renderer.getRenderTarget();return this.value=this.getTextureForReference(e),this.value}updateBefore(t){const e=t.renderer,n=e.getRenderTarget();n===null?e.getDrawingBufferSize(zo):zo.set(n.width,n.height);const i=this.getTextureForReference(n);(i.image.width!==zo.width||i.image.height!==zo.height)&&(i.image.width=zo.width,i.image.height=zo.height,i.needsUpdate=!0);const s=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,e.copyFramebufferToTexture(i),i.generateMipmaps=s}clone(){const t=new this.constructor(this.uvNode,this.levelNode,this.value);return t.generateMipmaps=this.generateMipmaps,t}}class Pc extends ni{constructor(t,e,n=eg,i,s,o,a=gi,l=gi,c,h=Up,u=1){if(h!==Up&&h!==AN)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,i,s,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Cg(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}let zh=null;class h3 extends c3{static get type(){return"ViewportDepthTextureNode"}constructor(t=Tg,e=null){zh===null&&(zh=new Pc),super(t,e,zh)}getTextureForReference(){return zh}}const u3=De(h3).setParameterLength(0,2);class $n extends Bt{static get type(){return"ViewportDepthNode"}constructor(t,e=null){super("float"),this.scope=t,this.valueNode=e,this.isViewportDepthNode=!0}generate(t){const{scope:e}=this;return e===$n.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){const{scope:e}=this,n=this.valueNode;let i=null;if(e===$n.DEPTH_BASE)n!==null&&(i=qM().assign(n));else if(e===$n.DEPTH)t.isPerspectiveCamera?i=WM(hn.z,Or,Br):i=Sl(hn.z,Or,Br);else if(e===$n.LINEAR_DEPTH)if(n!==null)if(t.isPerspectiveCamera){const s=XM(n,Or,Br);i=Sl(s,Or,Br)}else i=n;else i=Sl(hn.z,Or,Br);return i}}$n.DEPTH_BASE="depthBase";$n.DEPTH="depth";$n.LINEAR_DEPTH="linearDepth";const Sl=(r,t,e)=>r.add(t).div(t.sub(e)),WM=(r,t,e)=>t.add(r).mul(e).div(e.sub(t).mul(r)),d3=(r,t,e)=>t.mul(r.add(e)).div(r.mul(t.sub(e))),XM=Mt(([r,t,e],n)=>n.renderer.reversedDepthBuffer===!0?t.mul(e).div(t.sub(e).mul(r).sub(t)):t.mul(e).div(e.sub(t).mul(r).sub(e))),$M=(r,t,e)=>{t=t.max(1e-6).toVar();const n=$r(r.negate().div(t)),i=$r(e.div(t));return n.div(i)},qM=De($n,$n.DEPTH_BASE),YM=Ke($n,$n.DEPTH),f3=De($n,$n.LINEAR_DEPTH).setParameterLength(0,1);u3();YM.assign=r=>qM(r);class pi extends Bt{static get type(){return"ClippingNode"}constructor(t=pi.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);const e=t.clippingContext,{intersectionPlanes:n,unionPlanes:i}=e;return this.hardwareClipping=t.material.hardwareClipping,this.scope===pi.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,i):this.scope===pi.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(n,i)}setupAlphaToCoverage(t,e){return Mt(()=>{const n=kt().toVar("distanceToPlane"),i=kt().toVar("distanceToGradient"),s=kt(1).toVar("clipOpacity"),o=e.length;if(this.hardwareClipping===!1&&o>0){const l=Qi(e).setGroup(te);tr(o,({i:c})=>{const h=l.element(c);n.assign(hn.dot(h.xyz).negate().add(h.w)),i.assign(n.fwidth().div(2)),s.mulAssign(hc(i.negate(),i,n))})}const a=t.length;if(a>0){const l=Qi(t).setGroup(te),c=kt(1).toVar("intersectionClipOpacity");tr(a,({i:h})=>{const u=l.element(h);n.assign(hn.dot(u.xyz).negate().add(u.w)),i.assign(n.fwidth().div(2)),c.mulAssign(hc(i.negate(),i,n).oneMinus())}),s.mulAssign(c.oneMinus())}Hn.a.mulAssign(s),Hn.a.equal(0).discard()})()}setupDefault(t,e){return Mt(()=>{const n=e.length;if(this.hardwareClipping===!1&&n>0){const s=Qi(e).setGroup(te);tr(n,({i:o})=>{const a=s.element(o);hn.dot(a.xyz).greaterThan(a.w).discard()})}const i=t.length;if(i>0){const s=Qi(t).setGroup(te),o=fg(!0).toVar("clipped");tr(i,({i:a})=>{const l=s.element(a);o.assign(hn.dot(l.xyz).greaterThan(l.w).and(o))}),o.discard()}})()}setupHardwareClipping(t,e){const n=t.length;return e.enableHardwareClipping(n),Mt(()=>{const i=Qi(t).setGroup(te),s=Bd(e.getClipDistance());tr(n,({i:o})=>{const a=i.element(o),l=hn.dot(a.xyz).sub(a.w).negate();s.element(o).assign(l)})})()}}pi.ALPHA_TO_COVERAGE="alphaToCoverage";pi.DEFAULT="default";pi.HARDWARE="hardware";const p3=()=>new pi,m3=()=>new pi(pi.ALPHA_TO_COVERAGE),g3=()=>new pi(pi.HARDWARE),x3=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],tp=new WeakMap;class y3{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=x3,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1?(this.getRenderObjectData(t),!0):!1}needsVelocity(t){const e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){const{geometry:n,material:i,object:s}=t;if(e={material:this.getMaterialData(i),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexId:n.index?n.index.id:null,indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:s.matrixWorld.clone()},s.center&&(e.center=s.center.clone()),s.morphTargetInfluences&&(e.morphTargetInfluences=s.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),e.material.transmission>0){const{width:o,height:a}=t.context;e.bufferWidth=o,e.bufferHeight=a}e.lights=this.getLightsData(t.lightsNode.getLights()),this.renderObjects.set(t,e)}return e}getAttributesData(t){const e={};for(const n in t){const i=t[n];e[n]={id:i.id,version:i.version}}return e}containsNode(t){const e=t.material;for(const n in e)if(e[n]&&e[n].isNode)return!0;return!!(t.context.modelViewMatrix||t.context.modelNormalViewMatrix||t.context.getAO||t.context.getShadow)}getMaterialData(t){const e={};for(const n of this.refreshUniforms){const i=t[n];i!=null&&(typeof i=="object"&&i.clone!==void 0?i.isTexture===!0?e[n]={id:i.id,version:i.version}:e[n]=i.clone():e[n]=i)}return e}equals(t,e){const{object:n,material:i,geometry:s}=t,o=this.getRenderObjectData(t);if(o.worldMatrix.equals(n.matrixWorld)!==!0)return o.worldMatrix.copy(n.matrixWorld),!1;const a=o.material;for(const y in a){const v=a[y],_=i[y];if(v.equals!==void 0){if(v.equals(_)===!1)return v.copy(_),!1}else if(_.isTexture===!0){if(v.id!==_.id||v.version!==_.version)return v.id=_.id,v.version=_.version,!1}else if(v!==_)return a[y]=_,!1}if(a.transmission>0){const{width:y,height:v}=t.context;if(o.bufferWidth!==y||o.bufferHeight!==v)return o.bufferWidth=y,o.bufferHeight=v,!1}const l=o.geometry,c=s.attributes,h=l.attributes,u=Object.keys(h),d=Object.keys(c);if(l.id!==s.id)return l.id=s.id,!1;if(u.length!==d.length)return o.geometry.attributes=this.getAttributesData(c),!1;for(const y of u){const v=h[y],_=c[y];if(_===void 0)return delete h[y],!1;if(v.id!==_.id||v.version!==_.version)return v.id=_.id,v.version=_.version,!1}const f=s.index,p=l.indexId,x=l.indexVersion,g=f?f.id:null,m=f?f.version:null;if(p!==g||x!==m)return l.indexId=g,l.indexVersion=m,!1;if(l.drawRange.start!==s.drawRange.start||l.drawRange.count!==s.drawRange.count)return l.drawRange.start=s.drawRange.start,l.drawRange.count=s.drawRange.count,!1;if(o.morphTargetInfluences){let y=!1;for(let v=0;v<o.morphTargetInfluences.length;v++)o.morphTargetInfluences[v]!==n.morphTargetInfluences[v]&&(o.morphTargetInfluences[v]=n.morphTargetInfluences[v],y=!0);if(y)return!1}if(o.lights){for(let y=0;y<e.length;y++)if(o.lights[y].map!==e[y].map)return!1}return o.center&&o.center.equals(n.center)===!1?(o.center.copy(n.center),!0):(t.bundle!==null&&(o.version=t.bundle.version),!0)}getLightsData(t){const e=[];for(const n of t)n.isSpotLight===!0&&n.map!==null&&e.push({map:n.map.version});return e}getLights(t,e){if(tp.has(t)){const i=tp.get(t);if(i.renderId===e)return i.lightsData}const n=this.getLightsData(t.getLights());return tp.set(t,{renderId:e,lightsData:n}),n}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;const{renderId:n}=e;if(this.renderId!==n)return this.renderId=n,!0;const i=t.object.static===!0,s=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;if(i||s)return!1;const o=this.getLights(t.lightsNode,n);return this.equals(t,o)!==!0}}const _3=.05,cy=Mt(([r])=>Qr(Ve(1e4,ac(Ve(17,r.x).add(Ve(.1,r.y)))).mul(os(.1,Nc(ac(Ve(13,r.y).add(r.x))))))),hy=Mt(([r])=>cy(xe(cy(r.xy),r.z))),v3=Mt(([r])=>{const t=as(Vu(pM(r.xyz)),Vu(mM(r.xyz))),e=kt(1).div(kt(_3).mul(t)).toVar("pixScale"),n=xe(kp(hu($r(e))),kp(cM($r(e)))),i=xe(hy(hu(n.x.mul(r.xyz))),hy(hu(n.y.mul(r.xyz)))),s=Qr($r(e)),o=os(Ve(s.oneMinus(),i.x),Ve(s,i.y)),a=lc(s,s.oneMinus()),l=Pt(o.mul(o).div(Ve(2,a).mul(Wn(1,a))),o.sub(Ve(.5,a)).div(Wn(1,a)),Wn(1,Wn(1,o).mul(Wn(1,o)).div(Ve(2,a).mul(Wn(1,a))))),c=o.lessThan(a.oneMinus()).select(o.lessThan(a).select(l.x,l.y),l.z);return va(c,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class M3 extends AM{static get type(){return"VertexColorNode"}constructor(t){super(null,"vec4"),this.isVertexColorNode=!0,this.index=t}getAttributeName(){const t=this.index;return"color"+(t>0?t:"")}generate(t){const e=this.getAttributeName(t),n=t.hasGeometryAttribute(e);let i;return n===!0?i=super.generate(t):i=t.generateConst(this.nodeType,new Nn(1,1,1,1)),i}serialize(t){super.serialize(t),t.index=this.index}deserialize(t){super.deserialize(t),this.index=t.index}}const S3=(r=0)=>new M3(r),b3=Mt(([r])=>zn(r.rgb.mul(r.a),r.a),{color:"vec4",return:"vec4"});class qp extends Wp{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(t){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const t=[];for(const e of Object.getOwnPropertyNames(this)){if(e.startsWith("_")===!0)continue;const n=this[e];n&&n.isNode===!0&&t.push({property:e,childNode:n})}return t}customProgramCacheKey(){const t=[];for(const{property:e,childNode:n}of this._getNodeChildren())t.push(og(e.slice(0,-4)),n.getCacheKey());return this.type+Zv(t)}build(t){this.setup(t)}setupObserver(t){return new y3(t)}setup(t){t.context.setupNormal=()=>vl(this.setupNormal(t),"NORMAL","vec3"),t.context.setupPositionView=()=>this.setupPositionView(t),t.context.setupModelViewProjection=()=>this.setupModelViewProjection(t);const e=t.renderer,n=e.getRenderTarget();e.contextNode.isContextNode===!0?t.context={...t.context,...e.contextNode.getFlowContextData()}:Ne('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?t.context={...t.context,...this.contextNode.getFlowContextData()}:Ne('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),t.addStack();const i=this.setupVertex(t),s=vl(this.vertexNode||i,"VERTEX");t.context.clipSpace=s,t.stack.outputNode=s,this.setupHardwareClipping(t),this.geometryNode!==null&&(t.stack.outputNode=t.stack.outputNode.bypass(this.geometryNode)),t.addFlow("vertex",t.removeStack()),t.addStack();let o;const a=this.setupClipping(t);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(t):e.depth===!0&&this.setupDepth(t)),this.fragmentNode===null){this.setupDiffuseColor(t),this.setupVariants(t);const l=this.setupLighting(t);a!==null&&t.stack.addToStack(a);const c=zn(l,Hn.a).max(0);o=this.setupOutput(t,c),Wf.assign(o);const h=this.outputNode!==null;if(h&&(o=this.outputNode),t.context.getOutput&&(o=t.context.getOutput(o,t)),n!==null){const u=e.getMRT(),d=this.mrtNode;u!==null?(h&&Wf.assign(o),o=u,d!==null&&(o=u.merge(d))):d!==null&&(o=d)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=zn(l)),o=this.setupOutput(t,l)}t.stack.outputNode=o,t.addFlow("fragment",t.removeStack()),t.observer=this.setupObserver(t)}setupClipping(t){if(t.clippingContext===null)return null;const{unionPlanes:e,intersectionPlanes:n}=t.clippingContext;let i=null;if(e.length>0||n.length>0){const s=t.renderer.currentSamples;this.alphaToCoverage&&s>1?i=m3():t.stack.addToStack(p3())}return i}setupHardwareClipping(t){if(this.hardwareClipping=!1,t.clippingContext===null)return;const e=t.clippingContext.unionPlanes.length;e>0&&e<=8&&t.isAvailable("clipDistance")&&(t.stack.addToStack(g3()),this.hardwareClipping=!0)}setupDepth(t){const{renderer:e,camera:n}=t;let i=this.depthNode;if(i===null){const s="getMRT"in e&&e.getMRT();s&&s.has("depth")?i=s.get("depth"):e.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?i=$M(hn.z,Or,Br):i=Sl(hn.z,Or,Br))}i!==null&&YM.assign(i).toStack()}setupPositionView(){return NM.mul(Xn).xyz}setupModelViewProjection(){return BP.mul(hn)}setupVertex(t){return t.addStack(),this.setupPosition(t),t.context.position=t.removeStack(),B2}setupPosition(t){const{object:e,geometry:n}=t;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&i3(e).toStack(),e.isSkinnedMesh===!0&&K2(e).toStack(),this.displacementMap){const i=qo("displacementMap","texture"),s=qo("displacementScale","float"),o=qo("displacementBias","float");Xn.addAssign(ls.normalize().mul(i.x.mul(s).add(o)))}return e.isBatchedMesh&&J2(e).toStack(),e.isInstancedMesh&&e.instanceMatrix&&e.instanceMatrix.isInstancedBufferAttribute===!0&&Y2(e).toStack(),this.positionNode!==null&&Xn.assign(vl(this.positionNode,"POSITION","vec3")),Xn}setupDiffuseColor(t){const{object:e,geometry:n}=t;this.maskNode!==null&&fg(this.maskNode).not().discard();let i=this.colorNode?zn(this.colorNode):P2;this.vertexColors===!0&&n.hasAttribute("color")&&(i=i.mul(S3())),e.instanceColor&&(i=zu("vec3","vInstanceColor").mul(i)),e.isBatchedMesh&&e._colorsTexture&&(i=zu("vec3","vBatchColor").mul(i)),Hn.assign(i);const s=this.opacityNode?kt(this.opacityNode):F2;Hn.a.assign(Hn.a.mul(s));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?kt(this.alphaTestNode):I2,this.alphaToCoverage===!0?(Hn.a=hc(o,o.add(gM(Hn.a)),Hn.a),Hn.a.lessThanEqual(0).discard()):Hn.a.lessThanEqual(o).discard()),this.alphaHash===!0&&Hn.a.lessThan(v3(Xn)).discard(),t.isOpaque()&&Hn.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Pt(0):Hn.rgb}setupNormal(){return this.normalNode?Pt(this.normalNode):D2}setupEnvironment(){let t=null;return this.envNode?t=this.envNode:this.envMap&&(t=this.envMap.isCubeTexture?qo("envMap","cubeTexture"):qo("envMap","texture")),t}setupLightMap(t){let e=null;return t.material.lightMap&&(e=new a3(U2)),e}setupLights(t){const e=[],n=this.setupEnvironment(t);n&&n.isLightingNode&&e.push(n);const i=this.setupLightMap(t);i&&i.isLightingNode&&e.push(i);let s=this.aoNode;s===null&&t.material.aoMap&&(s=O2),t.context.getAO&&(s=t.context.getAO(s,t)),s&&e.push(new s3(s));let o=this.lightsNode||t.lightsNode;return e.length>0&&(o=t.renderer.lighting.createNode([...o.getLights(),...e])),o}setupLightingModel(){}setupLighting(t){const{material:e}=t,{backdropNode:n,backdropAlphaNode:i,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(t):null;let l=this.setupOutgoingLight(t);if(a&&a.getScope().hasLights){const c=this.setupLightingModel(t)||null;l=o3(a,c,n,i)}else n!==null&&(l=Pt(i!==null?Dn(l,n,i):n));return(s&&s.isNode===!0||e.emissive&&e.emissive.isColor===!0)&&(Wx.assign(Pt(s||L2)),l=l.add(Wx)),l}setupFog(t,e){const n=t.fogNode;return n&&(Wf.assign(e),e=zn(n.toVar())),e}setupPremultipliedAlpha(t,e){return b3(e)}setupOutput(t,e){return this.fog===!0&&(e=this.setupFog(t,e)),this.premultipliedAlpha===!0&&(e=this.setupPremultipliedAlpha(t,e)),e}setDefaultValues(t){for(const n in t){const i=t[n];this[n]===void 0&&(this[n]=i,i&&i.clone&&(this[n]=i.clone()))}const e=Object.getOwnPropertyDescriptors(t.constructor.prototype);for(const n in e)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&e[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,e[n])}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{},nodes:{}});const n=Wp.prototype.toJSON.call(this,t);n.inputNodes={};for(const{property:s,childNode:o}of this._getNodeChildren())n.inputNodes[s]=o.toJSON(t).uuid;function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images),a=i(t.nodes);s.length>0&&(n.textures=s),o.length>0&&(n.images=o),a.length>0&&(n.nodes=a)}return n}copy(t){return this.lightsNode=t.lightsNode,this.envNode=t.envNode,this.aoNode=t.aoNode,this.colorNode=t.colorNode,this.normalNode=t.normalNode,this.opacityNode=t.opacityNode,this.backdropNode=t.backdropNode,this.backdropAlphaNode=t.backdropAlphaNode,this.alphaTestNode=t.alphaTestNode,this.maskNode=t.maskNode,this.maskShadowNode=t.maskShadowNode,this.positionNode=t.positionNode,this.geometryNode=t.geometryNode,this.depthNode=t.depthNode,this.receivedShadowPositionNode=t.receivedShadowPositionNode,this.castShadowPositionNode=t.castShadowPositionNode,this.receivedShadowNode=t.receivedShadowNode,this.castShadowNode=t.castShadowNode,this.outputNode=t.outputNode,this.mrtNode=t.mrtNode,this.fragmentNode=t.fragmentNode,this.vertexNode=t.vertexNode,this.contextNode=t.contextNode,super.copy(t)}}class ZM extends Ia{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rc,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Nn(0,0,t,e),this.scissorTest=!1,this.viewport=new Nn(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},s=new ni(i),o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){const e={minFilter:rc,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new Cg(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class T3{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let w3=0;const uy=new H,Vo=new Ra,vs=new ke,Vh=new H,nl=new H,A3=new H,E3=new Ra,dy=new H(1,0,0),fy=new H(0,1,0),py=new H(0,0,1),my={type:"added"},C3={type:"removed"},ko={type:"childadded",child:null},ep={type:"childremoved",child:null};class Cn extends Ia{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:w3++}),this.uuid=Ps(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Cn.DEFAULT_UP.clone();const t=new H,e=new Oa,n=new Ra,i=new H(1,1,1);function s(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ke},normalMatrix:{value:new Mi}}),this.matrix=new ke,this.matrixWorld=new ke,this.matrixAutoUpdate=Cn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Cn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new T3,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Vo.setFromAxisAngle(t,e),this.quaternion.multiply(Vo),this}rotateOnWorldAxis(t,e){return Vo.setFromAxisAngle(t,e),this.quaternion.premultiply(Vo),this}rotateX(t){return this.rotateOnAxis(dy,t)}rotateY(t){return this.rotateOnAxis(fy,t)}rotateZ(t){return this.rotateOnAxis(py,t)}translateOnAxis(t,e){return uy.copy(t).applyQuaternion(this.quaternion),this.position.add(uy.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(dy,t)}translateY(t){return this.translateOnAxis(fy,t)}translateZ(t){return this.translateOnAxis(py,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(vs.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Vh.copy(t):Vh.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),nl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vs.lookAt(nl,Vh,this.up):vs.lookAt(Vh,nl,this.up),this.quaternion.setFromRotationMatrix(vs),i&&(vs.extractRotation(i.matrixWorld),Vo.setFromRotationMatrix(vs),this.quaternion.premultiply(Vo.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Ne("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(my),ko.child=t,this.dispatchEvent(ko),ko.child=null):Ne("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(C3),ep.child=t,this.dispatchEvent(ep),ep.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),vs.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),vs.multiply(t.parent.matrixWorld)),t.applyMatrix4(vs),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(my),ko.child=t,this.dispatchEvent(ko),ko.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,t,A3),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,E3,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,i=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*i,s[13]+=n-s[1]*e-s[5]*n-s[9]*i,s[14]+=i-s[2]*e-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(t.shapes,u)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),h=o(t.images),u=o(t.shapes),d=o(t.skeletons),f=o(t.animations),p=o(t.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}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),t.pivot!==null&&(this.pivot=t.pivot.clone()),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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}}Cn.DEFAULT_UP=new H(0,1,0);Cn.DEFAULT_MATRIX_AUTO_UPDATE=!0;Cn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const kh=new H,Gh=new Ra,Ji=new H;class JM extends Cn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ke,this.projectionMatrix=new ke,this.projectionMatrixInverse=new ke,this.coordinateSystem=ns,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(kh,Gh,Ji),Ji.x===1&&Ji.y===1&&Ji.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(kh,Gh,Ji.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose(kh,Gh,Ji),Ji.x===1&&Ji.y===1&&Ji.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(kh,Gh,Ji.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Js=new H,gy=new Ge,xy=new Ge;class jM extends JM{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=oc*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(xl*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return oc*2*Math.atan(Math.tan(xl*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Js.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Js.x,Js.y).multiplyScalar(-t/Js.z),Js.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Js.x,Js.y).multiplyScalar(-t/Js.z)}getViewSize(t,e){return this.getViewBounds(t,gy,xy),e.subVectors(xy,gy)}setViewOffset(t,e,n,i,s,o){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(xl*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,e-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}let N3=0;const ai=new ke,np=new Cn,Go=new H,Qn=new Ic,il=new Ic,ln=new H;class Wd extends Ia{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:N3++}),this.uuid=Ps(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(PN(t)?xP:gP)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Mi().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return ai.makeRotationFromQuaternion(t),this.applyMatrix4(ai),this}rotateX(t){return ai.makeRotationX(t),this.applyMatrix4(ai),this}rotateY(t){return ai.makeRotationY(t),this.applyMatrix4(ai),this}rotateZ(t){return ai.makeRotationZ(t),this.applyMatrix4(ai),this}translate(t,e,n){return ai.makeTranslation(t,e,n),this.applyMatrix4(ai),this}scale(t,e,n){return ai.makeScale(t,e,n),this.applyMatrix4(ai),this}lookAt(t){return np.lookAt(t),np.updateMatrix(),this.applyMatrix4(np.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Go).negate(),this.translate(Go.x,Go.y,Go.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let i=0,s=t.length;i<s;i++){const o=t[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Hp(n,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&ne("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ic);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ne("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const s=e[n];Qn.setFromBufferAttribute(s),this.morphTargetsRelative?(ln.addVectors(this.boundingBox.min,Qn.min),this.boundingBox.expandByPoint(ln),ln.addVectors(this.boundingBox.max,Qn.max),this.boundingBox.expandByPoint(ln)):(this.boundingBox.expandByPoint(Qn.min),this.boundingBox.expandByPoint(Qn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ne('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zd);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ne("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new H,1/0);return}if(t){const n=this.boundingSphere.center;if(Qn.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];il.setFromBufferAttribute(a),this.morphTargetsRelative?(ln.addVectors(Qn.min,il.min),Qn.expandByPoint(ln),ln.addVectors(Qn.max,il.max),Qn.expandByPoint(ln)):(Qn.expandByPoint(il.min),Qn.expandByPoint(il.max))}Qn.getCenter(n);let i=0;for(let s=0,o=t.count;s<o;s++)ln.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(ln));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)ln.fromBufferAttribute(a,c),l&&(Go.fromBufferAttribute(t,c),ln.add(Go)),i=Math.max(i,n.distanceToSquared(ln))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ne('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Ne("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new sr(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let M=0;M<n.count;M++)a[M]=new H,l[M]=new H;const c=new H,h=new H,u=new H,d=new Ge,f=new Ge,p=new Ge,x=new H,g=new H;function m(M,b,P){c.fromBufferAttribute(n,M),h.fromBufferAttribute(n,b),u.fromBufferAttribute(n,P),d.fromBufferAttribute(s,M),f.fromBufferAttribute(s,b),p.fromBufferAttribute(s,P),h.sub(c),u.sub(c),f.sub(d),p.sub(d);const N=1/(f.x*p.y-p.x*f.y);isFinite(N)&&(x.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(N),g.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(N),a[M].add(x),a[b].add(x),a[P].add(x),l[M].add(g),l[b].add(g),l[P].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let M=0,b=y.length;M<b;++M){const P=y[M],N=P.start,L=P.count;for(let U=N,V=N+L;U<V;U+=3)m(t.getX(U+0),t.getX(U+1),t.getX(U+2))}const v=new H,_=new H,w=new H,T=new H;function E(M){w.fromBufferAttribute(i,M),T.copy(w);const b=a[M];v.copy(b),v.sub(w.multiplyScalar(w.dot(b))).normalize(),_.crossVectors(T,b);const N=_.dot(l[M])<0?-1:1;o.setXYZW(M,v.x,v.y,v.z,N)}for(let M=0,b=y.length;M<b;++M){const P=y[M],N=P.start,L=P.count;for(let U=N,V=N+L;U<V;U+=3)E(t.getX(U+0)),E(t.getX(U+1)),E(t.getX(U+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new sr(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new H,s=new H,o=new H,a=new H,l=new H,c=new H,h=new H,u=new H;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),x=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,x),o.fromBufferAttribute(e,g),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),a.fromBufferAttribute(n,p),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,g),a.add(h),l.add(h),c.add(h),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ln.fromBufferAttribute(t,e),ln.normalize(),t.setXYZ(e,ln.x,ln.y,ln.z)}toNonIndexed(){function t(a,l){const c=a.array,h=a.itemSize,u=a.normalized,d=new c.constructor(l.length*h);let f=0,p=0;for(let x=0,g=l.length;x<g;x++){a.isInterleavedBufferAttribute?f=l[x]*a.data.stride+a.offset:f=l[x]*h;for(let m=0;m<h;m++)d[p++]=c[f++]}return new sr(d,h,u)}if(this.index===null)return ne("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Wd,n=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=t(l,n);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);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 n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),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 n=t.index;n!==null&&this.setIndex(n.clone());const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ms=new H,ip=new H,Hh=new H,js=new H,sp=new H,Wh=new H,rp=new H;class R3{constructor(t=new H,e=new H(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Ms)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ms.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ms.copy(this.origin).addScaledVector(this.direction,e),Ms.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ip.copy(t).add(e).multiplyScalar(.5),Hh.copy(e).sub(t).normalize(),js.copy(this.origin).sub(ip);const s=t.distanceTo(e)*.5,o=-this.direction.dot(Hh),a=js.dot(this.direction),l=-js.dot(Hh),c=js.lengthSq(),h=Math.abs(1-o*o);let u,d,f,p;if(h>0)if(u=o*l-a,d=o*a-l,p=s*h,u>=0)if(d>=-p)if(d<=p){const x=1/h;u*=x,d*=x,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-p?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=p?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(ip).addScaledVector(Hh,d),f}intersectSphere(t,e){Ms.subVectors(t.center,this.origin);const n=Ms.dot(this.direction),i=Ms.dot(Ms)-n*n,s=t.radius*t.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(s=(t.min.y-d.y)*h,o=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,o=(t.min.y-d.y)*h),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),u>=0?(a=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Ms)!==null}intersectTriangle(t,e,n,i,s){sp.subVectors(e,t),Wh.subVectors(n,t),rp.crossVectors(sp,Wh);let o=this.direction.dot(rp),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;js.subVectors(this.origin,t);const l=a*this.direction.dot(Wh.crossVectors(js,Wh));if(l<0)return null;const c=a*this.direction.dot(sp.cross(js));if(c<0||l+c>o)return null;const h=-a*js.dot(rp);return h<0?null:this.at(h/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}const Ci=new H,Ss=new H,op=new H,bs=new H,Ho=new H,Wo=new H,yy=new H,ap=new H,lp=new H,cp=new H,hp=new Nn,up=new Nn,dp=new Nn;class Pi{constructor(t=new H,e=new H,n=new H){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Ci.subVectors(t,e),i.cross(Ci);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){Ci.subVectors(i,e),Ss.subVectors(n,e),op.subVectors(t,e);const o=Ci.dot(Ci),a=Ci.dot(Ss),l=Ci.dot(op),c=Ss.dot(Ss),h=Ss.dot(op),u=o*c-a*a;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(c*l-a*h)*d,p=(o*h-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,bs)===null?!1:bs.x>=0&&bs.y>=0&&bs.x+bs.y<=1}static getInterpolation(t,e,n,i,s,o,a,l){return this.getBarycoord(t,e,n,i,bs)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,bs.x),l.addScaledVector(o,bs.y),l.addScaledVector(a,bs.z),l)}static getInterpolatedAttribute(t,e,n,i,s,o){return hp.setScalar(0),up.setScalar(0),dp.setScalar(0),hp.fromBufferAttribute(t,e),up.fromBufferAttribute(t,n),dp.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(hp,s.x),o.addScaledVector(up,s.y),o.addScaledVector(dp,s.z),o}static isFrontFacing(t,e,n,i){return Ci.subVectors(n,e),Ss.subVectors(t,e),Ci.cross(Ss).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ci.subVectors(this.c,this.b),Ss.subVectors(this.a,this.b),Ci.cross(Ss).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Pi.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Pi.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return Pi.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return Pi.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Pi.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,s=this.c;let o,a;Ho.subVectors(i,n),Wo.subVectors(s,n),ap.subVectors(t,n);const l=Ho.dot(ap),c=Wo.dot(ap);if(l<=0&&c<=0)return e.copy(n);lp.subVectors(t,i);const h=Ho.dot(lp),u=Wo.dot(lp);if(h>=0&&u<=h)return e.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(n).addScaledVector(Ho,o);cp.subVectors(t,s);const f=Ho.dot(cp),p=Wo.dot(cp);if(p>=0&&f<=p)return e.copy(s);const x=f*c-l*p;if(x<=0&&c>=0&&p<=0)return a=c/(c-p),e.copy(n).addScaledVector(Wo,a);const g=h*p-f*u;if(g<=0&&u-h>=0&&f-p>=0)return yy.subVectors(s,i),a=(u-h)/(u-h+(f-p)),e.copy(i).addScaledVector(yy,a);const m=1/(g+x+d);return o=x*m,a=d*m,e.copy(n).addScaledVector(Ho,o).addScaledVector(Wo,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class I3 extends Wp{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Oa,this.combine=gN,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const _y=new ke,Lr=new R3,Xh=new zd,vy=new H,$h=new H,qh=new H,Yh=new H,fp=new H,Zh=new H,My=new H,Jh=new H;class P3 extends Cn{constructor(t=new Wd,e=new I3){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){Zh.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],u=s[l];h!==0&&(fp.fromBufferAttribute(u,t),o?Zh.addScaledVector(fp,h):Zh.addScaledVector(fp.sub(e),h))}e.add(Zh)}return e}raycast(t,e){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Xh.copy(n.boundingSphere),Xh.applyMatrix4(s),Lr.copy(t.ray).recast(t.near),!(Xh.containsPoint(Lr.origin)===!1&&(Lr.intersectSphere(Xh,vy)===null||Lr.origin.distanceToSquared(vy)>(t.far-t.near)**2))&&(_y.copy(s).invert(),Lr.copy(t.ray).applyMatrix4(_y),!(n.boundingBox!==null&&Lr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Lr)))}_computeIntersections(t,e,n){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,x=d.length;p<x;p++){const g=d[p],m=o[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,w=v;_<w;_+=3){const T=a.getX(_),E=a.getX(_+1),M=a.getX(_+2);i=jh(this,m,t,n,c,h,u,T,E,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let g=p,m=x;g<m;g+=3){const y=a.getX(g),v=a.getX(g+1),_=a.getX(g+2);i=jh(this,o,t,n,c,h,u,y,v,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let p=0,x=d.length;p<x;p++){const g=d[p],m=o[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let _=y,w=v;_<w;_+=3){const T=_,E=_+1,M=_+2;i=jh(this,m,t,n,c,h,u,T,E,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),x=Math.min(l.count,f.start+f.count);for(let g=p,m=x;g<m;g+=3){const y=g,v=g+1,_=g+2;i=jh(this,o,t,n,c,h,u,y,v,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}}}function L3(r,t,e,n,i,s,o,a){let l;if(t.side===Qm?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,t.side===Fp,a),l===null)return null;Jh.copy(a),Jh.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(Jh);return c<e.near||c>e.far?null:{distance:c,point:Jh.clone(),object:r}}function jh(r,t,e,n,i,s,o,a,l,c){r.getVertexPosition(a,$h),r.getVertexPosition(l,qh),r.getVertexPosition(c,Yh);const h=L3(r,t,e,n,$h,qh,Yh,My);if(h){const u=new H;Pi.getBarycoord(My,$h,qh,Yh,u),i&&(h.uv=Pi.getInterpolatedAttribute(i,a,l,c,u,new Ge)),s&&(h.uv1=Pi.getInterpolatedAttribute(s,a,l,c,u,new Ge)),o&&(h.normal=Pi.getInterpolatedAttribute(o,a,l,c,u,new H),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new H,materialIndex:0};Pi.getNormal($h,qh,Yh,d.normal),h.face=d,h.barycoord=u}return h}class F3{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(t){if(t.isNodeMaterial)return t;let e=null;const n=this.getMaterialNodeClass(t.type);if(n!==null){e=new n;for(const i in t)e[i]=t[i]}return e}addToneMapping(t,e){this.addType(t,e,this.toneMappingNodes)}getToneMappingFunction(t){return this.toneMappingNodes.get(t)||null}getMaterialNodeClass(t){return this.materialNodes.get(t)||null}addMaterial(t,e){this.addType(t,e,this.materialNodes)}getLightNodeClass(t){return this.lightNodes.get(t)||null}addLight(t,e){this.addClass(t,e,this.lightNodes)}addType(t,e,n){if(n.has(e)){ne(`Redefinition of node ${e}`);return}if(typeof t!="function")throw new Error(`Node class ${t.name} is not a class.`);if(typeof e=="function"||typeof e=="object")throw new Error(`Base class ${e} is not a class.`);n.set(e,t)}addClass(t,e,n){if(n.has(e)){ne(`Redefinition of node ${e.name}`);return}if(typeof t!="function")throw new Error(`Node class ${t.name} is not a class.`);if(typeof e!="function")throw new Error(`Base class ${e.name} is not a class.`);n.set(e,t)}}class oo extends Cn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Vi(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}const pp=new H,D3=new H,U3=new Mi;class Dr{constructor(t=new H(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=pp.subVectors(n,e).cross(D3.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(pp),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||U3.getNormalMatrix(t),i=this.coplanarPoint(pp).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Fr=new zd,O3=new Ge(.5,.5),Kh=new H;class B3{constructor(t=new Dr,e=new Dr,n=new Dr,i=new Dr,s=new Dr,o=new Dr){this.planes=[t,e,n,i,s,o]}set(t,e,n,i,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=ns,n=!1){const i=this.planes,s=t.elements,o=s[0],a=s[1],l=s[2],c=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],x=s[9],g=s[10],m=s[11],y=s[12],v=s[13],_=s[14],w=s[15];if(i[0].setComponents(c-o,f-h,m-p,w-y).normalize(),i[1].setComponents(c+o,f+h,m+p,w+y).normalize(),i[2].setComponents(c+a,f+u,m+x,w+v).normalize(),i[3].setComponents(c-a,f-u,m-x,w-v).normalize(),n)i[4].setComponents(l,d,g,_).normalize(),i[5].setComponents(c-l,f-d,m-g,w-_).normalize();else if(i[4].setComponents(c-l,f-d,m-g,w-_).normalize(),e===ns)i[5].setComponents(c+l,f+d,m+g,w+_).normalize();else if(e===hr)i[5].setComponents(l,d,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Fr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Fr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Fr)}intersectsSprite(t){Fr.center.set(0,0,0);const e=O3.distanceTo(t.center);return Fr.radius=.7071067811865476+e,Fr.applyMatrix4(t.matrixWorld),this.intersectsSphere(Fr)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(Kh.x=i.normal.x>0?t.max.x:t.min.x,Kh.y=i.normal.y>0?t.max.y:t.min.y,Kh.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Kh)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const mp=new ke,Sy=new H,by=new H;class Ig{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ge(512,512),this.mapType=Hv,this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new B3,this._frameExtents=new Ge(1,1),this._viewportCount=1,this._viewports=[new Nn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Sy.setFromMatrixPosition(t.matrixWorld),e.position.copy(Sy),by.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(by),e.updateMatrixWorld(),mp.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mp,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===hr||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(mp)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class z3 extends Ig{constructor(){super(new jM(90,1,.5,500)),this.isPointLightShadow=!0}}class V3 extends oo{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new z3}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class KM extends JM{constructor(t=-1,e=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-t,o=n+t,a=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class k3 extends Ig{constructor(){super(new KM(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class G3 extends oo{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.shadow=new k3}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class H3 extends oo{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class W3 extends Ig{constructor(){super(new jM(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=oc*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Pg extends oo{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new W3}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class X3 extends oo{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class $3 extends oo{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Vi(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}class q3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new H)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*i),e.addScaledVector(o[2],.488603*s),e.addScaledVector(o[3],.488603*n),e.addScaledVector(o[4],1.092548*(n*i)),e.addScaledVector(o[5],1.092548*(i*s)),e.addScaledVector(o[6],.315392*(3*s*s-1)),e.addScaledVector(o[7],1.092548*(n*s)),e.addScaledVector(o[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],2*.511664*i),e.addScaledVector(o[2],2*.511664*s),e.addScaledVector(o[3],2*.511664*n),e.addScaledVector(o[4],2*.429043*n*i),e.addScaledVector(o[5],2*.429043*i*s),e.addScaledVector(o[6],.743125*s*s-.247708),e.addScaledVector(o[7],2*.429043*n*s),e.addScaledVector(o[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+i*3);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+i*3);return t}static getBasisAt(t,e){const n=t.x,i=t.y,s=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*s,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*n*s,e[8]=.546274*(n*n-i*i)}}class Y3 extends oo{constructor(t=new q3,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Z3 extends Pg{constructor(t,e,n,i,s,o){super(t,e,n,i,s,o),this.iesMap=null}copy(t,e){return super.copy(t,e),this.iesMap=t.iesMap,this}}class J3 extends Pg{constructor(t,e,n,i,s,o){super(t,e,n,i,s,o),this.aspect=null}copy(t,e){return super.copy(t,e),this.aspect=t.aspect,this}}Mt(({texture:r,uv:t})=>{const n=Pt().toVar();return hi(t.x.lessThan(1e-4),()=>{n.assign(Pt(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{n.assign(Pt(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{n.assign(Pt(0,0,1))}).ElseIf(t.x.greaterThan(1-1e-4),()=>{n.assign(Pt(-1,0,0))}).ElseIf(t.y.greaterThan(1-1e-4),()=>{n.assign(Pt(0,-1,0))}).ElseIf(t.z.greaterThan(1-1e-4),()=>{n.assign(Pt(0,0,-1))}).Else(()=>{const s=r.sample(t.add(Pt(-.01,0,0))).r.sub(r.sample(t.add(Pt(.01,0,0))).r),o=r.sample(t.add(Pt(0,-.01,0))).r.sub(r.sample(t.add(Pt(0,.01,0))).r),a=r.sample(t.add(Pt(0,0,-.01))).r.sub(r.sample(t.add(Pt(0,0,.01))).r);n.assign(Pt(s,o,a))}),n.normalize()});const Qh=new Ge;class j3 extends Hd{static get type(){return"PassTextureNode"}constructor(t,e){super(e),this.passNode=t,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(t){const e=t.getNodeProperties(this);return e.passNode=this.passNode,super.setup(t)}clone(){return new this.constructor(this.passNode,this.value)}}class Ty extends j3{static get type(){return"PassMultipleTextureNode"}constructor(t,e,n=!1){super(t,null),this.textureName=e,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(t){return this.updateTexture(),super.setup(t)}clone(){const t=new this.constructor(this.passNode,this.textureName,this.previousTexture);return t.uvNode=this.uvNode,t.levelNode=this.levelNode,t.biasNode=this.biasNode,t.sampler=this.sampler,t.depthNode=this.depthNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.offsetNode=this.offsetNode,t}}class Xd extends xn{static get type(){return"PassNode"}constructor(t,e,n,i={}){super("vec4"),this.scope=t,this.scene=e,this.camera=n,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const s=new Pc;s.isRenderTargetTexture=!0,s.name="depth";const o=new ZM(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:hl,...i});o.texture.name="output",o.depthTexture=s,this.renderTarget=o,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:o.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=de(0),this._cameraFar=de(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ue.FRAME,this.global=!0}setResolutionScale(t){return this._resolutionScale=t,this}getResolutionScale(){return this._resolutionScale}setResolution(t){return ne("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(t)}getResolution(){return ne("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(t){return this._layers=t,this}getLayers(){return this._layers}setMRT(t){return this._mrt=t,this}getMRT(){return this._mrt}getTexture(t){let e=this._textures[t];return e===void 0&&(e=this.renderTarget.texture.clone(),e.name=t,this._textures[t]=e,this.renderTarget.textures.push(e)),e}getPreviousTexture(t){let e=this._previousTextures[t];return e===void 0&&(e=this.getTexture(t).clone(),this._previousTextures[t]=e),e}toggleTexture(t){const e=this._previousTextures[t];if(e!==void 0){const n=this._textures[t],i=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[i]=e,this._textures[t]=e,this._previousTextures[t]=n,this._textureNodes[t].updateTexture(),this._previousTextureNodes[t].updateTexture()}}getTextureNode(t="output"){let e=this._textureNodes[t];return e===void 0&&(e=new Ty(this,t),e.updateTexture(),this._textureNodes[t]=e),e}getPreviousTextureNode(t="output"){let e=this._previousTextureNodes[t];return e===void 0&&(this._textureNodes[t]===void 0&&this.getTextureNode(t),e=new Ty(this,t,!0),e.updateTexture(),this._previousTextureNodes[t]=e),e}getViewZNode(t="depth"){let e=this._viewZNodes[t];if(e===void 0){const n=this._cameraNear,i=this._cameraFar;this._viewZNodes[t]=e=XM(this.getTextureNode(t),n,i)}return e}getLinearDepthNode(t="depth"){let e=this._linearDepthNodes[t];if(e===void 0){const n=this._cameraNear,i=this._cameraFar,s=this.getViewZNode(t);this._linearDepthNodes[t]=e=Sl(s,n,i)}return e}async compileAsync(t){const e=t.getRenderTarget(),n=t.getMRT();t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),await t.compileAsync(this.scene,this.camera),t.setRenderTarget(e),t.setMRT(n)}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),this.scope===Xd.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(t){const{renderer:e}=t,{scene:n}=this;let i,s;const o=e.getOutputRenderTarget();o&&o.isXRRenderTarget===!0?(s=1,i=e.xr.getCamera(),e.xr.updateCamera(i),Qh.set(o.width,o.height)):(i=this.camera,s=e.getPixelRatio(),e.getSize(Qh)),this._pixelRatio=s,this.setSize(Qh.width,Qh.height);const a=e.getRenderTarget(),l=e.getMRT(),c=e.autoClear,h=e.transparent,u=e.opaque,d=i.layers.mask,f=e.contextNode,p=n.overrideMaterial;this._cameraNear.value=i.near,this._cameraFar.value=i.far,this._layers!==null&&(i.layers.mask=this._layers.mask);for(const g in this._previousTextures)this.toggleTexture(g);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),e.autoClear=!0,e.transparent=this.transparent,e.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:La({...e.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),e.contextNode=this._contextNodeCache.context);const x=n.name;n.name=this.name?this.name:n.name,e.render(n,i),n.name=x,n.overrideMaterial=p,e.setRenderTarget(a),e.setMRT(l),e.autoClear=c,e.transparent=h,e.opaque=u,e.contextNode=f,i.layers.mask=d}setSize(t,e){this._width=t,this._height=e;const n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),i=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,i),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(t,e,n,i){t===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Nn),t.isVector4?this._scissor.copy(t):this._scissor.set(t,e,n,i),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(t,e,n,i){t===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Nn),t.isVector4?this._viewport.copy(t):this._viewport.set(t,e,n,i),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Xd.COLOR="color";Xd.DEPTH="depth";class hs extends Bt{static get type(){return"AtomicFunctionNode"}constructor(t,e,n){super("uint"),this.method=t,this.pointerNode=e,this.valueNode=n,this.parents=!0}getInputType(t){return this.pointerNode.getNodeType(t)}getNodeType(t){return this.getInputType(t)}generate(t){const e=t.getNodeProperties(this),n=e.parents,i=this.method,s=this.getNodeType(t),o=this.getInputType(t),a=this.pointerNode,l=this.valueNode,c=[];c.push(`&${a.build(t,o)}`),l!==null&&c.push(l.build(t,o));const h=`${t.getMethod(i,s)}( ${c.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)t.addLineFlowCode(h,this);else return e.constNode===void 0&&(e.constNode=Es(h,s).toConst()),e.constNode.build(t)}}hs.ATOMIC_LOAD="atomicLoad";hs.ATOMIC_STORE="atomicStore";hs.ATOMIC_ADD="atomicAdd";hs.ATOMIC_SUB="atomicSub";hs.ATOMIC_MAX="atomicMax";hs.ATOMIC_MIN="atomicMin";hs.ATOMIC_AND="atomicAnd";hs.ATOMIC_OR="atomicOr";hs.ATOMIC_XOR="atomicXor";De(hs);class K3 extends Bt{constructor(t){super(),this.scope=t}generate(t){const{scope:e}=this,{renderer:n}=t;n.backend.isWebGLBackend===!0?t.addFlowCode(` // ${e}Barrier
|
|
4084
|
+
`):t.addLineFlowCode(`${e}Barrier()`,this)}}De(K3);class ge extends xn{static get type(){return"SubgroupFunctionNode"}constructor(t,e=null,n=null){super(),this.method=t,this.aNode=e,this.bNode=n}getInputType(t){const e=this.aNode?this.aNode.getNodeType(t):null,n=this.bNode?this.bNode.getNodeType(t):null,i=t.isMatrix(e)?0:t.getTypeLength(e),s=t.isMatrix(n)?0:t.getTypeLength(n);return i>s?e:n}getNodeType(t){const e=this.method;return e===ge.SUBGROUP_ELECT?"bool":e===ge.SUBGROUP_BALLOT?"uvec4":this.getInputType(t)}generate(t,e){const n=this.method,i=this.getNodeType(t),s=this.getInputType(t),o=this.aNode,a=this.bNode,l=[];if(n===ge.SUBGROUP_BROADCAST||n===ge.SUBGROUP_SHUFFLE||n===ge.QUAD_BROADCAST){const h=a.getNodeType(t);l.push(o.build(t,i),a.build(t,h==="float"?"int":i))}else n===ge.SUBGROUP_SHUFFLE_XOR||n===ge.SUBGROUP_SHUFFLE_DOWN||n===ge.SUBGROUP_SHUFFLE_UP?l.push(o.build(t,i),a.build(t,"uint")):(o!==null&&l.push(o.build(t,s)),a!==null&&l.push(a.build(t,s)));const c=l.length===0?"()":`( ${l.join(", ")} )`;return t.format(`${t.getMethod(n,i)}${c}`,i,e)}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}ge.SUBGROUP_ELECT="subgroupElect";ge.SUBGROUP_BALLOT="subgroupBallot";ge.SUBGROUP_ADD="subgroupAdd";ge.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";ge.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";ge.SUBGROUP_MUL="subgroupMul";ge.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";ge.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";ge.SUBGROUP_AND="subgroupAnd";ge.SUBGROUP_OR="subgroupOr";ge.SUBGROUP_XOR="subgroupXor";ge.SUBGROUP_MIN="subgroupMin";ge.SUBGROUP_MAX="subgroupMax";ge.SUBGROUP_ALL="subgroupAll";ge.SUBGROUP_ANY="subgroupAny";ge.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";ge.QUAD_SWAP_X="quadSwapX";ge.QUAD_SWAP_Y="quadSwapY";ge.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";ge.SUBGROUP_BROADCAST="subgroupBroadcast";ge.SUBGROUP_SHUFFLE="subgroupShuffle";ge.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor";ge.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp";ge.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown";ge.QUAD_BROADCAST="quadBroadcast";class Q3 extends Bt{static get type(){return"ShadowBaseNode"}constructor(t){super(),this.light=t,this.updateBeforeType=ue.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:t,material:e}){QM.assign(e.receivedShadowPositionNode||t.shadowPositionWorld||Eg)}}const QM=lM("vec3","shadowPositionWorld"),gp=new KM(-1,1,1,-1,0,1);class tL extends Wd{constructor(t=!1){super();const e=t===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Hp([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Hp(e,2))}}const eL=new tL;class nL extends P3{constructor(t=null){super(eL,t),this.camera=gp,this.isQuadMesh=!0}async renderAsync(t){_a('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await t.init(),t.render(this,gp)}render(t){t.render(this,gp)}}let tu;function $d(r){tu=tu||new WeakMap;let t=tu.get(r);return t===void 0&&tu.set(r,t={}),t}function Lg(r){const t=$d(r);return t.shadowMatrix||(t.shadowMatrix=de("mat4").setGroup(te).onRenderUpdate(e=>((r.castShadow!==!0||e.renderer.shadowMap.enabled===!1)&&(r.shadow.camera.coordinateSystem!==e.camera.coordinateSystem&&(r.shadow.camera.coordinateSystem=e.camera.coordinateSystem,r.shadow.camera.updateProjectionMatrix()),r.shadow.updateMatrices(r)),r.shadow.matrix)))}function iL(r,t=Eg){const e=Lg(r).mul(t);return e.xyz.div(e.w)}function tS(r){const t=$d(r);return t.position||(t.position=de(new H).setGroup(te).onRenderUpdate((e,n)=>n.value.setFromMatrixPosition(r.matrixWorld)))}function sL(r){const t=$d(r);return t.targetPosition||(t.targetPosition=de(new H).setGroup(te).onRenderUpdate((e,n)=>n.value.setFromMatrixPosition(r.target.matrixWorld)))}function eS(r){const t=$d(r);return t.viewPosition||(t.viewPosition=de(new H).setGroup(te).onRenderUpdate(({camera:e},n)=>{n.value=n.value||new H,n.value.setFromMatrixPosition(r.matrixWorld),n.value.applyMatrix4(e.matrixWorldInverse)}))}const nS=r=>Ua.transformDirection(tS(r).sub(sL(r)));function rL(r,t={}){return t.toneMapping=r.toneMapping,t.toneMappingExposure=r.toneMappingExposure,t.outputColorSpace=r.outputColorSpace,t.renderTarget=r.getRenderTarget(),t.activeCubeFace=r.getActiveCubeFace(),t.activeMipmapLevel=r.getActiveMipmapLevel(),t.renderObjectFunction=r.getRenderObjectFunction(),t.pixelRatio=r.getPixelRatio(),t.mrt=r.getMRT(),t.clearColor=r.getClearColor(t.clearColor||new Vi),t.clearAlpha=r.getClearAlpha(),t.autoClear=r.autoClear,t.scissorTest=r.getScissorTest(),t}function oL(r,t){return t=rL(r,t),r.setMRT(null),r.setRenderObjectFunction(null),r.setClearColor(0,1),r.autoClear=!0,t}function aL(r,t){r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),r.setRenderObjectFunction(t.renderObjectFunction),r.setPixelRatio(t.pixelRatio),r.setMRT(t.mrt),r.setClearColor(t.clearColor,t.clearAlpha),r.autoClear=t.autoClear,r.setScissorTest(t.scissorTest)}function lL(r,t={}){return t.background=r.background,t.backgroundNode=r.backgroundNode,t.overrideMaterial=r.overrideMaterial,t}function cL(r,t){return t=lL(r,t),r.background=null,r.backgroundNode=null,r.overrideMaterial=null,t}function hL(r,t){r.background=t.background,r.backgroundNode=t.backgroundNode,r.overrideMaterial=t.overrideMaterial}function uL(r,t,e){return e=oL(r,e),e=cL(t,e),e}function dL(r,t,e){aL(r,e),hL(t,e)}const iS=Mt(([r])=>Qr(kt(52.9829189).mul(Qr(Rc(r,xe(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),es=Mt(([r,t,e])=>{const n=kt(2.399963229728653),i=Cc(kt(r).add(.5).div(kt(t))),s=kt(r).mul(n).add(e);return xe(hM(s),ac(s)).mul(i)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),Hu=new WeakMap,fL=Mt(({depthTexture:r,shadowCoord:t,depthLayer:e})=>{let n=pn(r,t.xy).setName("t_basic");return r.isArrayTexture&&(n=n.depth(e)),n.compare(t.z)}),pL=Mt(({depthTexture:r,shadowCoord:t,shadow:e,depthLayer:n})=>{const i=(h,u)=>{let d=pn(r,h);return r.isArrayTexture&&(d=d.depth(n)),d.compare(u)},s=tn("mapSize","vec2",e).setGroup(te),o=tn("radius","float",e).setGroup(te),a=xe(1).div(s),l=o.mul(a.x),c=iS(Da.xy).mul(6.28318530718);return os(i(t.xy.add(es(0,5,c).mul(l)),t.z),i(t.xy.add(es(1,5,c).mul(l)),t.z),i(t.xy.add(es(2,5,c).mul(l)),t.z),i(t.xy.add(es(3,5,c).mul(l)),t.z),i(t.xy.add(es(4,5,c).mul(l)),t.z)).mul(1/5)}),mL=Mt(({depthTexture:r,shadowCoord:t,shadow:e,depthLayer:n})=>{const i=(u,d)=>{let f=pn(r,u);return r.isArrayTexture&&(f=f.depth(n)),f.compare(d)},s=tn("mapSize","vec2",e).setGroup(te),o=xe(1).div(s),a=o.x,l=o.y,c=t.xy,h=Qr(c.mul(s).add(.5));return c.subAssign(h.mul(o)),os(i(c,t.z),i(c.add(xe(a,0)),t.z),i(c.add(xe(0,l)),t.z),i(c.add(o),t.z),Dn(i(c.add(xe(a.negate(),0)),t.z),i(c.add(xe(a.mul(2),0)),t.z),h.x),Dn(i(c.add(xe(a.negate(),l)),t.z),i(c.add(xe(a.mul(2),l)),t.z),h.x),Dn(i(c.add(xe(0,l.negate())),t.z),i(c.add(xe(0,l.mul(2))),t.z),h.y),Dn(i(c.add(xe(a,l.negate())),t.z),i(c.add(xe(a,l.mul(2))),t.z),h.y),Dn(Dn(i(c.add(xe(a.negate(),l.negate())),t.z),i(c.add(xe(a.mul(2),l.negate())),t.z),h.x),Dn(i(c.add(xe(a.negate(),l.mul(2))),t.z),i(c.add(xe(a.mul(2),l.mul(2))),t.z),h.x),h.y)).mul(1/9)}),gL=Mt(({depthTexture:r,shadowCoord:t,depthLayer:e},n)=>{let i=pn(r).sample(t.xy);r.isArrayTexture&&(i=i.depth(e)),i=i.rg;const s=i.x,o=as(1e-7,i.y.mul(i.y)),a=n.renderer.reversedDepthBuffer?cc(s,t.z):cc(t.z,s),l=kt(1).toVar();return hi(a.notEqual(1),()=>{const c=t.z.sub(s);let h=o.div(o.add(c.mul(c)));h=va(Wn(h,.3).div(.65)),l.assign(as(a,h))}),l}),xL=r=>{let t=Hu.get(r);return t===void 0&&(t=new qp,t.colorNode=zn(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=mN,t.fog=!1,Hu.set(r,t)),t},yL=r=>{const t=Hu.get(r);t!==void 0&&(t.dispose(),Hu.delete(r))};class _L{constructor(){this.weakMaps={}}_getWeakMap(t){const e=t.length;let n=this.weakMaps[e];return n===void 0&&(n=new WeakMap,this.weakMaps[e]=n),n}get(t){let e=this._getWeakMap(t);for(let n=0;n<t.length-1;n++)if(e=e.get(t[n]),e===void 0)return;return e.get(t[t.length-1])}set(t,e){let n=this._getWeakMap(t);for(let i=0;i<t.length-1;i++){const s=t[i];n.has(s)===!1&&n.set(s,new WeakMap),n=n.get(s)}return n.set(t[t.length-1],e),this}delete(t){let e=this._getWeakMap(t);for(let n=0;n<t.length-1;n++)if(e=e.get(t[n]),e===void 0)return!1;return e.delete(t[t.length-1])}}const wy=new _L,Xo=[],vL=(r,t,e,n)=>{Xo[0]=r,Xo[1]=t;let i=wy.get(Xo);return(i===void 0||i.shadowType!==e||i.useVelocity!==n)&&(i=(s,o,a,l,c,h,...u)=>{(s.castShadow===!0||s.receiveShadow&&e===cu)&&(n&&(iR(s).useVelocity=!0),s.onBeforeShadow(r,s,a,t.camera,l,o.overrideMaterial,h),r.renderObject(s,o,a,l,c,h,...u),s.onAfterShadow(r,s,a,t.camera,l,o.overrideMaterial,h))},i.shadowType=e,i.useVelocity=n,wy.set(Xo,i)),Xo[0]=null,Xo[1]=null,i},ML=Mt(({samples:r,radius:t,size:e,shadowPass:n,depthLayer:i})=>{const s=kt(0).toVar("meanVertical"),o=kt(0).toVar("squareMeanVertical"),a=r.lessThanEqual(kt(1)).select(kt(0),kt(2).div(r.sub(1))),l=r.lessThanEqual(kt(1)).select(kt(0),kt(-1));tr({start:Be(0),end:Be(r),type:"int",condition:"<"},({i:h})=>{const u=l.add(kt(h).mul(a));let d=n.sample(os(Da.xy,xe(0,u).mul(t)).div(e));n.value.isArrayTexture&&(d=d.depth(i)),d=d.x,s.addAssign(d),o.addAssign(d.mul(d))}),s.divAssign(r),o.divAssign(r);const c=Cc(o.sub(s.mul(s)).max(0));return xe(s,c)}),SL=Mt(({samples:r,radius:t,size:e,shadowPass:n,depthLayer:i})=>{const s=kt(0).toVar("meanHorizontal"),o=kt(0).toVar("squareMeanHorizontal"),a=r.lessThanEqual(kt(1)).select(kt(0),kt(2).div(r.sub(1))),l=r.lessThanEqual(kt(1)).select(kt(0),kt(-1));tr({start:Be(0),end:Be(r),type:"int",condition:"<"},({i:h})=>{const u=l.add(kt(h).mul(a));let d=n.sample(os(Da.xy,xe(u,0).mul(t)).div(e));n.value.isArrayTexture&&(d=d.depth(i)),s.addAssign(d.x),o.addAssign(os(d.y.mul(d.y),d.x.mul(d.x)))}),s.divAssign(r),o.divAssign(r);const c=Cc(o.sub(s.mul(s)).max(0));return xe(s,c)}),bL=[fL,pL,mL,gL];let xp;const eu=new nL;class sS extends Q3{static get type(){return"ShadowNode"}constructor(t,e=null){super(t),this.shadow=e||t.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(t,{filterFn:e,depthTexture:n,shadowCoord:i,shadow:s,depthLayer:o}){const a=i.x.greaterThanEqual(0).and(i.x.lessThanEqual(1)).and(i.y.greaterThanEqual(0)).and(i.y.lessThanEqual(1)).and(i.z.lessThanEqual(1)),l=e({depthTexture:n,shadowCoord:i,shadow:s,depthLayer:o});return a.select(l,kt(1))}setupShadowCoord(t,e){const{shadow:n}=this,{renderer:i}=t,s=n.biasNode||tn("bias","float",n).setGroup(te);let o=e,a;if(n.camera.isOrthographicCamera||i.logarithmicDepthBuffer!==!0)o=o.xyz.div(o.w),a=o.z;else{const l=o.w;o=o.xy.div(l);const c=tn("near","float",n.camera).setGroup(te),h=tn("far","float",n.camera).setGroup(te);a=$M(l.negate(),c,h)}return o=Pt(o.x,o.y.oneMinus(),i.reversedDepthBuffer?a.sub(s):a.add(s)),o}getShadowFilterFn(t){return bL[t]}setupRenderTarget(t,e){const n=new Pc(t.mapSize.width,t.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=e.renderer.reversedDepthBuffer?Ou:ng;const i=e.createRenderTarget(t.mapSize.width,t.mapSize.height);return i.texture.name="ShadowMap",i.texture.type=t.mapType,i.depthTexture=n,{shadowMap:i,depthTexture:n}}setupShadow(t){const{renderer:e,camera:n}=t,{light:i,shadow:s}=this,{depthTexture:o,shadowMap:a}=this.setupRenderTarget(s,t),l=e.shadowMap.type,c=e.hasCompatibility($v.TEXTURE_COMPARE);if((l===dN||l===fN)&&c?(o.minFilter=rc,o.magFilter=rc):(o.minFilter=gi,o.magFilter=gi),s.camera.coordinateSystem=n.coordinateSystem,s.camera.updateProjectionMatrix(),l===cu&&s.isPointLightShadow!==!0){o.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=t.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:ul,type:hl,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=t.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:ul,type:hl,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=t.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:ul,type:hl,depthBuffer:!1}),this.vsmShadowMapHorizontal=t.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:ul,type:hl,depthBuffer:!1}));let _=pn(o);o.isArrayTexture&&(_=_.depth(this.depthLayer));let w=pn(this.vsmShadowMapVertical.texture);o.isArrayTexture&&(w=w.depth(this.depthLayer));const T=tn("blurSamples","float",s).setGroup(te),E=tn("radius","float",s).setGroup(te),M=tn("mapSize","vec2",s).setGroup(te);let b=this.vsmMaterialVertical||(this.vsmMaterialVertical=new qp);b.fragmentNode=ML({samples:T,radius:E,size:M,shadowPass:_,depthLayer:this.depthLayer}).context(t.getSharedContext()),b.name="VSMVertical",b=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new qp),b.fragmentNode=SL({samples:T,radius:E,size:M,shadowPass:w,depthLayer:this.depthLayer}).context(t.getSharedContext()),b.name="VSMHorizontal"}const h=tn("intensity","float",s).setGroup(te),u=tn("normalBias","float",s).setGroup(te),d=Lg(i).mul(QM.add(kd.mul(u))),f=this.setupShadowCoord(t,d),p=s.filterNode||this.getShadowFilterFn(e.shadowMap.type)||null;if(p===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const x=l===cu&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:o,g=this.setupShadowFilter(t,{filterFn:p,shadowTexture:a.texture,depthTexture:x,shadowCoord:f,shadow:s,depthLayer:this.depthLayer});let m;e.shadowMap.transmitted===!0&&(a.texture.isCubeTexture?m=ts(a.texture,f.xyz):(m=pn(a.texture,f),o.isArrayTexture&&(m=m.depth(this.depthLayer))));let y;m?y=Dn(1,g.rgb.mix(m,1),h.mul(m.a)).toVar():y=Dn(1,g,h).toVar(),this.shadowMap=a,this.shadow.map=a;const v=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return m&&y.toInspector(`${v} / Color`,()=>this.shadowMap.texture.isCubeTexture?ts(this.shadowMap.texture):pn(this.shadowMap.texture)),y.toInspector(`${v} / Depth`,()=>this.shadowMap.texture.isCubeTexture?ts(this.shadowMap.texture).r.oneMinus():li(this.shadowMap.depthTexture,Gd().mul(oa(pn(this.shadowMap.depthTexture)))).r.oneMinus())}setup(t){if(t.renderer.shadowMap.enabled!==!1)return Mt(()=>{const e=t.renderer.shadowMap.type;this._currentShadowType!==e&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(t),n===null&&(this._node=n=this.setupShadow(t),this._currentShadowType=e),t.material.receivedShadowNode&&(n=t.material.receivedShadowNode(n)),n})()}renderShadow(t){const{shadow:e,shadowMap:n,light:i}=this,{renderer:s,scene:o}=t;e.updateMatrices(i),n.setSize(e.mapSize.width,e.mapSize.height,n.depth);const a=o.name;o.name=`Shadow Map [ ${i.name||"ID: "+i.id} ]`,s.render(o,e.camera),o.name=a}updateShadow(t){const{shadowMap:e,light:n,shadow:i}=this,{renderer:s,scene:o,camera:a}=t,l=s.shadowMap.type,c=e.depthTexture.version;this._depthVersionCached=c;const h=i.camera.layers.mask;(i.camera.layers.mask&4294967294)===0&&(i.camera.layers.mask=a.layers.mask);const u=s.getRenderObjectFunction(),d=s.getMRT(),f=d?d.has("velocity"):!1;xp=uL(s,o,xp),o.overrideMaterial=xL(n),s.setRenderObjectFunction(vL(s,i,l,f)),s.setClearColor(0,0),s.setRenderTarget(e),this.renderShadow(t),s.setRenderObjectFunction(u),l===cu&&i.isPointLightShadow!==!0&&this.vsmPass(s),i.camera.layers.mask=h,dL(s,o,xp)}vsmPass(t){const{shadow:e}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(e.mapSize.width,e.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(e.mapSize.width,e.mapSize.height,n),t.setRenderTarget(this.vsmShadowMapVertical),eu.material=this.vsmMaterialVertical,eu.render(t),t.setRenderTarget(this.vsmShadowMapHorizontal),eu.material=this.vsmMaterialHorizontal,eu.render(t)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,yL(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(t){const{shadow:e}=this;let n=e.needsUpdate||e.autoUpdate;n&&(this._cameraFrameId[t.camera]===t.frameId&&(n=!1),this._cameraFrameId[t.camera]=t.frameId),n&&(this.updateShadow(t),this.shadowMap.depthTexture.version===this._depthVersionCached&&(e.needsUpdate=!1))}}const TL=(r,t)=>new sS(r,t);class ao extends Rg{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new Vi,this.colorNode=t&&t.colorNode||de(this.color).setGroup(te),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ue.FRAME,t&&t.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},t.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(t){return eS(this.light).sub(t.context.positionView||hn)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return TL(this.light)}setupShadow(t){const{renderer:e}=t;if(e.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const i=this.light.shadow.shadowNode;let s;i!==void 0?s=Ot(i):s=this.setupShadowNode(),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}t.context.getShadow&&(n=t.context.getShadow(this,t)),this.colorNode=n}setup(t){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?t.object.receiveShadow&&this.setupShadow(t):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const e=this.setupDirect(t),n=this.setupDirectRectArea(t);e&&t.lightsNode.setupDirectLight(t,this,e),n&&t.lightsNode.setupDirectRectAreaLight(t,this,n)}update(){const{light:t}=this;this.color.copy(t.color).multiplyScalar(t.intensity)}}class wL extends ao{static get type(){return"AmbientLightNode"}constructor(t=null){super(t)}setup({context:t}){t.irradiance.addAssign(this.colorNode)}}class AL extends ao{static get type(){return"DirectionalLightNode"}constructor(t=null){super(t)}setupDirect(){const t=this.colorNode;return{lightDirection:nS(this.light),lightColor:t}}}class EL extends ao{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=tS(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=de(new Vi).setGroup(te)}update(t){const{light:e}=this;super.update(t),this.lightPositionNode.object3d=e,this.groundColorNode.value.copy(e.groundColor).multiplyScalar(e.intensity)}setup(t){const{colorNode:e,groundColorNode:n,lightDirectionNode:i}=this,o=kd.dot(i).mul(.5).add(.5),a=Dn(n,e,o);t.context.irradiance.addAssign(a)}}const rS=Mt(({lightDistance:r,cutoffDistance:t,decayExponent:e})=>{const n=r.pow(e).max(.01).reciprocal();return t.greaterThan(0).select(n.mul(r.div(t).pow4().oneMinus().clamp().pow2()),n)});class Fg extends ao{static get type(){return"SpotLightNode"}constructor(t=null){super(t),this.coneCosNode=de(0).setGroup(te),this.penumbraCosNode=de(0).setGroup(te),this.cutoffDistanceNode=de(0).setGroup(te),this.decayExponentNode=de(0).setGroup(te),this.colorNode=de(this.color).setGroup(te)}update(t){super.update(t);const{light:e}=this;this.coneCosNode.value=Math.cos(e.angle),this.penumbraCosNode.value=Math.cos(e.angle*(1-e.penumbra)),this.cutoffDistanceNode.value=e.distance,this.decayExponentNode.value=e.decay}getSpotAttenuation(t,e){const{coneCosNode:n,penumbraCosNode:i}=this;return hc(n,i,e)}getLightCoord(t){const e=t.getNodeProperties(this);let n=e.projectionUV;return n===void 0&&(n=iL(this.light,t.context.positionWorld),e.projectionUV=n),n}setupDirect(t){const{colorNode:e,cutoffDistanceNode:n,decayExponentNode:i,light:s}=this,o=this.getLightVector(t),a=o.normalize(),l=a.dot(nS(s)),c=this.getSpotAttenuation(t,l),h=o.length(),u=rS({lightDistance:h,cutoffDistance:n,decayExponent:i});let d=e.mul(c).mul(u),f,p;return s.colorNode?(p=this.getLightCoord(t),f=s.colorNode(p)):s.map&&(p=this.getLightCoord(t),f=pn(s.map,p.xy).onRenderUpdate(()=>s.map)),f&&(d=p.mul(2).sub(1).abs().lessThan(1).all().select(d.mul(f),d)),{lightColor:d,lightDirection:a}}}class CL extends Fg{static get type(){return"IESSpotLightNode"}getSpotAttenuation(t,e){const n=this.light.iesMap;let i=null;if(n&&n.isTexture===!0){const s=e.acos().mul(1/Math.PI);i=pn(n,xe(s,0),0).r}else i=super.getSpotAttenuation(e);return i}}const NL=Mt(([r,t])=>{const e=r.x,n=r.y,i=r.z;let s=t.element(0).mul(.886227);return s=s.add(t.element(1).mul(2*.511664).mul(n)),s=s.add(t.element(2).mul(2*.511664).mul(i)),s=s.add(t.element(3).mul(2*.511664).mul(e)),s=s.add(t.element(4).mul(2*.429043).mul(e).mul(n)),s=s.add(t.element(5).mul(2*.429043).mul(n).mul(i)),s=s.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),s=s.add(t.element(7).mul(2*.429043).mul(e).mul(i)),s=s.add(t.element(8).mul(.429043).mul(Ve(e,e).sub(Ve(n,n)))),s});class RL extends ao{static get type(){return"LightProbeNode"}constructor(t=null){super(t);const e=[];for(let n=0;n<9;n++)e.push(new H);this.lightProbe=Qi(e)}update(t){const{light:e}=this;super.update(t);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(e.sh.coefficients[n]).multiplyScalar(e.intensity)}setup(t){const e=NL(kd,this.lightProbe);t.context.irradiance.addAssign(e)}}class IL extends Pc{constructor(t,e=eg,n=tg,i,s,o=gi,a=gi,l,c=Up){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,i,s,o,a,l,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}const PL=new Vi,Ay=new ke,sl=new H,yp=new H,LL=[new H(1,0,0),new H(-1,0,0),new H(0,-1,0),new H(0,1,0),new H(0,0,1),new H(0,0,-1)],FL=[new H(0,-1,0),new H(0,-1,0),new H(0,0,-1),new H(0,0,1),new H(0,-1,0),new H(0,-1,0)],DL=[new H(1,0,0),new H(-1,0,0),new H(0,1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1)],UL=[new H(0,-1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1),new H(0,-1,0),new H(0,-1,0)],OL=Mt(({depthTexture:r,bd3D:t,dp:e})=>ts(r,t).compare(e)),BL=Mt(({depthTexture:r,bd3D:t,dp:e,shadow:n})=>{const i=tn("radius","float",n).setGroup(te),s=tn("mapSize","vec2",n).setGroup(te),o=i.div(s.x),a=Nc(t),l=mg(Gp(t,a.x.greaterThan(a.z).select(Pt(0,1,0),Pt(1,0,0)))),c=Gp(t,l),h=iS(Da.xy).mul(6.28318530718),u=es(0,5,h),d=es(1,5,h),f=es(2,5,h),p=es(3,5,h),x=es(4,5,h);return ts(r,t.add(l.mul(u.x).add(c.mul(u.y)).mul(o))).compare(e).add(ts(r,t.add(l.mul(d.x).add(c.mul(d.y)).mul(o))).compare(e)).add(ts(r,t.add(l.mul(f.x).add(c.mul(f.y)).mul(o))).compare(e)).add(ts(r,t.add(l.mul(p.x).add(c.mul(p.y)).mul(o))).compare(e)).add(ts(r,t.add(l.mul(x.x).add(c.mul(x.y)).mul(o))).compare(e)).mul(1/5)}),zL=Mt(({filterFn:r,depthTexture:t,shadowCoord:e,shadow:n},i)=>{const s=e.xyz.toConst(),o=s.abs().toConst(),a=o.x.max(o.y).max(o.z),l=de("float").setGroup(te).onRenderUpdate(()=>n.camera.near),c=de("float").setGroup(te).onRenderUpdate(()=>n.camera.far),h=tn("bias","float",n).setGroup(te),u=kt(1).toVar();return hi(a.sub(c).lessThanEqual(0).and(a.sub(l).greaterThanEqual(0)),()=>{let d;i.renderer.reversedDepthBuffer?(d=d3(a.negate(),l,c),d.subAssign(h)):(d=WM(a.negate(),l,c),d.addAssign(h));const f=s.normalize();u.assign(r({depthTexture:t,bd3D:f,dp:d,shadow:n}))}),u});class VL extends sS{static get type(){return"PointShadowNode"}constructor(t,e=null){super(t,e)}getShadowFilterFn(t){return t===uN?OL:BL}setupShadowCoord(t,e){return e}setupShadowFilter(t,{filterFn:e,depthTexture:n,shadowCoord:i,shadow:s}){return zL({filterFn:e,depthTexture:n,shadowCoord:i,shadow:s})}setupRenderTarget(t,e){const n=new IL(t.mapSize.width);n.name="PointShadowDepthTexture",n.compareFunction=e.renderer.reversedDepthBuffer?Ou:ng;const i=e.createCubeRenderTarget(t.mapSize.width);return i.texture.name="PointShadowMap",i.depthTexture=n,{shadowMap:i,depthTexture:n}}renderShadow(t){const{shadow:e,shadowMap:n,light:i}=this,{renderer:s,scene:o}=t,a=e.camera,l=e.matrix,c=s.coordinateSystem===hr,h=c?LL:DL,u=c?FL:UL;n.setSize(e.mapSize.width,e.mapSize.width);const d=s.autoClear,f=s.getClearColor(PL),p=s.getClearAlpha();s.autoClear=!1,s.setClearColor(e.clearColor,e.clearAlpha);for(let x=0;x<6;x++){s.setRenderTarget(n,x),s.clear();const g=i.distance||a.far;g!==a.far&&(a.far=g,a.updateProjectionMatrix()),sl.setFromMatrixPosition(i.matrixWorld),a.position.copy(sl),yp.copy(a.position),yp.add(h[x]),a.up.copy(u[x]),a.lookAt(yp),a.updateMatrixWorld(),l.makeTranslation(-sl.x,-sl.y,-sl.z),Ay.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),e._frustum.setFromProjectionMatrix(Ay,a.coordinateSystem,a.reversedDepth);const m=o.name;o.name=`Point Light Shadow [ ${i.name||"ID: "+i.id} ] - Face ${x+1}`,s.render(o,a),o.name=m}s.autoClear=d,s.setClearColor(f,p)}}const kL=(r,t)=>new VL(r,t),GL=({color:r,lightVector:t,cutoffDistance:e,decayExponent:n})=>{const i=t.normalize(),s=t.length(),o=rS({lightDistance:s,cutoffDistance:e,decayExponent:n}),a=r.mul(o);return{lightDirection:i,lightColor:a}};class HL extends ao{static get type(){return"PointLightNode"}constructor(t=null){super(t),this.cutoffDistanceNode=de(0).setGroup(te),this.decayExponentNode=de(2).setGroup(te)}update(t){const{light:e}=this;super.update(t),this.cutoffDistanceNode.value=e.distance,this.decayExponentNode.value=e.decay}setupShadowNode(){return kL(this.light)}setupDirect(t){return GL({color:this.colorNode,lightVector:this.getLightVector(t),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const WL=Mt(([r,t])=>{const e=r.abs().sub(t);return Vu(as(e,0)).add(lc(as(e.x,e.y),0))});class XL extends Fg{static get type(){return"ProjectorLightNode"}update(t){super.update(t);const e=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(e.angle*(1-e.penumbra)),.99999),e.aspect===null){let n=1;e.map!==null&&(n=e.map.width/e.map.height),e.shadow.aspect=n}else e.shadow.aspect=e.aspect}getSpotAttenuation(t){const e=kt(0),n=this.penumbraCosNode,i=Lg(this.light).mul(t.context.positionWorld||Eg);return hi(i.w.greaterThan(0),()=>{const s=i.xyz.div(i.w),o=WL(s.xy.sub(xe(.5)),xe(.5)),a=Od(-1,Wn(1,uM(n)).sub(1));e.assign(xg(o.mul(-2).mul(a)))}),e}}const _p=new ke,nu=new ke;let rl=null;class $L extends ao{static get type(){return"RectAreaLightNode"}constructor(t=null){super(t),this.halfHeight=de(new H).setGroup(te),this.halfWidth=de(new H).setGroup(te),this.updateType=ue.RENDER}update(t){super.update(t);const{light:e}=this,n=t.camera.matrixWorldInverse;nu.identity(),_p.copy(e.matrixWorld),_p.premultiply(n),nu.extractRotation(_p),this.halfWidth.value.set(e.width*.5,0,0),this.halfHeight.value.set(0,e.height*.5,0),this.halfWidth.value.applyMatrix4(nu),this.halfHeight.value.applyMatrix4(nu)}setupDirectRectArea(t){let e,n;t.isAvailable("float32Filterable")?(e=pn(rl.LTC_FLOAT_1),n=pn(rl.LTC_FLOAT_2)):(e=pn(rl.LTC_HALF_1),n=pn(rl.LTC_HALF_2));const{colorNode:i,light:s}=this,o=eS(s);return{lightColor:i,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:e,ltc_2:n}}static setLTC(t){rl=t}}class oS extends xn{static get type(){return"BitcastNode"}constructor(t,e,n=null){super(),this.valueNode=t,this.conversionType=e,this.inputType=n,this.isBitcastNode=!0}getNodeType(t){if(this.inputType!==null){const e=this.valueNode.getNodeType(t),n=t.getTypeLength(e);return t.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(t){const e=this.getNodeType(t);let n="";if(this.inputType!==null){const i=this.valueNode.getNodeType(t);n=t.getTypeLength(i)===1?this.inputType:t.changeComponentType(i,this.inputType)}else n=this.valueNode.getNodeType(t);return`${t.getBitcastMethod(e,n)}( ${this.valueNode.build(t,n)} )`}}const qL=At(oS).setParameterLength(2),YL=r=>new oS(r,"uint","float"),iu={};class qr extends z{static get type(){return"BitcountNode"}constructor(t,e){super(t,e),this.isBitcountNode=!0}_resolveElementType(t,e,n){n==="int"?e.assign(qL(t,"uint")):e.assign(t)}_returnDataNode(t){switch(t){case"uint":return fn;case"int":return Be;case"uvec2":return tM;case"uvec3":return nM;case"uvec4":return sM;case"ivec2":return ji;case"ivec3":return eM;case"ivec4":return iM}}_createTrailingZerosBaseLayout(t,e){const n=this._returnDataNode(e);return Mt(([s])=>{const o=fn(0);this._resolveElementType(s,o,e);const a=kt(o.bitAnd(fM(o))),c=YL(a).shiftRight(23).sub(127);return n(c)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createLeadingZerosBaseLayout(t,e){const n=this._returnDataNode(e);return Mt(([s])=>{hi(s.equal(fn(0)),()=>fn(32));const o=fn(0),a=fn(0);return this._resolveElementType(s,o,e),hi(o.shiftRight(16).equal(0),()=>{a.addAssign(16),o.shiftLeftAssign(16)}),hi(o.shiftRight(24).equal(0),()=>{a.addAssign(8),o.shiftLeftAssign(8)}),hi(o.shiftRight(28).equal(0),()=>{a.addAssign(4),o.shiftLeftAssign(4)}),hi(o.shiftRight(30).equal(0),()=>{a.addAssign(2),o.shiftLeftAssign(2)}),hi(o.shiftRight(31).equal(0),()=>{a.addAssign(1)}),n(a)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createOneBitsBaseLayout(t,e){const n=this._returnDataNode(e);return Mt(([s])=>{const o=fn(0);this._resolveElementType(s,o,e),o.assign(o.sub(o.shiftRight(fn(1)).bitAnd(fn(1431655765)))),o.assign(o.bitAnd(fn(858993459)).add(o.shiftRight(fn(2)).bitAnd(fn(858993459))));const a=o.add(o.shiftRight(fn(4))).bitAnd(fn(252645135)).mul(fn(16843009)).shiftRight(fn(24));return n(a)}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}_createMainLayout(t,e,n,i){const s=this._returnDataNode(e);return Mt(([a])=>{if(n===1)return s(i(a));{const l=s(0),c=["x","y","z","w"];for(let h=0;h<n;h++){const u=c[h];l[u].assign(i(a[u]))}return l}}).setLayout({name:t,type:e,inputs:[{name:"value",type:e}]})}setup(t){const{method:e,aNode:n}=this,{renderer:i}=t;if(i.backend.isWebGPUBackend)return super.setup(t);const s=this.getInputType(t),o=t.getElementType(s),a=t.getTypeLength(s),l=`${e}_base_${o}`,c=`${e}_${s}`;let h=iu[l];if(h===void 0){switch(e){case qr.COUNT_LEADING_ZEROS:{h=this._createLeadingZerosBaseLayout(l,o);break}case qr.COUNT_TRAILING_ZEROS:{h=this._createTrailingZerosBaseLayout(l,o);break}case qr.COUNT_ONE_BITS:{h=this._createOneBitsBaseLayout(l,o);break}}iu[l]=h}let u=iu[c];return u===void 0&&(u=this._createMainLayout(c,s,a,h),iu[c]=u),Mt(()=>u(n))()}}qr.COUNT_TRAILING_ZEROS="countTrailingZeros";qr.COUNT_LEADING_ZEROS="countLeadingZeros";qr.COUNT_ONE_BITS="countOneBits";class Rs extends Bt{static get type(){return"EventNode"}constructor(t,e){super("void"),this.eventType=t,this.callback=e,t===Rs.OBJECT?this.updateType=ue.OBJECT:t===Rs.MATERIAL?this.updateType=ue.RENDER:t===Rs.BEFORE_OBJECT?this.updateBeforeType=ue.OBJECT:t===Rs.BEFORE_MATERIAL&&(this.updateBeforeType=ue.RENDER)}update(t){this.callback(t)}updateBefore(t){this.callback(t)}}Rs.OBJECT="object";Rs.MATERIAL="material";Rs.BEFORE_OBJECT="beforeObject";Rs.BEFORE_MATERIAL="beforeMaterial";new Dr;new H;new H;new H;new ke;new H(0,0,-1);new Nn;new H;new H;new Nn;new Ge;const ZL=new ZM;Tg.flipX();ZL.depthTexture=new Pc(1,1);Pt(.04);kt(1);const JL=Mt(([r,t])=>r.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),jL=Mt(([r,t])=>(r=r.mul(t),r.div(r.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),KL=Mt(([r,t])=>{r=r.mul(t),r=r.sub(.004).max(0);const e=r.mul(r.mul(6.2).add(.5)),n=r.mul(r.mul(6.2).add(1.7)).add(.06);return e.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),QL=Mt(([r])=>{const t=r.mul(r.add(.0245786)).sub(90537e-9),e=r.mul(r.add(.432951).mul(.983729)).add(.238081);return t.div(e)}),tF=Mt(([r,t])=>{const e=yi(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=yi(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return r=r.mul(t).div(.6),r=e.mul(r),r=QL(r),r=n.mul(r),r.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),eF=yi(Pt(1.6605,-.1246,-.0182),Pt(-.5876,1.1329,-.1006),Pt(-.0728,-.0083,1.1187)),nF=yi(Pt(.6274,.0691,.0164),Pt(.3293,.9195,.088),Pt(.0433,.0113,.8956)),iF=Mt(([r])=>{const t=Pt(r).toVar(),e=Pt(t.mul(t)).toVar(),n=Pt(e.mul(e)).toVar();return kt(15.5).mul(n.mul(e)).sub(Ve(40.14,n.mul(t))).add(Ve(31.96,n).sub(Ve(6.868,e.mul(t))).add(Ve(.4298,e).add(Ve(.1191,t).sub(.00232))))}),sF=Mt(([r,t])=>{const e=Pt(r).toVar(),n=yi(Pt(.856627153315983,.137318972929847,.11189821299995),Pt(.0951212405381588,.761241990602591,.0767994186031903),Pt(.0482516061458583,.101439036467562,.811302368396859)),i=yi(Pt(1.1271005818144368,-.1413297634984383,-.14132976349843826),Pt(-.11060664309660323,1.157823702216272,-.11060664309660294),Pt(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=kt(-12.47393),o=kt(4.026069);return e.mulAssign(t),e.assign(nF.mul(e)),e.assign(n.mul(e)),e.assign(as(e,1e-10)),e.assign($r(e)),e.assign(e.sub(s).div(o.sub(s))),e.assign(va(e,0,1)),e.assign(iF(e)),e.assign(i.mul(e)),e.assign(gg(as(Pt(0),e),Pt(2.2))),e.assign(eF.mul(e)),e.assign(va(e,0,1)),e}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),rF=Mt(([r,t])=>{const e=kt(.76),n=kt(.15);r=r.mul(t);const i=lc(r.r,lc(r.g,r.b)),s=yg(i.lessThan(.08),i.sub(Ve(6.25,i.mul(i))),.04);r.subAssign(s);const o=as(r.r,as(r.g,r.b));hi(o.lessThan(e),()=>r);const a=Wn(1,e),l=Wn(1,a.mul(a).div(o.add(a.sub(e))));r.mulAssign(l.div(o));const c=Wn(1,Od(1,n.mul(o.sub(l)).add(1)));return Dn(r,Pt(l),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class oF extends F3{constructor(){super(),this.addLight(HL,V3),this.addLight(AL,G3),this.addLight($L,H3),this.addLight(Fg,Pg),this.addLight(wL,X3),this.addLight(EL,$3),this.addLight(RL,Y3),this.addLight(CL,Z3),this.addLight(XL,J3),this.addToneMapping(JL,xN),this.addToneMapping(jL,yN),this.addToneMapping(KL,_N),this.addToneMapping(tF,vN),this.addToneMapping(sF,MN),this.addToneMapping(rF,SN)}}function aF(r){const t={};for(const e in r){t[e]={};for(const n in r[e]){const i=r[e][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(ne("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}function lF(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}exports.ACESFilmicToneMapping=$u;exports.AdditiveBlending=uu;exports.AgXToneMapping=qu;exports.AlwaysDepth=Tl;exports.AlwaysStencilFunc=Cu;exports.AmbientLight=Wm;exports.AnimationClip=xa;exports.AnimationMixer=_v;exports.ArrayCamera=Ym;exports.Audio=Jm;exports.AudioContext=Nd;exports.AudioListener=mv;exports.AudioLoader=pv;exports.AxesHelper=Iv;exports.BackSide=An;exports.BasicDepthPacking=sm;exports.BasicNodeLibrary=oF;exports.BatchedMesh=mm;exports.Bone=hd;exports.BooleanKeyframeTrack=pr;exports.Box3=mn;exports.Box3Helper=Rv;exports.BoxGeometry=dr;exports.BoxHelper=Nv;exports.BufferAttribute=Te;exports.BufferGeometry=se;exports.Cache=Fi;exports.Camera=Tc;exports.CameraHelper=Cv;exports.CanvasTexture=H_;exports.CatmullRomCurve3=Sm;exports.ClampToEdgeWrapping=Bn;exports.Color=wt;exports.ColorKeyframeTrack=Ad;exports.ColorManagement=fe;exports.CompressedArrayTexture=k_;exports.CompressedCubeTexture=G_;exports.CompressedTexture=_c;exports.Controls=Lv;exports.CubeCamera=qm;exports.CubeTexture=ba;exports.CubeUVReflectionMapping=to;exports.Curve=vi;exports.CustomBlending=Yp;exports.CylinderGeometry=Ta;exports.Data3DTexture=mc;exports.DataTexture=fi;exports.DataTextureLoader=lv;exports.DataUtils=O_;exports.DecrementStencilOp=l_;exports.DecrementWrapStencilOp=h_;exports.DefaultLoadingManager=Bm;exports.DepthFormat=Oi;exports.DepthStencilFormat=Cs;exports.DepthTexture=jr;exports.DirectionalLight=Hm;exports.DirectionalLightHelper=Ev;exports.DoubleSide=Ri;exports.DynamicDrawUsage=w_;exports.EdgesGeometry=vm;exports.EqualDepth=Al;exports.EqualStencilFunc=p_;exports.EquirectangularReflectionMapping=jo;exports.EquirectangularRefractionMapping=Ko;exports.Euler=mi;exports.EventDispatcher=Bi;exports.ExtrudeGeometry=Mc;exports.FileLoader=rs;exports.Float32BufferAttribute=Ct;exports.FloatType=Tn;exports.Fog=lm;exports.FrontSide=is;exports.Frustum=no;exports.GLSL3=Nu;exports.GreaterDepth=Cl;exports.GreaterEqualDepth=El;exports.GreaterEqualStencilFunc=y_;exports.GreaterStencilFunc=g_;exports.GridHelper=Av;exports.Group=Gr;exports.HalfFloatType=Ui;exports.HemisphereLight=zm;exports.ImageBitmapLoader=fv;exports.ImageUtils=om;exports.IncrementStencilOp=a_;exports.IncrementWrapStencilOp=c_;exports.InstancedBufferAttribute=Jr;exports.InstancedBufferGeometry=$m;exports.InstancedInterleavedBuffer=vv;exports.InstancedMesh=pm;exports.InterleavedBuffer=xc;exports.InterleavedBufferAttribute=da;exports.Interpolant=so;exports.InterpolateDiscrete=ha;exports.InterpolateLinear=Yl;exports.InvertStencilOp=u_;exports.KeepStencilOp=Ks;exports.KeyframeTrack=ri;exports.LOD=dm;exports.Layers=gc;exports.LessDepth=wl;exports.LessEqualDepth=rr;exports.LessEqualStencilFunc=m_;exports.LessStencilFunc=f_;exports.Line=Fs;exports.Line3=Tv;exports.LineBasicMaterial=Rn;exports.LineLoop=gm;exports.LineSegments=zi;exports.LinearFilter=Fe;exports.LinearMipMapLinearFilter=Ky;exports.LinearMipmapLinearFilter=Li;exports.LinearMipmapNearestFilter=Qo;exports.LinearSRGBColorSpace=lr;exports.LinearToneMapping=Wu;exports.Loader=Vn;exports.LoaderUtils=Fu;exports.LoadingManager=Ed;exports.LoopOnce=em;exports.LoopRepeat=nm;exports.MOUSE=Ey;exports.Material=gn;exports.MathUtils=N_;exports.Matrix3=ae;exports.Matrix4=Qt;exports.MaxEquation=Zp;exports.Mesh=Ye;exports.MeshBasicMaterial=Ds;exports.MeshDepthMaterial=wd;exports.MeshLambertMaterial=Fm;exports.MeshNormalMaterial=Lm;exports.MeshPhongMaterial=Pm;exports.MeshPhysicalMaterial=Im;exports.MeshStandardMaterial=Td;exports.MirroredRepeatWrapping=la;exports.NearestFilter=Xe;exports.NearestMipMapNearestFilter=jy;exports.NearestMipmapLinearFilter=zr;exports.NearestMipmapNearestFilter=Ju;exports.NeutralToneMapping=Yu;exports.NeverDepth=bl;exports.NeverStencilFunc=d_;exports.NoBlending=Di;exports.NoColorSpace=Ki;exports.NoToneMapping=di;exports.NodeFrame=jP;exports.NormalBlending=nr;exports.NotEqualDepth=Nl;exports.NotEqualStencilFunc=x_;exports.NumberKeyframeTrack=ma;exports.Object3D=ve;exports.OctahedronGeometry=wa;exports.OrthographicCamera=Ca;exports.PCFShadowMap=Jo;exports.PMREMGenerator=Du;exports.PerspectiveCamera=cn;exports.Plane=Ts;exports.PlaneGeometry=io;exports.PointLight=Gm;exports.Points=xm;exports.PointsMaterial=dd;exports.PositionalAudio=gv;exports.PropertyBinding=me;exports.Quaternion=En;exports.QuaternionKeyframeTrack=Ea;exports.R11_EAC_Format=Ul;exports.RED_GREEN_RGTC2_Format=$l;exports.RED_RGTC1_Format=Wl;exports.REVISION=Wr;exports.RG11_EAC_Format=Bl;exports.RGBADepthPacking=i_;exports.RGBAFormat=wn;exports.RGBAIntegerFormat=pc;exports.RGBA_ASTC_4x4_Format=Vl;exports.RGBA_ASTC_6x6_Format=kl;exports.RGBA_BPTC_Format=Gl;exports.RGBA_ETC2_EAC_Format=Dl;exports.RGBA_PVRTC_2BPPV1_Format=Pl;exports.RGBA_PVRTC_4BPPV1_Format=Il;exports.RGBA_S3TC_DXT1_Format=ea;exports.RGBA_S3TC_DXT5_Format=na;exports.RGBFormat=nd;exports.RGB_BPTC_UNSIGNED_Format=Hl;exports.RGB_ETC1_Format=Ll;exports.RGB_ETC2_Format=Fl;exports.RGB_PVRTC_4BPPV1_Format=Rl;exports.RGB_S3TC_DXT1_Format=ta;exports.RGFormat=ar;exports.RGIntegerFormat=fc;exports.RawShaderMaterial=bd;exports.Ray=eo;exports.Raycaster=Mv;exports.RedFormat=dc;exports.RedIntegerFormat=Sa;exports.ReinhardToneMapping=Xu;exports.RepeatWrapping=aa;exports.ReplaceStencilOp=o_;exports.RingGeometry=Sc;exports.SIGNED_R11_EAC_Format=Ol;exports.SIGNED_RED_GREEN_RGTC2_Format=ql;exports.SIGNED_RED_RGTC1_Format=Xl;exports.SIGNED_RG11_EAC_Format=zl;exports.SRGBColorSpace=Fn;exports.Scene=cm;exports.ShaderChunk=oe;exports.ShaderLib=ci;exports.ShaderMaterial=si;exports.ShadowMaterial=Nm;exports.Shape=ir;exports.ShapePath=Pv;exports.ShapeUtils=ui;exports.Skeleton=yc;exports.SkinnedMesh=fm;exports.Source=Ns;exports.Sphere=un;exports.SphereGeometry=Aa;exports.Spherical=Sv;exports.SpotLight=km;exports.Sprite=um;exports.SpriteMaterial=cd;exports.THREE=hN;exports.TOUCH=Cy;exports.Texture=rn;exports.TextureLoader=cv;exports.Timer=Zm;exports.TorusGeometry=bc;exports.Triangle=ws;exports.TriangleFanDrawMode=n_;exports.TriangleStripDrawMode=e_;exports.TrianglesDrawMode=t_;exports.Uint16BufferAttribute=ld;exports.Uniform=Rd;exports.UniformsLib=gt;exports.UniformsUtils=Rm;exports.UnsignedByteType=Un;exports.UnsignedInt101111Type=ed;exports.UnsignedInt248Type=Yr;exports.UnsignedInt5999Type=td;exports.UnsignedIntType=ii;exports.Vector2=tt;exports.Vector3=R;exports.Vector4=Le;exports.VectorKeyframeTrack=ga;exports.VideoTexture=ym;exports.WebGLCubeRenderTarget=Pd;exports.WebGLRenderTarget=qn;exports.WebGLRenderer=Vv;exports.WireframeGeometry=Cm;exports.ZeroStencilOp=r_;exports.cloneUniforms=aF;exports.cloneUniformsGroups=lF;
|