@needle-tools/engine 5.1.0-experimental.2 → 5.1.0-experimental.4
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-B4-b_LbG.js → needle-engine.bundle-BAe6Zbj9.js} +4030 -4006
- package/dist/{needle-engine.bundle-CGeRwYBH.umd.cjs → needle-engine.bundle-BYO243m2.umd.cjs} +125 -125
- package/dist/{needle-engine.bundle-092kFd20.min.js → needle-engine.bundle-DRun3Rri.min.js} +125 -125
- package/dist/needle-engine.d.ts +12 -0
- 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/engine_three_utils.js +4 -2
- package/lib/engine/engine_three_utils.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/js-extensions/three.d.ts +40 -0
- package/lib/engine/js-extensions/three.js +52 -0
- package/lib/engine/js-extensions/three.js.map +1 -0
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +3 -8
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
- package/lib/engine/webcomponents/icons.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/Animation.js +0 -1
- package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +2 -2
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.js +2 -2
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/ui/Image.js +3 -1
- package/lib/engine-components/ui/Image.js.map +1 -1
- package/package.json +1 -2
- package/src/engine/engine_context.ts +2 -2
- package/src/engine/engine_serialization_builtin_serializer.ts +17 -3
- package/src/engine/engine_three_utils.ts +7 -5
- package/src/engine/js-extensions/RGBAColor.ts +6 -2
- package/src/engine/js-extensions/three.ts +72 -0
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +3 -8
- package/src/engine/webcomponents/icons.ts +1 -1
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +1 -1
- package/src/engine-components/export/usdz/extensions/Animation.ts +3 -4
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +1 -1
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +2 -2
- package/src/engine-components/timeline/TimelineTracks.ts +2 -2
- package/src/engine-components/ui/Image.ts +3 -1
package/dist/three.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const yn="183.2",Wg={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},jg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Xg=0,Yd=1,qg=2,pM=3,mM=0,Oo=1,Zd=2,ha=3,Vs=0,yi=1,Ms=2,bs=0,Or=1,Dh=2,Jd=3,Kd=4,$d=5,fM=6,Ur=100,Yg=101,Zg=102,Jg=103,Qd=104,Kg=200,$g=201,Qg=202,e0=203,Oh=204,Uh=205,t0=206,i0=207,s0=208,r0=209,n0=210,a0=211,o0=212,l0=213,h0=214,Uo=0,Fo=1,zo=2,Fr=3,Bo=4,Vo=5,ko=6,Go=7,Ho=0,c0=1,u0=2,rs=0,Fh=1,zh=2,ep=3,Bh=4,tp=5,Vh=6,kh=7,ip="attached",d0="detached",Gh=300,ks=301,zr=302,ca=303,ua=304,xn=306,da=1e3,Ci=1001,pa=1002,Ht=1003,Hh=1004,p0=1004,vn=1005,gM=1005,Rt=1006,ma=1007,yM=1007,Ss=1008,m0=1008,Ri=1009,sp=1010,rp=1011,fa=1012,Wh=1013,qi=1014,xi=1015,Ts=1016,jh=1017,Xh=1018,_n=1020,qh=35902,Yh=35899,np=1021,Zh=1022,vi=1023,ws=1026,ur=1027,Wo=1028,ga=1029,Br=1030,jo=1031,xM=1032,Xo=1033,ya=33776,xa=33777,qo=33778,va=33779,Yo=35840,Jh=35841,Zo=35842,Jo=35843,Ko=36196,$o=37492,Qo=37496,el=37488,tl=37489,il=37490,sl=37491,rl=37808,Kh=37809,$h=37810,Qh=37811,nl=37812,ec=37813,tc=37814,ic=37815,sc=37816,rc=37817,nc=37818,ac=37819,oc=37820,lc=37821,al=36492,hc=36494,ol=36495,ll=36283,hl=36284,cl=36285,ul=36286,ap=2200,op=2201,f0=2202,_a=2300,dl=2301,cc=2302,lp=2303,Mn=2400,bn=2401,pl=2402,uc=2500,hp=2501,g0=0,y0=1,x0=2,cp=3200,v0=3201,vM=3202,_M=3203,Vr=0,_0=1,Gs="",Ii="srgb",kr="srgb-linear",ml="linear",vt="srgb",MM="",bM="rg",SM="ga",M0=0,Gr=7680,b0=7681,S0=7682,T0=7683,w0=34055,E0=34056,A0=5386,N0=512,C0=513,R0=514,I0=515,P0=516,L0=517,D0=518,dc=519,O0=512,U0=513,F0=514,pc=515,z0=516,B0=517,mc=518,V0=519,fl=35044,k0=35048,TM=35040,wM=35045,EM=35049,AM=35041,NM=35046,CM=35050,RM=35042,IM="100",fc="300 es",Yi=2e3,Sn=2001,PM={COMPUTE:"compute",RENDER:"render"},LM={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},DM={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},OM={TEXTURE_COMPARE:"depthTextureCompare"};function UM(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const FM={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ma(s,e){return new FM[s](e)}function G0(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function gl(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function H0(){const s=gl("canvas");return s.style.display="block",s}const W0={};let Hr=null;function zM(s){Hr=s}function BM(){return Hr}function yl(...s){const e="THREE."+s.shift();Hr?Hr("log",e,...s):console.log(e,...s)}function j0(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function ge(...s){s=j0(s);const e="THREE."+s.shift();if(Hr)Hr("warn",e,...s);else{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function Ve(...s){s=j0(s);const e="THREE."+s.shift();if(Hr)Hr("error",e,...s);else{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function xl(...s){const e=s.join(" ");e in W0||(W0[e]=!0,ge(...s))}function VM(s,e,t){return new Promise(function(i,r){function n(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:r();break;case s.TIMEOUT_EXPIRED:setTimeout(n,t);break;default:i()}}setTimeout(n,t)})}const kM={[Uo]:Fo,[zo]:ko,[Bo]:Go,[Fr]:Vo,[Fo]:Uo,[ko]:zo,[Go]:Bo,[Vo]:Fr};let Es=class{addEventListener(s,e){this._listeners===void 0&&(this._listeners={});const t=this._listeners;t[s]===void 0&&(t[s]=[]),t[s].indexOf(e)===-1&&t[s].push(e)}hasEventListener(s,e){const t=this._listeners;return t===void 0?!1:t[s]!==void 0&&t[s].indexOf(e)!==-1}removeEventListener(s,e){const t=this._listeners;if(t===void 0)return;const i=t[s];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(s){const e=this._listeners;if(e===void 0)return;const t=e[s.type];if(t!==void 0){s.target=this;const i=t.slice(0);for(let r=0,n=i.length;r<n;r++)i[r].call(this,s);s.target=null}}};const _i=["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 X0=1234567;const Tn=Math.PI/180,ba=180/Math.PI;function Zi(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(_i[s&255]+_i[s>>8&255]+_i[s>>16&255]+_i[s>>24&255]+"-"+_i[e&255]+_i[e>>8&255]+"-"+_i[e>>16&15|64]+_i[e>>24&255]+"-"+_i[t&63|128]+_i[t>>8&255]+"-"+_i[t>>16&255]+_i[t>>24&255]+_i[i&255]+_i[i>>8&255]+_i[i>>16&255]+_i[i>>24&255]).toLowerCase()}function Ke(s,e,t){return Math.max(e,Math.min(t,s))}function up(s,e){return(s%e+e)%e}function GM(s,e,t,i,r){return i+(s-e)*(r-i)/(t-e)}function HM(s,e,t){return s!==e?(t-s)/(e-s):0}function vl(s,e,t){return(1-t)*s+t*e}function WM(s,e,t,i){return vl(s,e,1-Math.exp(-t*i))}function jM(s,e=1){return e-Math.abs(up(s,e*2)-e)}function XM(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function qM(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function YM(s,e){return s+Math.floor(Math.random()*(e-s+1))}function ZM(s,e){return s+Math.random()*(e-s)}function JM(s){return s*(.5-Math.random())}function KM(s){s!==void 0&&(X0=s);let e=X0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function $M(s){return s*Tn}function QM(s){return s*ba}function eb(s){return(s&s-1)===0&&s!==0}function tb(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function ib(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function sb(s,e,t,i,r){const n=Math.cos,a=Math.sin,o=n(t/2),l=a(t/2),h=n((e+i)/2),c=a((e+i)/2),d=n((e-i)/2),u=a((e-i)/2),p=n((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":s.set(o*c,l*d,l*u,o*h);break;case"YZY":s.set(l*u,o*c,l*d,o*h);break;case"ZXZ":s.set(l*d,l*u,o*c,o*h);break;case"XZX":s.set(o*c,l*m,l*p,o*h);break;case"YXY":s.set(l*p,o*c,l*m,o*h);break;case"ZYZ":s.set(l*m,l*p,o*c,o*h);break;default:ge("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Pi(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function nt(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const q0={DEG2RAD:Tn,RAD2DEG:ba,generateUUID:Zi,clamp:Ke,euclideanModulo:up,mapLinear:GM,inverseLerp:HM,lerp:vl,damp:WM,pingpong:jM,smoothstep:XM,smootherstep:qM,randInt:YM,randFloat:ZM,randFloatSpread:JM,seededRandom:KM,degToRad:$M,radToDeg:QM,isPowerOfTwo:eb,ceilPowerOfTwo:tb,floorPowerOfTwo:ib,setQuaternionFromProperEuler:sb,normalize:nt,denormalize:Pi};let te=class K1{constructor(e=0,t=0){K1.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ke(i,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Ke(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*r+e.x,this.y=n*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Mi=class{constructor(s=0,e=0,t=0,i=1){this.isQuaternion=!0,this._x=s,this._y=e,this._z=t,this._w=i}static slerpFlat(s,e,t,i,r,n,a){let o=t[i+0],l=t[i+1],h=t[i+2],c=t[i+3],d=r[n+0],u=r[n+1],p=r[n+2],m=r[n+3];if(c!==m||o!==d||l!==u||h!==p){let y=o*d+l*u+h*p+c*m;y<0&&(d=-d,u=-u,p=-p,m=-m,y=-y);let g=1-a;if(y<.9995){const f=Math.acos(y),x=Math.sin(f);g=Math.sin(g*f)/x,a=Math.sin(a*f)/x,o=o*g+d*a,l=l*g+u*a,h=h*g+p*a,c=c*g+m*a}else{o=o*g+d*a,l=l*g+u*a,h=h*g+p*a,c=c*g+m*a;const f=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=f,l*=f,h*=f,c*=f}}s[e]=o,s[e+1]=l,s[e+2]=h,s[e+3]=c}static multiplyQuaternionsFlat(s,e,t,i,r,n){const a=t[i],o=t[i+1],l=t[i+2],h=t[i+3],c=r[n],d=r[n+1],u=r[n+2],p=r[n+3];return s[e]=a*p+h*c+o*u-l*d,s[e+1]=o*p+h*d+l*c-a*u,s[e+2]=l*p+h*u+a*d-o*c,s[e+3]=h*p-a*c-o*d-l*u,s}get x(){return this._x}set x(s){this._x=s,this._onChangeCallback()}get y(){return this._y}set y(s){this._y=s,this._onChangeCallback()}get z(){return this._z}set z(s){this._z=s,this._onChangeCallback()}get w(){return this._w}set w(s){this._w=s,this._onChangeCallback()}set(s,e,t,i){return this._x=s,this._y=e,this._z=t,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(s){return this._x=s.x,this._y=s.y,this._z=s.z,this._w=s.w,this._onChangeCallback(),this}setFromEuler(s,e=!0){const t=s._x,i=s._y,r=s._z,n=s._order,a=Math.cos,o=Math.sin,l=a(t/2),h=a(i/2),c=a(r/2),d=o(t/2),u=o(i/2),p=o(r/2);switch(n){case"XYZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"YXZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"ZXY":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"ZYX":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"YZX":this._x=d*h*c+l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c-d*u*p;break;case"XZY":this._x=d*h*c-l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c+d*u*p;break;default:ge("Quaternion: .setFromEuler() encountered an unknown order: "+n)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(s,e){const t=e/2,i=Math.sin(t);return this._x=s.x*i,this._y=s.y*i,this._z=s.z*i,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(s){const e=s.elements,t=e[0],i=e[4],r=e[8],n=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],d=t+a+c;if(d>0){const u=.5/Math.sqrt(d+1);this._w=.25/u,this._x=(h-o)*u,this._y=(r-l)*u,this._z=(n-i)*u}else if(t>a&&t>c){const u=2*Math.sqrt(1+t-a-c);this._w=(h-o)/u,this._x=.25*u,this._y=(i+n)/u,this._z=(r+l)/u}else if(a>c){const u=2*Math.sqrt(1+a-t-c);this._w=(r-l)/u,this._x=(i+n)/u,this._y=.25*u,this._z=(o+h)/u}else{const u=2*Math.sqrt(1+c-t-a);this._w=(n-i)/u,this._x=(r+l)/u,this._y=(o+h)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(s,e){let t=s.dot(e)+1;return t<1e-8?(t=0,Math.abs(s.x)>Math.abs(s.z)?(this._x=-s.y,this._y=s.x,this._z=0,this._w=t):(this._x=0,this._y=-s.z,this._z=s.y,this._w=t)):(this._x=s.y*e.z-s.z*e.y,this._y=s.z*e.x-s.x*e.z,this._z=s.x*e.y-s.y*e.x,this._w=t),this.normalize()}angleTo(s){return 2*Math.acos(Math.abs(Ke(this.dot(s),-1,1)))}rotateTowards(s,e){const t=this.angleTo(s);if(t===0)return this;const i=Math.min(1,e/t);return this.slerp(s,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(s){return this._x*s._x+this._y*s._y+this._z*s._z+this._w*s._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 s=this.length();return s===0?(this._x=0,this._y=0,this._z=0,this._w=1):(s=1/s,this._x=this._x*s,this._y=this._y*s,this._z=this._z*s,this._w=this._w*s),this._onChangeCallback(),this}multiply(s){return this.multiplyQuaternions(this,s)}premultiply(s){return this.multiplyQuaternions(s,this)}multiplyQuaternions(s,e){const t=s._x,i=s._y,r=s._z,n=s._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=t*h+n*a+i*l-r*o,this._y=i*h+n*o+r*a-t*l,this._z=r*h+n*l+t*o-i*a,this._w=n*h-t*a-i*o-r*l,this._onChangeCallback(),this}slerp(s,e){let t=s._x,i=s._y,r=s._z,n=s._w,a=this.dot(s);a<0&&(t=-t,i=-i,r=-r,n=-n,a=-a);let o=1-e;if(a<.9995){const l=Math.acos(a),h=Math.sin(l);o=Math.sin(o*l)/h,e=Math.sin(e*l)/h,this._x=this._x*o+t*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+n*e,this._onChangeCallback()}else this._x=this._x*o+t*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+n*e,this.normalize();return this}slerpQuaternions(s,e,t){return this.copy(s).slerp(e,t)}random(){const s=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),t=Math.random(),i=Math.sqrt(1-t),r=Math.sqrt(t);return this.set(i*Math.sin(s),i*Math.cos(s),r*Math.sin(e),r*Math.cos(e))}equals(s){return s._x===this._x&&s._y===this._y&&s._z===this._z&&s._w===this._w}fromArray(s,e=0){return this._x=s[e],this._y=s[e+1],this._z=s[e+2],this._w=s[e+3],this._onChangeCallback(),this}toArray(s=[],e=0){return s[e]=this._x,s[e+1]=this._y,s[e+2]=this._z,s[e+3]=this._w,s}fromBufferAttribute(s,e){return this._x=s.getX(e),this._y=s.getY(e),this._z=s.getZ(e),this._w=s.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(s){return this._onChangeCallback=s,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},R=class $1{constructor(e=0,t=0,i=0){$1.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Y0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Y0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=e.elements,a=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*r-o*i),c=2*(o*t-n*r),d=2*(n*i-a*t);return this.x=t+l*h+a*d-o*c,this.y=i+l*c+o*h-n*d,this.z=r+l*d+n*c-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ke(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,n=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-n*o,this.y=n*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return dp.copy(this).projectOnVector(e),this.sub(dp)}reflect(e){return this.sub(dp.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Ke(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const dp=new R,Y0=new Mi;let at=class Q1{constructor(e,t,i,r,n,a,o,l,h){Q1.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,h)}set(e,t,i,r,n,a,o,l,h){const c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=t,c[4]=n,c[5]=l,c[6]=i,c[7]=a,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[3],l=i[6],h=i[1],c=i[4],d=i[7],u=i[2],p=i[5],m=i[8],y=r[0],g=r[3],f=r[6],x=r[1],v=r[4],M=r[7],w=r[2],T=r[5],A=r[8];return n[0]=a*y+o*x+l*w,n[3]=a*g+o*v+l*T,n[6]=a*f+o*M+l*A,n[1]=h*y+c*x+d*w,n[4]=h*g+c*v+d*T,n[7]=h*f+c*M+d*A,n[2]=u*y+p*x+m*w,n[5]=u*g+p*v+m*T,n[8]=u*f+p*M+m*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8];return t*a*c-t*o*h-i*n*c+i*o*l+r*n*h-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],d=c*a-o*h,u=o*l-c*n,p=h*n-a*l,m=t*d+i*u+r*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return e[0]=d*y,e[1]=(r*h-c*i)*y,e[2]=(o*i-r*a)*y,e[3]=u*y,e[4]=(c*t-r*l)*y,e[5]=(r*n-o*t)*y,e[6]=p*y,e[7]=(i*l-h*t)*y,e[8]=(a*t-i*n)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,n,a,o){const l=Math.cos(n),h=Math.sin(n);return this.set(i*l,i*h,-i*(l*a+h*o)+a+e,-r*h,r*l,-r*(-h*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(pp.makeScale(e,t)),this}rotate(e){return this.premultiply(pp.makeRotation(-e)),this}translate(e,t){return this.premultiply(pp.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const pp=new at,Z0=new at().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),J0=new at().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rb(){const s={enabled:!0,workingColorSpace:kr,spaces:{},convert:function(r,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===vt&&(r.r=dr(r.r),r.g=dr(r.g),r.b=dr(r.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[n].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===vt&&(r.r=Sa(r.r),r.g=Sa(r.g),r.b=Sa(r.b))),r},workingToColorSpace:function(r,n){return this.convert(r,this.workingColorSpace,n)},colorSpaceToWorking:function(r,n){return this.convert(r,n,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Gs?ml:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,n=this.workingColorSpace){return r.fromArray(this.spaces[n].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,n,a){return r.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,n){return xl("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(r,n)},toWorkingColorSpace:function(r,n){return xl("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(r,n)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[kr]:{primaries:e,whitePoint:i,transfer:ml,toXYZ:Z0,fromXYZ:J0,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ii},outputColorSpaceConfig:{drawingBufferColorSpace:Ii}},[Ii]:{primaries:e,whitePoint:i,transfer:vt,toXYZ:Z0,fromXYZ:J0,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ii}}}),s}const mt=rb();function dr(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Sa(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Ta,mp=class{static getDataURL(s,e="image/png"){if(/^data:/i.test(s.src)||typeof HTMLCanvasElement>"u")return s.src;let t;if(s instanceof HTMLCanvasElement)t=s;else{Ta===void 0&&(Ta=gl("canvas")),Ta.width=s.width,Ta.height=s.height;const i=Ta.getContext("2d");s instanceof ImageData?i.putImageData(s,0,0):i.drawImage(s,0,0,s.width,s.height),t=Ta}return t.toDataURL(e)}static sRGBToLinear(s){if(typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap){const e=gl("canvas");e.width=s.width,e.height=s.height;const t=e.getContext("2d");t.drawImage(s,0,0,s.width,s.height);const i=t.getImageData(0,0,s.width,s.height),r=i.data;for(let n=0;n<r.length;n++)r[n]=dr(r[n]/255)*255;return t.putImageData(i,0,0),e}else if(s.data){const e=s.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(dr(e[t]/255)*255):e[t]=dr(e[t]);return{data:e,width:s.width,height:s.height}}else return ge("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),s}},nb=0,pr=class{constructor(s=null){this.isSource=!0,Object.defineProperty(this,"id",{value:nb++}),this.uuid=Zi(),this.data=s,this.dataReady=!0,this.version=0}getSize(s){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?s.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?s.set(e.displayHeight,e.displayWidth,0):e!==null?s.set(e.width,e.height,e.depth||0):s.set(0,0,0),s}set needsUpdate(s){s===!0&&this.version++}toJSON(s){const e=s===void 0||typeof s=="string";if(!e&&s.images[this.uuid]!==void 0)return s.images[this.uuid];const t={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let n=0,a=i.length;n<a;n++)i[n].isDataTexture?r.push(fp(i[n].image)):r.push(fp(i[n]))}else r=fp(i);t.url=r}return e||(s.images[this.uuid]=t),t}};function fp(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?mp.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(ge("Texture: Unable to serialize Texture."),{})}let ab=0;const gp=new R;let ei=class Cd extends Es{constructor(e=Cd.DEFAULT_IMAGE,t=Cd.DEFAULT_MAPPING,i=Ci,r=Ci,n=Rt,a=Ss,o=vi,l=Ri,h=Cd.DEFAULT_ANISOTROPY,c=Gs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ab++}),this.uuid=Zi(),this.name="",this.source=new pr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new te(0,0),this.repeat=new te(1,1),this.center=new te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new at,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(gp).x}get height(){return this.source.getSize(gp).y}get depth(){return this.source.getSize(gp).z}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){ge(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){ge(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Gh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case da:e.x=e.x-Math.floor(e.x);break;case Ci:e.x=e.x<0?0:1;break;case pa:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case da:e.y=e.y-Math.floor(e.y);break;case Ci:e.y=e.y<0?0:1;break;case pa:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};ei.DEFAULT_IMAGE=null,ei.DEFAULT_MAPPING=Gh,ei.DEFAULT_ANISOTROPY=4;let It=class eM{constructor(e=0,t=0,i=0,r=1){eM.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*n,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*n,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*n,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,n;const a=e.elements,o=a[0],l=a[4],h=a[8],c=a[1],d=a[5],u=a[9],p=a[2],m=a[6],y=a[10];if(Math.abs(l-c)<.01&&Math.abs(h-p)<.01&&Math.abs(u-m)<.01){if(Math.abs(l+c)<.1&&Math.abs(h+p)<.1&&Math.abs(u+m)<.1&&Math.abs(o+d+y-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const f=(o+1)/2,x=(d+1)/2,v=(y+1)/2,M=(l+c)/4,w=(h+p)/4,T=(u+m)/4;return f>x&&f>v?f<.01?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(f),r=M/i,n=w/i):x>v?x<.01?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(x),i=M/r,n=T/r):v<.01?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(v),i=w/n,r=T/n),this.set(i,r,n,t),this}let g=Math.sqrt((m-u)*(m-u)+(h-p)*(h-p)+(c-l)*(c-l));return Math.abs(g)<.001&&(g=1),this.x=(m-u)/g,this.y=(h-p)/g,this.z=(c-l)/g,this.w=Math.acos((o+d+y-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this.w=Ke(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this.w=Ke(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ke(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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}},yp=class extends Es{constructor(s=1,e=1,t={}){super(),t=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},t),this.isRenderTarget=!0,this.width=s,this.height=e,this.depth=t.depth,this.scissor=new It(0,0,s,e),this.scissorTest=!1,this.viewport=new It(0,0,s,e),this.textures=[];const i={width:s,height:e,depth:t.depth},r=new ei(i),n=t.count;for(let a=0;a<n;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(t),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=t.depthTexture,this.samples=t.samples,this.multiview=t.multiview}_setTextureOptions(s={}){const e={minFilter:Rt,generateMipmaps:!1,flipY:!1,internalFormat:null};s.mapping!==void 0&&(e.mapping=s.mapping),s.wrapS!==void 0&&(e.wrapS=s.wrapS),s.wrapT!==void 0&&(e.wrapT=s.wrapT),s.wrapR!==void 0&&(e.wrapR=s.wrapR),s.magFilter!==void 0&&(e.magFilter=s.magFilter),s.minFilter!==void 0&&(e.minFilter=s.minFilter),s.format!==void 0&&(e.format=s.format),s.type!==void 0&&(e.type=s.type),s.anisotropy!==void 0&&(e.anisotropy=s.anisotropy),s.colorSpace!==void 0&&(e.colorSpace=s.colorSpace),s.flipY!==void 0&&(e.flipY=s.flipY),s.generateMipmaps!==void 0&&(e.generateMipmaps=s.generateMipmaps),s.internalFormat!==void 0&&(e.internalFormat=s.internalFormat);for(let t=0;t<this.textures.length;t++)this.textures[t].setValues(e)}get texture(){return this.textures[0]}set texture(s){this.textures[0]=s}set depthTexture(s){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),s!==null&&(s.renderTarget=this),this._depthTexture=s}get depthTexture(){return this._depthTexture}setSize(s,e,t=1){if(this.width!==s||this.height!==e||this.depth!==t){this.width=s,this.height=e,this.depth=t;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=s,this.textures[i].image.height=e,this.textures[i].image.depth=t,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,s,e),this.scissor.set(0,0,s,e)}clone(){return new this.constructor().copy(this)}copy(s){this.width=s.width,this.height=s.height,this.depth=s.depth,this.scissor.copy(s.scissor),this.scissorTest=s.scissorTest,this.viewport.copy(s.viewport),this.textures.length=0;for(let e=0,t=s.textures.length;e<t;e++){this.textures[e]=s.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},s.textures[e].image);this.textures[e].source=new pr(i)}return this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,s.depthTexture!==null&&(this.depthTexture=s.depthTexture.clone()),this.samples=s.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}};class Bi extends yp{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}let gc=class extends ei{constructor(s=null,e=1,t=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:s,width:e,height:t,depth:i},this.magFilter=Ht,this.minFilter=Ht,this.wrapR=Ci,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(s){this.layerUpdates.add(s)}clearLayerUpdates(){this.layerUpdates.clear()}};class ob extends Bi{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new gc(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class _l extends ei{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ht,this.minFilter=Ht,this.wrapR=Ci,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class lb extends Bi{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new _l(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}let et=class Pg{constructor(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g){Pg.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g)}set(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=n,f[5]=a,f[9]=o,f[13]=l,f[2]=h,f[6]=c,f[10]=d,f[14]=u,f[3]=p,f[7]=m,f[11]=y,f[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 Pg().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/wa.setFromMatrixColumn(e,0).length(),n=1/wa.setFromMatrixColumn(e,1).length(),a=1/wa.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),h=Math.sin(r),c=Math.cos(n),d=Math.sin(n);if(e.order==="XYZ"){const u=a*c,p=a*d,m=o*c,y=o*d;t[0]=l*c,t[4]=-l*d,t[8]=h,t[1]=p+m*h,t[5]=u-y*h,t[9]=-o*l,t[2]=y-u*h,t[6]=m+p*h,t[10]=a*l}else if(e.order==="YXZ"){const u=l*c,p=l*d,m=h*c,y=h*d;t[0]=u+y*o,t[4]=m*o-p,t[8]=a*h,t[1]=a*d,t[5]=a*c,t[9]=-o,t[2]=p*o-m,t[6]=y+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*c,p=l*d,m=h*c,y=h*d;t[0]=u-y*o,t[4]=-a*d,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*c,t[9]=y-u*o,t[2]=-a*h,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*c,p=a*d,m=o*c,y=o*d;t[0]=l*c,t[4]=m*h-p,t[8]=u*h+y,t[1]=l*d,t[5]=y*h+u,t[9]=p*h-m,t[2]=-h,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*h,m=o*l,y=o*h;t[0]=l*c,t[4]=y-u*d,t[8]=m*d+p,t[1]=d,t[5]=a*c,t[9]=-o*c,t[2]=-h*c,t[6]=p*d+m,t[10]=u-y*d}else if(e.order==="XZY"){const u=a*l,p=a*h,m=o*l,y=o*h;t[0]=l*c,t[4]=-d,t[8]=h*c,t[1]=u*d+y,t[5]=a*c,t[9]=p*d-m,t[2]=m*d-p,t[6]=o*c,t[10]=y*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(hb,e,cb)}lookAt(e,t,i){const r=this.elements;return Ji.subVectors(e,t),Ji.lengthSq()===0&&(Ji.z=1),Ji.normalize(),Wr.crossVectors(i,Ji),Wr.lengthSq()===0&&(Math.abs(i.z)===1?Ji.x+=1e-4:Ji.z+=1e-4,Ji.normalize(),Wr.crossVectors(i,Ji)),Wr.normalize(),yc.crossVectors(Ji,Wr),r[0]=Wr.x,r[4]=yc.x,r[8]=Ji.x,r[1]=Wr.y,r[5]=yc.y,r[9]=Ji.y,r[2]=Wr.z,r[6]=yc.z,r[10]=Ji.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[4],l=i[8],h=i[12],c=i[1],d=i[5],u=i[9],p=i[13],m=i[2],y=i[6],g=i[10],f=i[14],x=i[3],v=i[7],M=i[11],w=i[15],T=r[0],A=r[4],_=r[8],S=r[12],P=r[1],C=r[5],L=r[9],U=r[13],V=r[2],B=r[6],k=r[10],W=r[14],se=r[3],ie=r[7],oe=r[11],be=r[15];return n[0]=a*T+o*P+l*V+h*se,n[4]=a*A+o*C+l*B+h*ie,n[8]=a*_+o*L+l*k+h*oe,n[12]=a*S+o*U+l*W+h*be,n[1]=c*T+d*P+u*V+p*se,n[5]=c*A+d*C+u*B+p*ie,n[9]=c*_+d*L+u*k+p*oe,n[13]=c*S+d*U+u*W+p*be,n[2]=m*T+y*P+g*V+f*se,n[6]=m*A+y*C+g*B+f*ie,n[10]=m*_+y*L+g*k+f*oe,n[14]=m*S+y*U+g*W+f*be,n[3]=x*T+v*P+M*V+w*se,n[7]=x*A+v*C+M*B+w*ie,n[11]=x*_+v*L+M*k+w*oe,n[15]=x*S+v*U+M*W+w*be,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],c=e[2],d=e[6],u=e[10],p=e[14],m=e[3],y=e[7],g=e[11],f=e[15],x=l*p-h*u,v=o*p-h*d,M=o*u-l*d,w=a*p-h*c,T=a*u-l*c,A=a*d-o*c;return t*(y*x-g*v+f*M)-i*(m*x-g*w+f*T)+r*(m*v-y*w+f*A)-n*(m*M-y*T+g*A)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],d=e[9],u=e[10],p=e[11],m=e[12],y=e[13],g=e[14],f=e[15],x=t*o-i*a,v=t*l-r*a,M=t*h-n*a,w=i*l-r*o,T=i*h-n*o,A=r*h-n*l,_=c*y-d*m,S=c*g-u*m,P=c*f-p*m,C=d*g-u*y,L=d*f-p*y,U=u*f-p*g,V=x*U-v*L+M*C+w*P-T*S+A*_;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const B=1/V;return e[0]=(o*U-l*L+h*C)*B,e[1]=(r*L-i*U-n*C)*B,e[2]=(y*A-g*T+f*w)*B,e[3]=(u*T-d*A-p*w)*B,e[4]=(l*P-a*U-h*S)*B,e[5]=(t*U-r*P+n*S)*B,e[6]=(g*M-m*A-f*v)*B,e[7]=(c*A-u*M+p*v)*B,e[8]=(a*L-o*P+h*_)*B,e[9]=(i*P-t*L-n*_)*B,e[10]=(m*T-y*M+f*x)*B,e[11]=(d*M-c*T-p*x)*B,e[12]=(o*S-a*C-l*_)*B,e[13]=(t*C-i*S+r*_)*B,e[14]=(y*v-m*w-g*x)*B,e[15]=(c*w-d*v+u*x)*B,this}scale(e){const t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),n=1-i,a=e.x,o=e.y,l=e.z,h=n*a,c=n*o;return this.set(h*a+i,h*o-r*l,h*l+r*o,0,h*o+r*l,c*o+i,c*l-r*a,0,h*l-r*o,c*l+r*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,n,a){return this.set(1,i,n,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,n=t._x,a=t._y,o=t._z,l=t._w,h=n+n,c=a+a,d=o+o,u=n*h,p=n*c,m=n*d,y=a*c,g=a*d,f=o*d,x=l*h,v=l*c,M=l*d,w=i.x,T=i.y,A=i.z;return r[0]=(1-(y+f))*w,r[1]=(p+M)*w,r[2]=(m-v)*w,r[3]=0,r[4]=(p-M)*T,r[5]=(1-(u+f))*T,r[6]=(g+x)*T,r[7]=0,r[8]=(m+v)*A,r[9]=(g-x)*A,r[10]=(1-(u+y))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const n=this.determinant();if(n===0)return i.set(1,1,1),t.identity(),this;let a=wa.set(r[0],r[1],r[2]).length();const o=wa.set(r[4],r[5],r[6]).length(),l=wa.set(r[8],r[9],r[10]).length();n<0&&(a=-a),As.copy(this);const h=1/a,c=1/o,d=1/l;return As.elements[0]*=h,As.elements[1]*=h,As.elements[2]*=h,As.elements[4]*=c,As.elements[5]*=c,As.elements[6]*=c,As.elements[8]*=d,As.elements[9]*=d,As.elements[10]*=d,t.setFromRotationMatrix(As),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,r,n,a,o=Yi,l=!1){const h=this.elements,c=2*n/(t-e),d=2*n/(i-r),u=(t+e)/(t-e),p=(i+r)/(i-r);let m,y;if(l)m=n/(a-n),y=a*n/(a-n);else if(o===Yi)m=-(a+n)/(a-n),y=-2*a*n/(a-n);else if(o===Sn)m=-a/(a-n),y=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return h[0]=c,h[4]=0,h[8]=u,h[12]=0,h[1]=0,h[5]=d,h[9]=p,h[13]=0,h[2]=0,h[6]=0,h[10]=m,h[14]=y,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,r,n,a,o=Yi,l=!1){const h=this.elements,c=2/(t-e),d=2/(i-r),u=-(t+e)/(t-e),p=-(i+r)/(i-r);let m,y;if(l)m=1/(a-n),y=a/(a-n);else if(o===Yi)m=-2/(a-n),y=-(a+n)/(a-n);else if(o===Sn)m=-1/(a-n),y=-n/(a-n);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return h[0]=c,h[4]=0,h[8]=0,h[12]=u,h[1]=0,h[5]=d,h[9]=0,h[13]=p,h[2]=0,h[6]=0,h[10]=m,h[14]=y,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};const wa=new R,As=new et,hb=new R(0,0,0),cb=new R(1,1,1),Wr=new R,yc=new R,Ji=new R,K0=new et,$0=new Mi;let ns=class tM{constructor(e=0,t=0,i=0,r=tM.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,n=r[0],a=r[4],o=r[8],l=r[1],h=r[5],c=r[9],d=r[2],u=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Ke(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-d,n),this._z=0);break;case"ZXY":this._x=Math.asin(Ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-Ke(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(Ke(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-d,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ke(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-c,p),this._y=0);break;default:ge("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return K0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(K0,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return $0.setFromEuler(this),this.setFromQuaternion($0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ns.DEFAULT_ORDER="XYZ";let Ml=class{constructor(){this.mask=1}set(s){this.mask=(1<<s|0)>>>0}enable(s){this.mask|=1<<s|0}enableAll(){this.mask=-1}toggle(s){this.mask^=1<<s|0}disable(s){this.mask&=~(1<<s|0)}disableAll(){this.mask=0}test(s){return(this.mask&s.mask)!==0}isEnabled(s){return(this.mask&(1<<s|0))!==0}},ub=0;const Q0=new R,Ea=new Mi,mr=new et,xc=new R,bl=new R,db=new R,pb=new Mi,ey=new R(1,0,0),ty=new R(0,1,0),iy=new R(0,0,1),sy={type:"added"},mb={type:"removed"},Aa={type:"childadded",child:null},xp={type:"childremoved",child:null};let _t=class Rd extends Es{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ub++}),this.uuid=Zi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Rd.DEFAULT_UP.clone();const e=new R,t=new ns,i=new Mi,r=new R(1,1,1);function n(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(n),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new et},normalMatrix:{value:new at}}),this.matrix=new et,this.matrixWorld=new et,this.matrixAutoUpdate=Rd.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Rd.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ml,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ea.setFromAxisAngle(e,t),this.quaternion.multiply(Ea),this}rotateOnWorldAxis(e,t){return Ea.setFromAxisAngle(e,t),this.quaternion.premultiply(Ea),this}rotateX(e){return this.rotateOnAxis(ey,e)}rotateY(e){return this.rotateOnAxis(ty,e)}rotateZ(e){return this.rotateOnAxis(iy,e)}translateOnAxis(e,t){return Q0.copy(e).applyQuaternion(this.quaternion),this.position.add(Q0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ey,e)}translateY(e){return this.translateOnAxis(ty,e)}translateZ(e){return this.translateOnAxis(iy,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(mr.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?xc.copy(e):xc.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),bl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?mr.lookAt(bl,xc,this.up):mr.lookAt(xc,bl,this.up),this.quaternion.setFromRotationMatrix(mr),r&&(mr.extractRotation(r.matrixWorld),Ea.setFromRotationMatrix(mr),this.quaternion.premultiply(Ea.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ve("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(sy),Aa.child=e,this.dispatchEvent(Aa),Aa.child=null):Ve("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(mb),xp.child=e,this.dispatchEvent(xp),xp.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),mr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),mr.multiply(e.parent.matrixWorld)),e.applyMatrix4(mr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(sy),Aa.child=e,this.dispatchEvent(Aa),Aa.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const n=this.children[i].getObjectByProperty(e,t);if(n!==void 0)return n}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bl,e,db),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bl,pb,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,r=e.z,n=this.matrix.elements;n[12]+=t-n[0]*t-n[4]*i-n[8]*r,n[13]+=i-n[1]*t-n[5]*i-n[9]*r,n[14]+=r-n[2]*t-n[6]*i-n[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.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)),t===!0){const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=n(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let h=0,c=l.length;h<c;h++){const d=l[h];n(e.shapes,d)}else n(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(e.materials,this.material[l]));r.material=o}else r.material=n(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(n(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),h=a(e.textures),c=a(e.images),d=a(e.shapes),u=a(e.skeletons),p=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),h.length>0&&(i.textures=h),c.length>0&&(i.images=c),d.length>0&&(i.shapes=d),u.length>0&&(i.skeletons=u),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const h in o){const c=o[h];delete c.metadata,l.push(c)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}};_t.DEFAULT_UP=new R(0,1,0),_t.DEFAULT_MATRIX_AUTO_UPDATE=!0,_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class wn extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const fb={type:"move"};class vc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new wn,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 wn,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 wn,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(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,n=null,a=null;const o=this._targetRay,l=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const y of e.hand.values()){const g=t.getJointPose(y,i),f=this._getHandJoint(h,y);g!==null&&(f.matrix.fromArray(g.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=g.radius),f.visible=g!==null}const c=h.joints["index-finger-tip"],d=h.joints["thumb-tip"],u=c.position.distanceTo(d.position),p=.02,m=.005;h.inputState.pinching&&u>p+m?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&u<=p-m&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(n=t.getPose(e.gripSpace,i),n!==null&&(l.matrix.fromArray(n.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,n.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(n.linearVelocity)):l.hasLinearVelocity=!1,n.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(n.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&n!==null&&(r=n),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(fb)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=n!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new wn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const ry={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},jr={h:0,s:0,l:0},_c={h:0,s:0,l:0};function vp(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}let we=class{constructor(s,e,t){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(s,e,t)}set(s,e,t){if(e===void 0&&t===void 0){const i=s;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(s,e,t);return this}setScalar(s){return this.r=s,this.g=s,this.b=s,this}setHex(s,e=Ii){return s=Math.floor(s),this.r=(s>>16&255)/255,this.g=(s>>8&255)/255,this.b=(s&255)/255,mt.colorSpaceToWorking(this,e),this}setRGB(s,e,t,i=mt.workingColorSpace){return this.r=s,this.g=e,this.b=t,mt.colorSpaceToWorking(this,i),this}setHSL(s,e,t,i=mt.workingColorSpace){if(s=up(s,1),e=Ke(e,0,1),t=Ke(t,0,1),e===0)this.r=this.g=this.b=t;else{const r=t<=.5?t*(1+e):t+e-t*e,n=2*t-r;this.r=vp(n,r,s+1/3),this.g=vp(n,r,s),this.b=vp(n,r,s-1/3)}return mt.colorSpaceToWorking(this,i),this}setStyle(s,e=Ii){function t(r){r!==void 0&&parseFloat(r)<1&&ge("Color: Alpha component of "+s+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(s)){let r;const n=i[1],a=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return t(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return t(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return t(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:ge("Color: Unknown color model "+s)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(s)){const r=i[1],n=r.length;if(n===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(n===6)return this.setHex(parseInt(r,16),e);ge("Color: Invalid hex color "+s)}else if(s&&s.length>0)return this.setColorName(s,e);return this}setColorName(s,e=Ii){const t=ry[s.toLowerCase()];return t!==void 0?this.setHex(t,e):ge("Color: Unknown color "+s),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(s){return this.r=s.r,this.g=s.g,this.b=s.b,this}copySRGBToLinear(s){return this.r=dr(s.r),this.g=dr(s.g),this.b=dr(s.b),this}copyLinearToSRGB(s){return this.r=Sa(s.r),this.g=Sa(s.g),this.b=Sa(s.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(s=Ii){return mt.workingToColorSpace(bi.copy(this),s),Math.round(Ke(bi.r*255,0,255))*65536+Math.round(Ke(bi.g*255,0,255))*256+Math.round(Ke(bi.b*255,0,255))}getHexString(s=Ii){return("000000"+this.getHex(s).toString(16)).slice(-6)}getHSL(s,e=mt.workingColorSpace){mt.workingToColorSpace(bi.copy(this),e);const t=bi.r,i=bi.g,r=bi.b,n=Math.max(t,i,r),a=Math.min(t,i,r);let o,l;const h=(a+n)/2;if(a===n)o=0,l=0;else{const c=n-a;switch(l=h<=.5?c/(n+a):c/(2-n-a),n){case t:o=(i-r)/c+(i<r?6:0);break;case i:o=(r-t)/c+2;break;case r:o=(t-i)/c+4;break}o/=6}return s.h=o,s.s=l,s.l=h,s}getRGB(s,e=mt.workingColorSpace){return mt.workingToColorSpace(bi.copy(this),e),s.r=bi.r,s.g=bi.g,s.b=bi.b,s}getStyle(s=Ii){mt.workingToColorSpace(bi.copy(this),s);const e=bi.r,t=bi.g,i=bi.b;return s!==Ii?`color(${s} ${e.toFixed(3)} ${t.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(t*255)},${Math.round(i*255)})`}offsetHSL(s,e,t){return this.getHSL(jr),this.setHSL(jr.h+s,jr.s+e,jr.l+t)}add(s){return this.r+=s.r,this.g+=s.g,this.b+=s.b,this}addColors(s,e){return this.r=s.r+e.r,this.g=s.g+e.g,this.b=s.b+e.b,this}addScalar(s){return this.r+=s,this.g+=s,this.b+=s,this}sub(s){return this.r=Math.max(0,this.r-s.r),this.g=Math.max(0,this.g-s.g),this.b=Math.max(0,this.b-s.b),this}multiply(s){return this.r*=s.r,this.g*=s.g,this.b*=s.b,this}multiplyScalar(s){return this.r*=s,this.g*=s,this.b*=s,this}lerp(s,e){return this.r+=(s.r-this.r)*e,this.g+=(s.g-this.g)*e,this.b+=(s.b-this.b)*e,this}lerpColors(s,e,t){return this.r=s.r+(e.r-s.r)*t,this.g=s.g+(e.g-s.g)*t,this.b=s.b+(e.b-s.b)*t,this}lerpHSL(s,e){this.getHSL(jr),s.getHSL(_c);const t=vl(jr.h,_c.h,e),i=vl(jr.s,_c.s,e),r=vl(jr.l,_c.l,e);return this.setHSL(t,i,r),this}setFromVector3(s){return this.r=s.x,this.g=s.y,this.b=s.z,this}applyMatrix3(s){const e=this.r,t=this.g,i=this.b,r=s.elements;return this.r=r[0]*e+r[3]*t+r[6]*i,this.g=r[1]*e+r[4]*t+r[7]*i,this.b=r[2]*e+r[5]*t+r[8]*i,this}equals(s){return s.r===this.r&&s.g===this.g&&s.b===this.b}fromArray(s,e=0){return this.r=s[e],this.g=s[e+1],this.b=s[e+2],this}toArray(s=[],e=0){return s[e]=this.r,s[e+1]=this.g,s[e+2]=this.b,s}fromBufferAttribute(s,e){return this.r=s.getX(e),this.g=s.getY(e),this.b=s.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const bi=new we;we.NAMES=ry;class Id{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new we(e),this.density=t}clone(){return new Id(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let _p=class iM{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new we(e),this.near=t,this.far=i}clone(){return new iM(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Mp extends _t{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 ns,this.environmentIntensity=1,this.environmentRotation=new ns,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Ns=new R,fr=new R,bp=new R,gr=new R,Na=new R,Ca=new R,ny=new R,Sp=new R,Tp=new R,wp=new R,Ep=new It,Ap=new It,Np=new It;let yr=class Co{constructor(e=new R,t=new R,i=new R){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Ns.subVectors(e,t),r.cross(Ns);const n=r.lengthSq();return n>0?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)}static getBarycoord(e,t,i,r,n){Ns.subVectors(r,t),fr.subVectors(i,t),bp.subVectors(e,t);const a=Ns.dot(Ns),o=Ns.dot(fr),l=Ns.dot(bp),h=fr.dot(fr),c=fr.dot(bp),d=a*h-o*o;if(d===0)return n.set(0,0,0),null;const u=1/d,p=(h*l-o*c)*u,m=(a*c-o*l)*u;return n.set(1-p-m,m,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,gr)===null?!1:gr.x>=0&&gr.y>=0&&gr.x+gr.y<=1}static getInterpolation(e,t,i,r,n,a,o,l){return this.getBarycoord(e,t,i,r,gr)===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(n,gr.x),l.addScaledVector(a,gr.y),l.addScaledVector(o,gr.z),l)}static getInterpolatedAttribute(e,t,i,r,n,a){return Ep.setScalar(0),Ap.setScalar(0),Np.setScalar(0),Ep.fromBufferAttribute(e,t),Ap.fromBufferAttribute(e,i),Np.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Ep,n.x),a.addScaledVector(Ap,n.y),a.addScaledVector(Np,n.z),a}static isFrontFacing(e,t,i,r){return Ns.subVectors(i,t),fr.subVectors(e,t),Ns.cross(fr).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ns.subVectors(this.c,this.b),fr.subVectors(this.a,this.b),Ns.cross(fr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Co.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Co.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,n){return Co.getInterpolation(e,this.a,this.b,this.c,t,i,r,n)}containsPoint(e){return Co.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Co.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,n=this.c;let a,o;Na.subVectors(r,i),Ca.subVectors(n,i),Sp.subVectors(e,i);const l=Na.dot(Sp),h=Ca.dot(Sp);if(l<=0&&h<=0)return t.copy(i);Tp.subVectors(e,r);const c=Na.dot(Tp),d=Ca.dot(Tp);if(c>=0&&d<=c)return t.copy(r);const u=l*d-c*h;if(u<=0&&l>=0&&c<=0)return a=l/(l-c),t.copy(i).addScaledVector(Na,a);wp.subVectors(e,n);const p=Na.dot(wp),m=Ca.dot(wp);if(m>=0&&p<=m)return t.copy(n);const y=p*h-l*m;if(y<=0&&h>=0&&m<=0)return o=h/(h-m),t.copy(i).addScaledVector(Ca,o);const g=c*m-p*d;if(g<=0&&d-c>=0&&p-m>=0)return ny.subVectors(n,r),o=(d-c)/(d-c+(p-m)),t.copy(r).addScaledVector(ny,o);const f=1/(g+y+u);return a=y*f,o=u*f,t.copy(i).addScaledVector(Na,a).addScaledVector(Ca,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},di=class{constructor(s=new R(1/0,1/0,1/0),e=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=s,this.max=e}set(s,e){return this.min.copy(s),this.max.copy(e),this}setFromArray(s){this.makeEmpty();for(let e=0,t=s.length;e<t;e+=3)this.expandByPoint(Cs.fromArray(s,e));return this}setFromBufferAttribute(s){this.makeEmpty();for(let e=0,t=s.count;e<t;e++)this.expandByPoint(Cs.fromBufferAttribute(s,e));return this}setFromPoints(s){this.makeEmpty();for(let e=0,t=s.length;e<t;e++)this.expandByPoint(s[e]);return this}setFromCenterAndSize(s,e){const t=Cs.copy(e).multiplyScalar(.5);return this.min.copy(s).sub(t),this.max.copy(s).add(t),this}setFromObject(s,e=!1){return this.makeEmpty(),this.expandByObject(s,e)}clone(){return new this.constructor().copy(this)}copy(s){return this.min.copy(s.min),this.max.copy(s.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(s){return this.isEmpty()?s.set(0,0,0):s.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(s){return this.isEmpty()?s.set(0,0,0):s.subVectors(this.max,this.min)}expandByPoint(s){return this.min.min(s),this.max.max(s),this}expandByVector(s){return this.min.sub(s),this.max.add(s),this}expandByScalar(s){return this.min.addScalar(-s),this.max.addScalar(s),this}expandByObject(s,e=!1){s.updateWorldMatrix(!1,!1);const t=s.geometry;if(t!==void 0){const r=t.getAttribute("position");if(e===!0&&r!==void 0&&s.isInstancedMesh!==!0)for(let n=0,a=r.count;n<a;n++)s.isMesh===!0?s.getVertexPosition(n,Cs):Cs.fromBufferAttribute(r,n),Cs.applyMatrix4(s.matrixWorld),this.expandByPoint(Cs);else s.boundingBox!==void 0?(s.boundingBox===null&&s.computeBoundingBox(),Mc.copy(s.boundingBox)):(t.boundingBox===null&&t.computeBoundingBox(),Mc.copy(t.boundingBox)),Mc.applyMatrix4(s.matrixWorld),this.union(Mc)}const i=s.children;for(let r=0,n=i.length;r<n;r++)this.expandByObject(i[r],e);return this}containsPoint(s){return s.x>=this.min.x&&s.x<=this.max.x&&s.y>=this.min.y&&s.y<=this.max.y&&s.z>=this.min.z&&s.z<=this.max.z}containsBox(s){return this.min.x<=s.min.x&&s.max.x<=this.max.x&&this.min.y<=s.min.y&&s.max.y<=this.max.y&&this.min.z<=s.min.z&&s.max.z<=this.max.z}getParameter(s,e){return e.set((s.x-this.min.x)/(this.max.x-this.min.x),(s.y-this.min.y)/(this.max.y-this.min.y),(s.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(s){return s.max.x>=this.min.x&&s.min.x<=this.max.x&&s.max.y>=this.min.y&&s.min.y<=this.max.y&&s.max.z>=this.min.z&&s.min.z<=this.max.z}intersectsSphere(s){return this.clampPoint(s.center,Cs),Cs.distanceToSquared(s.center)<=s.radius*s.radius}intersectsPlane(s){let e,t;return s.normal.x>0?(e=s.normal.x*this.min.x,t=s.normal.x*this.max.x):(e=s.normal.x*this.max.x,t=s.normal.x*this.min.x),s.normal.y>0?(e+=s.normal.y*this.min.y,t+=s.normal.y*this.max.y):(e+=s.normal.y*this.max.y,t+=s.normal.y*this.min.y),s.normal.z>0?(e+=s.normal.z*this.min.z,t+=s.normal.z*this.max.z):(e+=s.normal.z*this.max.z,t+=s.normal.z*this.min.z),e<=-s.constant&&t>=-s.constant}intersectsTriangle(s){if(this.isEmpty())return!1;this.getCenter(Sl),bc.subVectors(this.max,Sl),Ra.subVectors(s.a,Sl),Ia.subVectors(s.b,Sl),Pa.subVectors(s.c,Sl),Xr.subVectors(Ia,Ra),qr.subVectors(Pa,Ia),En.subVectors(Ra,Pa);let e=[0,-Xr.z,Xr.y,0,-qr.z,qr.y,0,-En.z,En.y,Xr.z,0,-Xr.x,qr.z,0,-qr.x,En.z,0,-En.x,-Xr.y,Xr.x,0,-qr.y,qr.x,0,-En.y,En.x,0];return!Cp(e,Ra,Ia,Pa,bc)||(e=[1,0,0,0,1,0,0,0,1],!Cp(e,Ra,Ia,Pa,bc))?!1:(Sc.crossVectors(Xr,qr),e=[Sc.x,Sc.y,Sc.z],Cp(e,Ra,Ia,Pa,bc))}clampPoint(s,e){return e.copy(s).clamp(this.min,this.max)}distanceToPoint(s){return this.clampPoint(s,Cs).distanceTo(s)}getBoundingSphere(s){return this.isEmpty()?s.makeEmpty():(this.getCenter(s.center),s.radius=this.getSize(Cs).length()*.5),s}intersect(s){return this.min.max(s.min),this.max.min(s.max),this.isEmpty()&&this.makeEmpty(),this}union(s){return this.min.min(s.min),this.max.max(s.max),this}applyMatrix4(s){return this.isEmpty()?this:(xr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(s),xr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(s),xr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(s),xr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(s),xr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(s),xr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(s),xr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(s),xr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(s),this.setFromPoints(xr),this)}translate(s){return this.min.add(s),this.max.add(s),this}equals(s){return s.min.equals(this.min)&&s.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(s){return this.min.fromArray(s.min),this.max.fromArray(s.max),this}};const xr=[new R,new R,new R,new R,new R,new R,new R,new R],Cs=new R,Mc=new di,Ra=new R,Ia=new R,Pa=new R,Xr=new R,qr=new R,En=new R,Sl=new R,bc=new R,Sc=new R,An=new R;function Cp(s,e,t,i,r){for(let n=0,a=s.length-3;n<=a;n+=3){An.fromArray(s,n);const o=r.x*Math.abs(An.x)+r.y*Math.abs(An.y)+r.z*Math.abs(An.z),l=e.dot(An),h=t.dot(An),c=i.dot(An);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}const vr=gb();function gb(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const h=l-127;h<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):h<-14?(i[l]=1024>>-h-14,i[l|256]=1024>>-h-14|32768,r[l]=-h-1,r[l|256]=-h-1):h<=15?(i[l]=h+15<<10,i[l|256]=h+15<<10|32768,r[l]=13,r[l|256]=13):h<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,n[l]=h|c}for(let l=1024;l<2048;++l)n[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:n,exponentTable:a,offsetTable:o}}function Vi(s){Math.abs(s)>65504&&ge("DataUtils.toHalfFloat(): Value out of range."),s=Ke(s,-65504,65504),vr.floatView[0]=s;const e=vr.uint32View[0],t=e>>23&511;return vr.baseTable[t]+((e&8388607)>>vr.shiftTable[t])}function Tl(s){const e=s>>10;return vr.uint32View[0]=vr.mantissaTable[vr.offsetTable[e]+(s&1023)]+vr.exponentTable[e],vr.floatView[0]}class ay{static toHalfFloat(e){return Vi(e)}static fromHalfFloat(e){return Tl(e)}}const Zt=new R,Tc=new te;let yb=0,bt=class{constructor(s,e,t=!1){if(Array.isArray(s))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:yb++}),this.name="",this.array=s,this.itemSize=e,this.count=s!==void 0?s.length/e:0,this.normalized=t,this.usage=fl,this.updateRanges=[],this.gpuType=xi,this.version=0}onUploadCallback(){}set needsUpdate(s){s===!0&&this.version++}setUsage(s){return this.usage=s,this}addUpdateRange(s,e){this.updateRanges.push({start:s,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(s){return this.name=s.name,this.array=new s.array.constructor(s.array),this.itemSize=s.itemSize,this.count=s.count,this.normalized=s.normalized,this.usage=s.usage,this.gpuType=s.gpuType,this}copyAt(s,e,t){s*=this.itemSize,t*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[s+i]=e.array[t+i];return this}copyArray(s){return this.array.set(s),this}applyMatrix3(s){if(this.itemSize===2)for(let e=0,t=this.count;e<t;e++)Tc.fromBufferAttribute(this,e),Tc.applyMatrix3(s),this.setXY(e,Tc.x,Tc.y);else if(this.itemSize===3)for(let e=0,t=this.count;e<t;e++)Zt.fromBufferAttribute(this,e),Zt.applyMatrix3(s),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}applyMatrix4(s){for(let e=0,t=this.count;e<t;e++)Zt.fromBufferAttribute(this,e),Zt.applyMatrix4(s),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}applyNormalMatrix(s){for(let e=0,t=this.count;e<t;e++)Zt.fromBufferAttribute(this,e),Zt.applyNormalMatrix(s),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}transformDirection(s){for(let e=0,t=this.count;e<t;e++)Zt.fromBufferAttribute(this,e),Zt.transformDirection(s),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}set(s,e=0){return this.array.set(s,e),this}getComponent(s,e){let t=this.array[s*this.itemSize+e];return this.normalized&&(t=Pi(t,this.array)),t}setComponent(s,e,t){return this.normalized&&(t=nt(t,this.array)),this.array[s*this.itemSize+e]=t,this}getX(s){let e=this.array[s*this.itemSize];return this.normalized&&(e=Pi(e,this.array)),e}setX(s,e){return this.normalized&&(e=nt(e,this.array)),this.array[s*this.itemSize]=e,this}getY(s){let e=this.array[s*this.itemSize+1];return this.normalized&&(e=Pi(e,this.array)),e}setY(s,e){return this.normalized&&(e=nt(e,this.array)),this.array[s*this.itemSize+1]=e,this}getZ(s){let e=this.array[s*this.itemSize+2];return this.normalized&&(e=Pi(e,this.array)),e}setZ(s,e){return this.normalized&&(e=nt(e,this.array)),this.array[s*this.itemSize+2]=e,this}getW(s){let e=this.array[s*this.itemSize+3];return this.normalized&&(e=Pi(e,this.array)),e}setW(s,e){return this.normalized&&(e=nt(e,this.array)),this.array[s*this.itemSize+3]=e,this}setXY(s,e,t){return s*=this.itemSize,this.normalized&&(e=nt(e,this.array),t=nt(t,this.array)),this.array[s+0]=e,this.array[s+1]=t,this}setXYZ(s,e,t,i){return s*=this.itemSize,this.normalized&&(e=nt(e,this.array),t=nt(t,this.array),i=nt(i,this.array)),this.array[s+0]=e,this.array[s+1]=t,this.array[s+2]=i,this}setXYZW(s,e,t,i,r){return s*=this.itemSize,this.normalized&&(e=nt(e,this.array),t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array)),this.array[s+0]=e,this.array[s+1]=t,this.array[s+2]=i,this.array[s+3]=r,this}onUpload(s){return this.onUploadCallback=s,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const s={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(s.name=this.name),this.usage!==fl&&(s.usage=this.usage),s}};class xb extends bt{constructor(e,t,i){super(new Int8Array(e),t,i)}}class vb extends bt{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class _b extends bt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class Mb extends bt{constructor(e,t,i){super(new Int16Array(e),t,i)}}let wc=class extends bt{constructor(s,e,t){super(new Uint16Array(s),e,t)}};class bb extends bt{constructor(e,t,i){super(new Int32Array(e),t,i)}}let Rp=class extends bt{constructor(s,e,t){super(new Uint32Array(s),e,t)}};class Sb extends bt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=Tl(this.array[e*this.itemSize]);return this.normalized&&(t=Pi(t,this.array)),t}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize]=Vi(t),this}getY(e){let t=Tl(this.array[e*this.itemSize+1]);return this.normalized&&(t=Pi(t,this.array)),t}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+1]=Vi(t),this}getZ(e){let t=Tl(this.array[e*this.itemSize+2]);return this.normalized&&(t=Pi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+2]=Vi(t),this}getW(e){let t=Tl(this.array[e*this.itemSize+3]);return this.normalized&&(t=Pi(t,this.array)),t}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+3]=Vi(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array)),this.array[e+0]=Vi(t),this.array[e+1]=Vi(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array)),this.array[e+0]=Vi(t),this.array[e+1]=Vi(i),this.array[e+2]=Vi(r),this}setXYZW(e,t,i,r,n){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array),n=nt(n,this.array)),this.array[e+0]=Vi(t),this.array[e+1]=Vi(i),this.array[e+2]=Vi(r),this.array[e+3]=Vi(n),this}}let Ne=class extends bt{constructor(s,e,t){super(new Float32Array(s),e,t)}};const Tb=new di,wl=new R,Ip=new R;let ai=class{constructor(s=new R,e=-1){this.isSphere=!0,this.center=s,this.radius=e}set(s,e){return this.center.copy(s),this.radius=e,this}setFromPoints(s,e){const t=this.center;e!==void 0?t.copy(e):Tb.setFromPoints(s).getCenter(t);let i=0;for(let r=0,n=s.length;r<n;r++)i=Math.max(i,t.distanceToSquared(s[r]));return this.radius=Math.sqrt(i),this}copy(s){return this.center.copy(s.center),this.radius=s.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(s){return s.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(s){return s.distanceTo(this.center)-this.radius}intersectsSphere(s){const e=this.radius+s.radius;return s.center.distanceToSquared(this.center)<=e*e}intersectsBox(s){return s.intersectsSphere(this)}intersectsPlane(s){return Math.abs(s.distanceToPoint(this.center))<=this.radius}clampPoint(s,e){const t=this.center.distanceToSquared(s);return e.copy(s),t>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(s){return this.isEmpty()?(s.makeEmpty(),s):(s.set(this.center,this.center),s.expandByScalar(this.radius),s)}applyMatrix4(s){return this.center.applyMatrix4(s),this.radius=this.radius*s.getMaxScaleOnAxis(),this}translate(s){return this.center.add(s),this}expandByPoint(s){if(this.isEmpty())return this.center.copy(s),this.radius=0,this;wl.subVectors(s,this.center);const e=wl.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=(t-this.radius)*.5;this.center.addScaledVector(wl,i/t),this.radius+=i}return this}union(s){return s.isEmpty()?this:this.isEmpty()?(this.copy(s),this):(this.center.equals(s.center)===!0?this.radius=Math.max(this.radius,s.radius):(Ip.subVectors(s.center,this.center).setLength(s.radius),this.expandByPoint(wl.copy(s.center).add(Ip)),this.expandByPoint(wl.copy(s.center).sub(Ip))),this)}equals(s){return s.center.equals(this.center)&&s.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(s){return this.radius=s.radius,this.center.fromArray(s.center),this}},wb=0;const as=new et,Pp=new _t,La=new R,Ki=new di,El=new di,oi=new R;let rt=class sM extends Es{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:wb++}),this.uuid=Zi(),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(e){return Array.isArray(e)?this.index=new(UM(e)?Rp:wc)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new at().getNormalMatrix(e);i.applyNormalMatrix(n),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return as.makeRotationFromQuaternion(e),this.applyMatrix4(as),this}rotateX(e){return as.makeRotationX(e),this.applyMatrix4(as),this}rotateY(e){return as.makeRotationY(e),this.applyMatrix4(as),this}rotateZ(e){return as.makeRotationZ(e),this.applyMatrix4(as),this}translate(e,t,i){return as.makeTranslation(e,t,i),this.applyMatrix4(as),this}scale(e,t,i){return as.makeScale(e,t,i),this.applyMatrix4(as),this}lookAt(e){return Pp.lookAt(e),Pp.updateMatrix(),this.applyMatrix4(Pp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(La).negate(),this.translate(La.x,La.y,La.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,n=e.length;r<n;r++){const a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ne(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&ge("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new di);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("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(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const n=t[i];Ki.setFromBufferAttribute(n),this.morphTargetsRelative?(oi.addVectors(this.boundingBox.min,Ki.min),this.boundingBox.expandByPoint(oi),oi.addVectors(this.boundingBox.max,Ki.max),this.boundingBox.expandByPoint(oi)):(this.boundingBox.expandByPoint(Ki.min),this.boundingBox.expandByPoint(Ki.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ve('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 ai);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){const i=this.boundingSphere.center;if(Ki.setFromBufferAttribute(e),t)for(let n=0,a=t.length;n<a;n++){const o=t[n];El.setFromBufferAttribute(o),this.morphTargetsRelative?(oi.addVectors(Ki.min,El.min),Ki.expandByPoint(oi),oi.addVectors(Ki.max,El.max),Ki.expandByPoint(oi)):(Ki.expandByPoint(El.min),Ki.expandByPoint(El.max))}Ki.getCenter(i);let r=0;for(let n=0,a=e.count;n<a;n++)oi.fromBufferAttribute(e,n),r=Math.max(r,i.distanceToSquared(oi));if(t)for(let n=0,a=t.length;n<a;n++){const o=t[n],l=this.morphTargetsRelative;for(let h=0,c=o.count;h<c;h++)oi.fromBufferAttribute(o,h),l&&(La.fromBufferAttribute(e,h),oi.add(La)),r=Math.max(r,i.distanceToSquared(oi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Ve('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ve("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,n=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new bt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let _=0;_<i.count;_++)o[_]=new R,l[_]=new R;const h=new R,c=new R,d=new R,u=new te,p=new te,m=new te,y=new R,g=new R;function f(_,S,P){h.fromBufferAttribute(i,_),c.fromBufferAttribute(i,S),d.fromBufferAttribute(i,P),u.fromBufferAttribute(n,_),p.fromBufferAttribute(n,S),m.fromBufferAttribute(n,P),c.sub(h),d.sub(h),p.sub(u),m.sub(u);const C=1/(p.x*m.y-m.x*p.y);isFinite(C)&&(y.copy(c).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(C),g.copy(d).multiplyScalar(p.x).addScaledVector(c,-m.x).multiplyScalar(C),o[_].add(y),o[S].add(y),o[P].add(y),l[_].add(g),l[S].add(g),l[P].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let _=0,S=x.length;_<S;++_){const P=x[_],C=P.start,L=P.count;for(let U=C,V=C+L;U<V;U+=3)f(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const v=new R,M=new R,w=new R,T=new R;function A(_){w.fromBufferAttribute(r,_),T.copy(w);const S=o[_];v.copy(S),v.sub(w.multiplyScalar(w.dot(S))).normalize(),M.crossVectors(T,S);const P=M.dot(l[_])<0?-1:1;a.setXYZW(_,v.x,v.y,v.z,P)}for(let _=0,S=x.length;_<S;++_){const P=x[_],C=P.start,L=P.count;for(let U=C,V=C+L;U<V;U+=3)A(e.getX(U+0)),A(e.getX(U+1)),A(e.getX(U+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new bt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,p=i.count;u<p;u++)i.setXYZ(u,0,0,0);const r=new R,n=new R,a=new R,o=new R,l=new R,h=new R,c=new R,d=new R;if(e)for(let u=0,p=e.count;u<p;u+=3){const m=e.getX(u+0),y=e.getX(u+1),g=e.getX(u+2);r.fromBufferAttribute(t,m),n.fromBufferAttribute(t,y),a.fromBufferAttribute(t,g),c.subVectors(a,n),d.subVectors(r,n),c.cross(d),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,y),h.fromBufferAttribute(i,g),o.add(c),l.add(c),h.add(c),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(g,h.x,h.y,h.z)}else for(let u=0,p=t.count;u<p;u+=3)r.fromBufferAttribute(t,u+0),n.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),c.subVectors(a,n),d.subVectors(r,n),c.cross(d),i.setXYZ(u+0,c.x,c.y,c.z),i.setXYZ(u+1,c.x,c.y,c.z),i.setXYZ(u+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)oi.fromBufferAttribute(e,t),oi.normalize(),e.setXYZ(t,oi.x,oi.y,oi.z)}toNonIndexed(){function e(o,l){const h=o.array,c=o.itemSize,d=o.normalized,u=new h.constructor(l.length*c);let p=0,m=0;for(let y=0,g=l.length;y<g;y++){o.isInterleavedBufferAttribute?p=l[y]*o.data.stride+o.offset:p=l[y]*c;for(let f=0;f<c;f++)u[m++]=h[p++]}return new bt(u,c,d)}if(this.index===null)return ge("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new sM,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],h=e(l,i);t.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const l=[],h=n[o];for(let c=0,d=h.length;c<d;c++){const u=h[c],p=e(u,i);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const h=a[o];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const h in l)l[h]!==void 0&&(e[h]=l[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const h=i[l];e.data.attributes[l]=h.toJSON(e.data)}const r={};let n=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],c=[];for(let d=0,u=h.length;d<u;d++){const p=h[d];c.push(p.toJSON(e.data))}c.length>0&&(r[l]=c,n=!0)}n&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const h in r){const c=r[h];this.setAttribute(h,c.clone(t))}const n=e.morphAttributes;for(const h in n){const c=[],d=n[h];for(let u=0,p=d.length;u<p;u++)c.push(d[u].clone(t));this.morphAttributes[h]=c}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let h=0,c=a.length;h<c;h++){const d=a[h];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Al=class{constructor(s,e){this.isInterleavedBuffer=!0,this.array=s,this.stride=e,this.count=s!==void 0?s.length/e:0,this.usage=fl,this.updateRanges=[],this.version=0,this.uuid=Zi()}onUploadCallback(){}set needsUpdate(s){s===!0&&this.version++}setUsage(s){return this.usage=s,this}addUpdateRange(s,e){this.updateRanges.push({start:s,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(s){return this.array=new s.array.constructor(s.array),this.count=s.count,this.stride=s.stride,this.usage=s.usage,this}copyAt(s,e,t){s*=this.stride,t*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[s+i]=e.array[t+i];return this}set(s,e=0){return this.array.set(s,e),this}clone(s){s.arrayBuffers===void 0&&(s.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zi()),s.arrayBuffers[this.array.buffer._uuid]===void 0&&(s.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(s.arrayBuffers[this.array.buffer._uuid]),t=new this.constructor(e,this.stride);return t.setUsage(this.usage),t}onUpload(s){return this.onUploadCallback=s,this}toJSON(s){return s.arrayBuffers===void 0&&(s.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zi()),s.arrayBuffers[this.array.buffer._uuid]===void 0&&(s.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 Li=new R;let Da=class rM{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.applyMatrix4(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.applyNormalMatrix(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.transformDirection(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Pi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=nt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Pi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Pi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Pi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Pi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array),n=nt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}clone(e){if(e===void 0){yl("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return new bt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new rM(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){yl("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Eb=0,pi=class extends Es{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Eb++}),this.uuid=Zi(),this.name="",this.type="Material",this.blending=Or,this.side=Vs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Oh,this.blendDst=Uh,this.blendEquation=Ur,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new we(0,0,0),this.blendAlpha=0,this.depthFunc=Fr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=dc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Gr,this.stencilZFail=Gr,this.stencilZPass=Gr,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(s){this._alphaTest>0!=s>0&&this.version++,this._alphaTest=s}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(s){if(s!==void 0)for(const e in s){const t=s[e];if(t===void 0){ge(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){ge(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(t):i&&i.isVector3&&t&&t.isVector3?i.copy(t):this[e]=t}}toJSON(s){const e=s===void 0||typeof s=="string";e&&(s={textures:{},images:{}});const t={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.color&&this.color.isColor&&(t.color=this.color.getHex()),this.roughness!==void 0&&(t.roughness=this.roughness),this.metalness!==void 0&&(t.metalness=this.metalness),this.sheen!==void 0&&(t.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(t.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(t.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(t.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(t.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(t.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(t.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(t.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(t.shininess=this.shininess),this.clearcoat!==void 0&&(t.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(t.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(t.clearcoatMap=this.clearcoatMap.toJSON(s).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(t.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(s).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(t.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(s).uuid,t.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(t.sheenColorMap=this.sheenColorMap.toJSON(s).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(t.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(s).uuid),this.dispersion!==void 0&&(t.dispersion=this.dispersion),this.iridescence!==void 0&&(t.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(t.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(t.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(t.iridescenceMap=this.iridescenceMap.toJSON(s).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(t.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(s).uuid),this.anisotropy!==void 0&&(t.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(t.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(t.anisotropyMap=this.anisotropyMap.toJSON(s).uuid),this.map&&this.map.isTexture&&(t.map=this.map.toJSON(s).uuid),this.matcap&&this.matcap.isTexture&&(t.matcap=this.matcap.toJSON(s).uuid),this.alphaMap&&this.alphaMap.isTexture&&(t.alphaMap=this.alphaMap.toJSON(s).uuid),this.lightMap&&this.lightMap.isTexture&&(t.lightMap=this.lightMap.toJSON(s).uuid,t.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(t.aoMap=this.aoMap.toJSON(s).uuid,t.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(t.bumpMap=this.bumpMap.toJSON(s).uuid,t.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(t.normalMap=this.normalMap.toJSON(s).uuid,t.normalMapType=this.normalMapType,t.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(t.displacementMap=this.displacementMap.toJSON(s).uuid,t.displacementScale=this.displacementScale,t.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(t.roughnessMap=this.roughnessMap.toJSON(s).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(t.metalnessMap=this.metalnessMap.toJSON(s).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(t.emissiveMap=this.emissiveMap.toJSON(s).uuid),this.specularMap&&this.specularMap.isTexture&&(t.specularMap=this.specularMap.toJSON(s).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(t.specularIntensityMap=this.specularIntensityMap.toJSON(s).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(t.specularColorMap=this.specularColorMap.toJSON(s).uuid),this.envMap&&this.envMap.isTexture&&(t.envMap=this.envMap.toJSON(s).uuid,this.combine!==void 0&&(t.combine=this.combine)),this.envMapRotation!==void 0&&(t.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(t.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(t.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(t.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(t.gradientMap=this.gradientMap.toJSON(s).uuid),this.transmission!==void 0&&(t.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(t.transmissionMap=this.transmissionMap.toJSON(s).uuid),this.thickness!==void 0&&(t.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(t.thicknessMap=this.thicknessMap.toJSON(s).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(t.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(t.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(t.size=this.size),this.shadowSide!==null&&(t.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(t.sizeAttenuation=this.sizeAttenuation),this.blending!==Or&&(t.blending=this.blending),this.side!==Vs&&(t.side=this.side),this.vertexColors===!0&&(t.vertexColors=!0),this.opacity<1&&(t.opacity=this.opacity),this.transparent===!0&&(t.transparent=!0),this.blendSrc!==Oh&&(t.blendSrc=this.blendSrc),this.blendDst!==Uh&&(t.blendDst=this.blendDst),this.blendEquation!==Ur&&(t.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(t.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(t.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(t.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(t.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(t.blendAlpha=this.blendAlpha),this.depthFunc!==Fr&&(t.depthFunc=this.depthFunc),this.depthTest===!1&&(t.depthTest=this.depthTest),this.depthWrite===!1&&(t.depthWrite=this.depthWrite),this.colorWrite===!1&&(t.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(t.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==dc&&(t.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(t.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(t.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Gr&&(t.stencilFail=this.stencilFail),this.stencilZFail!==Gr&&(t.stencilZFail=this.stencilZFail),this.stencilZPass!==Gr&&(t.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(t.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(t.rotation=this.rotation),this.polygonOffset===!0&&(t.polygonOffset=!0),this.polygonOffsetFactor!==0&&(t.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(t.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(t.linewidth=this.linewidth),this.dashSize!==void 0&&(t.dashSize=this.dashSize),this.gapSize!==void 0&&(t.gapSize=this.gapSize),this.scale!==void 0&&(t.scale=this.scale),this.dithering===!0&&(t.dithering=!0),this.alphaTest>0&&(t.alphaTest=this.alphaTest),this.alphaHash===!0&&(t.alphaHash=!0),this.alphaToCoverage===!0&&(t.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(t.premultipliedAlpha=!0),this.forceSinglePass===!0&&(t.forceSinglePass=!0),this.allowOverride===!1&&(t.allowOverride=!1),this.wireframe===!0&&(t.wireframe=!0),this.wireframeLinewidth>1&&(t.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(t.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(t.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(t.flatShading=!0),this.visible===!1&&(t.visible=!1),this.toneMapped===!1&&(t.toneMapped=!1),this.fog===!1&&(t.fog=!1),Object.keys(this.userData).length>0&&(t.userData=this.userData);function i(r){const n=[];for(const a in r){const o=r[a];delete o.metadata,n.push(o)}return n}if(e){const r=i(s.textures),n=i(s.images);r.length>0&&(t.textures=r),n.length>0&&(t.images=n)}return t}clone(){return new this.constructor().copy(this)}copy(s){this.name=s.name,this.blending=s.blending,this.side=s.side,this.vertexColors=s.vertexColors,this.opacity=s.opacity,this.transparent=s.transparent,this.blendSrc=s.blendSrc,this.blendDst=s.blendDst,this.blendEquation=s.blendEquation,this.blendSrcAlpha=s.blendSrcAlpha,this.blendDstAlpha=s.blendDstAlpha,this.blendEquationAlpha=s.blendEquationAlpha,this.blendColor.copy(s.blendColor),this.blendAlpha=s.blendAlpha,this.depthFunc=s.depthFunc,this.depthTest=s.depthTest,this.depthWrite=s.depthWrite,this.stencilWriteMask=s.stencilWriteMask,this.stencilFunc=s.stencilFunc,this.stencilRef=s.stencilRef,this.stencilFuncMask=s.stencilFuncMask,this.stencilFail=s.stencilFail,this.stencilZFail=s.stencilZFail,this.stencilZPass=s.stencilZPass,this.stencilWrite=s.stencilWrite;const e=s.clippingPlanes;let t=null;if(e!==null){const i=e.length;t=new Array(i);for(let r=0;r!==i;++r)t[r]=e[r].clone()}return this.clippingPlanes=t,this.clipIntersection=s.clipIntersection,this.clipShadows=s.clipShadows,this.shadowSide=s.shadowSide,this.colorWrite=s.colorWrite,this.precision=s.precision,this.polygonOffset=s.polygonOffset,this.polygonOffsetFactor=s.polygonOffsetFactor,this.polygonOffsetUnits=s.polygonOffsetUnits,this.dithering=s.dithering,this.alphaTest=s.alphaTest,this.alphaHash=s.alphaHash,this.alphaToCoverage=s.alphaToCoverage,this.premultipliedAlpha=s.premultipliedAlpha,this.forceSinglePass=s.forceSinglePass,this.allowOverride=s.allowOverride,this.visible=s.visible,this.toneMapped=s.toneMapped,this.userData=JSON.parse(JSON.stringify(s.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(s){s===!0&&this.version++}};class Ec extends pi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new we(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Oa;const Nl=new R,Ua=new R,Fa=new R,za=new te,Cl=new te,oy=new et,Ac=new R,Rl=new R,Nc=new R,ly=new te,Lp=new te,hy=new te;class Dp extends _t{constructor(e=new Ec){if(super(),this.isSprite=!0,this.type="Sprite",Oa===void 0){Oa=new rt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Al(t,5);Oa.setIndex([0,1,2,0,2,3]),Oa.setAttribute("position",new Da(i,3,0,!1)),Oa.setAttribute("uv",new Da(i,2,3,!1))}this.geometry=Oa,this.material=e,this.center=new te(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ve('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ua.setFromMatrixScale(this.matrixWorld),oy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Fa.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ua.multiplyScalar(-Fa.z);const i=this.material.rotation;let r,n;i!==0&&(n=Math.cos(i),r=Math.sin(i));const a=this.center;Cc(Ac.set(-.5,-.5,0),Fa,a,Ua,r,n),Cc(Rl.set(.5,-.5,0),Fa,a,Ua,r,n),Cc(Nc.set(.5,.5,0),Fa,a,Ua,r,n),ly.set(0,0),Lp.set(1,0),hy.set(1,1);let o=e.ray.intersectTriangle(Ac,Rl,Nc,!1,Nl);if(o===null&&(Cc(Rl.set(-.5,.5,0),Fa,a,Ua,r,n),Lp.set(0,1),o=e.ray.intersectTriangle(Ac,Nc,Rl,!1,Nl),o===null))return;const l=e.ray.origin.distanceTo(Nl);l<e.near||l>e.far||t.push({distance:l,point:Nl.clone(),uv:yr.getInterpolation(Nl,Ac,Rl,Nc,ly,Lp,hy,new te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Cc(s,e,t,i,r,n){za.subVectors(s,t).addScalar(.5).multiply(i),r!==void 0?(Cl.x=n*za.x-r*za.y,Cl.y=r*za.x+n*za.y):Cl.copy(za),s.copy(e),s.x+=Cl.x,s.y+=Cl.y,s.applyMatrix4(oy)}const Rc=new R,cy=new R;class Op extends _t{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const n=t[i];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let n;for(n=0;n<r.length&&!(t<r[n].distance);n++);return r.splice(n,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const r=t.splice(i,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let n=t[i].distance;if(t[i].object.visible&&(n-=n*t[i].hysteresis),e<n)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Rc.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Rc);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Rc.setFromMatrixPosition(e.matrixWorld),cy.setFromMatrixPosition(this.matrixWorld);const i=Rc.distanceTo(cy)/e.zoom;t[0].object.visible=!0;let r,n;for(r=1,n=t.length;r<n;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),i>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<n;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,n=i.length;r<n;r++){const a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const _r=new R,Up=new R,Ic=new R,Yr=new R,Fp=new R,Pc=new R,zp=new R;let Nn=class{constructor(s=new R,e=new R(0,0,-1)){this.origin=s,this.direction=e}set(s,e){return this.origin.copy(s),this.direction.copy(e),this}copy(s){return this.origin.copy(s.origin),this.direction.copy(s.direction),this}at(s,e){return e.copy(this.origin).addScaledVector(this.direction,s)}lookAt(s){return this.direction.copy(s).sub(this.origin).normalize(),this}recast(s){return this.origin.copy(this.at(s,_r)),this}closestPointToPoint(s,e){e.subVectors(s,this.origin);const t=e.dot(this.direction);return t<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,t)}distanceToPoint(s){return Math.sqrt(this.distanceSqToPoint(s))}distanceSqToPoint(s){const e=_r.subVectors(s,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(s):(_r.copy(this.origin).addScaledVector(this.direction,e),_r.distanceToSquared(s))}distanceSqToSegment(s,e,t,i){Up.copy(s).add(e).multiplyScalar(.5),Ic.copy(e).sub(s).normalize(),Yr.copy(this.origin).sub(Up);const r=s.distanceTo(e)*.5,n=-this.direction.dot(Ic),a=Yr.dot(this.direction),o=-Yr.dot(Ic),l=Yr.lengthSq(),h=Math.abs(1-n*n);let c,d,u,p;if(h>0)if(c=n*o-a,d=n*a-o,p=r*h,c>=0)if(d>=-p)if(d<=p){const m=1/h;c*=m,d*=m,u=c*(c+n*d+2*a)+d*(n*c+d+2*o)+l}else d=r,c=Math.max(0,-(n*d+a)),u=-c*c+d*(d+2*o)+l;else d=-r,c=Math.max(0,-(n*d+a)),u=-c*c+d*(d+2*o)+l;else d<=-p?(c=Math.max(0,-(-n*r+a)),d=c>0?-r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+l):d<=p?(c=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(c=Math.max(0,-(n*r+a)),d=c>0?r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+l);else d=n>0?-r:r,c=Math.max(0,-(n*d+a)),u=-c*c+d*(d+2*o)+l;return t&&t.copy(this.origin).addScaledVector(this.direction,c),i&&i.copy(Up).addScaledVector(Ic,d),u}intersectSphere(s,e){_r.subVectors(s.center,this.origin);const t=_r.dot(this.direction),i=_r.dot(_r)-t*t,r=s.radius*s.radius;if(i>r)return null;const n=Math.sqrt(r-i),a=t-n,o=t+n;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(s){return s.radius<0?!1:this.distanceSqToPoint(s.center)<=s.radius*s.radius}distanceToPlane(s){const e=s.normal.dot(this.direction);if(e===0)return s.distanceToPoint(this.origin)===0?0:null;const t=-(this.origin.dot(s.normal)+s.constant)/e;return t>=0?t:null}intersectPlane(s,e){const t=this.distanceToPlane(s);return t===null?null:this.at(t,e)}intersectsPlane(s){const e=s.distanceToPoint(this.origin);return e===0||s.normal.dot(this.direction)*e<0}intersectBox(s,e){let t,i,r,n,a,o;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return l>=0?(t=(s.min.x-d.x)*l,i=(s.max.x-d.x)*l):(t=(s.max.x-d.x)*l,i=(s.min.x-d.x)*l),h>=0?(r=(s.min.y-d.y)*h,n=(s.max.y-d.y)*h):(r=(s.max.y-d.y)*h,n=(s.min.y-d.y)*h),t>n||r>i||((r>t||isNaN(t))&&(t=r),(n<i||isNaN(i))&&(i=n),c>=0?(a=(s.min.z-d.z)*c,o=(s.max.z-d.z)*c):(a=(s.max.z-d.z)*c,o=(s.min.z-d.z)*c),t>o||a>i)||((a>t||t!==t)&&(t=a),(o<i||i!==i)&&(i=o),i<0)?null:this.at(t>=0?t:i,e)}intersectsBox(s){return this.intersectBox(s,_r)!==null}intersectTriangle(s,e,t,i,r){Fp.subVectors(e,s),Pc.subVectors(t,s),zp.crossVectors(Fp,Pc);let n=this.direction.dot(zp),a;if(n>0){if(i)return null;a=1}else if(n<0)a=-1,n=-n;else return null;Yr.subVectors(this.origin,s);const o=a*this.direction.dot(Pc.crossVectors(Yr,Pc));if(o<0)return null;const l=a*this.direction.dot(Fp.cross(Yr));if(l<0||o+l>n)return null;const h=-a*Yr.dot(zp);return h<0?null:this.at(h/n,r)}applyMatrix4(s){return this.origin.applyMatrix4(s),this.direction.transformDirection(s),this}equals(s){return s.origin.equals(this.origin)&&s.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Mr=class extends pi{constructor(s){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new we(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 ns,this.combine=Ho,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.lightMap=s.lightMap,this.lightMapIntensity=s.lightMapIntensity,this.aoMap=s.aoMap,this.aoMapIntensity=s.aoMapIntensity,this.specularMap=s.specularMap,this.alphaMap=s.alphaMap,this.envMap=s.envMap,this.envMapRotation.copy(s.envMapRotation),this.combine=s.combine,this.reflectivity=s.reflectivity,this.refractionRatio=s.refractionRatio,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.wireframeLinecap=s.wireframeLinecap,this.wireframeLinejoin=s.wireframeLinejoin,this.fog=s.fog,this}};const uy=new et,Cn=new Nn,Lc=new ai,dy=new R,Dc=new R,Oc=new R,Uc=new R,Bp=new R,Fc=new R,py=new R,zc=new R;let Xt=class extends _t{constructor(s=new rt,e=new Mr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=s,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(s,e){return super.copy(s,e),s.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=s.morphTargetInfluences.slice()),s.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},s.morphTargetDictionary)),this.material=Array.isArray(s.material)?s.material.slice():s.material,this.geometry=s.geometry,this}updateMorphTargets(){const s=this.geometry.morphAttributes,e=Object.keys(s);if(e.length>0){const t=s[e[0]];if(t!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++){const n=t[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=i}}}}getVertexPosition(s,e){const t=this.geometry,i=t.attributes.position,r=t.morphAttributes.position,n=t.morphTargetsRelative;e.fromBufferAttribute(i,s);const a=this.morphTargetInfluences;if(r&&a){Fc.set(0,0,0);for(let o=0,l=r.length;o<l;o++){const h=a[o],c=r[o];h!==0&&(Bp.fromBufferAttribute(c,s),n?Fc.addScaledVector(Bp,h):Fc.addScaledVector(Bp.sub(e),h))}e.add(Fc)}return e}raycast(s,e){const t=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(t.boundingSphere===null&&t.computeBoundingSphere(),Lc.copy(t.boundingSphere),Lc.applyMatrix4(r),Cn.copy(s.ray).recast(s.near),!(Lc.containsPoint(Cn.origin)===!1&&(Cn.intersectSphere(Lc,dy)===null||Cn.origin.distanceToSquared(dy)>(s.far-s.near)**2))&&(uy.copy(r).invert(),Cn.copy(s.ray).applyMatrix4(uy),!(t.boundingBox!==null&&Cn.intersectsBox(t.boundingBox)===!1)&&this._computeIntersections(s,e,Cn)))}_computeIntersections(s,e,t){let i;const r=this.geometry,n=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,d=r.groups,u=r.drawRange;if(a!==null)if(Array.isArray(n))for(let p=0,m=d.length;p<m;p++){const y=d[p],g=n[y.materialIndex],f=Math.max(y.start,u.start),x=Math.min(a.count,Math.min(y.start+y.count,u.start+u.count));for(let v=f,M=x;v<M;v+=3){const w=a.getX(v),T=a.getX(v+1),A=a.getX(v+2);i=Bc(this,g,s,t,l,h,c,w,T,A),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{const p=Math.max(0,u.start),m=Math.min(a.count,u.start+u.count);for(let y=p,g=m;y<g;y+=3){const f=a.getX(y),x=a.getX(y+1),v=a.getX(y+2);i=Bc(this,n,s,t,l,h,c,f,x,v),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}else if(o!==void 0)if(Array.isArray(n))for(let p=0,m=d.length;p<m;p++){const y=d[p],g=n[y.materialIndex],f=Math.max(y.start,u.start),x=Math.min(o.count,Math.min(y.start+y.count,u.start+u.count));for(let v=f,M=x;v<M;v+=3){const w=v,T=v+1,A=v+2;i=Bc(this,g,s,t,l,h,c,w,T,A),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{const p=Math.max(0,u.start),m=Math.min(o.count,u.start+u.count);for(let y=p,g=m;y<g;y+=3){const f=y,x=y+1,v=y+2;i=Bc(this,n,s,t,l,h,c,f,x,v),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}}};function Ab(s,e,t,i,r,n,a,o){let l;if(e.side===yi?l=i.intersectTriangle(a,n,r,!0,o):l=i.intersectTriangle(r,n,a,e.side===Vs,o),l===null)return null;zc.copy(o),zc.applyMatrix4(s.matrixWorld);const h=t.ray.origin.distanceTo(zc);return h<t.near||h>t.far?null:{distance:h,point:zc.clone(),object:s}}function Bc(s,e,t,i,r,n,a,o,l,h){s.getVertexPosition(o,Dc),s.getVertexPosition(l,Oc),s.getVertexPosition(h,Uc);const c=Ab(s,e,t,i,Dc,Oc,Uc,py);if(c){const d=new R;yr.getBarycoord(py,Dc,Oc,Uc,d),r&&(c.uv=yr.getInterpolatedAttribute(r,o,l,h,d,new te)),n&&(c.uv1=yr.getInterpolatedAttribute(n,o,l,h,d,new te)),a&&(c.normal=yr.getInterpolatedAttribute(a,o,l,h,d,new R),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const u={a:o,b:l,c:h,normal:new R,materialIndex:0};yr.getNormal(Dc,Oc,Uc,u.normal),c.face=u,c.barycoord=d}return c}const my=new R,fy=new It,gy=new It,Nb=new R,yy=new et,Vc=new R,Vp=new ai,xy=new et,kp=new Nn;class Gp extends Xt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ip,this.bindMatrix=new et,this.bindMatrixInverse=new et,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new di),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Vc),this.boundingBox.expandByPoint(Vc)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ai),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Vc),this.boundingSphere.expandByPoint(Vc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Vp.copy(this.boundingSphere),Vp.applyMatrix4(r),e.ray.intersectsSphere(Vp)!==!1&&(xy.copy(r).invert(),kp.copy(e.ray).applyMatrix4(xy),!(this.boundingBox!==null&&kp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,kp)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new It,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ip?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===d0?this.bindMatrixInverse.copy(this.bindMatrix).invert():ge("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;fy.fromBufferAttribute(r.attributes.skinIndex,e),gy.fromBufferAttribute(r.attributes.skinWeight,e),my.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let n=0;n<4;n++){const a=gy.getComponent(n);if(a!==0){const o=fy.getComponent(n);yy.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(Nb.copy(my).applyMatrix4(yy),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class kc extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class os extends ei{constructor(e=null,t=1,i=1,r,n,a,o,l,h=Ht,c=Ht,d,u){super(null,a,o,l,h,c,r,n,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const vy=new et,Cb=new et;class Ah{constructor(e=[],t=[]){this.uuid=Zi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){ge("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new et)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new et;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let n=0,a=e.length;n<a;n++){const o=e[n]?e[n].matrixWorld:Cb;vy.multiplyMatrices(o,t[n]),vy.toArray(i,n*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Ah(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new os(t,e,e,vi,xi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const n=e.bones[i];let a=t[n];a===void 0&&(ge("Skeleton: No bone found with UUID:",n),a=new kc),this.bones.push(a),this.boneInverses.push(new et().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,n=t.length;r<n;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}let Rn=class extends bt{constructor(s,e,t,i=1){super(s,e,t),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(s){return super.copy(s),this.meshPerAttribute=s.meshPerAttribute,this}toJSON(){const s=super.toJSON();return s.meshPerAttribute=this.meshPerAttribute,s.isInstancedBufferAttribute=!0,s}};const Ba=new et,_y=new et,Gc=[],My=new di,Rb=new et,Il=new Xt,Pl=new ai;class Hp extends Xt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Rn(new Float32Array(i*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,Rb)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new di),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ba),My.copy(e.boundingBox).applyMatrix4(Ba),this.boundingBox.union(My)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ba),Pl.copy(e.boundingSphere).applyMatrix4(Ba),this.boundingSphere.union(Pl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,n=i.length+1,a=e*n+1;for(let o=0;o<i.length;o++)i[o]=r[a+o]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(Il.geometry=this.geometry,Il.material=this.material,Il.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Pl.copy(this.boundingSphere),Pl.applyMatrix4(i),e.ray.intersectsSphere(Pl)!==!1))for(let n=0;n<r;n++){this.getMatrixAt(n,Ba),_y.multiplyMatrices(i,Ba),Il.matrixWorld=_y,Il.raycast(e,Gc);for(let a=0,o=Gc.length;a<o;a++){const l=Gc[a];l.instanceId=n,l.object=this,t.push(l)}Gc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Rn(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new os(new Float32Array(r*this.count),r,this.count,Wo,xi));const n=this.morphTexture.source.data.data;let a=0;for(let h=0;h<i.length;h++)a+=i[h];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;n[l]=o,n.set(i,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Wp=new R,Ib=new R,Pb=new at;let br=class{constructor(s=new R(1,0,0),e=0){this.isPlane=!0,this.normal=s,this.constant=e}set(s,e){return this.normal.copy(s),this.constant=e,this}setComponents(s,e,t,i){return this.normal.set(s,e,t),this.constant=i,this}setFromNormalAndCoplanarPoint(s,e){return this.normal.copy(s),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(s,e,t){const i=Wp.subVectors(t,e).cross(Ib.subVectors(s,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,s),this}copy(s){return this.normal.copy(s.normal),this.constant=s.constant,this}normalize(){const s=1/this.normal.length();return this.normal.multiplyScalar(s),this.constant*=s,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(s){return this.normal.dot(s)+this.constant}distanceToSphere(s){return this.distanceToPoint(s.center)-s.radius}projectPoint(s,e){return e.copy(s).addScaledVector(this.normal,-this.distanceToPoint(s))}intersectLine(s,e){const t=s.delta(Wp),i=this.normal.dot(t);if(i===0)return this.distanceToPoint(s.start)===0?e.copy(s.start):null;const r=-(s.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(s.start).addScaledVector(t,r)}intersectsLine(s){const e=this.distanceToPoint(s.start),t=this.distanceToPoint(s.end);return e<0&&t>0||t<0&&e>0}intersectsBox(s){return s.intersectsPlane(this)}intersectsSphere(s){return s.intersectsPlane(this)}coplanarPoint(s){return s.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(s,e){const t=e||Pb.getNormalMatrix(s),i=this.coplanarPoint(Wp).applyMatrix4(s),r=this.normal.applyMatrix3(t).normalize();return this.constant=-i.dot(r),this}translate(s){return this.constant-=s.dot(this.normal),this}equals(s){return s.normal.equals(this.normal)&&s.constant===this.constant}clone(){return new this.constructor().copy(this)}};const In=new ai,Lb=new te(.5,.5),Hc=new R;let Pn=class{constructor(s=new br,e=new br,t=new br,i=new br,r=new br,n=new br){this.planes=[s,e,t,i,r,n]}set(s,e,t,i,r,n){const a=this.planes;return a[0].copy(s),a[1].copy(e),a[2].copy(t),a[3].copy(i),a[4].copy(r),a[5].copy(n),this}copy(s){const e=this.planes;for(let t=0;t<6;t++)e[t].copy(s.planes[t]);return this}setFromProjectionMatrix(s,e=Yi,t=!1){const i=this.planes,r=s.elements,n=r[0],a=r[1],o=r[2],l=r[3],h=r[4],c=r[5],d=r[6],u=r[7],p=r[8],m=r[9],y=r[10],g=r[11],f=r[12],x=r[13],v=r[14],M=r[15];if(i[0].setComponents(l-n,u-h,g-p,M-f).normalize(),i[1].setComponents(l+n,u+h,g+p,M+f).normalize(),i[2].setComponents(l+a,u+c,g+m,M+x).normalize(),i[3].setComponents(l-a,u-c,g-m,M-x).normalize(),t)i[4].setComponents(o,d,y,v).normalize(),i[5].setComponents(l-o,u-d,g-y,M-v).normalize();else if(i[4].setComponents(l-o,u-d,g-y,M-v).normalize(),e===Yi)i[5].setComponents(l+o,u+d,g+y,M+v).normalize();else if(e===Sn)i[5].setComponents(o,d,y,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(s){if(s.boundingSphere!==void 0)s.boundingSphere===null&&s.computeBoundingSphere(),In.copy(s.boundingSphere).applyMatrix4(s.matrixWorld);else{const e=s.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),In.copy(e.boundingSphere).applyMatrix4(s.matrixWorld)}return this.intersectsSphere(In)}intersectsSprite(s){In.center.set(0,0,0);const e=Lb.distanceTo(s.center);return In.radius=.7071067811865476+e,In.applyMatrix4(s.matrixWorld),this.intersectsSphere(In)}intersectsSphere(s){const e=this.planes,t=s.center,i=-s.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(t)<i)return!1;return!0}intersectsBox(s){const e=this.planes;for(let t=0;t<6;t++){const i=e[t];if(Hc.x=i.normal.x>0?s.max.x:s.min.x,Hc.y=i.normal.y>0?s.max.y:s.min.y,Hc.z=i.normal.z>0?s.max.z:s.min.z,i.distanceToPoint(Hc)<0)return!1}return!0}containsPoint(s){const e=this.planes;for(let t=0;t<6;t++)if(e[t].distanceToPoint(s)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};const Hs=new et,Ws=new Pn;class Pd{constructor(){this.coordinateSystem=Yi}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.containsPoint(e))return!0}return!1}clone(){return new Pd}}function jp(s,e){return s-e}function Db(s,e){return s.z-e.z}function Ob(s,e){return e.z-s.z}class Ub{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,r){const n=this.pool,a=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1,index:-1});const o=n[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=i,o.index=r}reset(){this.list.length=0,this.index=0}}const ki=new et,Fb=new we(1,1,1),by=new Pn,zb=new Pd,Wc=new di,Ln=new ai,Ll=new R,Sy=new R,Bb=new R,Xp=new Ub,Si=new Xt,jc=[];function Vb(s,e,t=0){const i=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const r=s.count;for(let n=0;n<r;n++)for(let a=0;a<i;a++)e.setComponent(n+t,a,s.getComponent(n,a))}else e.array.set(s.array,t*i);e.needsUpdate=!0}function Dn(s,e){if(s.constructor!==e.constructor){const t=Math.min(s.length,e.length);for(let i=0;i<t;i++)e[i]=s[i]}else{const t=Math.min(s.length,e.length);e.set(new s.constructor(s.buffer,0,t))}}class qp extends Xt{constructor(e,t,i=t*2,r){super(new rt,r),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=e,this._maxVertexCount=t,this._maxIndexCount=i,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),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 e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new os(t,e,e,vi,xi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new os(t,e,e,ga,qi);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new os(t,e,e,vi,xi);i.colorSpace=mt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const n in e.attributes){const a=e.getAttribute(n),{array:o,itemSize:l,normalized:h}=a,c=new o.constructor(i*l),d=new bt(c,l,h);t.setAttribute(n,d)}if(e.getIndex()!==null){const n=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new bt(n,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),n=t.getAttribute(i);if(r.itemSize!==n.itemSize||r.normalized!==n.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new di);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const n=t[i].geometryIndex;this.getMatrixAt(i,ki),this.getBoundingBoxAt(n,Wc).applyMatrix4(ki),e.union(Wc)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ai);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const n=t[i].geometryIndex;this.getMatrixAt(i,ki),this.getBoundingSphereAt(n,Ln).applyMatrix4(ki),e.union(Ln)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(jp),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=t):(i=this._instanceInfo.length,this._instanceInfo.push(t));const r=this._matricesTexture;ki.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;const n=this._colorsTexture;return n&&(Fb.toArray(n.image.data,i*4),n.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},n=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=i===-1?a.count:i),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(jp),o=this._availableGeometryIds.shift(),n[o]=r):(o=this._geometryCount,this._geometryCount++,n.push(r)),this.setGeometryAt(o,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,n=i.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,h=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const c in i.attributes){const d=t.getAttribute(c),u=i.getAttribute(c);Vb(d,u,l);const p=d.itemSize;for(let m=d.count,y=h;m<y;m++){const g=l+m;for(let f=0;f<p;f++)u.setComponent(g,f,0)}u.needsUpdate=!0,u.addUpdateRange(l*p,h*p)}if(r){const c=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let u=0;u<a.count;u++)n.setX(c+u,l+a.getX(u));for(let u=a.count,p=d;u<p;u++)n.setX(c+u,l);n.needsUpdate=!0,n.addUpdateRange(c,o.reservedIndexCount)}return o.start=r?o.indexStart:o.vertexStart,o.count=r?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let r=0,n=i.length;r<n;r++)i[r].active&&i[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const i=this._geometryInfo,r=i.map((a,o)=>o).sort((a,o)=>i[a].vertexStart-i[o].vertexStart),n=this.geometry;for(let a=0,o=i.length;a<o;a++){const l=r[a],h=i[l];if(h.active!==!1){if(n.index!==null){if(h.indexStart!==t){const{indexStart:c,vertexStart:d,reservedIndexCount:u}=h,p=n.index,m=p.array,y=e-d;for(let g=c;g<c+u;g++)m[g]=m[g]+y;p.array.copyWithin(t,c,c+u),p.addUpdateRange(t,u),p.needsUpdate=!0,h.indexStart=t}t+=h.reservedIndexCount}if(h.vertexStart!==e){const{vertexStart:c,reservedVertexCount:d}=h,u=n.attributes;for(const p in u){const m=u[p],{array:y,itemSize:g}=m;y.copyWithin(e*g,c*g,(c+d)*g),m.addUpdateRange(e*g,d*g),m.needsUpdate=!0}h.vertexStart=e}e+=h.reservedVertexCount,h.start=n.index?h.indexStart:h.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const n=new di,a=i.index,o=i.attributes.position;for(let l=r.start,h=r.start+r.count;l<h;l++){let c=l;a&&(c=a.getX(c)),n.expandByPoint(Ll.fromBufferAttribute(o,c))}r.boundingBox=n}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const n=new ai;this.getBoundingBoxAt(e,Wc),Wc.getCenter(n.center);const a=i.index,o=i.attributes.position;let l=0;for(let h=r.start,c=r.start+r.count;h<c;h++){let d=h;a&&(d=a.getX(d)),Ll.fromBufferAttribute(o,d),l=Math.max(l,n.center.distanceToSquared(Ll))}n.radius=Math.sqrt(l),r.boundingSphere=n}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),i.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const i=this._geometryInfo[e];return t.vertexStart=i.vertexStart,t.vertexCount=i.vertexCount,t.reservedVertexCount=i.reservedVertexCount,t.indexStart=i.indexStart,t.indexCount=i.indexCount,t.reservedIndexCount=i.reservedIndexCount,t.start=i.start,t.count=i.count,t}setInstanceCount(e){const t=this._availableInstanceIds,i=this._instanceInfo;for(t.sort(jp);t[t.length-1]===i.length-1;)i.pop(),t.pop();if(e<i.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const r=new Int32Array(e),n=new Int32Array(e);Dn(this._multiDrawCounts,r),Dn(this._multiDrawStarts,n),this._multiDrawCounts=r,this._multiDrawStarts=n,this._maxInstanceCount=e;const a=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Dn(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),Dn(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),Dn(l.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const i=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...i.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(a=>a.indexStart+a.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new rt,this._initializeGeometry(r));const n=this.geometry;r.index&&Dn(r.index.array,n.index.array);for(const a in r.attributes)Dn(r.attributes[a].array,n.attributes[a].array)}raycast(e,t){const i=this._instanceInfo,r=this._geometryInfo,n=this.matrixWorld,a=this.geometry;Si.material=this.material,Si.geometry.index=a.index,Si.geometry.attributes=a.attributes,Si.geometry.boundingBox===null&&(Si.geometry.boundingBox=new di),Si.geometry.boundingSphere===null&&(Si.geometry.boundingSphere=new ai);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const h=i[o].geometryIndex,c=r[h];Si.geometry.setDrawRange(c.start,c.count),this.getMatrixAt(o,Si.matrixWorld).premultiply(n),this.getBoundingBoxAt(h,Si.geometry.boundingBox),this.getBoundingSphereAt(h,Si.geometry.boundingSphere),Si.raycast(e,jc);for(let d=0,u=jc.length;d<u;d++){const p=jc[d];p.object=this,p.batchId=o,t.push(p)}jc.length=0}Si.material=null,Si.geometry.index=null,Si.geometry.attributes={},Si.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._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(e,t,i,r,n){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex();let o=a===null?1:a.array.BYTES_PER_ELEMENT,l=1;n.wireframe&&(l=2,o=r.attributes.position.count>65535?4:2);const h=this._instanceInfo,c=this._multiDrawStarts,d=this._multiDrawCounts,u=this._geometryInfo,p=this.perObjectFrustumCulled,m=this._indirectTexture,y=m.image.data,g=i.isArrayCamera?zb:by;p&&!i.isArrayCamera&&(ki.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),by.setFromProjectionMatrix(ki,i.coordinateSystem,i.reversedDepth));let f=0;if(this.sortObjects){ki.copy(this.matrixWorld).invert(),Ll.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ki),Sy.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(ki);for(let M=0,w=h.length;M<w;M++)if(h[M].visible&&h[M].active){const T=h[M].geometryIndex;this.getMatrixAt(M,ki),this.getBoundingSphereAt(T,Ln).applyMatrix4(ki);let A=!1;if(p&&(A=!g.intersectsSphere(Ln,i)),!A){const _=u[T],S=Bb.subVectors(Ln.center,Ll).dot(Sy);Xp.push(_.start,_.count,S,M)}}const x=Xp.list,v=this.customSort;v===null?x.sort(n.transparent?Ob:Db):v.call(this,x,i);for(let M=0,w=x.length;M<w;M++){const T=x[M];c[f]=T.start*o*l,d[f]=T.count*l,y[f]=T.index,f++}Xp.reset()}else for(let x=0,v=h.length;x<v;x++)if(h[x].visible&&h[x].active){const M=h[x].geometryIndex;let w=!1;if(p&&(this.getMatrixAt(x,ki),this.getBoundingSphereAt(M,Ln).applyMatrix4(ki),w=!g.intersectsSphere(Ln,i)),!w){const T=u[M];c[f]=T.start*o*l,d[f]=T.count*l,y[f]=x,f++}}m.needsUpdate=!0,this._multiDrawCount=f,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,n,a){this.onBeforeRender(e,null,r,n,a)}}class Ti extends pi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new we(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Xc=new R,qc=new R,Ty=new et,Dl=new Nn,Yc=new ai,Yp=new R,wy=new R;class Sr extends _t{constructor(e=new rt,t=new Ti){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,n=t.count;r<n;r++)Xc.fromBufferAttribute(t,r-1),qc.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Xc.distanceTo(qc);e.setAttribute("lineDistance",new Ne(i,1))}else ge("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,n=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Yc.copy(i.boundingSphere),Yc.applyMatrix4(r),Yc.radius+=n,e.ray.intersectsSphere(Yc)===!1)return;Ty.copy(r).invert(),Dl.copy(e.ray).applyMatrix4(Ty);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,h=this.isLineSegments?2:1,c=i.index,d=i.attributes.position;if(c!==null){const u=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let m=u,y=p-1;m<y;m+=h){const g=c.getX(m),f=c.getX(m+1),x=Zc(this,e,Dl,l,g,f,m);x&&t.push(x)}if(this.isLineLoop){const m=c.getX(p-1),y=c.getX(u),g=Zc(this,e,Dl,l,m,y,p-1);g&&t.push(g)}}else{const u=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let m=u,y=p-1;m<y;m+=h){const g=Zc(this,e,Dl,l,m,m+1,m);g&&t.push(g)}if(this.isLineLoop){const m=Zc(this,e,Dl,l,p-1,u,p-1);m&&t.push(m)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Zc(s,e,t,i,r,n,a){const o=s.geometry.attributes.position;if(Xc.fromBufferAttribute(o,r),qc.fromBufferAttribute(o,n),t.distanceSqToSegment(Xc,qc,Yp,wy)>i)return;Yp.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(Yp);if(!(l<e.near||l>e.far))return{distance:l,point:wy.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Ey=new R,Ay=new R;class Rs extends Sr{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,n=t.count;r<n;r+=2)Ey.fromBufferAttribute(t,r),Ay.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ey.distanceTo(Ay);e.setAttribute("lineDistance",new Ne(i,1))}else ge("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Zp extends Sr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Jc extends pi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new we(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Ny=new et,Jp=new Nn,Kc=new ai,$c=new R;class Kp extends _t{constructor(e=new rt,t=new Jc){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,n=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Kc.copy(i.boundingSphere),Kc.applyMatrix4(r),Kc.radius+=n,e.ray.intersectsSphere(Kc)===!1)return;Ny.copy(r).invert(),Jp.copy(e.ray).applyMatrix4(Ny);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,h=i.index,c=i.attributes.position;if(h!==null){const d=Math.max(0,a.start),u=Math.min(h.count,a.start+a.count);for(let p=d,m=u;p<m;p++){const y=h.getX(p);$c.fromBufferAttribute(c,y),Cy($c,y,l,r,e,t,this)}}else{const d=Math.max(0,a.start),u=Math.min(c.count,a.start+a.count);for(let p=d,m=u;p<m;p++)$c.fromBufferAttribute(c,p),Cy($c,p,l,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Cy(s,e,t,i,r,n,a){const o=Jp.distanceSqToPoint(s);if(o<t){const l=new R;Jp.closestPointToPoint(s,l),l.applyMatrix4(i);const h=r.ray.origin.distanceTo(l);if(h<r.near||h>r.far)return;n.push({distance:h,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class $p extends ei{constructor(e,t,i,r,n=Rt,a=Rt,o,l,h){super(e,t,i,r,n,a,o,l,h),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const c=this;function d(){c.needsUpdate=!0,c._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class kb extends $p{constructor(e,t,i,r,n,a,o,l){super({},e,t,i,r,n,a,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}let Gb=class extends ei{constructor(s,e){super({width:s,height:e}),this.isFramebufferTexture=!0,this.magFilter=Ht,this.minFilter=Ht,this.generateMipmaps=!1,this.needsUpdate=!0}};class Ol extends ei{constructor(e,t,i,r,n,a,o,l,h,c,d,u){super(null,a,o,l,h,c,r,n,d,u),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Ry extends Ol{constructor(e,t,i,r,n,a){super(e,t,i,n,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Ci,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Iy extends Ol{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,ks),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}let Va=class extends ei{constructor(s=[],e=ks,t,i,r,n,a,o,l,h){super(s,e,t,i,r,n,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(s){this.image=s}};class Py extends ei{constructor(e,t,i,r,n,a,o,l,h){super(e,t,i,r,n,a,o,l,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}let On=class extends ei{constructor(s,e,t=qi,i,r,n,a=Ht,o=Ht,l,h=ws,c=1){if(h!==ws&&h!==ur)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:s,height:e,depth:c};super(d,i,r,n,a,o,h,t,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(s){return super.copy(s),this.source=new pr(Object.assign({},s.image)),this.compareFunction=s.compareFunction,this}toJSON(s){const e=super.toJSON(s);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},Ly=class extends On{constructor(s,e=qi,t=ks,i,r,n=Ht,a=Ht,o,l=ws){const h={width:s,height:s,depth:1},c=[h,h,h,h,h,h];super(s,s,e,t,i,r,n,a,o,l),this.image=c,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(s){this.image=s}};class Qp extends ei{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class dn extends rt{constructor(e=1,t=1,i=1,r=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:n,depthSegments:a};const o=this;r=Math.floor(r),n=Math.floor(n),a=Math.floor(a);const l=[],h=[],c=[],d=[];let u=0,p=0;m("z","y","x",-1,-1,i,t,e,a,n,0),m("z","y","x",1,-1,i,t,-e,a,n,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,n,4),m("x","y","z",-1,-1,e,t,-i,r,n,5),this.setIndex(l),this.setAttribute("position",new Ne(h,3)),this.setAttribute("normal",new Ne(c,3)),this.setAttribute("uv",new Ne(d,2));function m(y,g,f,x,v,M,w,T,A,_,S){const P=M/A,C=w/_,L=M/2,U=w/2,V=T/2,B=A+1,k=_+1;let W=0,se=0;const ie=new R;for(let oe=0;oe<k;oe++){const be=oe*C-U;for(let Ce=0;Ce<B;Ce++){const tt=Ce*P-L;ie[y]=tt*x,ie[g]=be*v,ie[f]=V,h.push(ie.x,ie.y,ie.z),ie[y]=0,ie[g]=0,ie[f]=T>0?1:-1,c.push(ie.x,ie.y,ie.z),d.push(Ce/A),d.push(1-oe/_),W+=1}}for(let oe=0;oe<_;oe++)for(let be=0;be<A;be++){const Ce=u+be+B*oe,tt=u+be+B*(oe+1),wt=u+(be+1)+B*(oe+1),Et=u+(be+1)+B*oe;l.push(Ce,tt,Et),l.push(tt,wt,Et),se+=6}o.addGroup(p,se,S),p+=se,u+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Ld extends rt{constructor(e=1,t=1,i=4,r=8,n=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:r,heightSegments:n},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),r=Math.max(3,Math.floor(r)),n=Math.max(1,Math.floor(n));const a=[],o=[],l=[],h=[],c=t/2,d=Math.PI/2*e,u=t,p=2*d+u,m=i*2+n,y=r+1,g=new R,f=new R;for(let x=0;x<=m;x++){let v=0,M=0,w=0,T=0;if(x<=i){const S=x/i,P=S*Math.PI/2;M=-c-e*Math.cos(P),w=e*Math.sin(P),T=-e*Math.cos(P),v=S*d}else if(x<=i+n){const S=(x-i)/n;M=-c+S*t,w=e,T=0,v=d+S*u}else{const S=(x-i-n)/i,P=S*Math.PI/2;M=c+e*Math.sin(P),w=e*Math.cos(P),T=e*Math.sin(P),v=d+u+S*d}const A=Math.max(0,Math.min(1,v/p));let _=0;x===0?_=.5/r:x===m&&(_=-.5/r);for(let S=0;S<=r;S++){const P=S/r,C=P*Math.PI*2,L=Math.sin(C),U=Math.cos(C);f.x=-w*U,f.y=M,f.z=w*L,o.push(f.x,f.y,f.z),g.set(-w*U,T,w*L),g.normalize(),l.push(g.x,g.y,g.z),h.push(P+_,A)}if(x>0){const S=(x-1)*y;for(let P=0;P<r;P++){const C=S+P,L=S+P+1,U=x*y+P,V=x*y+P+1;a.push(C,L,U),a.push(L,V,U)}}}this.setIndex(a),this.setAttribute("position",new Ne(o,3)),this.setAttribute("normal",new Ne(l,3)),this.setAttribute("uv",new Ne(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ld(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Dd extends rt{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const n=[],a=[],o=[],l=[],h=new R,c=new te;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const p=i+d/t*r;h.x=e*Math.cos(p),h.y=e*Math.sin(p),a.push(h.x,h.y,h.z),o.push(0,0,1),c.x=(a[u]/e+1)/2,c.y=(a[u+1]/e+1)/2,l.push(c.x,c.y)}for(let d=1;d<=t;d++)n.push(d,d+1,0);this.setIndex(n),this.setAttribute("position",new Ne(a,3)),this.setAttribute("normal",new Ne(o,3)),this.setAttribute("uv",new Ne(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Dd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Ro extends rt{constructor(e=1,t=1,i=1,r=32,n=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l};const h=this;r=Math.floor(r),n=Math.floor(n);const c=[],d=[],u=[],p=[];let m=0;const y=[],g=i/2;let f=0;x(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Ne(d,3)),this.setAttribute("normal",new Ne(u,3)),this.setAttribute("uv",new Ne(p,2));function x(){const M=new R,w=new R;let T=0;const A=(t-e)/i;for(let _=0;_<=n;_++){const S=[],P=_/n,C=P*(t-e)+e;for(let L=0;L<=r;L++){const U=L/r,V=U*l+o,B=Math.sin(V),k=Math.cos(V);w.x=C*B,w.y=-P*i+g,w.z=C*k,d.push(w.x,w.y,w.z),M.set(B,A,k).normalize(),u.push(M.x,M.y,M.z),p.push(U,1-P),S.push(m++)}y.push(S)}for(let _=0;_<r;_++)for(let S=0;S<n;S++){const P=y[S][_],C=y[S+1][_],L=y[S+1][_+1],U=y[S][_+1];(e>0||S!==0)&&(c.push(P,C,U),T+=3),(t>0||S!==n-1)&&(c.push(C,L,U),T+=3)}h.addGroup(f,T,0),f+=T}function v(M){const w=m,T=new te,A=new R;let _=0;const S=M===!0?e:t,P=M===!0?1:-1;for(let L=1;L<=r;L++)d.push(0,g*P,0),u.push(0,P,0),p.push(.5,.5),m++;const C=m;for(let L=0;L<=r;L++){const U=L/r*l+o,V=Math.cos(U),B=Math.sin(U);A.x=S*B,A.y=g*P,A.z=S*V,d.push(A.x,A.y,A.z),u.push(0,P,0),T.x=V*.5+.5,T.y=B*.5*P+.5,p.push(T.x,T.y),m++}for(let L=0;L<r;L++){const U=w+L,V=C+L;M===!0?c.push(V,V+1,U):c.push(V+1,V,U),_+=3}h.addGroup(f,_,M===!0?1:2),f+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ro(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Nh extends Ro{constructor(e=1,t=1,i=32,r=1,n=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,n,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Nh(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class pn extends rt{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const n=[],a=[];o(r),h(i),c(),this.setAttribute("position",new Ne(n,3)),this.setAttribute("normal",new Ne(n.slice(),3)),this.setAttribute("uv",new Ne(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){const v=new R,M=new R,w=new R;for(let T=0;T<t.length;T+=3)p(t[T+0],v),p(t[T+1],M),p(t[T+2],w),l(v,M,w,x)}function l(x,v,M,w){const T=w+1,A=[];for(let _=0;_<=T;_++){A[_]=[];const S=x.clone().lerp(M,_/T),P=v.clone().lerp(M,_/T),C=T-_;for(let L=0;L<=C;L++)L===0&&_===T?A[_][L]=S:A[_][L]=S.clone().lerp(P,L/C)}for(let _=0;_<T;_++)for(let S=0;S<2*(T-_)-1;S++){const P=Math.floor(S/2);S%2===0?(u(A[_][P+1]),u(A[_+1][P]),u(A[_][P])):(u(A[_][P+1]),u(A[_+1][P+1]),u(A[_+1][P]))}}function h(x){const v=new R;for(let M=0;M<n.length;M+=3)v.x=n[M+0],v.y=n[M+1],v.z=n[M+2],v.normalize().multiplyScalar(x),n[M+0]=v.x,n[M+1]=v.y,n[M+2]=v.z}function c(){const x=new R;for(let v=0;v<n.length;v+=3){x.x=n[v+0],x.y=n[v+1],x.z=n[v+2];const M=g(x)/2/Math.PI+.5,w=f(x)/Math.PI+.5;a.push(M,1-w)}m(),d()}function d(){for(let x=0;x<a.length;x+=6){const v=a[x+0],M=a[x+2],w=a[x+4],T=Math.max(v,M,w),A=Math.min(v,M,w);T>.9&&A<.1&&(v<.2&&(a[x+0]+=1),M<.2&&(a[x+2]+=1),w<.2&&(a[x+4]+=1))}}function u(x){n.push(x.x,x.y,x.z)}function p(x,v){const M=x*3;v.x=e[M+0],v.y=e[M+1],v.z=e[M+2]}function m(){const x=new R,v=new R,M=new R,w=new R,T=new te,A=new te,_=new te;for(let S=0,P=0;S<n.length;S+=9,P+=6){x.set(n[S+0],n[S+1],n[S+2]),v.set(n[S+3],n[S+4],n[S+5]),M.set(n[S+6],n[S+7],n[S+8]),T.set(a[P+0],a[P+1]),A.set(a[P+2],a[P+3]),_.set(a[P+4],a[P+5]),w.copy(x).add(v).add(M).divideScalar(3);const C=g(w);y(T,P+0,x,C),y(A,P+2,v,C),y(_,P+4,M,C)}}function y(x,v,M,w){w<0&&x.x===1&&(a[v]=x.x-1),M.x===0&&M.z===0&&(a[v]=w/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function f(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pn(e.vertices,e.indices,e.radius,e.detail)}}class Od extends pn{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[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(n,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Od(e.radius,e.detail)}}const Qc=new R,eu=new R,em=new R,tu=new yr;class tm extends rt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(Tn*t),n=e.getIndex(),a=e.getAttribute("position"),o=n?n.count:a.count,l=[0,0,0],h=["a","b","c"],c=new Array(3),d={},u=[];for(let p=0;p<o;p+=3){n?(l[0]=n.getX(p),l[1]=n.getX(p+1),l[2]=n.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:m,b:y,c:g}=tu;if(m.fromBufferAttribute(a,l[0]),y.fromBufferAttribute(a,l[1]),g.fromBufferAttribute(a,l[2]),tu.getNormal(em),c[0]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,c[1]=`${Math.round(y.x*i)},${Math.round(y.y*i)},${Math.round(y.z*i)}`,c[2]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,!(c[0]===c[1]||c[1]===c[2]||c[2]===c[0]))for(let f=0;f<3;f++){const x=(f+1)%3,v=c[f],M=c[x],w=tu[h[f]],T=tu[h[x]],A=`${v}_${M}`,_=`${M}_${v}`;_ in d&&d[_]?(em.dot(d[_].normal)<=r&&(u.push(w.x,w.y,w.z),u.push(T.x,T.y,T.z)),d[_]=null):A in d||(d[A]={index0:l[f],index1:l[x],normal:em.clone()})}}for(const p in d)if(d[p]){const{index0:m,index1:y}=d[p];Qc.fromBufferAttribute(a,m),eu.fromBufferAttribute(a,y),u.push(Qc.x,Qc.y,Qc.z),u.push(eu.x,eu.y,eu.z)}this.setAttribute("position",new Ne(u,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class ls{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){ge("Curve: .getPoint() not implemented.")}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),n=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),n+=i.distanceTo(r),t.push(n),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let r=0;const n=i.length;let a;t?a=t:a=e*i[n-1];let o=0,l=n-1,h;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),h=i[r]-a,h<0)o=r+1;else if(h>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(n-1);const c=i[r],d=i[r+1]-c,u=(a-c)/d;return(r+u)/(n-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const n=this.getPoint(i),a=this.getPoint(r),o=t||(n.isVector2?new te:new R);return o.copy(a).sub(n).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new R,r=[],n=[],a=[],o=new R,l=new et;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new R)}n[0]=new R,a[0]=new R;let h=Number.MAX_VALUE;const c=Math.abs(r[0].x),d=Math.abs(r[0].y),u=Math.abs(r[0].z);c<=h&&(h=c,i.set(1,0,0)),d<=h&&(h=d,i.set(0,1,0)),u<=h&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),n[0].crossVectors(r[0],o),a[0].crossVectors(r[0],n[0]);for(let p=1;p<=e;p++){if(n[p]=n[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Ke(r[p-1].dot(r[p]),-1,1));n[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],n[p])}if(t===!0){let p=Math.acos(Ke(n[0].dot(n[e]),-1,1));p/=e,r[0].dot(o.crossVectors(n[0],n[e]))>0&&(p=-p);for(let m=1;m<=e;m++)n[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],n[m])}return{tangents:r,normals:n,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class iu extends ls{constructor(e=0,t=0,i=1,r=1,n=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=n,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new te){const i=t,r=Math.PI*2;let n=this.aEndAngle-this.aStartAngle;const a=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=r;for(;n>r;)n-=r;n<Number.EPSILON&&(a?n=0:n=r),this.aClockwise===!0&&!a&&(n===r?n=-r:n=n-r);const o=this.aStartAngle+e*n;let l=this.aX+this.xRadius*Math.cos(o),h=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),u=l-this.aX,p=h-this.aY;l=u*c-p*d+this.aX,h=u*d+p*c+this.aY}return i.set(l,h)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Dy extends iu{constructor(e,t,i,r,n,a){super(e,t,i,i,r,n,a),this.isArcCurve=!0,this.type="ArcCurve"}}function im(){let s=0,e=0,t=0,i=0;function r(n,a,o,l){s=n,e=o,t=-3*n+3*a-2*o-l,i=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){r(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,c,d){let u=(a-n)/h-(o-n)/(h+c)+(o-a)/c,p=(o-a)/c-(l-a)/(c+d)+(l-o)/d;u*=c,p*=c,r(a,o,u,p)},calc:function(n){const a=n*n,o=a*n;return s+e*n+t*a+i*o}}}const su=new R,sm=new im,rm=new im,nm=new im;class am extends ls{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new R){const i=t,r=this.points,n=r.length,a=(n-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/n)+1)*n:l===0&&o===n-1&&(o=n-2,l=1);let h,c;this.closed||o>0?h=r[(o-1)%n]:(su.subVectors(r[0],r[1]).add(r[0]),h=su);const d=r[o%n],u=r[(o+1)%n];if(this.closed||o+2<n?c=r[(o+2)%n]:(su.subVectors(r[n-1],r[n-2]).add(r[n-1]),c=su),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(h.distanceToSquared(d),p),y=Math.pow(d.distanceToSquared(u),p),g=Math.pow(u.distanceToSquared(c),p);y<1e-4&&(y=1),m<1e-4&&(m=y),g<1e-4&&(g=y),sm.initNonuniformCatmullRom(h.x,d.x,u.x,c.x,m,y,g),rm.initNonuniformCatmullRom(h.y,d.y,u.y,c.y,m,y,g),nm.initNonuniformCatmullRom(h.z,d.z,u.z,c.z,m,y,g)}else this.curveType==="catmullrom"&&(sm.initCatmullRom(h.x,d.x,u.x,c.x,this.tension),rm.initCatmullRom(h.y,d.y,u.y,c.y,this.tension),nm.initCatmullRom(h.z,d.z,u.z,c.z,this.tension));return i.set(sm.calc(l),rm.calc(l),nm.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new R().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Oy(s,e,t,i,r){const n=(i-e)*.5,a=(r-t)*.5,o=s*s,l=s*o;return(2*t-2*i+n+a)*l+(-3*t+3*i-2*n-a)*o+n*s+t}function Hb(s,e){const t=1-s;return t*t*e}function Wb(s,e){return 2*(1-s)*s*e}function jb(s,e){return s*s*e}function Ul(s,e,t,i){return Hb(s,e)+Wb(s,t)+jb(s,i)}function Xb(s,e){const t=1-s;return t*t*t*e}function qb(s,e){const t=1-s;return 3*t*t*s*e}function Yb(s,e){return 3*(1-s)*s*s*e}function Zb(s,e){return s*s*s*e}function Fl(s,e,t,i,r){return Xb(s,e)+qb(s,t)+Yb(s,i)+Zb(s,r)}class om extends ls{constructor(e=new te,t=new te,i=new te,r=new te){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new te){const i=t,r=this.v0,n=this.v1,a=this.v2,o=this.v3;return i.set(Fl(e,r.x,n.x,a.x,o.x),Fl(e,r.y,n.y,a.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Uy extends ls{constructor(e=new R,t=new R,i=new R,r=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new R){const i=t,r=this.v0,n=this.v1,a=this.v2,o=this.v3;return i.set(Fl(e,r.x,n.x,a.x,o.x),Fl(e,r.y,n.y,a.y,o.y),Fl(e,r.z,n.z,a.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class lm extends ls{constructor(e=new te,t=new te){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new te){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new te){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Fy extends ls{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class hm extends ls{constructor(e=new te,t=new te,i=new te){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new te){const i=t,r=this.v0,n=this.v1,a=this.v2;return i.set(Ul(e,r.x,n.x,a.x),Ul(e,r.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class cm extends ls{constructor(e=new R,t=new R,i=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new R){const i=t,r=this.v0,n=this.v1,a=this.v2;return i.set(Ul(e,r.x,n.x,a.x),Ul(e,r.y,n.y,a.y),Ul(e,r.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class um extends ls{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new te){const i=t,r=this.points,n=(r.length-1)*e,a=Math.floor(n),o=n-a,l=r[a===0?a:a-1],h=r[a],c=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return i.set(Oy(o,l.x,h.x,c.x,d.x),Oy(o,l.y,h.y,c.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new te().fromArray(r))}return this}}var ru=Object.freeze({__proto__:null,ArcCurve:Dy,CatmullRomCurve3:am,CubicBezierCurve:om,CubicBezierCurve3:Uy,EllipseCurve:iu,LineCurve:lm,LineCurve3:Fy,QuadraticBezierCurve:hm,QuadraticBezierCurve3:cm,SplineCurve:um});class zy extends ls{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ru[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let n=0;for(;n<r.length;){if(r[n]>=i){const a=r[n]-i,o=this.curves[n],l=o.getLength(),h=l===0?0:1-a/l;return o.getPointAt(h,t)}n++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,n=this.curves;r<n.length;r++){const a=n[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let h=0;h<l.length;h++){const c=l[h];i&&i.equals(c)||(t.push(c),i=c)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new ru[r.type]().fromJSON(r))}return this}}class nu extends zy{constructor(e){super(),this.type="Path",this.currentPoint=new te,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new lm(this.currentPoint.clone(),new te(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const n=new hm(this.currentPoint.clone(),new te(e,t),new te(i,r));return this.curves.push(n),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,n,a){const o=new om(this.currentPoint.clone(),new te(e,t),new te(i,r),new te(n,a));return this.curves.push(o),this.currentPoint.set(n,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new um(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,n,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,n,a),this}absarc(e,t,i,r,n,a){return this.absellipse(e,t,i,i,r,n,a),this}ellipse(e,t,i,r,n,a,o,l){const h=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+h,t+c,i,r,n,a,o,l),this}absellipse(e,t,i,r,n,a,o,l){const h=new iu(e,t,i,r,n,a,o,l);if(this.curves.length>0){const d=h.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(h);const c=h.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Zr extends nu{constructor(e){super(e),this.uuid=Zi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new nu().fromJSON(r))}return this}}function Jb(s,e,t=2){const i=e&&e.length,r=i?e[0]*t:s.length;let n=By(s,0,r,t,!0);const a=[];if(!n||n.next===n.prev)return a;let o,l,h;if(i&&(n=tS(s,e,n,t)),s.length>80*t){o=s[0],l=s[1];let c=o,d=l;for(let u=t;u<r;u+=t){const p=s[u],m=s[u+1];p<o&&(o=p),m<l&&(l=m),p>c&&(c=p),m>d&&(d=m)}h=Math.max(c-o,d-l),h=h!==0?32767/h:0}return zl(n,a,t,o,l,h,0),a}function By(s,e,t,i,r){let n;if(r===dS(s,e,t,i)>0)for(let a=e;a<t;a+=i)n=Hy(a/i|0,s[a],s[a+1],n);else for(let a=t-i;a>=e;a-=i)n=Hy(a/i|0,s[a],s[a+1],n);return n&&ka(n,n.next)&&(kl(n),n=n.next),n}function Un(s,e){if(!s)return s;e||(e=s);let t=s,i;do if(i=!1,!t.steiner&&(ka(t,t.next)||Ft(t.prev,t,t.next)===0)){if(kl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function zl(s,e,t,i,r,n,a){if(!s)return;!a&&n&&aS(s,i,r,n);let o=s;for(;s.prev!==s.next;){const l=s.prev,h=s.next;if(n?$b(s,i,r,n):Kb(s)){e.push(l.i,s.i,h.i),kl(s),s=h.next,o=h.next;continue}if(s=h,s===o){a?a===1?(s=Qb(Un(s),e),zl(s,e,t,i,r,n,2)):a===2&&eS(s,e,t,i,r,n):zl(Un(s),e,t,i,r,n,1);break}}}function Kb(s){const e=s.prev,t=s,i=s.next;if(Ft(e,t,i)>=0)return!1;const r=e.x,n=t.x,a=i.x,o=e.y,l=t.y,h=i.y,c=Math.min(r,n,a),d=Math.min(o,l,h),u=Math.max(r,n,a),p=Math.max(o,l,h);let m=i.next;for(;m!==e;){if(m.x>=c&&m.x<=u&&m.y>=d&&m.y<=p&&Bl(r,o,n,l,a,h,m.x,m.y)&&Ft(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function $b(s,e,t,i){const r=s.prev,n=s,a=s.next;if(Ft(r,n,a)>=0)return!1;const o=r.x,l=n.x,h=a.x,c=r.y,d=n.y,u=a.y,p=Math.min(o,l,h),m=Math.min(c,d,u),y=Math.max(o,l,h),g=Math.max(c,d,u),f=dm(p,m,e,t,i),x=dm(y,g,e,t,i);let v=s.prevZ,M=s.nextZ;for(;v&&v.z>=f&&M&&M.z<=x;){if(v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&Bl(o,c,l,d,h,u,v.x,v.y)&&Ft(v.prev,v,v.next)>=0||(v=v.prevZ,M.x>=p&&M.x<=y&&M.y>=m&&M.y<=g&&M!==r&&M!==a&&Bl(o,c,l,d,h,u,M.x,M.y)&&Ft(M.prev,M,M.next)>=0))return!1;M=M.nextZ}for(;v&&v.z>=f;){if(v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&Bl(o,c,l,d,h,u,v.x,v.y)&&Ft(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;M&&M.z<=x;){if(M.x>=p&&M.x<=y&&M.y>=m&&M.y<=g&&M!==r&&M!==a&&Bl(o,c,l,d,h,u,M.x,M.y)&&Ft(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function Qb(s,e){let t=s;do{const i=t.prev,r=t.next.next;!ka(i,r)&&ky(i,t,t.next,r)&&Vl(i,r)&&Vl(r,i)&&(e.push(i.i,t.i,r.i),kl(t),kl(t.next),t=s=r),t=t.next}while(t!==s);return Un(t)}function eS(s,e,t,i,r,n){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&hS(a,o)){let l=Gy(a,o);a=Un(a,a.next),l=Un(l,l.next),zl(a,e,t,i,r,n,0),zl(l,e,t,i,r,n,0);return}o=o.next}a=a.next}while(a!==s)}function tS(s,e,t,i){const r=[];for(let n=0,a=e.length;n<a;n++){const o=e[n]*i,l=n<a-1?e[n+1]*i:s.length,h=By(s,o,l,i,!1);h===h.next&&(h.steiner=!0),r.push(lS(h))}r.sort(iS);for(let n=0;n<r.length;n++)t=sS(r[n],t);return t}function iS(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const i=(s.next.y-s.y)/(s.next.x-s.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=i-r}return t}function sS(s,e){const t=rS(s,e);if(!t)return e;const i=Gy(t,s);return Un(i,i.next),Un(t,t.next)}function rS(s,e){let t=e;const i=s.x,r=s.y;let n=-1/0,a;if(ka(s,t))return t;do{if(ka(s,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const d=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>n&&(n=d,a=t.x<t.next.x?t:t.next,d===i))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,l=a.x,h=a.y;let c=1/0;t=a;do{if(i>=t.x&&t.x>=l&&i!==t.x&&Vy(r<h?i:n,r,l,h,r<h?n:i,r,t.x,t.y)){const d=Math.abs(r-t.y)/(i-t.x);Vl(t,s)&&(d<c||d===c&&(t.x>a.x||t.x===a.x&&nS(a,t)))&&(a=t,c=d)}t=t.next}while(t!==o);return a}function nS(s,e){return Ft(s.prev,s,e.prev)<0&&Ft(e.next,s,s.next)<0}function aS(s,e,t,i){let r=s;do r.z===0&&(r.z=dm(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,oS(r)}function oS(s){let e,t=1;do{let i=s,r;s=null;let n=null;for(e=0;i;){e++;let a=i,o=0;for(let h=0;h<t&&(o++,a=a.nextZ,!!a);h++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(r=i,i=i.nextZ,o--):(r=a,a=a.nextZ,l--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;i=a}n.nextZ=null,t*=2}while(e>1);return s}function dm(s,e,t,i,r){return s=(s-t)*r|0,e=(e-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function lS(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Vy(s,e,t,i,r,n,a,o){return(r-a)*(e-o)>=(s-a)*(n-o)&&(s-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(n-o)>=(r-a)*(i-o)}function Bl(s,e,t,i,r,n,a,o){return!(s===a&&e===o)&&Vy(s,e,t,i,r,n,a,o)}function hS(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!cS(s,e)&&(Vl(s,e)&&Vl(e,s)&&uS(s,e)&&(Ft(s.prev,s,e.prev)||Ft(s,e.prev,e))||ka(s,e)&&Ft(s.prev,s,s.next)>0&&Ft(e.prev,e,e.next)>0)}function Ft(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function ka(s,e){return s.x===e.x&&s.y===e.y}function ky(s,e,t,i){const r=ou(Ft(s,e,t)),n=ou(Ft(s,e,i)),a=ou(Ft(t,i,s)),o=ou(Ft(t,i,e));return!!(r!==n&&a!==o||r===0&&au(s,t,e)||n===0&&au(s,i,e)||a===0&&au(t,s,i)||o===0&&au(t,e,i))}function au(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function ou(s){return s>0?1:s<0?-1:0}function cS(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&ky(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Vl(s,e){return Ft(s.prev,s,s.next)<0?Ft(s,e,s.next)>=0&&Ft(s,s.prev,e)>=0:Ft(s,e,s.prev)<0||Ft(s,s.next,e)<0}function uS(s,e){let t=s,i=!1;const r=(s.x+e.x)/2,n=(s.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&r<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==s);return i}function Gy(s,e){const t=pm(s.i,s.x,s.y),i=pm(e.i,e.x,e.y),r=s.next,n=e.prev;return s.next=e,e.prev=s,t.next=r,r.prev=t,i.next=t,t.prev=i,n.next=i,i.prev=n,i}function Hy(s,e,t,i){const r=pm(s,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function kl(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function pm(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function dS(s,e,t,i){let r=0;for(let n=e,a=t-i;n<t;n+=i)r+=(s[a]-s[n])*(s[n+1]+s[a+1]),a=n;return r}class pS{static triangulate(e,t,i=2){return Jb(e,t,i)}}class ys{static area(e){const t=e.length;let i=0;for(let r=t-1,n=0;n<t;r=n++)i+=e[r].x*e[n].y-e[n].x*e[r].y;return i*.5}static isClockWise(e){return ys.area(e)<0}static triangulateShape(e,t){const i=[],r=[],n=[];Wy(e),jy(i,e);let a=e.length;t.forEach(Wy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,jy(i,t[l]);const o=pS.triangulate(i,r);for(let l=0;l<o.length;l+=3)n.push(o.slice(l,l+3));return n}}function Wy(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function jy(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Ch extends rt{constructor(e=new Zr([new te(.5,.5),new te(-.5,.5),new te(-.5,-.5),new te(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],n=[];for(let o=0,l=e.length;o<l;o++){const h=e[o];a(h)}this.setAttribute("position",new Ne(r,3)),this.setAttribute("uv",new Ne(n,2)),this.computeVertexNormals();function a(o){const l=[],h=t.curveSegments!==void 0?t.curveSegments:12,c=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let u=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const f=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:mS;let v,M=!1,w,T,A,_;if(f){v=f.getSpacedPoints(c),M=!0,u=!1;const Q=f.isCatmullRomCurve3?f.closed:!1;w=f.computeFrenetFrames(c,Q),T=new R,A=new R,_=new R}u||(g=0,p=0,m=0,y=0);const S=o.extractPoints(h);let P=S.shape;const C=S.holes;if(!ys.isClockWise(P)){P=P.reverse();for(let Q=0,ee=C.length;Q<ee;Q++){const he=C[Q];ys.isClockWise(he)&&(C[Q]=he.reverse())}}function L(Q){const ee=10000000000000001e-36;let he=Q[0];for(let _e=1;_e<=Q.length;_e++){const Se=_e%Q.length,I=Q[Se],Ge=I.x-he.x,We=I.y-he.y,Je=Ge*Ge+We*We,fe=Math.max(Math.abs(I.x),Math.abs(I.y),Math.abs(he.x),Math.abs(he.y)),N=ee*fe*fe;if(Je<=N){Q.splice(Se,1),_e--;continue}he=I}}L(P),C.forEach(L);const U=C.length,V=P;for(let Q=0;Q<U;Q++){const ee=C[Q];P=P.concat(ee)}function B(Q,ee,he){return ee||Ve("ExtrudeGeometry: vec does not exist"),Q.clone().addScaledVector(ee,he)}const k=P.length;function W(Q,ee,he){let _e,Se,I;const Ge=Q.x-ee.x,We=Q.y-ee.y,Je=he.x-Q.x,fe=he.y-Q.y,N=Ge*Ge+We*We,b=Ge*fe-We*Je;if(Math.abs(b)>Number.EPSILON){const D=Math.sqrt(N),Z=Math.sqrt(Je*Je+fe*fe),$=ee.x-We/D,J=ee.y+Ge/D,Oe=he.x-fe/Z,pe=he.y+Je/Z,He=((Oe-$)*fe-(pe-J)*Je)/(Ge*fe-We*Je);_e=$+Ge*He-Q.x,Se=J+We*He-Q.y;const Be=_e*_e+Se*Se;if(Be<=2)return new te(_e,Se);I=Math.sqrt(Be/2)}else{let D=!1;Ge>Number.EPSILON?Je>Number.EPSILON&&(D=!0):Ge<-Number.EPSILON?Je<-Number.EPSILON&&(D=!0):Math.sign(We)===Math.sign(fe)&&(D=!0),D?(_e=-We,Se=Ge,I=Math.sqrt(N)):(_e=Ge,Se=We,I=Math.sqrt(N/2))}return new te(_e/I,Se/I)}const se=[];for(let Q=0,ee=V.length,he=ee-1,_e=Q+1;Q<ee;Q++,he++,_e++)he===ee&&(he=0),_e===ee&&(_e=0),se[Q]=W(V[Q],V[he],V[_e]);const ie=[];let oe,be=se.concat();for(let Q=0,ee=U;Q<ee;Q++){const he=C[Q];oe=[];for(let _e=0,Se=he.length,I=Se-1,Ge=_e+1;_e<Se;_e++,I++,Ge++)I===Se&&(I=0),Ge===Se&&(Ge=0),oe[_e]=W(he[_e],he[I],he[Ge]);ie.push(oe),be=be.concat(oe)}let Ce;if(g===0)Ce=ys.triangulateShape(V,C);else{const Q=[],ee=[];for(let he=0;he<g;he++){const _e=he/g,Se=p*Math.cos(_e*Math.PI/2),I=m*Math.sin(_e*Math.PI/2)+y;for(let Ge=0,We=V.length;Ge<We;Ge++){const Je=B(V[Ge],se[Ge],I);le(Je.x,Je.y,-Se),_e===0&&Q.push(Je)}for(let Ge=0,We=U;Ge<We;Ge++){const Je=C[Ge];oe=ie[Ge];const fe=[];for(let N=0,b=Je.length;N<b;N++){const D=B(Je[N],oe[N],I);le(D.x,D.y,-Se),_e===0&&fe.push(D)}_e===0&&ee.push(fe)}}Ce=ys.triangulateShape(Q,ee)}const tt=Ce.length,wt=m+y;for(let Q=0;Q<k;Q++){const ee=u?B(P[Q],be[Q],wt):P[Q];M?(A.copy(w.normals[0]).multiplyScalar(ee.x),T.copy(w.binormals[0]).multiplyScalar(ee.y),_.copy(v[0]).add(A).add(T),le(_.x,_.y,_.z)):le(ee.x,ee.y,0)}for(let Q=1;Q<=c;Q++)for(let ee=0;ee<k;ee++){const he=u?B(P[ee],be[ee],wt):P[ee];M?(A.copy(w.normals[Q]).multiplyScalar(he.x),T.copy(w.binormals[Q]).multiplyScalar(he.y),_.copy(v[Q]).add(A).add(T),le(_.x,_.y,_.z)):le(he.x,he.y,d/c*Q)}for(let Q=g-1;Q>=0;Q--){const ee=Q/g,he=p*Math.cos(ee*Math.PI/2),_e=m*Math.sin(ee*Math.PI/2)+y;for(let Se=0,I=V.length;Se<I;Se++){const Ge=B(V[Se],se[Se],_e);le(Ge.x,Ge.y,d+he)}for(let Se=0,I=C.length;Se<I;Se++){const Ge=C[Se];oe=ie[Se];for(let We=0,Je=Ge.length;We<Je;We++){const fe=B(Ge[We],oe[We],_e);M?le(fe.x,fe.y+v[c-1].y,v[c-1].x+he):le(fe.x,fe.y,d+he)}}}Et(),K();function Et(){const Q=r.length/3;if(u){let ee=0,he=k*ee;for(let _e=0;_e<tt;_e++){const Se=Ce[_e];Qe(Se[2]+he,Se[1]+he,Se[0]+he)}ee=c+g*2,he=k*ee;for(let _e=0;_e<tt;_e++){const Se=Ce[_e];Qe(Se[0]+he,Se[1]+he,Se[2]+he)}}else{for(let ee=0;ee<tt;ee++){const he=Ce[ee];Qe(he[2],he[1],he[0])}for(let ee=0;ee<tt;ee++){const he=Ce[ee];Qe(he[0]+k*c,he[1]+k*c,he[2]+k*c)}}i.addGroup(Q,r.length/3-Q,0)}function K(){const Q=r.length/3;let ee=0;ae(V,ee),ee+=V.length;for(let he=0,_e=C.length;he<_e;he++){const Se=C[he];ae(Se,ee),ee+=Se.length}i.addGroup(Q,r.length/3-Q,1)}function ae(Q,ee){let he=Q.length;for(;--he>=0;){const _e=he;let Se=he-1;Se<0&&(Se=Q.length-1);for(let I=0,Ge=c+g*2;I<Ge;I++){const We=k*I,Je=k*(I+1),fe=ee+_e+We,N=ee+Se+We,b=ee+Se+Je,D=ee+_e+Je;Ye(fe,N,b,D)}}}function le(Q,ee,he){l.push(Q),l.push(ee),l.push(he)}function Qe(Q,ee,he){Te(Q),Te(ee),Te(he);const _e=r.length/3,Se=x.generateTopUV(i,r,_e-3,_e-2,_e-1);ct(Se[0]),ct(Se[1]),ct(Se[2])}function Ye(Q,ee,he,_e){Te(Q),Te(ee),Te(_e),Te(ee),Te(he),Te(_e);const Se=r.length/3,I=x.generateSideWallUV(i,r,Se-6,Se-3,Se-2,Se-1);ct(I[0]),ct(I[1]),ct(I[3]),ct(I[1]),ct(I[2]),ct(I[3])}function Te(Q){r.push(l[Q*3+0]),r.push(l[Q*3+1]),r.push(l[Q*3+2])}function ct(Q){n.push(Q.x),n.push(Q.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return fS(t,i,e)}static fromJSON(e,t){const i=[];for(let n=0,a=e.shapes.length;n<a;n++){const o=t[e.shapes[n]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new ru[r.type]().fromJSON(r)),new Ch(i,e.options)}}const mS={generateTopUV:function(s,e,t,i,r){const n=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],h=e[r*3],c=e[r*3+1];return[new te(n,a),new te(o,l),new te(h,c)]},generateSideWallUV:function(s,e,t,i,r,n){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],h=e[i*3],c=e[i*3+1],d=e[i*3+2],u=e[r*3],p=e[r*3+1],m=e[r*3+2],y=e[n*3],g=e[n*3+1],f=e[n*3+2];return Math.abs(o-c)<Math.abs(a-h)?[new te(a,1-l),new te(h,1-d),new te(u,1-m),new te(y,1-f)]:[new te(o,1-l),new te(c,1-d),new te(p,1-m),new te(g,1-f)]}};function fS(s,e,t){if(t.shapes=[],Array.isArray(s))for(let i=0,r=s.length;i<r;i++){const n=s[i];t.shapes.push(n.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Ud extends pn{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,n,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ud(e.radius,e.detail)}}class Fd extends rt{constructor(e=[new te(0,-.5),new te(.5,0),new te(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Ke(r,0,Math.PI*2);const n=[],a=[],o=[],l=[],h=[],c=1/t,d=new R,u=new te,p=new R,m=new R,y=new R;let g=0,f=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:g=e[x+1].x-e[x].x,f=e[x+1].y-e[x].y,p.x=f*1,p.y=-g,p.z=f*0,y.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(y.x,y.y,y.z);break;default:g=e[x+1].x-e[x].x,f=e[x+1].y-e[x].y,p.x=f*1,p.y=-g,p.z=f*0,m.copy(p),p.x+=y.x,p.y+=y.y,p.z+=y.z,p.normalize(),l.push(p.x,p.y,p.z),y.copy(m)}for(let x=0;x<=t;x++){const v=i+x*c*r,M=Math.sin(v),w=Math.cos(v);for(let T=0;T<=e.length-1;T++){d.x=e[T].x*M,d.y=e[T].y,d.z=e[T].x*w,a.push(d.x,d.y,d.z),u.x=x/t,u.y=T/(e.length-1),o.push(u.x,u.y);const A=l[3*T+0]*M,_=l[3*T+1],S=l[3*T+0]*w;h.push(A,_,S)}}for(let x=0;x<t;x++)for(let v=0;v<e.length-1;v++){const M=v+x*e.length,w=M,T=M+e.length,A=M+e.length+1,_=M+1;n.push(w,T,_),n.push(A,_,T)}this.setIndex(n),this.setAttribute("position",new Ne(a,3)),this.setAttribute("uv",new Ne(o,2)),this.setAttribute("normal",new Ne(h,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fd(e.points,e.segments,e.phiStart,e.phiLength)}}class Io extends pn{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Io(e.radius,e.detail)}}class na extends rt{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const n=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),h=o+1,c=l+1,d=e/o,u=t/l,p=[],m=[],y=[],g=[];for(let f=0;f<c;f++){const x=f*u-a;for(let v=0;v<h;v++){const M=v*d-n;m.push(M,-x,0),y.push(0,0,1),g.push(v/o),g.push(1-f/l)}}for(let f=0;f<l;f++)for(let x=0;x<o;x++){const v=x+h*f,M=x+h*(f+1),w=x+1+h*(f+1),T=x+1+h*f;p.push(v,M,T),p.push(M,w,T)}this.setIndex(p),this.setAttribute("position",new Ne(m,3)),this.setAttribute("normal",new Ne(y,3)),this.setAttribute("uv",new Ne(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new na(e.width,e.height,e.widthSegments,e.heightSegments)}}class Rh extends rt{constructor(e=.5,t=1,i=32,r=1,n=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],h=[],c=[];let d=e;const u=(t-e)/r,p=new R,m=new te;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){const f=n+g/i*a;p.x=d*Math.cos(f),p.y=d*Math.sin(f),l.push(p.x,p.y,p.z),h.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,c.push(m.x,m.y)}d+=u}for(let y=0;y<r;y++){const g=y*(i+1);for(let f=0;f<i;f++){const x=f+g,v=x,M=x+i+1,w=x+i+2,T=x+1;o.push(v,M,T),o.push(M,w,T)}}this.setIndex(o),this.setAttribute("position",new Ne(l,3)),this.setAttribute("normal",new Ne(h,3)),this.setAttribute("uv",new Ne(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rh(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class zd extends rt{constructor(e=new Zr([new te(0,.5),new te(-.5,-.5),new te(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],n=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)h(e);else for(let c=0;c<e.length;c++)h(e[c]),this.addGroup(o,l,c),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new Ne(r,3)),this.setAttribute("normal",new Ne(n,3)),this.setAttribute("uv",new Ne(a,2));function h(c){const d=r.length/3,u=c.extractPoints(t);let p=u.shape;const m=u.holes;ys.isClockWise(p)===!1&&(p=p.reverse());for(let g=0,f=m.length;g<f;g++){const x=m[g];ys.isClockWise(x)===!0&&(m[g]=x.reverse())}const y=ys.triangulateShape(p,m);for(let g=0,f=m.length;g<f;g++){const x=m[g];p=p.concat(x)}for(let g=0,f=p.length;g<f;g++){const x=p[g];r.push(x.x,x.y,0),n.push(0,0,1),a.push(x.x,x.y)}for(let g=0,f=y.length;g<f;g++){const x=y[g],v=x[0]+d,M=x[1]+d,w=x[2]+d;i.push(v,M,w),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return gS(t,e)}static fromJSON(e,t){const i=[];for(let r=0,n=e.shapes.length;r<n;r++){const a=t[e.shapes[r]];i.push(a)}return new zd(i,e.curveSegments)}}function gS(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,i=s.length;t<i;t++){const r=s[t];e.shapes.push(r.uuid)}else e.shapes.push(s.uuid);return e}class Po extends rt{constructor(e=1,t=32,i=16,r=0,n=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:n,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let h=0;const c=[],d=new R,u=new R,p=[],m=[],y=[],g=[];for(let f=0;f<=i;f++){const x=[],v=f/i;let M=0;f===0&&a===0?M=.5/t:f===i&&l===Math.PI&&(M=-.5/t);for(let w=0;w<=t;w++){const T=w/t;d.x=-e*Math.cos(r+T*n)*Math.sin(a+v*o),d.y=e*Math.cos(a+v*o),d.z=e*Math.sin(r+T*n)*Math.sin(a+v*o),m.push(d.x,d.y,d.z),u.copy(d).normalize(),y.push(u.x,u.y,u.z),g.push(T+M,1-v),x.push(h++)}c.push(x)}for(let f=0;f<i;f++)for(let x=0;x<t;x++){const v=c[f][x+1],M=c[f][x],w=c[f+1][x],T=c[f+1][x+1];(f!==0||a>0)&&p.push(v,M,T),(f!==i-1||l<Math.PI)&&p.push(M,w,T)}this.setIndex(p),this.setAttribute("position",new Ne(m,3)),this.setAttribute("normal",new Ne(y,3)),this.setAttribute("uv",new Ne(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Po(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Bd extends pn{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Bd(e.radius,e.detail)}}class Ih extends rt{constructor(e=1,t=.4,i=12,r=48,n=Math.PI*2,a=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:n,thetaStart:a,thetaLength:o},i=Math.floor(i),r=Math.floor(r);const l=[],h=[],c=[],d=[],u=new R,p=new R,m=new R;for(let y=0;y<=i;y++){const g=a+y/i*o;for(let f=0;f<=r;f++){const x=f/r*n;p.x=(e+t*Math.cos(g))*Math.cos(x),p.y=(e+t*Math.cos(g))*Math.sin(x),p.z=t*Math.sin(g),h.push(p.x,p.y,p.z),u.x=e*Math.cos(x),u.y=e*Math.sin(x),m.subVectors(p,u).normalize(),c.push(m.x,m.y,m.z),d.push(f/r),d.push(y/i)}}for(let y=1;y<=i;y++)for(let g=1;g<=r;g++){const f=(r+1)*y+g-1,x=(r+1)*(y-1)+g-1,v=(r+1)*(y-1)+g,M=(r+1)*y+g;l.push(f,x,M),l.push(x,v,M)}this.setIndex(l),this.setAttribute("position",new Ne(h,3)),this.setAttribute("normal",new Ne(c,3)),this.setAttribute("uv",new Ne(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ih(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Vd extends rt{constructor(e=1,t=.4,i=64,r=8,n=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:n,q:a},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],h=[],c=[],d=new R,u=new R,p=new R,m=new R,y=new R,g=new R,f=new R;for(let v=0;v<=i;++v){const M=v/i*n*Math.PI*2;x(M,n,a,e,p),x(M+.01,n,a,e,m),g.subVectors(m,p),f.addVectors(m,p),y.crossVectors(g,f),f.crossVectors(y,g),y.normalize(),f.normalize();for(let w=0;w<=r;++w){const T=w/r*Math.PI*2,A=-t*Math.cos(T),_=t*Math.sin(T);d.x=p.x+(A*f.x+_*y.x),d.y=p.y+(A*f.y+_*y.y),d.z=p.z+(A*f.z+_*y.z),l.push(d.x,d.y,d.z),u.subVectors(d,p).normalize(),h.push(u.x,u.y,u.z),c.push(v/i),c.push(w/r)}}for(let v=1;v<=i;v++)for(let M=1;M<=r;M++){const w=(r+1)*(v-1)+(M-1),T=(r+1)*v+(M-1),A=(r+1)*v+M,_=(r+1)*(v-1)+M;o.push(w,T,_),o.push(T,A,_)}this.setIndex(o),this.setAttribute("position",new Ne(l,3)),this.setAttribute("normal",new Ne(h,3)),this.setAttribute("uv",new Ne(c,2));function x(v,M,w,T,A){const _=Math.cos(v),S=Math.sin(v),P=w/M*v,C=Math.cos(P);A.x=T*(2+C)*.5*_,A.y=T*(2+C)*S*.5,A.z=T*Math.sin(P)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class kd extends rt{constructor(e=new cm(new R(-1,-1,0),new R(-1,1,0),new R(1,1,0)),t=64,i=1,r=8,n=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n};const a=e.computeFrenetFrames(t,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new R,l=new R,h=new te;let c=new R;const d=[],u=[],p=[],m=[];y(),this.setIndex(m),this.setAttribute("position",new Ne(d,3)),this.setAttribute("normal",new Ne(u,3)),this.setAttribute("uv",new Ne(p,2));function y(){for(let v=0;v<t;v++)g(v);g(n===!1?t:0),x(),f()}function g(v){c=e.getPointAt(v/t,c);const M=a.normals[v],w=a.binormals[v];for(let T=0;T<=r;T++){const A=T/r*Math.PI*2,_=Math.sin(A),S=-Math.cos(A);l.x=S*M.x+_*w.x,l.y=S*M.y+_*w.y,l.z=S*M.z+_*w.z,l.normalize(),u.push(l.x,l.y,l.z),o.x=c.x+i*l.x,o.y=c.y+i*l.y,o.z=c.z+i*l.z,d.push(o.x,o.y,o.z)}}function f(){for(let v=1;v<=t;v++)for(let M=1;M<=r;M++){const w=(r+1)*(v-1)+(M-1),T=(r+1)*v+(M-1),A=(r+1)*v+M,_=(r+1)*(v-1)+M;m.push(w,T,_),m.push(T,A,_)}}function x(){for(let v=0;v<=t;v++)for(let M=0;M<=r;M++)h.x=v/t,h.y=M/r,p.push(h.x,h.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new kd(new ru[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class mm extends rt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new R,n=new R;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let h=0,c=l.length;h<c;++h){const d=l[h],u=d.start,p=d.count;for(let m=u,y=u+p;m<y;m+=3)for(let g=0;g<3;g++){const f=o.getX(m+g),x=o.getX(m+(g+1)%3);r.fromBufferAttribute(a,f),n.fromBufferAttribute(a,x),Xy(r,n,i)===!0&&(t.push(r.x,r.y,r.z),t.push(n.x,n.y,n.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let h=0;h<3;h++){const c=3*o+h,d=3*o+(h+1)%3;r.fromBufferAttribute(a,c),n.fromBufferAttribute(a,d),Xy(r,n,i)===!0&&(t.push(r.x,r.y,r.z),t.push(n.x,n.y,n.z))}}this.setAttribute("position",new Ne(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Xy(s,e,t){const i=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var qy=Object.freeze({__proto__:null,BoxGeometry:dn,CapsuleGeometry:Ld,CircleGeometry:Dd,ConeGeometry:Nh,CylinderGeometry:Ro,DodecahedronGeometry:Od,EdgesGeometry:tm,ExtrudeGeometry:Ch,IcosahedronGeometry:Ud,LatheGeometry:Fd,OctahedronGeometry:Io,PlaneGeometry:na,PolyhedronGeometry:pn,RingGeometry:Rh,ShapeGeometry:zd,SphereGeometry:Po,TetrahedronGeometry:Bd,TorusGeometry:Ih,TorusKnotGeometry:Vd,TubeGeometry:kd,WireframeGeometry:mm});class fm extends pi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new we(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}function Ga(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const r=s[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(ge("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Di(s){const e={};for(let t=0;t<s.length;t++){const i=Ga(s[t]);for(const r in i)e[r]=i[r]}return e}function yS(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Yy(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:mt.workingColorSpace}const gm={clone:Ga,merge:Di};var xS=`void main() {
|
|
1
|
+
const yn="183.2",Hg={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Wg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},jg=0,Yd=1,Xg=2,pM=3,mM=0,ha=1,qg=2,ca=3,Vs=0,yi=1,Ms=2,bs=0,Or=1,Dh=2,Zd=3,Jd=4,Kd=5,fM=6,Ur=100,Yg=101,Zg=102,Jg=103,$d=104,Kg=200,$g=201,Qg=202,e0=203,Oh=204,Uh=205,t0=206,i0=207,s0=208,r0=209,n0=210,a0=211,o0=212,l0=213,h0=214,Uo=0,Fo=1,zo=2,Fr=3,Bo=4,Vo=5,ko=6,Go=7,Ho=0,c0=1,u0=2,rs=0,Fh=1,zh=2,Qd=3,Bh=4,ep=5,Vh=6,kh=7,tp="attached",d0="detached",Gh=300,ks=301,zr=302,ua=303,da=304,xn=306,pa=1e3,Ci=1001,ma=1002,Ht=1003,Hh=1004,p0=1004,vn=1005,gM=1005,Rt=1006,fa=1007,yM=1007,Ss=1008,m0=1008,Ri=1009,ip=1010,sp=1011,ga=1012,Wh=1013,qi=1014,xi=1015,Ts=1016,jh=1017,Xh=1018,_n=1020,qh=35902,Yh=35899,rp=1021,Zh=1022,vi=1023,ws=1026,ur=1027,Wo=1028,ya=1029,Br=1030,jo=1031,xM=1032,Xo=1033,xa=33776,va=33777,qo=33778,_a=33779,Yo=35840,Jh=35841,Zo=35842,Jo=35843,Ko=36196,$o=37492,Qo=37496,el=37488,tl=37489,il=37490,sl=37491,rl=37808,Kh=37809,$h=37810,Qh=37811,nl=37812,ec=37813,tc=37814,ic=37815,sc=37816,rc=37817,nc=37818,ac=37819,oc=37820,lc=37821,al=36492,hc=36494,ol=36495,ll=36283,hl=36284,cl=36285,ul=36286,np=2200,ap=2201,f0=2202,Ma=2300,dl=2301,cc=2302,op=2303,Mn=2400,bn=2401,pl=2402,uc=2500,lp=2501,g0=0,y0=1,x0=2,hp=3200,v0=3201,vM=3202,_M=3203,Vr=0,_0=1,Gs="",Ii="srgb",kr="srgb-linear",ml="linear",vt="srgb",MM="",bM="rg",SM="ga",M0=0,Gr=7680,b0=7681,S0=7682,T0=7683,w0=34055,E0=34056,A0=5386,N0=512,C0=513,R0=514,I0=515,P0=516,L0=517,D0=518,dc=519,O0=512,U0=513,F0=514,pc=515,z0=516,B0=517,mc=518,V0=519,fl=35044,k0=35048,TM=35040,wM=35045,EM=35049,AM=35041,NM=35046,CM=35050,RM=35042,IM="100",fc="300 es",Yi=2e3,Sn=2001,PM={COMPUTE:"compute",RENDER:"render"},LM={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},DM={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},OM={TEXTURE_COMPARE:"depthTextureCompare"};function UM(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const FM={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ba(s,e){return new FM[s](e)}function G0(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function gl(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function H0(){const s=gl("canvas");return s.style.display="block",s}const W0={};let Hr=null;function zM(s){Hr=s}function BM(){return Hr}function yl(...s){const e="THREE."+s.shift();Hr?Hr("log",e,...s):console.log(e,...s)}function j0(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function ge(...s){s=j0(s);const e="THREE."+s.shift();if(Hr)Hr("warn",e,...s);else{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function Ve(...s){s=j0(s);const e="THREE."+s.shift();if(Hr)Hr("error",e,...s);else{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function xl(...s){const e=s.join(" ");e in W0||(W0[e]=!0,ge(...s))}function VM(s,e,t){return new Promise(function(i,r){function n(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:r();break;case s.TIMEOUT_EXPIRED:setTimeout(n,t);break;default:i()}}setTimeout(n,t)})}const kM={[Uo]:Fo,[zo]:ko,[Bo]:Go,[Fr]:Vo,[Fo]:Uo,[ko]:zo,[Go]:Bo,[Vo]:Fr};let Es=class{addEventListener(s,e){this._listeners===void 0&&(this._listeners={});const t=this._listeners;t[s]===void 0&&(t[s]=[]),t[s].indexOf(e)===-1&&t[s].push(e)}hasEventListener(s,e){const t=this._listeners;return t===void 0?!1:t[s]!==void 0&&t[s].indexOf(e)!==-1}removeEventListener(s,e){const t=this._listeners;if(t===void 0)return;const i=t[s];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(s){const e=this._listeners;if(e===void 0)return;const t=e[s.type];if(t!==void 0){s.target=this;const i=t.slice(0);for(let r=0,n=i.length;r<n;r++)i[r].call(this,s);s.target=null}}};const _i=["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 X0=1234567;const Tn=Math.PI/180,Sa=180/Math.PI;function Zi(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(_i[s&255]+_i[s>>8&255]+_i[s>>16&255]+_i[s>>24&255]+"-"+_i[e&255]+_i[e>>8&255]+"-"+_i[e>>16&15|64]+_i[e>>24&255]+"-"+_i[t&63|128]+_i[t>>8&255]+"-"+_i[t>>16&255]+_i[t>>24&255]+_i[i&255]+_i[i>>8&255]+_i[i>>16&255]+_i[i>>24&255]).toLowerCase()}function Ke(s,e,t){return Math.max(e,Math.min(t,s))}function cp(s,e){return(s%e+e)%e}function GM(s,e,t,i,r){return i+(s-e)*(r-i)/(t-e)}function HM(s,e,t){return s!==e?(t-s)/(e-s):0}function vl(s,e,t){return(1-t)*s+t*e}function WM(s,e,t,i){return vl(s,e,1-Math.exp(-t*i))}function jM(s,e=1){return e-Math.abs(cp(s,e*2)-e)}function XM(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function qM(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function YM(s,e){return s+Math.floor(Math.random()*(e-s+1))}function ZM(s,e){return s+Math.random()*(e-s)}function JM(s){return s*(.5-Math.random())}function KM(s){s!==void 0&&(X0=s);let e=X0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function $M(s){return s*Tn}function QM(s){return s*Sa}function eb(s){return(s&s-1)===0&&s!==0}function tb(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function ib(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function sb(s,e,t,i,r){const n=Math.cos,a=Math.sin,o=n(t/2),l=a(t/2),h=n((e+i)/2),c=a((e+i)/2),d=n((e-i)/2),u=a((e-i)/2),p=n((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":s.set(o*c,l*d,l*u,o*h);break;case"YZY":s.set(l*u,o*c,l*d,o*h);break;case"ZXZ":s.set(l*d,l*u,o*c,o*h);break;case"XZX":s.set(o*c,l*m,l*p,o*h);break;case"YXY":s.set(l*p,o*c,l*m,o*h);break;case"ZYZ":s.set(l*m,l*p,o*c,o*h);break;default:ge("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Pi(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function nt(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const q0={DEG2RAD:Tn,RAD2DEG:Sa,generateUUID:Zi,clamp:Ke,euclideanModulo:cp,mapLinear:GM,inverseLerp:HM,lerp:vl,damp:WM,pingpong:jM,smoothstep:XM,smootherstep:qM,randInt:YM,randFloat:ZM,randFloatSpread:JM,seededRandom:KM,degToRad:$M,radToDeg:QM,isPowerOfTwo:eb,ceilPowerOfTwo:tb,floorPowerOfTwo:ib,setQuaternionFromProperEuler:sb,normalize:nt,denormalize:Pi};let te=class K1{constructor(e=0,t=0){K1.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ke(i,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Ke(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*r+e.x,this.y=n*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Mi=class{constructor(s=0,e=0,t=0,i=1){this.isQuaternion=!0,this._x=s,this._y=e,this._z=t,this._w=i}static slerpFlat(s,e,t,i,r,n,a){let o=t[i+0],l=t[i+1],h=t[i+2],c=t[i+3],d=r[n+0],u=r[n+1],p=r[n+2],m=r[n+3];if(c!==m||o!==d||l!==u||h!==p){let y=o*d+l*u+h*p+c*m;y<0&&(d=-d,u=-u,p=-p,m=-m,y=-y);let g=1-a;if(y<.9995){const f=Math.acos(y),x=Math.sin(f);g=Math.sin(g*f)/x,a=Math.sin(a*f)/x,o=o*g+d*a,l=l*g+u*a,h=h*g+p*a,c=c*g+m*a}else{o=o*g+d*a,l=l*g+u*a,h=h*g+p*a,c=c*g+m*a;const f=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=f,l*=f,h*=f,c*=f}}s[e]=o,s[e+1]=l,s[e+2]=h,s[e+3]=c}static multiplyQuaternionsFlat(s,e,t,i,r,n){const a=t[i],o=t[i+1],l=t[i+2],h=t[i+3],c=r[n],d=r[n+1],u=r[n+2],p=r[n+3];return s[e]=a*p+h*c+o*u-l*d,s[e+1]=o*p+h*d+l*c-a*u,s[e+2]=l*p+h*u+a*d-o*c,s[e+3]=h*p-a*c-o*d-l*u,s}get x(){return this._x}set x(s){this._x=s,this._onChangeCallback()}get y(){return this._y}set y(s){this._y=s,this._onChangeCallback()}get z(){return this._z}set z(s){this._z=s,this._onChangeCallback()}get w(){return this._w}set w(s){this._w=s,this._onChangeCallback()}set(s,e,t,i){return this._x=s,this._y=e,this._z=t,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(s){return this._x=s.x,this._y=s.y,this._z=s.z,this._w=s.w,this._onChangeCallback(),this}setFromEuler(s,e=!0){const t=s._x,i=s._y,r=s._z,n=s._order,a=Math.cos,o=Math.sin,l=a(t/2),h=a(i/2),c=a(r/2),d=o(t/2),u=o(i/2),p=o(r/2);switch(n){case"XYZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"YXZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"ZXY":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"ZYX":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"YZX":this._x=d*h*c+l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c-d*u*p;break;case"XZY":this._x=d*h*c-l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c+d*u*p;break;default:ge("Quaternion: .setFromEuler() encountered an unknown order: "+n)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(s,e){const t=e/2,i=Math.sin(t);return this._x=s.x*i,this._y=s.y*i,this._z=s.z*i,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(s){const e=s.elements,t=e[0],i=e[4],r=e[8],n=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],d=t+a+c;if(d>0){const u=.5/Math.sqrt(d+1);this._w=.25/u,this._x=(h-o)*u,this._y=(r-l)*u,this._z=(n-i)*u}else if(t>a&&t>c){const u=2*Math.sqrt(1+t-a-c);this._w=(h-o)/u,this._x=.25*u,this._y=(i+n)/u,this._z=(r+l)/u}else if(a>c){const u=2*Math.sqrt(1+a-t-c);this._w=(r-l)/u,this._x=(i+n)/u,this._y=.25*u,this._z=(o+h)/u}else{const u=2*Math.sqrt(1+c-t-a);this._w=(n-i)/u,this._x=(r+l)/u,this._y=(o+h)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(s,e){let t=s.dot(e)+1;return t<1e-8?(t=0,Math.abs(s.x)>Math.abs(s.z)?(this._x=-s.y,this._y=s.x,this._z=0,this._w=t):(this._x=0,this._y=-s.z,this._z=s.y,this._w=t)):(this._x=s.y*e.z-s.z*e.y,this._y=s.z*e.x-s.x*e.z,this._z=s.x*e.y-s.y*e.x,this._w=t),this.normalize()}angleTo(s){return 2*Math.acos(Math.abs(Ke(this.dot(s),-1,1)))}rotateTowards(s,e){const t=this.angleTo(s);if(t===0)return this;const i=Math.min(1,e/t);return this.slerp(s,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(s){return this._x*s._x+this._y*s._y+this._z*s._z+this._w*s._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 s=this.length();return s===0?(this._x=0,this._y=0,this._z=0,this._w=1):(s=1/s,this._x=this._x*s,this._y=this._y*s,this._z=this._z*s,this._w=this._w*s),this._onChangeCallback(),this}multiply(s){return this.multiplyQuaternions(this,s)}premultiply(s){return this.multiplyQuaternions(s,this)}multiplyQuaternions(s,e){const t=s._x,i=s._y,r=s._z,n=s._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=t*h+n*a+i*l-r*o,this._y=i*h+n*o+r*a-t*l,this._z=r*h+n*l+t*o-i*a,this._w=n*h-t*a-i*o-r*l,this._onChangeCallback(),this}slerp(s,e){let t=s._x,i=s._y,r=s._z,n=s._w,a=this.dot(s);a<0&&(t=-t,i=-i,r=-r,n=-n,a=-a);let o=1-e;if(a<.9995){const l=Math.acos(a),h=Math.sin(l);o=Math.sin(o*l)/h,e=Math.sin(e*l)/h,this._x=this._x*o+t*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+n*e,this._onChangeCallback()}else this._x=this._x*o+t*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+n*e,this.normalize();return this}slerpQuaternions(s,e,t){return this.copy(s).slerp(e,t)}random(){const s=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),t=Math.random(),i=Math.sqrt(1-t),r=Math.sqrt(t);return this.set(i*Math.sin(s),i*Math.cos(s),r*Math.sin(e),r*Math.cos(e))}equals(s){return s._x===this._x&&s._y===this._y&&s._z===this._z&&s._w===this._w}fromArray(s,e=0){return this._x=s[e],this._y=s[e+1],this._z=s[e+2],this._w=s[e+3],this._onChangeCallback(),this}toArray(s=[],e=0){return s[e]=this._x,s[e+1]=this._y,s[e+2]=this._z,s[e+3]=this._w,s}fromBufferAttribute(s,e){return this._x=s.getX(e),this._y=s.getY(e),this._z=s.getZ(e),this._w=s.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(s){return this._onChangeCallback=s,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},R=class $1{constructor(e=0,t=0,i=0){$1.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Y0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Y0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=e.elements,a=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*r-o*i),c=2*(o*t-n*r),d=2*(n*i-a*t);return this.x=t+l*h+a*d-o*c,this.y=i+l*c+o*h-n*d,this.z=r+l*d+n*c-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ke(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,n=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-n*o,this.y=n*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return up.copy(this).projectOnVector(e),this.sub(up)}reflect(e){return this.sub(up.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Ke(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const up=new R,Y0=new Mi;let at=class Q1{constructor(e,t,i,r,n,a,o,l,h){Q1.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,h)}set(e,t,i,r,n,a,o,l,h){const c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=t,c[4]=n,c[5]=l,c[6]=i,c[7]=a,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[3],l=i[6],h=i[1],c=i[4],d=i[7],u=i[2],p=i[5],m=i[8],y=r[0],g=r[3],f=r[6],x=r[1],v=r[4],M=r[7],w=r[2],T=r[5],A=r[8];return n[0]=a*y+o*x+l*w,n[3]=a*g+o*v+l*T,n[6]=a*f+o*M+l*A,n[1]=h*y+c*x+d*w,n[4]=h*g+c*v+d*T,n[7]=h*f+c*M+d*A,n[2]=u*y+p*x+m*w,n[5]=u*g+p*v+m*T,n[8]=u*f+p*M+m*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8];return t*a*c-t*o*h-i*n*c+i*o*l+r*n*h-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],d=c*a-o*h,u=o*l-c*n,p=h*n-a*l,m=t*d+i*u+r*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return e[0]=d*y,e[1]=(r*h-c*i)*y,e[2]=(o*i-r*a)*y,e[3]=u*y,e[4]=(c*t-r*l)*y,e[5]=(r*n-o*t)*y,e[6]=p*y,e[7]=(i*l-h*t)*y,e[8]=(a*t-i*n)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,n,a,o){const l=Math.cos(n),h=Math.sin(n);return this.set(i*l,i*h,-i*(l*a+h*o)+a+e,-r*h,r*l,-r*(-h*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(dp.makeScale(e,t)),this}rotate(e){return this.premultiply(dp.makeRotation(-e)),this}translate(e,t){return this.premultiply(dp.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const dp=new at,Z0=new at().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),J0=new at().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rb(){const s={enabled:!0,workingColorSpace:kr,spaces:{},convert:function(r,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===vt&&(r.r=dr(r.r),r.g=dr(r.g),r.b=dr(r.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[n].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===vt&&(r.r=Ta(r.r),r.g=Ta(r.g),r.b=Ta(r.b))),r},workingToColorSpace:function(r,n){return this.convert(r,this.workingColorSpace,n)},colorSpaceToWorking:function(r,n){return this.convert(r,n,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Gs?ml:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,n=this.workingColorSpace){return r.fromArray(this.spaces[n].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,n,a){return r.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,n){return xl("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(r,n)},toWorkingColorSpace:function(r,n){return xl("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(r,n)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[kr]:{primaries:e,whitePoint:i,transfer:ml,toXYZ:Z0,fromXYZ:J0,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ii},outputColorSpaceConfig:{drawingBufferColorSpace:Ii}},[Ii]:{primaries:e,whitePoint:i,transfer:vt,toXYZ:Z0,fromXYZ:J0,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ii}}}),s}const mt=rb();function dr(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ta(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let wa,pp=class{static getDataURL(s,e="image/png"){if(/^data:/i.test(s.src)||typeof HTMLCanvasElement>"u")return s.src;let t;if(s instanceof HTMLCanvasElement)t=s;else{wa===void 0&&(wa=gl("canvas")),wa.width=s.width,wa.height=s.height;const i=wa.getContext("2d");s instanceof ImageData?i.putImageData(s,0,0):i.drawImage(s,0,0,s.width,s.height),t=wa}return t.toDataURL(e)}static sRGBToLinear(s){if(typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap){const e=gl("canvas");e.width=s.width,e.height=s.height;const t=e.getContext("2d");t.drawImage(s,0,0,s.width,s.height);const i=t.getImageData(0,0,s.width,s.height),r=i.data;for(let n=0;n<r.length;n++)r[n]=dr(r[n]/255)*255;return t.putImageData(i,0,0),e}else if(s.data){const e=s.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(dr(e[t]/255)*255):e[t]=dr(e[t]);return{data:e,width:s.width,height:s.height}}else return ge("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),s}},nb=0,pr=class{constructor(s=null){this.isSource=!0,Object.defineProperty(this,"id",{value:nb++}),this.uuid=Zi(),this.data=s,this.dataReady=!0,this.version=0}getSize(s){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?s.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?s.set(e.displayHeight,e.displayWidth,0):e!==null?s.set(e.width,e.height,e.depth||0):s.set(0,0,0),s}set needsUpdate(s){s===!0&&this.version++}toJSON(s){const e=s===void 0||typeof s=="string";if(!e&&s.images[this.uuid]!==void 0)return s.images[this.uuid];const t={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let n=0,a=i.length;n<a;n++)i[n].isDataTexture?r.push(mp(i[n].image)):r.push(mp(i[n]))}else r=mp(i);t.url=r}return e||(s.images[this.uuid]=t),t}};function mp(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?pp.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(ge("Texture: Unable to serialize Texture."),{})}let ab=0;const fp=new R;let ei=class Cd extends Es{constructor(e=Cd.DEFAULT_IMAGE,t=Cd.DEFAULT_MAPPING,i=Ci,r=Ci,n=Rt,a=Ss,o=vi,l=Ri,h=Cd.DEFAULT_ANISOTROPY,c=Gs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ab++}),this.uuid=Zi(),this.name="",this.source=new pr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new te(0,0),this.repeat=new te(1,1),this.center=new te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new at,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(fp).x}get height(){return this.source.getSize(fp).y}get depth(){return this.source.getSize(fp).z}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){ge(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){ge(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Gh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pa:e.x=e.x-Math.floor(e.x);break;case Ci:e.x=e.x<0?0:1;break;case ma:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case pa:e.y=e.y-Math.floor(e.y);break;case Ci:e.y=e.y<0?0:1;break;case ma:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};ei.DEFAULT_IMAGE=null,ei.DEFAULT_MAPPING=Gh,ei.DEFAULT_ANISOTROPY=4;let It=class eM{constructor(e=0,t=0,i=0,r=1){eM.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*n,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*n,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*n,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,n;const a=e.elements,o=a[0],l=a[4],h=a[8],c=a[1],d=a[5],u=a[9],p=a[2],m=a[6],y=a[10];if(Math.abs(l-c)<.01&&Math.abs(h-p)<.01&&Math.abs(u-m)<.01){if(Math.abs(l+c)<.1&&Math.abs(h+p)<.1&&Math.abs(u+m)<.1&&Math.abs(o+d+y-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const f=(o+1)/2,x=(d+1)/2,v=(y+1)/2,M=(l+c)/4,w=(h+p)/4,T=(u+m)/4;return f>x&&f>v?f<.01?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(f),r=M/i,n=w/i):x>v?x<.01?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(x),i=M/r,n=T/r):v<.01?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(v),i=w/n,r=T/n),this.set(i,r,n,t),this}let g=Math.sqrt((m-u)*(m-u)+(h-p)*(h-p)+(c-l)*(c-l));return Math.abs(g)<.001&&(g=1),this.x=(m-u)/g,this.y=(h-p)/g,this.z=(c-l)/g,this.w=Math.acos((o+d+y-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this.w=Ke(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this.w=Ke(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ke(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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}},gp=class extends Es{constructor(s=1,e=1,t={}){super(),t=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},t),this.isRenderTarget=!0,this.width=s,this.height=e,this.depth=t.depth,this.scissor=new It(0,0,s,e),this.scissorTest=!1,this.viewport=new It(0,0,s,e),this.textures=[];const i={width:s,height:e,depth:t.depth},r=new ei(i),n=t.count;for(let a=0;a<n;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(t),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=t.depthTexture,this.samples=t.samples,this.multiview=t.multiview}_setTextureOptions(s={}){const e={minFilter:Rt,generateMipmaps:!1,flipY:!1,internalFormat:null};s.mapping!==void 0&&(e.mapping=s.mapping),s.wrapS!==void 0&&(e.wrapS=s.wrapS),s.wrapT!==void 0&&(e.wrapT=s.wrapT),s.wrapR!==void 0&&(e.wrapR=s.wrapR),s.magFilter!==void 0&&(e.magFilter=s.magFilter),s.minFilter!==void 0&&(e.minFilter=s.minFilter),s.format!==void 0&&(e.format=s.format),s.type!==void 0&&(e.type=s.type),s.anisotropy!==void 0&&(e.anisotropy=s.anisotropy),s.colorSpace!==void 0&&(e.colorSpace=s.colorSpace),s.flipY!==void 0&&(e.flipY=s.flipY),s.generateMipmaps!==void 0&&(e.generateMipmaps=s.generateMipmaps),s.internalFormat!==void 0&&(e.internalFormat=s.internalFormat);for(let t=0;t<this.textures.length;t++)this.textures[t].setValues(e)}get texture(){return this.textures[0]}set texture(s){this.textures[0]=s}set depthTexture(s){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),s!==null&&(s.renderTarget=this),this._depthTexture=s}get depthTexture(){return this._depthTexture}setSize(s,e,t=1){if(this.width!==s||this.height!==e||this.depth!==t){this.width=s,this.height=e,this.depth=t;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=s,this.textures[i].image.height=e,this.textures[i].image.depth=t,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,s,e),this.scissor.set(0,0,s,e)}clone(){return new this.constructor().copy(this)}copy(s){this.width=s.width,this.height=s.height,this.depth=s.depth,this.scissor.copy(s.scissor),this.scissorTest=s.scissorTest,this.viewport.copy(s.viewport),this.textures.length=0;for(let e=0,t=s.textures.length;e<t;e++){this.textures[e]=s.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},s.textures[e].image);this.textures[e].source=new pr(i)}return this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,s.depthTexture!==null&&(this.depthTexture=s.depthTexture.clone()),this.samples=s.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}};class Bi extends gp{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}let gc=class extends ei{constructor(s=null,e=1,t=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:s,width:e,height:t,depth:i},this.magFilter=Ht,this.minFilter=Ht,this.wrapR=Ci,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(s){this.layerUpdates.add(s)}clearLayerUpdates(){this.layerUpdates.clear()}};class ob extends Bi{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new gc(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class _l extends ei{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ht,this.minFilter=Ht,this.wrapR=Ci,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class lb extends Bi{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new _l(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}let et=class Ig{constructor(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g){Ig.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g)}set(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=n,f[5]=a,f[9]=o,f[13]=l,f[2]=h,f[6]=c,f[10]=d,f[14]=u,f[3]=p,f[7]=m,f[11]=y,f[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 Ig().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/Ea.setFromMatrixColumn(e,0).length(),n=1/Ea.setFromMatrixColumn(e,1).length(),a=1/Ea.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),h=Math.sin(r),c=Math.cos(n),d=Math.sin(n);if(e.order==="XYZ"){const u=a*c,p=a*d,m=o*c,y=o*d;t[0]=l*c,t[4]=-l*d,t[8]=h,t[1]=p+m*h,t[5]=u-y*h,t[9]=-o*l,t[2]=y-u*h,t[6]=m+p*h,t[10]=a*l}else if(e.order==="YXZ"){const u=l*c,p=l*d,m=h*c,y=h*d;t[0]=u+y*o,t[4]=m*o-p,t[8]=a*h,t[1]=a*d,t[5]=a*c,t[9]=-o,t[2]=p*o-m,t[6]=y+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*c,p=l*d,m=h*c,y=h*d;t[0]=u-y*o,t[4]=-a*d,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*c,t[9]=y-u*o,t[2]=-a*h,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*c,p=a*d,m=o*c,y=o*d;t[0]=l*c,t[4]=m*h-p,t[8]=u*h+y,t[1]=l*d,t[5]=y*h+u,t[9]=p*h-m,t[2]=-h,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*h,m=o*l,y=o*h;t[0]=l*c,t[4]=y-u*d,t[8]=m*d+p,t[1]=d,t[5]=a*c,t[9]=-o*c,t[2]=-h*c,t[6]=p*d+m,t[10]=u-y*d}else if(e.order==="XZY"){const u=a*l,p=a*h,m=o*l,y=o*h;t[0]=l*c,t[4]=-d,t[8]=h*c,t[1]=u*d+y,t[5]=a*c,t[9]=p*d-m,t[2]=m*d-p,t[6]=o*c,t[10]=y*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(hb,e,cb)}lookAt(e,t,i){const r=this.elements;return Ji.subVectors(e,t),Ji.lengthSq()===0&&(Ji.z=1),Ji.normalize(),Wr.crossVectors(i,Ji),Wr.lengthSq()===0&&(Math.abs(i.z)===1?Ji.x+=1e-4:Ji.z+=1e-4,Ji.normalize(),Wr.crossVectors(i,Ji)),Wr.normalize(),yc.crossVectors(Ji,Wr),r[0]=Wr.x,r[4]=yc.x,r[8]=Ji.x,r[1]=Wr.y,r[5]=yc.y,r[9]=Ji.y,r[2]=Wr.z,r[6]=yc.z,r[10]=Ji.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[4],l=i[8],h=i[12],c=i[1],d=i[5],u=i[9],p=i[13],m=i[2],y=i[6],g=i[10],f=i[14],x=i[3],v=i[7],M=i[11],w=i[15],T=r[0],A=r[4],_=r[8],S=r[12],P=r[1],C=r[5],L=r[9],U=r[13],V=r[2],B=r[6],k=r[10],W=r[14],se=r[3],ie=r[7],oe=r[11],be=r[15];return n[0]=a*T+o*P+l*V+h*se,n[4]=a*A+o*C+l*B+h*ie,n[8]=a*_+o*L+l*k+h*oe,n[12]=a*S+o*U+l*W+h*be,n[1]=c*T+d*P+u*V+p*se,n[5]=c*A+d*C+u*B+p*ie,n[9]=c*_+d*L+u*k+p*oe,n[13]=c*S+d*U+u*W+p*be,n[2]=m*T+y*P+g*V+f*se,n[6]=m*A+y*C+g*B+f*ie,n[10]=m*_+y*L+g*k+f*oe,n[14]=m*S+y*U+g*W+f*be,n[3]=x*T+v*P+M*V+w*se,n[7]=x*A+v*C+M*B+w*ie,n[11]=x*_+v*L+M*k+w*oe,n[15]=x*S+v*U+M*W+w*be,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],c=e[2],d=e[6],u=e[10],p=e[14],m=e[3],y=e[7],g=e[11],f=e[15],x=l*p-h*u,v=o*p-h*d,M=o*u-l*d,w=a*p-h*c,T=a*u-l*c,A=a*d-o*c;return t*(y*x-g*v+f*M)-i*(m*x-g*w+f*T)+r*(m*v-y*w+f*A)-n*(m*M-y*T+g*A)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],d=e[9],u=e[10],p=e[11],m=e[12],y=e[13],g=e[14],f=e[15],x=t*o-i*a,v=t*l-r*a,M=t*h-n*a,w=i*l-r*o,T=i*h-n*o,A=r*h-n*l,_=c*y-d*m,S=c*g-u*m,P=c*f-p*m,C=d*g-u*y,L=d*f-p*y,U=u*f-p*g,V=x*U-v*L+M*C+w*P-T*S+A*_;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const B=1/V;return e[0]=(o*U-l*L+h*C)*B,e[1]=(r*L-i*U-n*C)*B,e[2]=(y*A-g*T+f*w)*B,e[3]=(u*T-d*A-p*w)*B,e[4]=(l*P-a*U-h*S)*B,e[5]=(t*U-r*P+n*S)*B,e[6]=(g*M-m*A-f*v)*B,e[7]=(c*A-u*M+p*v)*B,e[8]=(a*L-o*P+h*_)*B,e[9]=(i*P-t*L-n*_)*B,e[10]=(m*T-y*M+f*x)*B,e[11]=(d*M-c*T-p*x)*B,e[12]=(o*S-a*C-l*_)*B,e[13]=(t*C-i*S+r*_)*B,e[14]=(y*v-m*w-g*x)*B,e[15]=(c*w-d*v+u*x)*B,this}scale(e){const t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),n=1-i,a=e.x,o=e.y,l=e.z,h=n*a,c=n*o;return this.set(h*a+i,h*o-r*l,h*l+r*o,0,h*o+r*l,c*o+i,c*l-r*a,0,h*l-r*o,c*l+r*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,n,a){return this.set(1,i,n,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,n=t._x,a=t._y,o=t._z,l=t._w,h=n+n,c=a+a,d=o+o,u=n*h,p=n*c,m=n*d,y=a*c,g=a*d,f=o*d,x=l*h,v=l*c,M=l*d,w=i.x,T=i.y,A=i.z;return r[0]=(1-(y+f))*w,r[1]=(p+M)*w,r[2]=(m-v)*w,r[3]=0,r[4]=(p-M)*T,r[5]=(1-(u+f))*T,r[6]=(g+x)*T,r[7]=0,r[8]=(m+v)*A,r[9]=(g-x)*A,r[10]=(1-(u+y))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const n=this.determinant();if(n===0)return i.set(1,1,1),t.identity(),this;let a=Ea.set(r[0],r[1],r[2]).length();const o=Ea.set(r[4],r[5],r[6]).length(),l=Ea.set(r[8],r[9],r[10]).length();n<0&&(a=-a),As.copy(this);const h=1/a,c=1/o,d=1/l;return As.elements[0]*=h,As.elements[1]*=h,As.elements[2]*=h,As.elements[4]*=c,As.elements[5]*=c,As.elements[6]*=c,As.elements[8]*=d,As.elements[9]*=d,As.elements[10]*=d,t.setFromRotationMatrix(As),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,r,n,a,o=Yi,l=!1){const h=this.elements,c=2*n/(t-e),d=2*n/(i-r),u=(t+e)/(t-e),p=(i+r)/(i-r);let m,y;if(l)m=n/(a-n),y=a*n/(a-n);else if(o===Yi)m=-(a+n)/(a-n),y=-2*a*n/(a-n);else if(o===Sn)m=-a/(a-n),y=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return h[0]=c,h[4]=0,h[8]=u,h[12]=0,h[1]=0,h[5]=d,h[9]=p,h[13]=0,h[2]=0,h[6]=0,h[10]=m,h[14]=y,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,r,n,a,o=Yi,l=!1){const h=this.elements,c=2/(t-e),d=2/(i-r),u=-(t+e)/(t-e),p=-(i+r)/(i-r);let m,y;if(l)m=1/(a-n),y=a/(a-n);else if(o===Yi)m=-2/(a-n),y=-(a+n)/(a-n);else if(o===Sn)m=-1/(a-n),y=-n/(a-n);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return h[0]=c,h[4]=0,h[8]=0,h[12]=u,h[1]=0,h[5]=d,h[9]=0,h[13]=p,h[2]=0,h[6]=0,h[10]=m,h[14]=y,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};const Ea=new R,As=new et,hb=new R(0,0,0),cb=new R(1,1,1),Wr=new R,yc=new R,Ji=new R,K0=new et,$0=new Mi;let ns=class tM{constructor(e=0,t=0,i=0,r=tM.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,n=r[0],a=r[4],o=r[8],l=r[1],h=r[5],c=r[9],d=r[2],u=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Ke(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-d,n),this._z=0);break;case"ZXY":this._x=Math.asin(Ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-Ke(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(Ke(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-d,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ke(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-c,p),this._y=0);break;default:ge("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return K0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(K0,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return $0.setFromEuler(this),this.setFromQuaternion($0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ns.DEFAULT_ORDER="XYZ";let Ml=class{constructor(){this.mask=1}set(s){this.mask=(1<<s|0)>>>0}enable(s){this.mask|=1<<s|0}enableAll(){this.mask=-1}toggle(s){this.mask^=1<<s|0}disable(s){this.mask&=~(1<<s|0)}disableAll(){this.mask=0}test(s){return(this.mask&s.mask)!==0}isEnabled(s){return(this.mask&(1<<s|0))!==0}},ub=0;const Q0=new R,Aa=new Mi,mr=new et,xc=new R,bl=new R,db=new R,pb=new Mi,ey=new R(1,0,0),ty=new R(0,1,0),iy=new R(0,0,1),sy={type:"added"},mb={type:"removed"},Na={type:"childadded",child:null},yp={type:"childremoved",child:null};let _t=class Rd extends Es{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ub++}),this.uuid=Zi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Rd.DEFAULT_UP.clone();const e=new R,t=new ns,i=new Mi,r=new R(1,1,1);function n(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(n),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new et},normalMatrix:{value:new at}}),this.matrix=new et,this.matrixWorld=new et,this.matrixAutoUpdate=Rd.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Rd.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ml,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Aa.setFromAxisAngle(e,t),this.quaternion.multiply(Aa),this}rotateOnWorldAxis(e,t){return Aa.setFromAxisAngle(e,t),this.quaternion.premultiply(Aa),this}rotateX(e){return this.rotateOnAxis(ey,e)}rotateY(e){return this.rotateOnAxis(ty,e)}rotateZ(e){return this.rotateOnAxis(iy,e)}translateOnAxis(e,t){return Q0.copy(e).applyQuaternion(this.quaternion),this.position.add(Q0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ey,e)}translateY(e){return this.translateOnAxis(ty,e)}translateZ(e){return this.translateOnAxis(iy,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(mr.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?xc.copy(e):xc.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),bl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?mr.lookAt(bl,xc,this.up):mr.lookAt(xc,bl,this.up),this.quaternion.setFromRotationMatrix(mr),r&&(mr.extractRotation(r.matrixWorld),Aa.setFromRotationMatrix(mr),this.quaternion.premultiply(Aa.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ve("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(sy),Na.child=e,this.dispatchEvent(Na),Na.child=null):Ve("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(mb),yp.child=e,this.dispatchEvent(yp),yp.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),mr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),mr.multiply(e.parent.matrixWorld)),e.applyMatrix4(mr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(sy),Na.child=e,this.dispatchEvent(Na),Na.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const n=this.children[i].getObjectByProperty(e,t);if(n!==void 0)return n}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bl,e,db),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bl,pb,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,r=e.z,n=this.matrix.elements;n[12]+=t-n[0]*t-n[4]*i-n[8]*r,n[13]+=i-n[1]*t-n[5]*i-n[9]*r,n[14]+=r-n[2]*t-n[6]*i-n[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.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)),t===!0){const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=n(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let h=0,c=l.length;h<c;h++){const d=l[h];n(e.shapes,d)}else n(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(e.materials,this.material[l]));r.material=o}else r.material=n(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(n(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),h=a(e.textures),c=a(e.images),d=a(e.shapes),u=a(e.skeletons),p=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),h.length>0&&(i.textures=h),c.length>0&&(i.images=c),d.length>0&&(i.shapes=d),u.length>0&&(i.skeletons=u),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const h in o){const c=o[h];delete c.metadata,l.push(c)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}};_t.DEFAULT_UP=new R(0,1,0),_t.DEFAULT_MATRIX_AUTO_UPDATE=!0,_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class wn extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const fb={type:"move"};class vc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new wn,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 wn,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 wn,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(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,n=null,a=null;const o=this._targetRay,l=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const y of e.hand.values()){const g=t.getJointPose(y,i),f=this._getHandJoint(h,y);g!==null&&(f.matrix.fromArray(g.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=g.radius),f.visible=g!==null}const c=h.joints["index-finger-tip"],d=h.joints["thumb-tip"],u=c.position.distanceTo(d.position),p=.02,m=.005;h.inputState.pinching&&u>p+m?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&u<=p-m&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(n=t.getPose(e.gripSpace,i),n!==null&&(l.matrix.fromArray(n.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,n.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(n.linearVelocity)):l.hasLinearVelocity=!1,n.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(n.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&n!==null&&(r=n),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(fb)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=n!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new wn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const ry={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},jr={h:0,s:0,l:0},_c={h:0,s:0,l:0};function xp(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}let we=class{constructor(s,e,t){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(s,e,t)}set(s,e,t){if(e===void 0&&t===void 0){const i=s;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(s,e,t);return this}setScalar(s){return this.r=s,this.g=s,this.b=s,this}setHex(s,e=Ii){return s=Math.floor(s),this.r=(s>>16&255)/255,this.g=(s>>8&255)/255,this.b=(s&255)/255,mt.colorSpaceToWorking(this,e),this}setRGB(s,e,t,i=mt.workingColorSpace){return this.r=s,this.g=e,this.b=t,mt.colorSpaceToWorking(this,i),this}setHSL(s,e,t,i=mt.workingColorSpace){if(s=cp(s,1),e=Ke(e,0,1),t=Ke(t,0,1),e===0)this.r=this.g=this.b=t;else{const r=t<=.5?t*(1+e):t+e-t*e,n=2*t-r;this.r=xp(n,r,s+1/3),this.g=xp(n,r,s),this.b=xp(n,r,s-1/3)}return mt.colorSpaceToWorking(this,i),this}setStyle(s,e=Ii){function t(r){r!==void 0&&parseFloat(r)<1&&ge("Color: Alpha component of "+s+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(s)){let r;const n=i[1],a=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return t(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return t(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return t(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:ge("Color: Unknown color model "+s)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(s)){const r=i[1],n=r.length;if(n===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(n===6)return this.setHex(parseInt(r,16),e);ge("Color: Invalid hex color "+s)}else if(s&&s.length>0)return this.setColorName(s,e);return this}setColorName(s,e=Ii){const t=ry[s.toLowerCase()];return t!==void 0?this.setHex(t,e):ge("Color: Unknown color "+s),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(s){return this.r=s.r,this.g=s.g,this.b=s.b,this}copySRGBToLinear(s){return this.r=dr(s.r),this.g=dr(s.g),this.b=dr(s.b),this}copyLinearToSRGB(s){return this.r=Ta(s.r),this.g=Ta(s.g),this.b=Ta(s.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(s=Ii){return mt.workingToColorSpace(bi.copy(this),s),Math.round(Ke(bi.r*255,0,255))*65536+Math.round(Ke(bi.g*255,0,255))*256+Math.round(Ke(bi.b*255,0,255))}getHexString(s=Ii){return("000000"+this.getHex(s).toString(16)).slice(-6)}getHSL(s,e=mt.workingColorSpace){mt.workingToColorSpace(bi.copy(this),e);const t=bi.r,i=bi.g,r=bi.b,n=Math.max(t,i,r),a=Math.min(t,i,r);let o,l;const h=(a+n)/2;if(a===n)o=0,l=0;else{const c=n-a;switch(l=h<=.5?c/(n+a):c/(2-n-a),n){case t:o=(i-r)/c+(i<r?6:0);break;case i:o=(r-t)/c+2;break;case r:o=(t-i)/c+4;break}o/=6}return s.h=o,s.s=l,s.l=h,s}getRGB(s,e=mt.workingColorSpace){return mt.workingToColorSpace(bi.copy(this),e),s.r=bi.r,s.g=bi.g,s.b=bi.b,s}getStyle(s=Ii){mt.workingToColorSpace(bi.copy(this),s);const e=bi.r,t=bi.g,i=bi.b;return s!==Ii?`color(${s} ${e.toFixed(3)} ${t.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(t*255)},${Math.round(i*255)})`}offsetHSL(s,e,t){return this.getHSL(jr),this.setHSL(jr.h+s,jr.s+e,jr.l+t)}add(s){return this.r+=s.r,this.g+=s.g,this.b+=s.b,this}addColors(s,e){return this.r=s.r+e.r,this.g=s.g+e.g,this.b=s.b+e.b,this}addScalar(s){return this.r+=s,this.g+=s,this.b+=s,this}sub(s){return this.r=Math.max(0,this.r-s.r),this.g=Math.max(0,this.g-s.g),this.b=Math.max(0,this.b-s.b),this}multiply(s){return this.r*=s.r,this.g*=s.g,this.b*=s.b,this}multiplyScalar(s){return this.r*=s,this.g*=s,this.b*=s,this}lerp(s,e){return this.r+=(s.r-this.r)*e,this.g+=(s.g-this.g)*e,this.b+=(s.b-this.b)*e,this}lerpColors(s,e,t){return this.r=s.r+(e.r-s.r)*t,this.g=s.g+(e.g-s.g)*t,this.b=s.b+(e.b-s.b)*t,this}lerpHSL(s,e){this.getHSL(jr),s.getHSL(_c);const t=vl(jr.h,_c.h,e),i=vl(jr.s,_c.s,e),r=vl(jr.l,_c.l,e);return this.setHSL(t,i,r),this}setFromVector3(s){return this.r=s.x,this.g=s.y,this.b=s.z,this}applyMatrix3(s){const e=this.r,t=this.g,i=this.b,r=s.elements;return this.r=r[0]*e+r[3]*t+r[6]*i,this.g=r[1]*e+r[4]*t+r[7]*i,this.b=r[2]*e+r[5]*t+r[8]*i,this}equals(s){return s.r===this.r&&s.g===this.g&&s.b===this.b}fromArray(s,e=0){return this.r=s[e],this.g=s[e+1],this.b=s[e+2],this}toArray(s=[],e=0){return s[e]=this.r,s[e+1]=this.g,s[e+2]=this.b,s}fromBufferAttribute(s,e){return this.r=s.getX(e),this.g=s.getY(e),this.b=s.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const bi=new we;we.NAMES=ry;class Id{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new we(e),this.density=t}clone(){return new Id(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let vp=class iM{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new we(e),this.near=t,this.far=i}clone(){return new iM(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class _p extends _t{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 ns,this.environmentIntensity=1,this.environmentRotation=new ns,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Ns=new R,fr=new R,Mp=new R,gr=new R,Ca=new R,Ra=new R,ny=new R,bp=new R,Sp=new R,Tp=new R,wp=new It,Ep=new It,Ap=new It;let yr=class Ro{constructor(e=new R,t=new R,i=new R){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Ns.subVectors(e,t),r.cross(Ns);const n=r.lengthSq();return n>0?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)}static getBarycoord(e,t,i,r,n){Ns.subVectors(r,t),fr.subVectors(i,t),Mp.subVectors(e,t);const a=Ns.dot(Ns),o=Ns.dot(fr),l=Ns.dot(Mp),h=fr.dot(fr),c=fr.dot(Mp),d=a*h-o*o;if(d===0)return n.set(0,0,0),null;const u=1/d,p=(h*l-o*c)*u,m=(a*c-o*l)*u;return n.set(1-p-m,m,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,gr)===null?!1:gr.x>=0&&gr.y>=0&&gr.x+gr.y<=1}static getInterpolation(e,t,i,r,n,a,o,l){return this.getBarycoord(e,t,i,r,gr)===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(n,gr.x),l.addScaledVector(a,gr.y),l.addScaledVector(o,gr.z),l)}static getInterpolatedAttribute(e,t,i,r,n,a){return wp.setScalar(0),Ep.setScalar(0),Ap.setScalar(0),wp.fromBufferAttribute(e,t),Ep.fromBufferAttribute(e,i),Ap.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(wp,n.x),a.addScaledVector(Ep,n.y),a.addScaledVector(Ap,n.z),a}static isFrontFacing(e,t,i,r){return Ns.subVectors(i,t),fr.subVectors(e,t),Ns.cross(fr).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ns.subVectors(this.c,this.b),fr.subVectors(this.a,this.b),Ns.cross(fr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ro.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ro.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,n){return Ro.getInterpolation(e,this.a,this.b,this.c,t,i,r,n)}containsPoint(e){return Ro.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ro.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,n=this.c;let a,o;Ca.subVectors(r,i),Ra.subVectors(n,i),bp.subVectors(e,i);const l=Ca.dot(bp),h=Ra.dot(bp);if(l<=0&&h<=0)return t.copy(i);Sp.subVectors(e,r);const c=Ca.dot(Sp),d=Ra.dot(Sp);if(c>=0&&d<=c)return t.copy(r);const u=l*d-c*h;if(u<=0&&l>=0&&c<=0)return a=l/(l-c),t.copy(i).addScaledVector(Ca,a);Tp.subVectors(e,n);const p=Ca.dot(Tp),m=Ra.dot(Tp);if(m>=0&&p<=m)return t.copy(n);const y=p*h-l*m;if(y<=0&&h>=0&&m<=0)return o=h/(h-m),t.copy(i).addScaledVector(Ra,o);const g=c*m-p*d;if(g<=0&&d-c>=0&&p-m>=0)return ny.subVectors(n,r),o=(d-c)/(d-c+(p-m)),t.copy(r).addScaledVector(ny,o);const f=1/(g+y+u);return a=y*f,o=u*f,t.copy(i).addScaledVector(Ca,a).addScaledVector(Ra,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},di=class{constructor(s=new R(1/0,1/0,1/0),e=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=s,this.max=e}set(s,e){return this.min.copy(s),this.max.copy(e),this}setFromArray(s){this.makeEmpty();for(let e=0,t=s.length;e<t;e+=3)this.expandByPoint(Cs.fromArray(s,e));return this}setFromBufferAttribute(s){this.makeEmpty();for(let e=0,t=s.count;e<t;e++)this.expandByPoint(Cs.fromBufferAttribute(s,e));return this}setFromPoints(s){this.makeEmpty();for(let e=0,t=s.length;e<t;e++)this.expandByPoint(s[e]);return this}setFromCenterAndSize(s,e){const t=Cs.copy(e).multiplyScalar(.5);return this.min.copy(s).sub(t),this.max.copy(s).add(t),this}setFromObject(s,e=!1){return this.makeEmpty(),this.expandByObject(s,e)}clone(){return new this.constructor().copy(this)}copy(s){return this.min.copy(s.min),this.max.copy(s.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(s){return this.isEmpty()?s.set(0,0,0):s.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(s){return this.isEmpty()?s.set(0,0,0):s.subVectors(this.max,this.min)}expandByPoint(s){return this.min.min(s),this.max.max(s),this}expandByVector(s){return this.min.sub(s),this.max.add(s),this}expandByScalar(s){return this.min.addScalar(-s),this.max.addScalar(s),this}expandByObject(s,e=!1){s.updateWorldMatrix(!1,!1);const t=s.geometry;if(t!==void 0){const r=t.getAttribute("position");if(e===!0&&r!==void 0&&s.isInstancedMesh!==!0)for(let n=0,a=r.count;n<a;n++)s.isMesh===!0?s.getVertexPosition(n,Cs):Cs.fromBufferAttribute(r,n),Cs.applyMatrix4(s.matrixWorld),this.expandByPoint(Cs);else s.boundingBox!==void 0?(s.boundingBox===null&&s.computeBoundingBox(),Mc.copy(s.boundingBox)):(t.boundingBox===null&&t.computeBoundingBox(),Mc.copy(t.boundingBox)),Mc.applyMatrix4(s.matrixWorld),this.union(Mc)}const i=s.children;for(let r=0,n=i.length;r<n;r++)this.expandByObject(i[r],e);return this}containsPoint(s){return s.x>=this.min.x&&s.x<=this.max.x&&s.y>=this.min.y&&s.y<=this.max.y&&s.z>=this.min.z&&s.z<=this.max.z}containsBox(s){return this.min.x<=s.min.x&&s.max.x<=this.max.x&&this.min.y<=s.min.y&&s.max.y<=this.max.y&&this.min.z<=s.min.z&&s.max.z<=this.max.z}getParameter(s,e){return e.set((s.x-this.min.x)/(this.max.x-this.min.x),(s.y-this.min.y)/(this.max.y-this.min.y),(s.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(s){return s.max.x>=this.min.x&&s.min.x<=this.max.x&&s.max.y>=this.min.y&&s.min.y<=this.max.y&&s.max.z>=this.min.z&&s.min.z<=this.max.z}intersectsSphere(s){return this.clampPoint(s.center,Cs),Cs.distanceToSquared(s.center)<=s.radius*s.radius}intersectsPlane(s){let e,t;return s.normal.x>0?(e=s.normal.x*this.min.x,t=s.normal.x*this.max.x):(e=s.normal.x*this.max.x,t=s.normal.x*this.min.x),s.normal.y>0?(e+=s.normal.y*this.min.y,t+=s.normal.y*this.max.y):(e+=s.normal.y*this.max.y,t+=s.normal.y*this.min.y),s.normal.z>0?(e+=s.normal.z*this.min.z,t+=s.normal.z*this.max.z):(e+=s.normal.z*this.max.z,t+=s.normal.z*this.min.z),e<=-s.constant&&t>=-s.constant}intersectsTriangle(s){if(this.isEmpty())return!1;this.getCenter(Sl),bc.subVectors(this.max,Sl),Ia.subVectors(s.a,Sl),Pa.subVectors(s.b,Sl),La.subVectors(s.c,Sl),Xr.subVectors(Pa,Ia),qr.subVectors(La,Pa),En.subVectors(Ia,La);let e=[0,-Xr.z,Xr.y,0,-qr.z,qr.y,0,-En.z,En.y,Xr.z,0,-Xr.x,qr.z,0,-qr.x,En.z,0,-En.x,-Xr.y,Xr.x,0,-qr.y,qr.x,0,-En.y,En.x,0];return!Np(e,Ia,Pa,La,bc)||(e=[1,0,0,0,1,0,0,0,1],!Np(e,Ia,Pa,La,bc))?!1:(Sc.crossVectors(Xr,qr),e=[Sc.x,Sc.y,Sc.z],Np(e,Ia,Pa,La,bc))}clampPoint(s,e){return e.copy(s).clamp(this.min,this.max)}distanceToPoint(s){return this.clampPoint(s,Cs).distanceTo(s)}getBoundingSphere(s){return this.isEmpty()?s.makeEmpty():(this.getCenter(s.center),s.radius=this.getSize(Cs).length()*.5),s}intersect(s){return this.min.max(s.min),this.max.min(s.max),this.isEmpty()&&this.makeEmpty(),this}union(s){return this.min.min(s.min),this.max.max(s.max),this}applyMatrix4(s){return this.isEmpty()?this:(xr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(s),xr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(s),xr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(s),xr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(s),xr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(s),xr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(s),xr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(s),xr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(s),this.setFromPoints(xr),this)}translate(s){return this.min.add(s),this.max.add(s),this}equals(s){return s.min.equals(this.min)&&s.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(s){return this.min.fromArray(s.min),this.max.fromArray(s.max),this}};const xr=[new R,new R,new R,new R,new R,new R,new R,new R],Cs=new R,Mc=new di,Ia=new R,Pa=new R,La=new R,Xr=new R,qr=new R,En=new R,Sl=new R,bc=new R,Sc=new R,An=new R;function Np(s,e,t,i,r){for(let n=0,a=s.length-3;n<=a;n+=3){An.fromArray(s,n);const o=r.x*Math.abs(An.x)+r.y*Math.abs(An.y)+r.z*Math.abs(An.z),l=e.dot(An),h=t.dot(An),c=i.dot(An);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}const vr=gb();function gb(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const h=l-127;h<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):h<-14?(i[l]=1024>>-h-14,i[l|256]=1024>>-h-14|32768,r[l]=-h-1,r[l|256]=-h-1):h<=15?(i[l]=h+15<<10,i[l|256]=h+15<<10|32768,r[l]=13,r[l|256]=13):h<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,n[l]=h|c}for(let l=1024;l<2048;++l)n[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:n,exponentTable:a,offsetTable:o}}function Vi(s){Math.abs(s)>65504&&ge("DataUtils.toHalfFloat(): Value out of range."),s=Ke(s,-65504,65504),vr.floatView[0]=s;const e=vr.uint32View[0],t=e>>23&511;return vr.baseTable[t]+((e&8388607)>>vr.shiftTable[t])}function Tl(s){const e=s>>10;return vr.uint32View[0]=vr.mantissaTable[vr.offsetTable[e]+(s&1023)]+vr.exponentTable[e],vr.floatView[0]}class ay{static toHalfFloat(e){return Vi(e)}static fromHalfFloat(e){return Tl(e)}}const Zt=new R,Tc=new te;let yb=0,bt=class{constructor(s,e,t=!1){if(Array.isArray(s))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:yb++}),this.name="",this.array=s,this.itemSize=e,this.count=s!==void 0?s.length/e:0,this.normalized=t,this.usage=fl,this.updateRanges=[],this.gpuType=xi,this.version=0}onUploadCallback(){}set needsUpdate(s){s===!0&&this.version++}setUsage(s){return this.usage=s,this}addUpdateRange(s,e){this.updateRanges.push({start:s,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(s){return this.name=s.name,this.array=new s.array.constructor(s.array),this.itemSize=s.itemSize,this.count=s.count,this.normalized=s.normalized,this.usage=s.usage,this.gpuType=s.gpuType,this}copyAt(s,e,t){s*=this.itemSize,t*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[s+i]=e.array[t+i];return this}copyArray(s){return this.array.set(s),this}applyMatrix3(s){if(this.itemSize===2)for(let e=0,t=this.count;e<t;e++)Tc.fromBufferAttribute(this,e),Tc.applyMatrix3(s),this.setXY(e,Tc.x,Tc.y);else if(this.itemSize===3)for(let e=0,t=this.count;e<t;e++)Zt.fromBufferAttribute(this,e),Zt.applyMatrix3(s),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}applyMatrix4(s){for(let e=0,t=this.count;e<t;e++)Zt.fromBufferAttribute(this,e),Zt.applyMatrix4(s),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}applyNormalMatrix(s){for(let e=0,t=this.count;e<t;e++)Zt.fromBufferAttribute(this,e),Zt.applyNormalMatrix(s),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}transformDirection(s){for(let e=0,t=this.count;e<t;e++)Zt.fromBufferAttribute(this,e),Zt.transformDirection(s),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}set(s,e=0){return this.array.set(s,e),this}getComponent(s,e){let t=this.array[s*this.itemSize+e];return this.normalized&&(t=Pi(t,this.array)),t}setComponent(s,e,t){return this.normalized&&(t=nt(t,this.array)),this.array[s*this.itemSize+e]=t,this}getX(s){let e=this.array[s*this.itemSize];return this.normalized&&(e=Pi(e,this.array)),e}setX(s,e){return this.normalized&&(e=nt(e,this.array)),this.array[s*this.itemSize]=e,this}getY(s){let e=this.array[s*this.itemSize+1];return this.normalized&&(e=Pi(e,this.array)),e}setY(s,e){return this.normalized&&(e=nt(e,this.array)),this.array[s*this.itemSize+1]=e,this}getZ(s){let e=this.array[s*this.itemSize+2];return this.normalized&&(e=Pi(e,this.array)),e}setZ(s,e){return this.normalized&&(e=nt(e,this.array)),this.array[s*this.itemSize+2]=e,this}getW(s){let e=this.array[s*this.itemSize+3];return this.normalized&&(e=Pi(e,this.array)),e}setW(s,e){return this.normalized&&(e=nt(e,this.array)),this.array[s*this.itemSize+3]=e,this}setXY(s,e,t){return s*=this.itemSize,this.normalized&&(e=nt(e,this.array),t=nt(t,this.array)),this.array[s+0]=e,this.array[s+1]=t,this}setXYZ(s,e,t,i){return s*=this.itemSize,this.normalized&&(e=nt(e,this.array),t=nt(t,this.array),i=nt(i,this.array)),this.array[s+0]=e,this.array[s+1]=t,this.array[s+2]=i,this}setXYZW(s,e,t,i,r){return s*=this.itemSize,this.normalized&&(e=nt(e,this.array),t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array)),this.array[s+0]=e,this.array[s+1]=t,this.array[s+2]=i,this.array[s+3]=r,this}onUpload(s){return this.onUploadCallback=s,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const s={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(s.name=this.name),this.usage!==fl&&(s.usage=this.usage),s}};class xb extends bt{constructor(e,t,i){super(new Int8Array(e),t,i)}}class vb extends bt{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class _b extends bt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class Mb extends bt{constructor(e,t,i){super(new Int16Array(e),t,i)}}let wc=class extends bt{constructor(s,e,t){super(new Uint16Array(s),e,t)}};class bb extends bt{constructor(e,t,i){super(new Int32Array(e),t,i)}}let Cp=class extends bt{constructor(s,e,t){super(new Uint32Array(s),e,t)}};class Sb extends bt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=Tl(this.array[e*this.itemSize]);return this.normalized&&(t=Pi(t,this.array)),t}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize]=Vi(t),this}getY(e){let t=Tl(this.array[e*this.itemSize+1]);return this.normalized&&(t=Pi(t,this.array)),t}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+1]=Vi(t),this}getZ(e){let t=Tl(this.array[e*this.itemSize+2]);return this.normalized&&(t=Pi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+2]=Vi(t),this}getW(e){let t=Tl(this.array[e*this.itemSize+3]);return this.normalized&&(t=Pi(t,this.array)),t}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+3]=Vi(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array)),this.array[e+0]=Vi(t),this.array[e+1]=Vi(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array)),this.array[e+0]=Vi(t),this.array[e+1]=Vi(i),this.array[e+2]=Vi(r),this}setXYZW(e,t,i,r,n){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array),n=nt(n,this.array)),this.array[e+0]=Vi(t),this.array[e+1]=Vi(i),this.array[e+2]=Vi(r),this.array[e+3]=Vi(n),this}}let Ne=class extends bt{constructor(s,e,t){super(new Float32Array(s),e,t)}};const Tb=new di,wl=new R,Rp=new R;let ai=class{constructor(s=new R,e=-1){this.isSphere=!0,this.center=s,this.radius=e}set(s,e){return this.center.copy(s),this.radius=e,this}setFromPoints(s,e){const t=this.center;e!==void 0?t.copy(e):Tb.setFromPoints(s).getCenter(t);let i=0;for(let r=0,n=s.length;r<n;r++)i=Math.max(i,t.distanceToSquared(s[r]));return this.radius=Math.sqrt(i),this}copy(s){return this.center.copy(s.center),this.radius=s.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(s){return s.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(s){return s.distanceTo(this.center)-this.radius}intersectsSphere(s){const e=this.radius+s.radius;return s.center.distanceToSquared(this.center)<=e*e}intersectsBox(s){return s.intersectsSphere(this)}intersectsPlane(s){return Math.abs(s.distanceToPoint(this.center))<=this.radius}clampPoint(s,e){const t=this.center.distanceToSquared(s);return e.copy(s),t>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(s){return this.isEmpty()?(s.makeEmpty(),s):(s.set(this.center,this.center),s.expandByScalar(this.radius),s)}applyMatrix4(s){return this.center.applyMatrix4(s),this.radius=this.radius*s.getMaxScaleOnAxis(),this}translate(s){return this.center.add(s),this}expandByPoint(s){if(this.isEmpty())return this.center.copy(s),this.radius=0,this;wl.subVectors(s,this.center);const e=wl.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=(t-this.radius)*.5;this.center.addScaledVector(wl,i/t),this.radius+=i}return this}union(s){return s.isEmpty()?this:this.isEmpty()?(this.copy(s),this):(this.center.equals(s.center)===!0?this.radius=Math.max(this.radius,s.radius):(Rp.subVectors(s.center,this.center).setLength(s.radius),this.expandByPoint(wl.copy(s.center).add(Rp)),this.expandByPoint(wl.copy(s.center).sub(Rp))),this)}equals(s){return s.center.equals(this.center)&&s.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(s){return this.radius=s.radius,this.center.fromArray(s.center),this}},wb=0;const as=new et,Ip=new _t,Da=new R,Ki=new di,El=new di,oi=new R;let rt=class sM extends Es{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:wb++}),this.uuid=Zi(),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(e){return Array.isArray(e)?this.index=new(UM(e)?Cp:wc)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new at().getNormalMatrix(e);i.applyNormalMatrix(n),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return as.makeRotationFromQuaternion(e),this.applyMatrix4(as),this}rotateX(e){return as.makeRotationX(e),this.applyMatrix4(as),this}rotateY(e){return as.makeRotationY(e),this.applyMatrix4(as),this}rotateZ(e){return as.makeRotationZ(e),this.applyMatrix4(as),this}translate(e,t,i){return as.makeTranslation(e,t,i),this.applyMatrix4(as),this}scale(e,t,i){return as.makeScale(e,t,i),this.applyMatrix4(as),this}lookAt(e){return Ip.lookAt(e),Ip.updateMatrix(),this.applyMatrix4(Ip.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Da).negate(),this.translate(Da.x,Da.y,Da.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,n=e.length;r<n;r++){const a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ne(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&ge("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new di);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("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(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const n=t[i];Ki.setFromBufferAttribute(n),this.morphTargetsRelative?(oi.addVectors(this.boundingBox.min,Ki.min),this.boundingBox.expandByPoint(oi),oi.addVectors(this.boundingBox.max,Ki.max),this.boundingBox.expandByPoint(oi)):(this.boundingBox.expandByPoint(Ki.min),this.boundingBox.expandByPoint(Ki.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ve('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 ai);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){const i=this.boundingSphere.center;if(Ki.setFromBufferAttribute(e),t)for(let n=0,a=t.length;n<a;n++){const o=t[n];El.setFromBufferAttribute(o),this.morphTargetsRelative?(oi.addVectors(Ki.min,El.min),Ki.expandByPoint(oi),oi.addVectors(Ki.max,El.max),Ki.expandByPoint(oi)):(Ki.expandByPoint(El.min),Ki.expandByPoint(El.max))}Ki.getCenter(i);let r=0;for(let n=0,a=e.count;n<a;n++)oi.fromBufferAttribute(e,n),r=Math.max(r,i.distanceToSquared(oi));if(t)for(let n=0,a=t.length;n<a;n++){const o=t[n],l=this.morphTargetsRelative;for(let h=0,c=o.count;h<c;h++)oi.fromBufferAttribute(o,h),l&&(Da.fromBufferAttribute(e,h),oi.add(Da)),r=Math.max(r,i.distanceToSquared(oi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Ve('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ve("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,n=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new bt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let _=0;_<i.count;_++)o[_]=new R,l[_]=new R;const h=new R,c=new R,d=new R,u=new te,p=new te,m=new te,y=new R,g=new R;function f(_,S,P){h.fromBufferAttribute(i,_),c.fromBufferAttribute(i,S),d.fromBufferAttribute(i,P),u.fromBufferAttribute(n,_),p.fromBufferAttribute(n,S),m.fromBufferAttribute(n,P),c.sub(h),d.sub(h),p.sub(u),m.sub(u);const C=1/(p.x*m.y-m.x*p.y);isFinite(C)&&(y.copy(c).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(C),g.copy(d).multiplyScalar(p.x).addScaledVector(c,-m.x).multiplyScalar(C),o[_].add(y),o[S].add(y),o[P].add(y),l[_].add(g),l[S].add(g),l[P].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let _=0,S=x.length;_<S;++_){const P=x[_],C=P.start,L=P.count;for(let U=C,V=C+L;U<V;U+=3)f(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const v=new R,M=new R,w=new R,T=new R;function A(_){w.fromBufferAttribute(r,_),T.copy(w);const S=o[_];v.copy(S),v.sub(w.multiplyScalar(w.dot(S))).normalize(),M.crossVectors(T,S);const P=M.dot(l[_])<0?-1:1;a.setXYZW(_,v.x,v.y,v.z,P)}for(let _=0,S=x.length;_<S;++_){const P=x[_],C=P.start,L=P.count;for(let U=C,V=C+L;U<V;U+=3)A(e.getX(U+0)),A(e.getX(U+1)),A(e.getX(U+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new bt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,p=i.count;u<p;u++)i.setXYZ(u,0,0,0);const r=new R,n=new R,a=new R,o=new R,l=new R,h=new R,c=new R,d=new R;if(e)for(let u=0,p=e.count;u<p;u+=3){const m=e.getX(u+0),y=e.getX(u+1),g=e.getX(u+2);r.fromBufferAttribute(t,m),n.fromBufferAttribute(t,y),a.fromBufferAttribute(t,g),c.subVectors(a,n),d.subVectors(r,n),c.cross(d),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,y),h.fromBufferAttribute(i,g),o.add(c),l.add(c),h.add(c),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(g,h.x,h.y,h.z)}else for(let u=0,p=t.count;u<p;u+=3)r.fromBufferAttribute(t,u+0),n.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),c.subVectors(a,n),d.subVectors(r,n),c.cross(d),i.setXYZ(u+0,c.x,c.y,c.z),i.setXYZ(u+1,c.x,c.y,c.z),i.setXYZ(u+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)oi.fromBufferAttribute(e,t),oi.normalize(),e.setXYZ(t,oi.x,oi.y,oi.z)}toNonIndexed(){function e(o,l){const h=o.array,c=o.itemSize,d=o.normalized,u=new h.constructor(l.length*c);let p=0,m=0;for(let y=0,g=l.length;y<g;y++){o.isInterleavedBufferAttribute?p=l[y]*o.data.stride+o.offset:p=l[y]*c;for(let f=0;f<c;f++)u[m++]=h[p++]}return new bt(u,c,d)}if(this.index===null)return ge("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new sM,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],h=e(l,i);t.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const l=[],h=n[o];for(let c=0,d=h.length;c<d;c++){const u=h[c],p=e(u,i);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const h=a[o];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const h in l)l[h]!==void 0&&(e[h]=l[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const h=i[l];e.data.attributes[l]=h.toJSON(e.data)}const r={};let n=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],c=[];for(let d=0,u=h.length;d<u;d++){const p=h[d];c.push(p.toJSON(e.data))}c.length>0&&(r[l]=c,n=!0)}n&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const h in r){const c=r[h];this.setAttribute(h,c.clone(t))}const n=e.morphAttributes;for(const h in n){const c=[],d=n[h];for(let u=0,p=d.length;u<p;u++)c.push(d[u].clone(t));this.morphAttributes[h]=c}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let h=0,c=a.length;h<c;h++){const d=a[h];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Al=class{constructor(s,e){this.isInterleavedBuffer=!0,this.array=s,this.stride=e,this.count=s!==void 0?s.length/e:0,this.usage=fl,this.updateRanges=[],this.version=0,this.uuid=Zi()}onUploadCallback(){}set needsUpdate(s){s===!0&&this.version++}setUsage(s){return this.usage=s,this}addUpdateRange(s,e){this.updateRanges.push({start:s,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(s){return this.array=new s.array.constructor(s.array),this.count=s.count,this.stride=s.stride,this.usage=s.usage,this}copyAt(s,e,t){s*=this.stride,t*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[s+i]=e.array[t+i];return this}set(s,e=0){return this.array.set(s,e),this}clone(s){s.arrayBuffers===void 0&&(s.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zi()),s.arrayBuffers[this.array.buffer._uuid]===void 0&&(s.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(s.arrayBuffers[this.array.buffer._uuid]),t=new this.constructor(e,this.stride);return t.setUsage(this.usage),t}onUpload(s){return this.onUploadCallback=s,this}toJSON(s){return s.arrayBuffers===void 0&&(s.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zi()),s.arrayBuffers[this.array.buffer._uuid]===void 0&&(s.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 Li=new R;let Oa=class rM{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.applyMatrix4(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.applyNormalMatrix(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.transformDirection(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Pi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=nt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Pi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Pi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Pi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Pi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),i=nt(i,this.array),r=nt(r,this.array),n=nt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}clone(e){if(e===void 0){yl("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return new bt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new rM(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){yl("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Eb=0,pi=class extends Es{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Eb++}),this.uuid=Zi(),this.name="",this.type="Material",this.blending=Or,this.side=Vs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Oh,this.blendDst=Uh,this.blendEquation=Ur,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new we(0,0,0),this.blendAlpha=0,this.depthFunc=Fr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=dc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Gr,this.stencilZFail=Gr,this.stencilZPass=Gr,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(s){this._alphaTest>0!=s>0&&this.version++,this._alphaTest=s}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(s){if(s!==void 0)for(const e in s){const t=s[e];if(t===void 0){ge(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){ge(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(t):i&&i.isVector3&&t&&t.isVector3?i.copy(t):this[e]=t}}toJSON(s){const e=s===void 0||typeof s=="string";e&&(s={textures:{},images:{}});const t={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.color&&this.color.isColor&&(t.color=this.color.getHex()),this.roughness!==void 0&&(t.roughness=this.roughness),this.metalness!==void 0&&(t.metalness=this.metalness),this.sheen!==void 0&&(t.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(t.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(t.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(t.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(t.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(t.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(t.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(t.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(t.shininess=this.shininess),this.clearcoat!==void 0&&(t.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(t.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(t.clearcoatMap=this.clearcoatMap.toJSON(s).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(t.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(s).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(t.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(s).uuid,t.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(t.sheenColorMap=this.sheenColorMap.toJSON(s).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(t.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(s).uuid),this.dispersion!==void 0&&(t.dispersion=this.dispersion),this.iridescence!==void 0&&(t.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(t.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(t.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(t.iridescenceMap=this.iridescenceMap.toJSON(s).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(t.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(s).uuid),this.anisotropy!==void 0&&(t.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(t.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(t.anisotropyMap=this.anisotropyMap.toJSON(s).uuid),this.map&&this.map.isTexture&&(t.map=this.map.toJSON(s).uuid),this.matcap&&this.matcap.isTexture&&(t.matcap=this.matcap.toJSON(s).uuid),this.alphaMap&&this.alphaMap.isTexture&&(t.alphaMap=this.alphaMap.toJSON(s).uuid),this.lightMap&&this.lightMap.isTexture&&(t.lightMap=this.lightMap.toJSON(s).uuid,t.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(t.aoMap=this.aoMap.toJSON(s).uuid,t.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(t.bumpMap=this.bumpMap.toJSON(s).uuid,t.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(t.normalMap=this.normalMap.toJSON(s).uuid,t.normalMapType=this.normalMapType,t.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(t.displacementMap=this.displacementMap.toJSON(s).uuid,t.displacementScale=this.displacementScale,t.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(t.roughnessMap=this.roughnessMap.toJSON(s).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(t.metalnessMap=this.metalnessMap.toJSON(s).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(t.emissiveMap=this.emissiveMap.toJSON(s).uuid),this.specularMap&&this.specularMap.isTexture&&(t.specularMap=this.specularMap.toJSON(s).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(t.specularIntensityMap=this.specularIntensityMap.toJSON(s).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(t.specularColorMap=this.specularColorMap.toJSON(s).uuid),this.envMap&&this.envMap.isTexture&&(t.envMap=this.envMap.toJSON(s).uuid,this.combine!==void 0&&(t.combine=this.combine)),this.envMapRotation!==void 0&&(t.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(t.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(t.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(t.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(t.gradientMap=this.gradientMap.toJSON(s).uuid),this.transmission!==void 0&&(t.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(t.transmissionMap=this.transmissionMap.toJSON(s).uuid),this.thickness!==void 0&&(t.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(t.thicknessMap=this.thicknessMap.toJSON(s).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(t.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(t.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(t.size=this.size),this.shadowSide!==null&&(t.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(t.sizeAttenuation=this.sizeAttenuation),this.blending!==Or&&(t.blending=this.blending),this.side!==Vs&&(t.side=this.side),this.vertexColors===!0&&(t.vertexColors=!0),this.opacity<1&&(t.opacity=this.opacity),this.transparent===!0&&(t.transparent=!0),this.blendSrc!==Oh&&(t.blendSrc=this.blendSrc),this.blendDst!==Uh&&(t.blendDst=this.blendDst),this.blendEquation!==Ur&&(t.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(t.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(t.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(t.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(t.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(t.blendAlpha=this.blendAlpha),this.depthFunc!==Fr&&(t.depthFunc=this.depthFunc),this.depthTest===!1&&(t.depthTest=this.depthTest),this.depthWrite===!1&&(t.depthWrite=this.depthWrite),this.colorWrite===!1&&(t.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(t.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==dc&&(t.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(t.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(t.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Gr&&(t.stencilFail=this.stencilFail),this.stencilZFail!==Gr&&(t.stencilZFail=this.stencilZFail),this.stencilZPass!==Gr&&(t.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(t.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(t.rotation=this.rotation),this.polygonOffset===!0&&(t.polygonOffset=!0),this.polygonOffsetFactor!==0&&(t.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(t.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(t.linewidth=this.linewidth),this.dashSize!==void 0&&(t.dashSize=this.dashSize),this.gapSize!==void 0&&(t.gapSize=this.gapSize),this.scale!==void 0&&(t.scale=this.scale),this.dithering===!0&&(t.dithering=!0),this.alphaTest>0&&(t.alphaTest=this.alphaTest),this.alphaHash===!0&&(t.alphaHash=!0),this.alphaToCoverage===!0&&(t.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(t.premultipliedAlpha=!0),this.forceSinglePass===!0&&(t.forceSinglePass=!0),this.allowOverride===!1&&(t.allowOverride=!1),this.wireframe===!0&&(t.wireframe=!0),this.wireframeLinewidth>1&&(t.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(t.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(t.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(t.flatShading=!0),this.visible===!1&&(t.visible=!1),this.toneMapped===!1&&(t.toneMapped=!1),this.fog===!1&&(t.fog=!1),Object.keys(this.userData).length>0&&(t.userData=this.userData);function i(r){const n=[];for(const a in r){const o=r[a];delete o.metadata,n.push(o)}return n}if(e){const r=i(s.textures),n=i(s.images);r.length>0&&(t.textures=r),n.length>0&&(t.images=n)}return t}clone(){return new this.constructor().copy(this)}copy(s){this.name=s.name,this.blending=s.blending,this.side=s.side,this.vertexColors=s.vertexColors,this.opacity=s.opacity,this.transparent=s.transparent,this.blendSrc=s.blendSrc,this.blendDst=s.blendDst,this.blendEquation=s.blendEquation,this.blendSrcAlpha=s.blendSrcAlpha,this.blendDstAlpha=s.blendDstAlpha,this.blendEquationAlpha=s.blendEquationAlpha,this.blendColor.copy(s.blendColor),this.blendAlpha=s.blendAlpha,this.depthFunc=s.depthFunc,this.depthTest=s.depthTest,this.depthWrite=s.depthWrite,this.stencilWriteMask=s.stencilWriteMask,this.stencilFunc=s.stencilFunc,this.stencilRef=s.stencilRef,this.stencilFuncMask=s.stencilFuncMask,this.stencilFail=s.stencilFail,this.stencilZFail=s.stencilZFail,this.stencilZPass=s.stencilZPass,this.stencilWrite=s.stencilWrite;const e=s.clippingPlanes;let t=null;if(e!==null){const i=e.length;t=new Array(i);for(let r=0;r!==i;++r)t[r]=e[r].clone()}return this.clippingPlanes=t,this.clipIntersection=s.clipIntersection,this.clipShadows=s.clipShadows,this.shadowSide=s.shadowSide,this.colorWrite=s.colorWrite,this.precision=s.precision,this.polygonOffset=s.polygonOffset,this.polygonOffsetFactor=s.polygonOffsetFactor,this.polygonOffsetUnits=s.polygonOffsetUnits,this.dithering=s.dithering,this.alphaTest=s.alphaTest,this.alphaHash=s.alphaHash,this.alphaToCoverage=s.alphaToCoverage,this.premultipliedAlpha=s.premultipliedAlpha,this.forceSinglePass=s.forceSinglePass,this.allowOverride=s.allowOverride,this.visible=s.visible,this.toneMapped=s.toneMapped,this.userData=JSON.parse(JSON.stringify(s.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(s){s===!0&&this.version++}};class Ec extends pi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new we(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Ua;const Nl=new R,Fa=new R,za=new R,Ba=new te,Cl=new te,oy=new et,Ac=new R,Rl=new R,Nc=new R,ly=new te,Pp=new te,hy=new te;class Lp extends _t{constructor(e=new Ec){if(super(),this.isSprite=!0,this.type="Sprite",Ua===void 0){Ua=new rt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Al(t,5);Ua.setIndex([0,1,2,0,2,3]),Ua.setAttribute("position",new Oa(i,3,0,!1)),Ua.setAttribute("uv",new Oa(i,2,3,!1))}this.geometry=Ua,this.material=e,this.center=new te(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ve('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Fa.setFromMatrixScale(this.matrixWorld),oy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),za.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Fa.multiplyScalar(-za.z);const i=this.material.rotation;let r,n;i!==0&&(n=Math.cos(i),r=Math.sin(i));const a=this.center;Cc(Ac.set(-.5,-.5,0),za,a,Fa,r,n),Cc(Rl.set(.5,-.5,0),za,a,Fa,r,n),Cc(Nc.set(.5,.5,0),za,a,Fa,r,n),ly.set(0,0),Pp.set(1,0),hy.set(1,1);let o=e.ray.intersectTriangle(Ac,Rl,Nc,!1,Nl);if(o===null&&(Cc(Rl.set(-.5,.5,0),za,a,Fa,r,n),Pp.set(0,1),o=e.ray.intersectTriangle(Ac,Nc,Rl,!1,Nl),o===null))return;const l=e.ray.origin.distanceTo(Nl);l<e.near||l>e.far||t.push({distance:l,point:Nl.clone(),uv:yr.getInterpolation(Nl,Ac,Rl,Nc,ly,Pp,hy,new te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Cc(s,e,t,i,r,n){Ba.subVectors(s,t).addScalar(.5).multiply(i),r!==void 0?(Cl.x=n*Ba.x-r*Ba.y,Cl.y=r*Ba.x+n*Ba.y):Cl.copy(Ba),s.copy(e),s.x+=Cl.x,s.y+=Cl.y,s.applyMatrix4(oy)}const Rc=new R,cy=new R;class Dp extends _t{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const n=t[i];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let n;for(n=0;n<r.length&&!(t<r[n].distance);n++);return r.splice(n,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const r=t.splice(i,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let n=t[i].distance;if(t[i].object.visible&&(n-=n*t[i].hysteresis),e<n)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Rc.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Rc);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Rc.setFromMatrixPosition(e.matrixWorld),cy.setFromMatrixPosition(this.matrixWorld);const i=Rc.distanceTo(cy)/e.zoom;t[0].object.visible=!0;let r,n;for(r=1,n=t.length;r<n;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),i>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<n;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,n=i.length;r<n;r++){const a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const _r=new R,Op=new R,Ic=new R,Yr=new R,Up=new R,Pc=new R,Fp=new R;let Nn=class{constructor(s=new R,e=new R(0,0,-1)){this.origin=s,this.direction=e}set(s,e){return this.origin.copy(s),this.direction.copy(e),this}copy(s){return this.origin.copy(s.origin),this.direction.copy(s.direction),this}at(s,e){return e.copy(this.origin).addScaledVector(this.direction,s)}lookAt(s){return this.direction.copy(s).sub(this.origin).normalize(),this}recast(s){return this.origin.copy(this.at(s,_r)),this}closestPointToPoint(s,e){e.subVectors(s,this.origin);const t=e.dot(this.direction);return t<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,t)}distanceToPoint(s){return Math.sqrt(this.distanceSqToPoint(s))}distanceSqToPoint(s){const e=_r.subVectors(s,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(s):(_r.copy(this.origin).addScaledVector(this.direction,e),_r.distanceToSquared(s))}distanceSqToSegment(s,e,t,i){Op.copy(s).add(e).multiplyScalar(.5),Ic.copy(e).sub(s).normalize(),Yr.copy(this.origin).sub(Op);const r=s.distanceTo(e)*.5,n=-this.direction.dot(Ic),a=Yr.dot(this.direction),o=-Yr.dot(Ic),l=Yr.lengthSq(),h=Math.abs(1-n*n);let c,d,u,p;if(h>0)if(c=n*o-a,d=n*a-o,p=r*h,c>=0)if(d>=-p)if(d<=p){const m=1/h;c*=m,d*=m,u=c*(c+n*d+2*a)+d*(n*c+d+2*o)+l}else d=r,c=Math.max(0,-(n*d+a)),u=-c*c+d*(d+2*o)+l;else d=-r,c=Math.max(0,-(n*d+a)),u=-c*c+d*(d+2*o)+l;else d<=-p?(c=Math.max(0,-(-n*r+a)),d=c>0?-r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+l):d<=p?(c=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(c=Math.max(0,-(n*r+a)),d=c>0?r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+l);else d=n>0?-r:r,c=Math.max(0,-(n*d+a)),u=-c*c+d*(d+2*o)+l;return t&&t.copy(this.origin).addScaledVector(this.direction,c),i&&i.copy(Op).addScaledVector(Ic,d),u}intersectSphere(s,e){_r.subVectors(s.center,this.origin);const t=_r.dot(this.direction),i=_r.dot(_r)-t*t,r=s.radius*s.radius;if(i>r)return null;const n=Math.sqrt(r-i),a=t-n,o=t+n;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(s){return s.radius<0?!1:this.distanceSqToPoint(s.center)<=s.radius*s.radius}distanceToPlane(s){const e=s.normal.dot(this.direction);if(e===0)return s.distanceToPoint(this.origin)===0?0:null;const t=-(this.origin.dot(s.normal)+s.constant)/e;return t>=0?t:null}intersectPlane(s,e){const t=this.distanceToPlane(s);return t===null?null:this.at(t,e)}intersectsPlane(s){const e=s.distanceToPoint(this.origin);return e===0||s.normal.dot(this.direction)*e<0}intersectBox(s,e){let t,i,r,n,a,o;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return l>=0?(t=(s.min.x-d.x)*l,i=(s.max.x-d.x)*l):(t=(s.max.x-d.x)*l,i=(s.min.x-d.x)*l),h>=0?(r=(s.min.y-d.y)*h,n=(s.max.y-d.y)*h):(r=(s.max.y-d.y)*h,n=(s.min.y-d.y)*h),t>n||r>i||((r>t||isNaN(t))&&(t=r),(n<i||isNaN(i))&&(i=n),c>=0?(a=(s.min.z-d.z)*c,o=(s.max.z-d.z)*c):(a=(s.max.z-d.z)*c,o=(s.min.z-d.z)*c),t>o||a>i)||((a>t||t!==t)&&(t=a),(o<i||i!==i)&&(i=o),i<0)?null:this.at(t>=0?t:i,e)}intersectsBox(s){return this.intersectBox(s,_r)!==null}intersectTriangle(s,e,t,i,r){Up.subVectors(e,s),Pc.subVectors(t,s),Fp.crossVectors(Up,Pc);let n=this.direction.dot(Fp),a;if(n>0){if(i)return null;a=1}else if(n<0)a=-1,n=-n;else return null;Yr.subVectors(this.origin,s);const o=a*this.direction.dot(Pc.crossVectors(Yr,Pc));if(o<0)return null;const l=a*this.direction.dot(Up.cross(Yr));if(l<0||o+l>n)return null;const h=-a*Yr.dot(Fp);return h<0?null:this.at(h/n,r)}applyMatrix4(s){return this.origin.applyMatrix4(s),this.direction.transformDirection(s),this}equals(s){return s.origin.equals(this.origin)&&s.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Mr=class extends pi{constructor(s){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new we(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 ns,this.combine=Ho,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.lightMap=s.lightMap,this.lightMapIntensity=s.lightMapIntensity,this.aoMap=s.aoMap,this.aoMapIntensity=s.aoMapIntensity,this.specularMap=s.specularMap,this.alphaMap=s.alphaMap,this.envMap=s.envMap,this.envMapRotation.copy(s.envMapRotation),this.combine=s.combine,this.reflectivity=s.reflectivity,this.refractionRatio=s.refractionRatio,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.wireframeLinecap=s.wireframeLinecap,this.wireframeLinejoin=s.wireframeLinejoin,this.fog=s.fog,this}};const uy=new et,Cn=new Nn,Lc=new ai,dy=new R,Dc=new R,Oc=new R,Uc=new R,zp=new R,Fc=new R,py=new R,zc=new R;let Xt=class extends _t{constructor(s=new rt,e=new Mr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=s,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(s,e){return super.copy(s,e),s.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=s.morphTargetInfluences.slice()),s.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},s.morphTargetDictionary)),this.material=Array.isArray(s.material)?s.material.slice():s.material,this.geometry=s.geometry,this}updateMorphTargets(){const s=this.geometry.morphAttributes,e=Object.keys(s);if(e.length>0){const t=s[e[0]];if(t!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++){const n=t[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=i}}}}getVertexPosition(s,e){const t=this.geometry,i=t.attributes.position,r=t.morphAttributes.position,n=t.morphTargetsRelative;e.fromBufferAttribute(i,s);const a=this.morphTargetInfluences;if(r&&a){Fc.set(0,0,0);for(let o=0,l=r.length;o<l;o++){const h=a[o],c=r[o];h!==0&&(zp.fromBufferAttribute(c,s),n?Fc.addScaledVector(zp,h):Fc.addScaledVector(zp.sub(e),h))}e.add(Fc)}return e}raycast(s,e){const t=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(t.boundingSphere===null&&t.computeBoundingSphere(),Lc.copy(t.boundingSphere),Lc.applyMatrix4(r),Cn.copy(s.ray).recast(s.near),!(Lc.containsPoint(Cn.origin)===!1&&(Cn.intersectSphere(Lc,dy)===null||Cn.origin.distanceToSquared(dy)>(s.far-s.near)**2))&&(uy.copy(r).invert(),Cn.copy(s.ray).applyMatrix4(uy),!(t.boundingBox!==null&&Cn.intersectsBox(t.boundingBox)===!1)&&this._computeIntersections(s,e,Cn)))}_computeIntersections(s,e,t){let i;const r=this.geometry,n=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,d=r.groups,u=r.drawRange;if(a!==null)if(Array.isArray(n))for(let p=0,m=d.length;p<m;p++){const y=d[p],g=n[y.materialIndex],f=Math.max(y.start,u.start),x=Math.min(a.count,Math.min(y.start+y.count,u.start+u.count));for(let v=f,M=x;v<M;v+=3){const w=a.getX(v),T=a.getX(v+1),A=a.getX(v+2);i=Bc(this,g,s,t,l,h,c,w,T,A),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{const p=Math.max(0,u.start),m=Math.min(a.count,u.start+u.count);for(let y=p,g=m;y<g;y+=3){const f=a.getX(y),x=a.getX(y+1),v=a.getX(y+2);i=Bc(this,n,s,t,l,h,c,f,x,v),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}else if(o!==void 0)if(Array.isArray(n))for(let p=0,m=d.length;p<m;p++){const y=d[p],g=n[y.materialIndex],f=Math.max(y.start,u.start),x=Math.min(o.count,Math.min(y.start+y.count,u.start+u.count));for(let v=f,M=x;v<M;v+=3){const w=v,T=v+1,A=v+2;i=Bc(this,g,s,t,l,h,c,w,T,A),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{const p=Math.max(0,u.start),m=Math.min(o.count,u.start+u.count);for(let y=p,g=m;y<g;y+=3){const f=y,x=y+1,v=y+2;i=Bc(this,n,s,t,l,h,c,f,x,v),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}}};function Ab(s,e,t,i,r,n,a,o){let l;if(e.side===yi?l=i.intersectTriangle(a,n,r,!0,o):l=i.intersectTriangle(r,n,a,e.side===Vs,o),l===null)return null;zc.copy(o),zc.applyMatrix4(s.matrixWorld);const h=t.ray.origin.distanceTo(zc);return h<t.near||h>t.far?null:{distance:h,point:zc.clone(),object:s}}function Bc(s,e,t,i,r,n,a,o,l,h){s.getVertexPosition(o,Dc),s.getVertexPosition(l,Oc),s.getVertexPosition(h,Uc);const c=Ab(s,e,t,i,Dc,Oc,Uc,py);if(c){const d=new R;yr.getBarycoord(py,Dc,Oc,Uc,d),r&&(c.uv=yr.getInterpolatedAttribute(r,o,l,h,d,new te)),n&&(c.uv1=yr.getInterpolatedAttribute(n,o,l,h,d,new te)),a&&(c.normal=yr.getInterpolatedAttribute(a,o,l,h,d,new R),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const u={a:o,b:l,c:h,normal:new R,materialIndex:0};yr.getNormal(Dc,Oc,Uc,u.normal),c.face=u,c.barycoord=d}return c}const my=new R,fy=new It,gy=new It,Nb=new R,yy=new et,Vc=new R,Bp=new ai,xy=new et,Vp=new Nn;class kp extends Xt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=tp,this.bindMatrix=new et,this.bindMatrixInverse=new et,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new di),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Vc),this.boundingBox.expandByPoint(Vc)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ai),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Vc),this.boundingSphere.expandByPoint(Vc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Bp.copy(this.boundingSphere),Bp.applyMatrix4(r),e.ray.intersectsSphere(Bp)!==!1&&(xy.copy(r).invert(),Vp.copy(e.ray).applyMatrix4(xy),!(this.boundingBox!==null&&Vp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Vp)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new It,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===tp?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===d0?this.bindMatrixInverse.copy(this.bindMatrix).invert():ge("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;fy.fromBufferAttribute(r.attributes.skinIndex,e),gy.fromBufferAttribute(r.attributes.skinWeight,e),my.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let n=0;n<4;n++){const a=gy.getComponent(n);if(a!==0){const o=fy.getComponent(n);yy.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(Nb.copy(my).applyMatrix4(yy),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class kc extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class os extends ei{constructor(e=null,t=1,i=1,r,n,a,o,l,h=Ht,c=Ht,d,u){super(null,a,o,l,h,c,r,n,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const vy=new et,Cb=new et;class Ah{constructor(e=[],t=[]){this.uuid=Zi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){ge("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new et)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new et;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let n=0,a=e.length;n<a;n++){const o=e[n]?e[n].matrixWorld:Cb;vy.multiplyMatrices(o,t[n]),vy.toArray(i,n*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Ah(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new os(t,e,e,vi,xi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const n=e.bones[i];let a=t[n];a===void 0&&(ge("Skeleton: No bone found with UUID:",n),a=new kc),this.bones.push(a),this.boneInverses.push(new et().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,n=t.length;r<n;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}let Rn=class extends bt{constructor(s,e,t,i=1){super(s,e,t),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(s){return super.copy(s),this.meshPerAttribute=s.meshPerAttribute,this}toJSON(){const s=super.toJSON();return s.meshPerAttribute=this.meshPerAttribute,s.isInstancedBufferAttribute=!0,s}};const Va=new et,_y=new et,Gc=[],My=new di,Rb=new et,Il=new Xt,Pl=new ai;class Gp extends Xt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Rn(new Float32Array(i*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,Rb)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new di),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Va),My.copy(e.boundingBox).applyMatrix4(Va),this.boundingBox.union(My)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Va),Pl.copy(e.boundingSphere).applyMatrix4(Va),this.boundingSphere.union(Pl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,n=i.length+1,a=e*n+1;for(let o=0;o<i.length;o++)i[o]=r[a+o]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(Il.geometry=this.geometry,Il.material=this.material,Il.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Pl.copy(this.boundingSphere),Pl.applyMatrix4(i),e.ray.intersectsSphere(Pl)!==!1))for(let n=0;n<r;n++){this.getMatrixAt(n,Va),_y.multiplyMatrices(i,Va),Il.matrixWorld=_y,Il.raycast(e,Gc);for(let a=0,o=Gc.length;a<o;a++){const l=Gc[a];l.instanceId=n,l.object=this,t.push(l)}Gc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Rn(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new os(new Float32Array(r*this.count),r,this.count,Wo,xi));const n=this.morphTexture.source.data.data;let a=0;for(let h=0;h<i.length;h++)a+=i[h];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;n[l]=o,n.set(i,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Hp=new R,Ib=new R,Pb=new at;let br=class{constructor(s=new R(1,0,0),e=0){this.isPlane=!0,this.normal=s,this.constant=e}set(s,e){return this.normal.copy(s),this.constant=e,this}setComponents(s,e,t,i){return this.normal.set(s,e,t),this.constant=i,this}setFromNormalAndCoplanarPoint(s,e){return this.normal.copy(s),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(s,e,t){const i=Hp.subVectors(t,e).cross(Ib.subVectors(s,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,s),this}copy(s){return this.normal.copy(s.normal),this.constant=s.constant,this}normalize(){const s=1/this.normal.length();return this.normal.multiplyScalar(s),this.constant*=s,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(s){return this.normal.dot(s)+this.constant}distanceToSphere(s){return this.distanceToPoint(s.center)-s.radius}projectPoint(s,e){return e.copy(s).addScaledVector(this.normal,-this.distanceToPoint(s))}intersectLine(s,e){const t=s.delta(Hp),i=this.normal.dot(t);if(i===0)return this.distanceToPoint(s.start)===0?e.copy(s.start):null;const r=-(s.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(s.start).addScaledVector(t,r)}intersectsLine(s){const e=this.distanceToPoint(s.start),t=this.distanceToPoint(s.end);return e<0&&t>0||t<0&&e>0}intersectsBox(s){return s.intersectsPlane(this)}intersectsSphere(s){return s.intersectsPlane(this)}coplanarPoint(s){return s.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(s,e){const t=e||Pb.getNormalMatrix(s),i=this.coplanarPoint(Hp).applyMatrix4(s),r=this.normal.applyMatrix3(t).normalize();return this.constant=-i.dot(r),this}translate(s){return this.constant-=s.dot(this.normal),this}equals(s){return s.normal.equals(this.normal)&&s.constant===this.constant}clone(){return new this.constructor().copy(this)}};const In=new ai,Lb=new te(.5,.5),Hc=new R;let Pn=class{constructor(s=new br,e=new br,t=new br,i=new br,r=new br,n=new br){this.planes=[s,e,t,i,r,n]}set(s,e,t,i,r,n){const a=this.planes;return a[0].copy(s),a[1].copy(e),a[2].copy(t),a[3].copy(i),a[4].copy(r),a[5].copy(n),this}copy(s){const e=this.planes;for(let t=0;t<6;t++)e[t].copy(s.planes[t]);return this}setFromProjectionMatrix(s,e=Yi,t=!1){const i=this.planes,r=s.elements,n=r[0],a=r[1],o=r[2],l=r[3],h=r[4],c=r[5],d=r[6],u=r[7],p=r[8],m=r[9],y=r[10],g=r[11],f=r[12],x=r[13],v=r[14],M=r[15];if(i[0].setComponents(l-n,u-h,g-p,M-f).normalize(),i[1].setComponents(l+n,u+h,g+p,M+f).normalize(),i[2].setComponents(l+a,u+c,g+m,M+x).normalize(),i[3].setComponents(l-a,u-c,g-m,M-x).normalize(),t)i[4].setComponents(o,d,y,v).normalize(),i[5].setComponents(l-o,u-d,g-y,M-v).normalize();else if(i[4].setComponents(l-o,u-d,g-y,M-v).normalize(),e===Yi)i[5].setComponents(l+o,u+d,g+y,M+v).normalize();else if(e===Sn)i[5].setComponents(o,d,y,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(s){if(s.boundingSphere!==void 0)s.boundingSphere===null&&s.computeBoundingSphere(),In.copy(s.boundingSphere).applyMatrix4(s.matrixWorld);else{const e=s.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),In.copy(e.boundingSphere).applyMatrix4(s.matrixWorld)}return this.intersectsSphere(In)}intersectsSprite(s){In.center.set(0,0,0);const e=Lb.distanceTo(s.center);return In.radius=.7071067811865476+e,In.applyMatrix4(s.matrixWorld),this.intersectsSphere(In)}intersectsSphere(s){const e=this.planes,t=s.center,i=-s.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(t)<i)return!1;return!0}intersectsBox(s){const e=this.planes;for(let t=0;t<6;t++){const i=e[t];if(Hc.x=i.normal.x>0?s.max.x:s.min.x,Hc.y=i.normal.y>0?s.max.y:s.min.y,Hc.z=i.normal.z>0?s.max.z:s.min.z,i.distanceToPoint(Hc)<0)return!1}return!0}containsPoint(s){const e=this.planes;for(let t=0;t<6;t++)if(e[t].distanceToPoint(s)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};const Hs=new et,Ws=new Pn;class Pd{constructor(){this.coordinateSystem=Yi}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Hs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ws.setFromProjectionMatrix(Hs,r.coordinateSystem,r.reversedDepth),Ws.containsPoint(e))return!0}return!1}clone(){return new Pd}}function Wp(s,e){return s-e}function Db(s,e){return s.z-e.z}function Ob(s,e){return e.z-s.z}class Ub{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,r){const n=this.pool,a=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1,index:-1});const o=n[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=i,o.index=r}reset(){this.list.length=0,this.index=0}}const ki=new et,Fb=new we(1,1,1),by=new Pn,zb=new Pd,Wc=new di,Ln=new ai,Ll=new R,Sy=new R,Bb=new R,jp=new Ub,Si=new Xt,jc=[];function Vb(s,e,t=0){const i=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const r=s.count;for(let n=0;n<r;n++)for(let a=0;a<i;a++)e.setComponent(n+t,a,s.getComponent(n,a))}else e.array.set(s.array,t*i);e.needsUpdate=!0}function Dn(s,e){if(s.constructor!==e.constructor){const t=Math.min(s.length,e.length);for(let i=0;i<t;i++)e[i]=s[i]}else{const t=Math.min(s.length,e.length);e.set(new s.constructor(s.buffer,0,t))}}class Xp extends Xt{constructor(e,t,i=t*2,r){super(new rt,r),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=e,this._maxVertexCount=t,this._maxIndexCount=i,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),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 e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new os(t,e,e,vi,xi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new os(t,e,e,ya,qi);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new os(t,e,e,vi,xi);i.colorSpace=mt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const n in e.attributes){const a=e.getAttribute(n),{array:o,itemSize:l,normalized:h}=a,c=new o.constructor(i*l),d=new bt(c,l,h);t.setAttribute(n,d)}if(e.getIndex()!==null){const n=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new bt(n,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),n=t.getAttribute(i);if(r.itemSize!==n.itemSize||r.normalized!==n.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new di);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const n=t[i].geometryIndex;this.getMatrixAt(i,ki),this.getBoundingBoxAt(n,Wc).applyMatrix4(ki),e.union(Wc)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ai);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const n=t[i].geometryIndex;this.getMatrixAt(i,ki),this.getBoundingSphereAt(n,Ln).applyMatrix4(ki),e.union(Ln)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Wp),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=t):(i=this._instanceInfo.length,this._instanceInfo.push(t));const r=this._matricesTexture;ki.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;const n=this._colorsTexture;return n&&(Fb.toArray(n.image.data,i*4),n.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},n=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=i===-1?a.count:i),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Wp),o=this._availableGeometryIds.shift(),n[o]=r):(o=this._geometryCount,this._geometryCount++,n.push(r)),this.setGeometryAt(o,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,n=i.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,h=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const c in i.attributes){const d=t.getAttribute(c),u=i.getAttribute(c);Vb(d,u,l);const p=d.itemSize;for(let m=d.count,y=h;m<y;m++){const g=l+m;for(let f=0;f<p;f++)u.setComponent(g,f,0)}u.needsUpdate=!0,u.addUpdateRange(l*p,h*p)}if(r){const c=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let u=0;u<a.count;u++)n.setX(c+u,l+a.getX(u));for(let u=a.count,p=d;u<p;u++)n.setX(c+u,l);n.needsUpdate=!0,n.addUpdateRange(c,o.reservedIndexCount)}return o.start=r?o.indexStart:o.vertexStart,o.count=r?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let r=0,n=i.length;r<n;r++)i[r].active&&i[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const i=this._geometryInfo,r=i.map((a,o)=>o).sort((a,o)=>i[a].vertexStart-i[o].vertexStart),n=this.geometry;for(let a=0,o=i.length;a<o;a++){const l=r[a],h=i[l];if(h.active!==!1){if(n.index!==null){if(h.indexStart!==t){const{indexStart:c,vertexStart:d,reservedIndexCount:u}=h,p=n.index,m=p.array,y=e-d;for(let g=c;g<c+u;g++)m[g]=m[g]+y;p.array.copyWithin(t,c,c+u),p.addUpdateRange(t,u),p.needsUpdate=!0,h.indexStart=t}t+=h.reservedIndexCount}if(h.vertexStart!==e){const{vertexStart:c,reservedVertexCount:d}=h,u=n.attributes;for(const p in u){const m=u[p],{array:y,itemSize:g}=m;y.copyWithin(e*g,c*g,(c+d)*g),m.addUpdateRange(e*g,d*g),m.needsUpdate=!0}h.vertexStart=e}e+=h.reservedVertexCount,h.start=n.index?h.indexStart:h.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const n=new di,a=i.index,o=i.attributes.position;for(let l=r.start,h=r.start+r.count;l<h;l++){let c=l;a&&(c=a.getX(c)),n.expandByPoint(Ll.fromBufferAttribute(o,c))}r.boundingBox=n}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const n=new ai;this.getBoundingBoxAt(e,Wc),Wc.getCenter(n.center);const a=i.index,o=i.attributes.position;let l=0;for(let h=r.start,c=r.start+r.count;h<c;h++){let d=h;a&&(d=a.getX(d)),Ll.fromBufferAttribute(o,d),l=Math.max(l,n.center.distanceToSquared(Ll))}n.radius=Math.sqrt(l),r.boundingSphere=n}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),i.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const i=this._geometryInfo[e];return t.vertexStart=i.vertexStart,t.vertexCount=i.vertexCount,t.reservedVertexCount=i.reservedVertexCount,t.indexStart=i.indexStart,t.indexCount=i.indexCount,t.reservedIndexCount=i.reservedIndexCount,t.start=i.start,t.count=i.count,t}setInstanceCount(e){const t=this._availableInstanceIds,i=this._instanceInfo;for(t.sort(Wp);t[t.length-1]===i.length-1;)i.pop(),t.pop();if(e<i.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const r=new Int32Array(e),n=new Int32Array(e);Dn(this._multiDrawCounts,r),Dn(this._multiDrawStarts,n),this._multiDrawCounts=r,this._multiDrawStarts=n,this._maxInstanceCount=e;const a=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Dn(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),Dn(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),Dn(l.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const i=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...i.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(a=>a.indexStart+a.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new rt,this._initializeGeometry(r));const n=this.geometry;r.index&&Dn(r.index.array,n.index.array);for(const a in r.attributes)Dn(r.attributes[a].array,n.attributes[a].array)}raycast(e,t){const i=this._instanceInfo,r=this._geometryInfo,n=this.matrixWorld,a=this.geometry;Si.material=this.material,Si.geometry.index=a.index,Si.geometry.attributes=a.attributes,Si.geometry.boundingBox===null&&(Si.geometry.boundingBox=new di),Si.geometry.boundingSphere===null&&(Si.geometry.boundingSphere=new ai);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const h=i[o].geometryIndex,c=r[h];Si.geometry.setDrawRange(c.start,c.count),this.getMatrixAt(o,Si.matrixWorld).premultiply(n),this.getBoundingBoxAt(h,Si.geometry.boundingBox),this.getBoundingSphereAt(h,Si.geometry.boundingSphere),Si.raycast(e,jc);for(let d=0,u=jc.length;d<u;d++){const p=jc[d];p.object=this,p.batchId=o,t.push(p)}jc.length=0}Si.material=null,Si.geometry.index=null,Si.geometry.attributes={},Si.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._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(e,t,i,r,n){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex();let o=a===null?1:a.array.BYTES_PER_ELEMENT,l=1;n.wireframe&&(l=2,o=r.attributes.position.count>65535?4:2);const h=this._instanceInfo,c=this._multiDrawStarts,d=this._multiDrawCounts,u=this._geometryInfo,p=this.perObjectFrustumCulled,m=this._indirectTexture,y=m.image.data,g=i.isArrayCamera?zb:by;p&&!i.isArrayCamera&&(ki.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),by.setFromProjectionMatrix(ki,i.coordinateSystem,i.reversedDepth));let f=0;if(this.sortObjects){ki.copy(this.matrixWorld).invert(),Ll.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ki),Sy.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(ki);for(let M=0,w=h.length;M<w;M++)if(h[M].visible&&h[M].active){const T=h[M].geometryIndex;this.getMatrixAt(M,ki),this.getBoundingSphereAt(T,Ln).applyMatrix4(ki);let A=!1;if(p&&(A=!g.intersectsSphere(Ln,i)),!A){const _=u[T],S=Bb.subVectors(Ln.center,Ll).dot(Sy);jp.push(_.start,_.count,S,M)}}const x=jp.list,v=this.customSort;v===null?x.sort(n.transparent?Ob:Db):v.call(this,x,i);for(let M=0,w=x.length;M<w;M++){const T=x[M];c[f]=T.start*o*l,d[f]=T.count*l,y[f]=T.index,f++}jp.reset()}else for(let x=0,v=h.length;x<v;x++)if(h[x].visible&&h[x].active){const M=h[x].geometryIndex;let w=!1;if(p&&(this.getMatrixAt(x,ki),this.getBoundingSphereAt(M,Ln).applyMatrix4(ki),w=!g.intersectsSphere(Ln,i)),!w){const T=u[M];c[f]=T.start*o*l,d[f]=T.count*l,y[f]=x,f++}}m.needsUpdate=!0,this._multiDrawCount=f,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,n,a){this.onBeforeRender(e,null,r,n,a)}}class Ti extends pi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new we(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Xc=new R,qc=new R,Ty=new et,Dl=new Nn,Yc=new ai,qp=new R,wy=new R;class Sr extends _t{constructor(e=new rt,t=new Ti){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,n=t.count;r<n;r++)Xc.fromBufferAttribute(t,r-1),qc.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Xc.distanceTo(qc);e.setAttribute("lineDistance",new Ne(i,1))}else ge("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,n=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Yc.copy(i.boundingSphere),Yc.applyMatrix4(r),Yc.radius+=n,e.ray.intersectsSphere(Yc)===!1)return;Ty.copy(r).invert(),Dl.copy(e.ray).applyMatrix4(Ty);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,h=this.isLineSegments?2:1,c=i.index,d=i.attributes.position;if(c!==null){const u=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let m=u,y=p-1;m<y;m+=h){const g=c.getX(m),f=c.getX(m+1),x=Zc(this,e,Dl,l,g,f,m);x&&t.push(x)}if(this.isLineLoop){const m=c.getX(p-1),y=c.getX(u),g=Zc(this,e,Dl,l,m,y,p-1);g&&t.push(g)}}else{const u=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let m=u,y=p-1;m<y;m+=h){const g=Zc(this,e,Dl,l,m,m+1,m);g&&t.push(g)}if(this.isLineLoop){const m=Zc(this,e,Dl,l,p-1,u,p-1);m&&t.push(m)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Zc(s,e,t,i,r,n,a){const o=s.geometry.attributes.position;if(Xc.fromBufferAttribute(o,r),qc.fromBufferAttribute(o,n),t.distanceSqToSegment(Xc,qc,qp,wy)>i)return;qp.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(qp);if(!(l<e.near||l>e.far))return{distance:l,point:wy.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Ey=new R,Ay=new R;class Rs extends Sr{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,n=t.count;r<n;r+=2)Ey.fromBufferAttribute(t,r),Ay.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ey.distanceTo(Ay);e.setAttribute("lineDistance",new Ne(i,1))}else ge("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Yp extends Sr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Jc extends pi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new we(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Ny=new et,Zp=new Nn,Kc=new ai,$c=new R;class Jp extends _t{constructor(e=new rt,t=new Jc){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,n=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Kc.copy(i.boundingSphere),Kc.applyMatrix4(r),Kc.radius+=n,e.ray.intersectsSphere(Kc)===!1)return;Ny.copy(r).invert(),Zp.copy(e.ray).applyMatrix4(Ny);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,h=i.index,c=i.attributes.position;if(h!==null){const d=Math.max(0,a.start),u=Math.min(h.count,a.start+a.count);for(let p=d,m=u;p<m;p++){const y=h.getX(p);$c.fromBufferAttribute(c,y),Cy($c,y,l,r,e,t,this)}}else{const d=Math.max(0,a.start),u=Math.min(c.count,a.start+a.count);for(let p=d,m=u;p<m;p++)$c.fromBufferAttribute(c,p),Cy($c,p,l,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Cy(s,e,t,i,r,n,a){const o=Zp.distanceSqToPoint(s);if(o<t){const l=new R;Zp.closestPointToPoint(s,l),l.applyMatrix4(i);const h=r.ray.origin.distanceTo(l);if(h<r.near||h>r.far)return;n.push({distance:h,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Kp extends ei{constructor(e,t,i,r,n=Rt,a=Rt,o,l,h){super(e,t,i,r,n,a,o,l,h),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const c=this;function d(){c.needsUpdate=!0,c._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class kb extends Kp{constructor(e,t,i,r,n,a,o,l){super({},e,t,i,r,n,a,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}let Gb=class extends ei{constructor(s,e){super({width:s,height:e}),this.isFramebufferTexture=!0,this.magFilter=Ht,this.minFilter=Ht,this.generateMipmaps=!1,this.needsUpdate=!0}};class Ol extends ei{constructor(e,t,i,r,n,a,o,l,h,c,d,u){super(null,a,o,l,h,c,r,n,d,u),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Ry extends Ol{constructor(e,t,i,r,n,a){super(e,t,i,n,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Ci,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Iy extends Ol{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,ks),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}let ka=class extends ei{constructor(s=[],e=ks,t,i,r,n,a,o,l,h){super(s,e,t,i,r,n,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(s){this.image=s}};class Py extends ei{constructor(e,t,i,r,n,a,o,l,h){super(e,t,i,r,n,a,o,l,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}let On=class extends ei{constructor(s,e,t=qi,i,r,n,a=Ht,o=Ht,l,h=ws,c=1){if(h!==ws&&h!==ur)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:s,height:e,depth:c};super(d,i,r,n,a,o,h,t,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(s){return super.copy(s),this.source=new pr(Object.assign({},s.image)),this.compareFunction=s.compareFunction,this}toJSON(s){const e=super.toJSON(s);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},Ly=class extends On{constructor(s,e=qi,t=ks,i,r,n=Ht,a=Ht,o,l=ws){const h={width:s,height:s,depth:1},c=[h,h,h,h,h,h];super(s,s,e,t,i,r,n,a,o,l),this.image=c,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(s){this.image=s}};class $p extends ei{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class dn extends rt{constructor(e=1,t=1,i=1,r=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:n,depthSegments:a};const o=this;r=Math.floor(r),n=Math.floor(n),a=Math.floor(a);const l=[],h=[],c=[],d=[];let u=0,p=0;m("z","y","x",-1,-1,i,t,e,a,n,0),m("z","y","x",1,-1,i,t,-e,a,n,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,n,4),m("x","y","z",-1,-1,e,t,-i,r,n,5),this.setIndex(l),this.setAttribute("position",new Ne(h,3)),this.setAttribute("normal",new Ne(c,3)),this.setAttribute("uv",new Ne(d,2));function m(y,g,f,x,v,M,w,T,A,_,S){const P=M/A,C=w/_,L=M/2,U=w/2,V=T/2,B=A+1,k=_+1;let W=0,se=0;const ie=new R;for(let oe=0;oe<k;oe++){const be=oe*C-U;for(let Ce=0;Ce<B;Ce++){const tt=Ce*P-L;ie[y]=tt*x,ie[g]=be*v,ie[f]=V,h.push(ie.x,ie.y,ie.z),ie[y]=0,ie[g]=0,ie[f]=T>0?1:-1,c.push(ie.x,ie.y,ie.z),d.push(Ce/A),d.push(1-oe/_),W+=1}}for(let oe=0;oe<_;oe++)for(let be=0;be<A;be++){const Ce=u+be+B*oe,tt=u+be+B*(oe+1),wt=u+(be+1)+B*(oe+1),Et=u+(be+1)+B*oe;l.push(Ce,tt,Et),l.push(tt,wt,Et),se+=6}o.addGroup(p,se,S),p+=se,u+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Ld extends rt{constructor(e=1,t=1,i=4,r=8,n=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:r,heightSegments:n},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),r=Math.max(3,Math.floor(r)),n=Math.max(1,Math.floor(n));const a=[],o=[],l=[],h=[],c=t/2,d=Math.PI/2*e,u=t,p=2*d+u,m=i*2+n,y=r+1,g=new R,f=new R;for(let x=0;x<=m;x++){let v=0,M=0,w=0,T=0;if(x<=i){const S=x/i,P=S*Math.PI/2;M=-c-e*Math.cos(P),w=e*Math.sin(P),T=-e*Math.cos(P),v=S*d}else if(x<=i+n){const S=(x-i)/n;M=-c+S*t,w=e,T=0,v=d+S*u}else{const S=(x-i-n)/i,P=S*Math.PI/2;M=c+e*Math.sin(P),w=e*Math.cos(P),T=e*Math.sin(P),v=d+u+S*d}const A=Math.max(0,Math.min(1,v/p));let _=0;x===0?_=.5/r:x===m&&(_=-.5/r);for(let S=0;S<=r;S++){const P=S/r,C=P*Math.PI*2,L=Math.sin(C),U=Math.cos(C);f.x=-w*U,f.y=M,f.z=w*L,o.push(f.x,f.y,f.z),g.set(-w*U,T,w*L),g.normalize(),l.push(g.x,g.y,g.z),h.push(P+_,A)}if(x>0){const S=(x-1)*y;for(let P=0;P<r;P++){const C=S+P,L=S+P+1,U=x*y+P,V=x*y+P+1;a.push(C,L,U),a.push(L,V,U)}}}this.setIndex(a),this.setAttribute("position",new Ne(o,3)),this.setAttribute("normal",new Ne(l,3)),this.setAttribute("uv",new Ne(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ld(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Dd extends rt{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const n=[],a=[],o=[],l=[],h=new R,c=new te;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const p=i+d/t*r;h.x=e*Math.cos(p),h.y=e*Math.sin(p),a.push(h.x,h.y,h.z),o.push(0,0,1),c.x=(a[u]/e+1)/2,c.y=(a[u+1]/e+1)/2,l.push(c.x,c.y)}for(let d=1;d<=t;d++)n.push(d,d+1,0);this.setIndex(n),this.setAttribute("position",new Ne(a,3)),this.setAttribute("normal",new Ne(o,3)),this.setAttribute("uv",new Ne(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Dd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Io extends rt{constructor(e=1,t=1,i=1,r=32,n=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l};const h=this;r=Math.floor(r),n=Math.floor(n);const c=[],d=[],u=[],p=[];let m=0;const y=[],g=i/2;let f=0;x(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Ne(d,3)),this.setAttribute("normal",new Ne(u,3)),this.setAttribute("uv",new Ne(p,2));function x(){const M=new R,w=new R;let T=0;const A=(t-e)/i;for(let _=0;_<=n;_++){const S=[],P=_/n,C=P*(t-e)+e;for(let L=0;L<=r;L++){const U=L/r,V=U*l+o,B=Math.sin(V),k=Math.cos(V);w.x=C*B,w.y=-P*i+g,w.z=C*k,d.push(w.x,w.y,w.z),M.set(B,A,k).normalize(),u.push(M.x,M.y,M.z),p.push(U,1-P),S.push(m++)}y.push(S)}for(let _=0;_<r;_++)for(let S=0;S<n;S++){const P=y[S][_],C=y[S+1][_],L=y[S+1][_+1],U=y[S][_+1];(e>0||S!==0)&&(c.push(P,C,U),T+=3),(t>0||S!==n-1)&&(c.push(C,L,U),T+=3)}h.addGroup(f,T,0),f+=T}function v(M){const w=m,T=new te,A=new R;let _=0;const S=M===!0?e:t,P=M===!0?1:-1;for(let L=1;L<=r;L++)d.push(0,g*P,0),u.push(0,P,0),p.push(.5,.5),m++;const C=m;for(let L=0;L<=r;L++){const U=L/r*l+o,V=Math.cos(U),B=Math.sin(U);A.x=S*B,A.y=g*P,A.z=S*V,d.push(A.x,A.y,A.z),u.push(0,P,0),T.x=V*.5+.5,T.y=B*.5*P+.5,p.push(T.x,T.y),m++}for(let L=0;L<r;L++){const U=w+L,V=C+L;M===!0?c.push(V,V+1,U):c.push(V+1,V,U),_+=3}h.addGroup(f,_,M===!0?1:2),f+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Io(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Nh extends Io{constructor(e=1,t=1,i=32,r=1,n=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,n,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Nh(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class pn extends rt{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const n=[],a=[];o(r),h(i),c(),this.setAttribute("position",new Ne(n,3)),this.setAttribute("normal",new Ne(n.slice(),3)),this.setAttribute("uv",new Ne(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){const v=new R,M=new R,w=new R;for(let T=0;T<t.length;T+=3)p(t[T+0],v),p(t[T+1],M),p(t[T+2],w),l(v,M,w,x)}function l(x,v,M,w){const T=w+1,A=[];for(let _=0;_<=T;_++){A[_]=[];const S=x.clone().lerp(M,_/T),P=v.clone().lerp(M,_/T),C=T-_;for(let L=0;L<=C;L++)L===0&&_===T?A[_][L]=S:A[_][L]=S.clone().lerp(P,L/C)}for(let _=0;_<T;_++)for(let S=0;S<2*(T-_)-1;S++){const P=Math.floor(S/2);S%2===0?(u(A[_][P+1]),u(A[_+1][P]),u(A[_][P])):(u(A[_][P+1]),u(A[_+1][P+1]),u(A[_+1][P]))}}function h(x){const v=new R;for(let M=0;M<n.length;M+=3)v.x=n[M+0],v.y=n[M+1],v.z=n[M+2],v.normalize().multiplyScalar(x),n[M+0]=v.x,n[M+1]=v.y,n[M+2]=v.z}function c(){const x=new R;for(let v=0;v<n.length;v+=3){x.x=n[v+0],x.y=n[v+1],x.z=n[v+2];const M=g(x)/2/Math.PI+.5,w=f(x)/Math.PI+.5;a.push(M,1-w)}m(),d()}function d(){for(let x=0;x<a.length;x+=6){const v=a[x+0],M=a[x+2],w=a[x+4],T=Math.max(v,M,w),A=Math.min(v,M,w);T>.9&&A<.1&&(v<.2&&(a[x+0]+=1),M<.2&&(a[x+2]+=1),w<.2&&(a[x+4]+=1))}}function u(x){n.push(x.x,x.y,x.z)}function p(x,v){const M=x*3;v.x=e[M+0],v.y=e[M+1],v.z=e[M+2]}function m(){const x=new R,v=new R,M=new R,w=new R,T=new te,A=new te,_=new te;for(let S=0,P=0;S<n.length;S+=9,P+=6){x.set(n[S+0],n[S+1],n[S+2]),v.set(n[S+3],n[S+4],n[S+5]),M.set(n[S+6],n[S+7],n[S+8]),T.set(a[P+0],a[P+1]),A.set(a[P+2],a[P+3]),_.set(a[P+4],a[P+5]),w.copy(x).add(v).add(M).divideScalar(3);const C=g(w);y(T,P+0,x,C),y(A,P+2,v,C),y(_,P+4,M,C)}}function y(x,v,M,w){w<0&&x.x===1&&(a[v]=x.x-1),M.x===0&&M.z===0&&(a[v]=w/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function f(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pn(e.vertices,e.indices,e.radius,e.detail)}}class Od extends pn{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[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(n,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Od(e.radius,e.detail)}}const Qc=new R,eu=new R,Qp=new R,tu=new yr;class em extends rt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(Tn*t),n=e.getIndex(),a=e.getAttribute("position"),o=n?n.count:a.count,l=[0,0,0],h=["a","b","c"],c=new Array(3),d={},u=[];for(let p=0;p<o;p+=3){n?(l[0]=n.getX(p),l[1]=n.getX(p+1),l[2]=n.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:m,b:y,c:g}=tu;if(m.fromBufferAttribute(a,l[0]),y.fromBufferAttribute(a,l[1]),g.fromBufferAttribute(a,l[2]),tu.getNormal(Qp),c[0]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,c[1]=`${Math.round(y.x*i)},${Math.round(y.y*i)},${Math.round(y.z*i)}`,c[2]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,!(c[0]===c[1]||c[1]===c[2]||c[2]===c[0]))for(let f=0;f<3;f++){const x=(f+1)%3,v=c[f],M=c[x],w=tu[h[f]],T=tu[h[x]],A=`${v}_${M}`,_=`${M}_${v}`;_ in d&&d[_]?(Qp.dot(d[_].normal)<=r&&(u.push(w.x,w.y,w.z),u.push(T.x,T.y,T.z)),d[_]=null):A in d||(d[A]={index0:l[f],index1:l[x],normal:Qp.clone()})}}for(const p in d)if(d[p]){const{index0:m,index1:y}=d[p];Qc.fromBufferAttribute(a,m),eu.fromBufferAttribute(a,y),u.push(Qc.x,Qc.y,Qc.z),u.push(eu.x,eu.y,eu.z)}this.setAttribute("position",new Ne(u,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class ls{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){ge("Curve: .getPoint() not implemented.")}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),n=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),n+=i.distanceTo(r),t.push(n),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let r=0;const n=i.length;let a;t?a=t:a=e*i[n-1];let o=0,l=n-1,h;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),h=i[r]-a,h<0)o=r+1;else if(h>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(n-1);const c=i[r],d=i[r+1]-c,u=(a-c)/d;return(r+u)/(n-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const n=this.getPoint(i),a=this.getPoint(r),o=t||(n.isVector2?new te:new R);return o.copy(a).sub(n).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new R,r=[],n=[],a=[],o=new R,l=new et;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new R)}n[0]=new R,a[0]=new R;let h=Number.MAX_VALUE;const c=Math.abs(r[0].x),d=Math.abs(r[0].y),u=Math.abs(r[0].z);c<=h&&(h=c,i.set(1,0,0)),d<=h&&(h=d,i.set(0,1,0)),u<=h&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),n[0].crossVectors(r[0],o),a[0].crossVectors(r[0],n[0]);for(let p=1;p<=e;p++){if(n[p]=n[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Ke(r[p-1].dot(r[p]),-1,1));n[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],n[p])}if(t===!0){let p=Math.acos(Ke(n[0].dot(n[e]),-1,1));p/=e,r[0].dot(o.crossVectors(n[0],n[e]))>0&&(p=-p);for(let m=1;m<=e;m++)n[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],n[m])}return{tangents:r,normals:n,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class iu extends ls{constructor(e=0,t=0,i=1,r=1,n=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=n,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new te){const i=t,r=Math.PI*2;let n=this.aEndAngle-this.aStartAngle;const a=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=r;for(;n>r;)n-=r;n<Number.EPSILON&&(a?n=0:n=r),this.aClockwise===!0&&!a&&(n===r?n=-r:n=n-r);const o=this.aStartAngle+e*n;let l=this.aX+this.xRadius*Math.cos(o),h=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),u=l-this.aX,p=h-this.aY;l=u*c-p*d+this.aX,h=u*d+p*c+this.aY}return i.set(l,h)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Dy extends iu{constructor(e,t,i,r,n,a){super(e,t,i,i,r,n,a),this.isArcCurve=!0,this.type="ArcCurve"}}function tm(){let s=0,e=0,t=0,i=0;function r(n,a,o,l){s=n,e=o,t=-3*n+3*a-2*o-l,i=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){r(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,c,d){let u=(a-n)/h-(o-n)/(h+c)+(o-a)/c,p=(o-a)/c-(l-a)/(c+d)+(l-o)/d;u*=c,p*=c,r(a,o,u,p)},calc:function(n){const a=n*n,o=a*n;return s+e*n+t*a+i*o}}}const su=new R,im=new tm,sm=new tm,rm=new tm;class nm extends ls{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new R){const i=t,r=this.points,n=r.length,a=(n-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/n)+1)*n:l===0&&o===n-1&&(o=n-2,l=1);let h,c;this.closed||o>0?h=r[(o-1)%n]:(su.subVectors(r[0],r[1]).add(r[0]),h=su);const d=r[o%n],u=r[(o+1)%n];if(this.closed||o+2<n?c=r[(o+2)%n]:(su.subVectors(r[n-1],r[n-2]).add(r[n-1]),c=su),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(h.distanceToSquared(d),p),y=Math.pow(d.distanceToSquared(u),p),g=Math.pow(u.distanceToSquared(c),p);y<1e-4&&(y=1),m<1e-4&&(m=y),g<1e-4&&(g=y),im.initNonuniformCatmullRom(h.x,d.x,u.x,c.x,m,y,g),sm.initNonuniformCatmullRom(h.y,d.y,u.y,c.y,m,y,g),rm.initNonuniformCatmullRom(h.z,d.z,u.z,c.z,m,y,g)}else this.curveType==="catmullrom"&&(im.initCatmullRom(h.x,d.x,u.x,c.x,this.tension),sm.initCatmullRom(h.y,d.y,u.y,c.y,this.tension),rm.initCatmullRom(h.z,d.z,u.z,c.z,this.tension));return i.set(im.calc(l),sm.calc(l),rm.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new R().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Oy(s,e,t,i,r){const n=(i-e)*.5,a=(r-t)*.5,o=s*s,l=s*o;return(2*t-2*i+n+a)*l+(-3*t+3*i-2*n-a)*o+n*s+t}function Hb(s,e){const t=1-s;return t*t*e}function Wb(s,e){return 2*(1-s)*s*e}function jb(s,e){return s*s*e}function Ul(s,e,t,i){return Hb(s,e)+Wb(s,t)+jb(s,i)}function Xb(s,e){const t=1-s;return t*t*t*e}function qb(s,e){const t=1-s;return 3*t*t*s*e}function Yb(s,e){return 3*(1-s)*s*s*e}function Zb(s,e){return s*s*s*e}function Fl(s,e,t,i,r){return Xb(s,e)+qb(s,t)+Yb(s,i)+Zb(s,r)}class am extends ls{constructor(e=new te,t=new te,i=new te,r=new te){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new te){const i=t,r=this.v0,n=this.v1,a=this.v2,o=this.v3;return i.set(Fl(e,r.x,n.x,a.x,o.x),Fl(e,r.y,n.y,a.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Uy extends ls{constructor(e=new R,t=new R,i=new R,r=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new R){const i=t,r=this.v0,n=this.v1,a=this.v2,o=this.v3;return i.set(Fl(e,r.x,n.x,a.x,o.x),Fl(e,r.y,n.y,a.y,o.y),Fl(e,r.z,n.z,a.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class om extends ls{constructor(e=new te,t=new te){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new te){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new te){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Fy extends ls{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class lm extends ls{constructor(e=new te,t=new te,i=new te){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new te){const i=t,r=this.v0,n=this.v1,a=this.v2;return i.set(Ul(e,r.x,n.x,a.x),Ul(e,r.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class hm extends ls{constructor(e=new R,t=new R,i=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new R){const i=t,r=this.v0,n=this.v1,a=this.v2;return i.set(Ul(e,r.x,n.x,a.x),Ul(e,r.y,n.y,a.y),Ul(e,r.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class cm extends ls{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new te){const i=t,r=this.points,n=(r.length-1)*e,a=Math.floor(n),o=n-a,l=r[a===0?a:a-1],h=r[a],c=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return i.set(Oy(o,l.x,h.x,c.x,d.x),Oy(o,l.y,h.y,c.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new te().fromArray(r))}return this}}var ru=Object.freeze({__proto__:null,ArcCurve:Dy,CatmullRomCurve3:nm,CubicBezierCurve:am,CubicBezierCurve3:Uy,EllipseCurve:iu,LineCurve:om,LineCurve3:Fy,QuadraticBezierCurve:lm,QuadraticBezierCurve3:hm,SplineCurve:cm});class zy extends ls{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ru[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let n=0;for(;n<r.length;){if(r[n]>=i){const a=r[n]-i,o=this.curves[n],l=o.getLength(),h=l===0?0:1-a/l;return o.getPointAt(h,t)}n++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,n=this.curves;r<n.length;r++){const a=n[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let h=0;h<l.length;h++){const c=l[h];i&&i.equals(c)||(t.push(c),i=c)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new ru[r.type]().fromJSON(r))}return this}}class nu extends zy{constructor(e){super(),this.type="Path",this.currentPoint=new te,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new om(this.currentPoint.clone(),new te(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const n=new lm(this.currentPoint.clone(),new te(e,t),new te(i,r));return this.curves.push(n),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,n,a){const o=new am(this.currentPoint.clone(),new te(e,t),new te(i,r),new te(n,a));return this.curves.push(o),this.currentPoint.set(n,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new cm(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,n,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,n,a),this}absarc(e,t,i,r,n,a){return this.absellipse(e,t,i,i,r,n,a),this}ellipse(e,t,i,r,n,a,o,l){const h=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+h,t+c,i,r,n,a,o,l),this}absellipse(e,t,i,r,n,a,o,l){const h=new iu(e,t,i,r,n,a,o,l);if(this.curves.length>0){const d=h.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(h);const c=h.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Zr extends nu{constructor(e){super(e),this.uuid=Zi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new nu().fromJSON(r))}return this}}function Jb(s,e,t=2){const i=e&&e.length,r=i?e[0]*t:s.length;let n=By(s,0,r,t,!0);const a=[];if(!n||n.next===n.prev)return a;let o,l,h;if(i&&(n=tS(s,e,n,t)),s.length>80*t){o=s[0],l=s[1];let c=o,d=l;for(let u=t;u<r;u+=t){const p=s[u],m=s[u+1];p<o&&(o=p),m<l&&(l=m),p>c&&(c=p),m>d&&(d=m)}h=Math.max(c-o,d-l),h=h!==0?32767/h:0}return zl(n,a,t,o,l,h,0),a}function By(s,e,t,i,r){let n;if(r===dS(s,e,t,i)>0)for(let a=e;a<t;a+=i)n=Hy(a/i|0,s[a],s[a+1],n);else for(let a=t-i;a>=e;a-=i)n=Hy(a/i|0,s[a],s[a+1],n);return n&&Ga(n,n.next)&&(kl(n),n=n.next),n}function Un(s,e){if(!s)return s;e||(e=s);let t=s,i;do if(i=!1,!t.steiner&&(Ga(t,t.next)||Ft(t.prev,t,t.next)===0)){if(kl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function zl(s,e,t,i,r,n,a){if(!s)return;!a&&n&&aS(s,i,r,n);let o=s;for(;s.prev!==s.next;){const l=s.prev,h=s.next;if(n?$b(s,i,r,n):Kb(s)){e.push(l.i,s.i,h.i),kl(s),s=h.next,o=h.next;continue}if(s=h,s===o){a?a===1?(s=Qb(Un(s),e),zl(s,e,t,i,r,n,2)):a===2&&eS(s,e,t,i,r,n):zl(Un(s),e,t,i,r,n,1);break}}}function Kb(s){const e=s.prev,t=s,i=s.next;if(Ft(e,t,i)>=0)return!1;const r=e.x,n=t.x,a=i.x,o=e.y,l=t.y,h=i.y,c=Math.min(r,n,a),d=Math.min(o,l,h),u=Math.max(r,n,a),p=Math.max(o,l,h);let m=i.next;for(;m!==e;){if(m.x>=c&&m.x<=u&&m.y>=d&&m.y<=p&&Bl(r,o,n,l,a,h,m.x,m.y)&&Ft(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function $b(s,e,t,i){const r=s.prev,n=s,a=s.next;if(Ft(r,n,a)>=0)return!1;const o=r.x,l=n.x,h=a.x,c=r.y,d=n.y,u=a.y,p=Math.min(o,l,h),m=Math.min(c,d,u),y=Math.max(o,l,h),g=Math.max(c,d,u),f=um(p,m,e,t,i),x=um(y,g,e,t,i);let v=s.prevZ,M=s.nextZ;for(;v&&v.z>=f&&M&&M.z<=x;){if(v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&Bl(o,c,l,d,h,u,v.x,v.y)&&Ft(v.prev,v,v.next)>=0||(v=v.prevZ,M.x>=p&&M.x<=y&&M.y>=m&&M.y<=g&&M!==r&&M!==a&&Bl(o,c,l,d,h,u,M.x,M.y)&&Ft(M.prev,M,M.next)>=0))return!1;M=M.nextZ}for(;v&&v.z>=f;){if(v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&Bl(o,c,l,d,h,u,v.x,v.y)&&Ft(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;M&&M.z<=x;){if(M.x>=p&&M.x<=y&&M.y>=m&&M.y<=g&&M!==r&&M!==a&&Bl(o,c,l,d,h,u,M.x,M.y)&&Ft(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function Qb(s,e){let t=s;do{const i=t.prev,r=t.next.next;!Ga(i,r)&&ky(i,t,t.next,r)&&Vl(i,r)&&Vl(r,i)&&(e.push(i.i,t.i,r.i),kl(t),kl(t.next),t=s=r),t=t.next}while(t!==s);return Un(t)}function eS(s,e,t,i,r,n){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&hS(a,o)){let l=Gy(a,o);a=Un(a,a.next),l=Un(l,l.next),zl(a,e,t,i,r,n,0),zl(l,e,t,i,r,n,0);return}o=o.next}a=a.next}while(a!==s)}function tS(s,e,t,i){const r=[];for(let n=0,a=e.length;n<a;n++){const o=e[n]*i,l=n<a-1?e[n+1]*i:s.length,h=By(s,o,l,i,!1);h===h.next&&(h.steiner=!0),r.push(lS(h))}r.sort(iS);for(let n=0;n<r.length;n++)t=sS(r[n],t);return t}function iS(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const i=(s.next.y-s.y)/(s.next.x-s.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=i-r}return t}function sS(s,e){const t=rS(s,e);if(!t)return e;const i=Gy(t,s);return Un(i,i.next),Un(t,t.next)}function rS(s,e){let t=e;const i=s.x,r=s.y;let n=-1/0,a;if(Ga(s,t))return t;do{if(Ga(s,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const d=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>n&&(n=d,a=t.x<t.next.x?t:t.next,d===i))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,l=a.x,h=a.y;let c=1/0;t=a;do{if(i>=t.x&&t.x>=l&&i!==t.x&&Vy(r<h?i:n,r,l,h,r<h?n:i,r,t.x,t.y)){const d=Math.abs(r-t.y)/(i-t.x);Vl(t,s)&&(d<c||d===c&&(t.x>a.x||t.x===a.x&&nS(a,t)))&&(a=t,c=d)}t=t.next}while(t!==o);return a}function nS(s,e){return Ft(s.prev,s,e.prev)<0&&Ft(e.next,s,s.next)<0}function aS(s,e,t,i){let r=s;do r.z===0&&(r.z=um(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,oS(r)}function oS(s){let e,t=1;do{let i=s,r;s=null;let n=null;for(e=0;i;){e++;let a=i,o=0;for(let h=0;h<t&&(o++,a=a.nextZ,!!a);h++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(r=i,i=i.nextZ,o--):(r=a,a=a.nextZ,l--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;i=a}n.nextZ=null,t*=2}while(e>1);return s}function um(s,e,t,i,r){return s=(s-t)*r|0,e=(e-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function lS(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Vy(s,e,t,i,r,n,a,o){return(r-a)*(e-o)>=(s-a)*(n-o)&&(s-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(n-o)>=(r-a)*(i-o)}function Bl(s,e,t,i,r,n,a,o){return!(s===a&&e===o)&&Vy(s,e,t,i,r,n,a,o)}function hS(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!cS(s,e)&&(Vl(s,e)&&Vl(e,s)&&uS(s,e)&&(Ft(s.prev,s,e.prev)||Ft(s,e.prev,e))||Ga(s,e)&&Ft(s.prev,s,s.next)>0&&Ft(e.prev,e,e.next)>0)}function Ft(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function Ga(s,e){return s.x===e.x&&s.y===e.y}function ky(s,e,t,i){const r=ou(Ft(s,e,t)),n=ou(Ft(s,e,i)),a=ou(Ft(t,i,s)),o=ou(Ft(t,i,e));return!!(r!==n&&a!==o||r===0&&au(s,t,e)||n===0&&au(s,i,e)||a===0&&au(t,s,i)||o===0&&au(t,e,i))}function au(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function ou(s){return s>0?1:s<0?-1:0}function cS(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&ky(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Vl(s,e){return Ft(s.prev,s,s.next)<0?Ft(s,e,s.next)>=0&&Ft(s,s.prev,e)>=0:Ft(s,e,s.prev)<0||Ft(s,s.next,e)<0}function uS(s,e){let t=s,i=!1;const r=(s.x+e.x)/2,n=(s.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&r<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==s);return i}function Gy(s,e){const t=dm(s.i,s.x,s.y),i=dm(e.i,e.x,e.y),r=s.next,n=e.prev;return s.next=e,e.prev=s,t.next=r,r.prev=t,i.next=t,t.prev=i,n.next=i,i.prev=n,i}function Hy(s,e,t,i){const r=dm(s,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function kl(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function dm(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function dS(s,e,t,i){let r=0;for(let n=e,a=t-i;n<t;n+=i)r+=(s[a]-s[n])*(s[n+1]+s[a+1]),a=n;return r}class pS{static triangulate(e,t,i=2){return Jb(e,t,i)}}class ys{static area(e){const t=e.length;let i=0;for(let r=t-1,n=0;n<t;r=n++)i+=e[r].x*e[n].y-e[n].x*e[r].y;return i*.5}static isClockWise(e){return ys.area(e)<0}static triangulateShape(e,t){const i=[],r=[],n=[];Wy(e),jy(i,e);let a=e.length;t.forEach(Wy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,jy(i,t[l]);const o=pS.triangulate(i,r);for(let l=0;l<o.length;l+=3)n.push(o.slice(l,l+3));return n}}function Wy(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function jy(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Ch extends rt{constructor(e=new Zr([new te(.5,.5),new te(-.5,.5),new te(-.5,-.5),new te(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],n=[];for(let o=0,l=e.length;o<l;o++){const h=e[o];a(h)}this.setAttribute("position",new Ne(r,3)),this.setAttribute("uv",new Ne(n,2)),this.computeVertexNormals();function a(o){const l=[],h=t.curveSegments!==void 0?t.curveSegments:12,c=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let u=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const f=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:mS;let v,M=!1,w,T,A,_;if(f){v=f.getSpacedPoints(c),M=!0,u=!1;const Q=f.isCatmullRomCurve3?f.closed:!1;w=f.computeFrenetFrames(c,Q),T=new R,A=new R,_=new R}u||(g=0,p=0,m=0,y=0);const S=o.extractPoints(h);let P=S.shape;const C=S.holes;if(!ys.isClockWise(P)){P=P.reverse();for(let Q=0,ee=C.length;Q<ee;Q++){const he=C[Q];ys.isClockWise(he)&&(C[Q]=he.reverse())}}function L(Q){const ee=10000000000000001e-36;let he=Q[0];for(let _e=1;_e<=Q.length;_e++){const Se=_e%Q.length,I=Q[Se],Ge=I.x-he.x,We=I.y-he.y,Je=Ge*Ge+We*We,fe=Math.max(Math.abs(I.x),Math.abs(I.y),Math.abs(he.x),Math.abs(he.y)),N=ee*fe*fe;if(Je<=N){Q.splice(Se,1),_e--;continue}he=I}}L(P),C.forEach(L);const U=C.length,V=P;for(let Q=0;Q<U;Q++){const ee=C[Q];P=P.concat(ee)}function B(Q,ee,he){return ee||Ve("ExtrudeGeometry: vec does not exist"),Q.clone().addScaledVector(ee,he)}const k=P.length;function W(Q,ee,he){let _e,Se,I;const Ge=Q.x-ee.x,We=Q.y-ee.y,Je=he.x-Q.x,fe=he.y-Q.y,N=Ge*Ge+We*We,b=Ge*fe-We*Je;if(Math.abs(b)>Number.EPSILON){const D=Math.sqrt(N),Z=Math.sqrt(Je*Je+fe*fe),$=ee.x-We/D,J=ee.y+Ge/D,Oe=he.x-fe/Z,pe=he.y+Je/Z,He=((Oe-$)*fe-(pe-J)*Je)/(Ge*fe-We*Je);_e=$+Ge*He-Q.x,Se=J+We*He-Q.y;const Be=_e*_e+Se*Se;if(Be<=2)return new te(_e,Se);I=Math.sqrt(Be/2)}else{let D=!1;Ge>Number.EPSILON?Je>Number.EPSILON&&(D=!0):Ge<-Number.EPSILON?Je<-Number.EPSILON&&(D=!0):Math.sign(We)===Math.sign(fe)&&(D=!0),D?(_e=-We,Se=Ge,I=Math.sqrt(N)):(_e=Ge,Se=We,I=Math.sqrt(N/2))}return new te(_e/I,Se/I)}const se=[];for(let Q=0,ee=V.length,he=ee-1,_e=Q+1;Q<ee;Q++,he++,_e++)he===ee&&(he=0),_e===ee&&(_e=0),se[Q]=W(V[Q],V[he],V[_e]);const ie=[];let oe,be=se.concat();for(let Q=0,ee=U;Q<ee;Q++){const he=C[Q];oe=[];for(let _e=0,Se=he.length,I=Se-1,Ge=_e+1;_e<Se;_e++,I++,Ge++)I===Se&&(I=0),Ge===Se&&(Ge=0),oe[_e]=W(he[_e],he[I],he[Ge]);ie.push(oe),be=be.concat(oe)}let Ce;if(g===0)Ce=ys.triangulateShape(V,C);else{const Q=[],ee=[];for(let he=0;he<g;he++){const _e=he/g,Se=p*Math.cos(_e*Math.PI/2),I=m*Math.sin(_e*Math.PI/2)+y;for(let Ge=0,We=V.length;Ge<We;Ge++){const Je=B(V[Ge],se[Ge],I);le(Je.x,Je.y,-Se),_e===0&&Q.push(Je)}for(let Ge=0,We=U;Ge<We;Ge++){const Je=C[Ge];oe=ie[Ge];const fe=[];for(let N=0,b=Je.length;N<b;N++){const D=B(Je[N],oe[N],I);le(D.x,D.y,-Se),_e===0&&fe.push(D)}_e===0&&ee.push(fe)}}Ce=ys.triangulateShape(Q,ee)}const tt=Ce.length,wt=m+y;for(let Q=0;Q<k;Q++){const ee=u?B(P[Q],be[Q],wt):P[Q];M?(A.copy(w.normals[0]).multiplyScalar(ee.x),T.copy(w.binormals[0]).multiplyScalar(ee.y),_.copy(v[0]).add(A).add(T),le(_.x,_.y,_.z)):le(ee.x,ee.y,0)}for(let Q=1;Q<=c;Q++)for(let ee=0;ee<k;ee++){const he=u?B(P[ee],be[ee],wt):P[ee];M?(A.copy(w.normals[Q]).multiplyScalar(he.x),T.copy(w.binormals[Q]).multiplyScalar(he.y),_.copy(v[Q]).add(A).add(T),le(_.x,_.y,_.z)):le(he.x,he.y,d/c*Q)}for(let Q=g-1;Q>=0;Q--){const ee=Q/g,he=p*Math.cos(ee*Math.PI/2),_e=m*Math.sin(ee*Math.PI/2)+y;for(let Se=0,I=V.length;Se<I;Se++){const Ge=B(V[Se],se[Se],_e);le(Ge.x,Ge.y,d+he)}for(let Se=0,I=C.length;Se<I;Se++){const Ge=C[Se];oe=ie[Se];for(let We=0,Je=Ge.length;We<Je;We++){const fe=B(Ge[We],oe[We],_e);M?le(fe.x,fe.y+v[c-1].y,v[c-1].x+he):le(fe.x,fe.y,d+he)}}}Et(),K();function Et(){const Q=r.length/3;if(u){let ee=0,he=k*ee;for(let _e=0;_e<tt;_e++){const Se=Ce[_e];Qe(Se[2]+he,Se[1]+he,Se[0]+he)}ee=c+g*2,he=k*ee;for(let _e=0;_e<tt;_e++){const Se=Ce[_e];Qe(Se[0]+he,Se[1]+he,Se[2]+he)}}else{for(let ee=0;ee<tt;ee++){const he=Ce[ee];Qe(he[2],he[1],he[0])}for(let ee=0;ee<tt;ee++){const he=Ce[ee];Qe(he[0]+k*c,he[1]+k*c,he[2]+k*c)}}i.addGroup(Q,r.length/3-Q,0)}function K(){const Q=r.length/3;let ee=0;ae(V,ee),ee+=V.length;for(let he=0,_e=C.length;he<_e;he++){const Se=C[he];ae(Se,ee),ee+=Se.length}i.addGroup(Q,r.length/3-Q,1)}function ae(Q,ee){let he=Q.length;for(;--he>=0;){const _e=he;let Se=he-1;Se<0&&(Se=Q.length-1);for(let I=0,Ge=c+g*2;I<Ge;I++){const We=k*I,Je=k*(I+1),fe=ee+_e+We,N=ee+Se+We,b=ee+Se+Je,D=ee+_e+Je;Ye(fe,N,b,D)}}}function le(Q,ee,he){l.push(Q),l.push(ee),l.push(he)}function Qe(Q,ee,he){Te(Q),Te(ee),Te(he);const _e=r.length/3,Se=x.generateTopUV(i,r,_e-3,_e-2,_e-1);ct(Se[0]),ct(Se[1]),ct(Se[2])}function Ye(Q,ee,he,_e){Te(Q),Te(ee),Te(_e),Te(ee),Te(he),Te(_e);const Se=r.length/3,I=x.generateSideWallUV(i,r,Se-6,Se-3,Se-2,Se-1);ct(I[0]),ct(I[1]),ct(I[3]),ct(I[1]),ct(I[2]),ct(I[3])}function Te(Q){r.push(l[Q*3+0]),r.push(l[Q*3+1]),r.push(l[Q*3+2])}function ct(Q){n.push(Q.x),n.push(Q.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return fS(t,i,e)}static fromJSON(e,t){const i=[];for(let n=0,a=e.shapes.length;n<a;n++){const o=t[e.shapes[n]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new ru[r.type]().fromJSON(r)),new Ch(i,e.options)}}const mS={generateTopUV:function(s,e,t,i,r){const n=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],h=e[r*3],c=e[r*3+1];return[new te(n,a),new te(o,l),new te(h,c)]},generateSideWallUV:function(s,e,t,i,r,n){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],h=e[i*3],c=e[i*3+1],d=e[i*3+2],u=e[r*3],p=e[r*3+1],m=e[r*3+2],y=e[n*3],g=e[n*3+1],f=e[n*3+2];return Math.abs(o-c)<Math.abs(a-h)?[new te(a,1-l),new te(h,1-d),new te(u,1-m),new te(y,1-f)]:[new te(o,1-l),new te(c,1-d),new te(p,1-m),new te(g,1-f)]}};function fS(s,e,t){if(t.shapes=[],Array.isArray(s))for(let i=0,r=s.length;i<r;i++){const n=s[i];t.shapes.push(n.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Ud extends pn{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,n,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ud(e.radius,e.detail)}}class Fd extends rt{constructor(e=[new te(0,-.5),new te(.5,0),new te(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Ke(r,0,Math.PI*2);const n=[],a=[],o=[],l=[],h=[],c=1/t,d=new R,u=new te,p=new R,m=new R,y=new R;let g=0,f=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:g=e[x+1].x-e[x].x,f=e[x+1].y-e[x].y,p.x=f*1,p.y=-g,p.z=f*0,y.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(y.x,y.y,y.z);break;default:g=e[x+1].x-e[x].x,f=e[x+1].y-e[x].y,p.x=f*1,p.y=-g,p.z=f*0,m.copy(p),p.x+=y.x,p.y+=y.y,p.z+=y.z,p.normalize(),l.push(p.x,p.y,p.z),y.copy(m)}for(let x=0;x<=t;x++){const v=i+x*c*r,M=Math.sin(v),w=Math.cos(v);for(let T=0;T<=e.length-1;T++){d.x=e[T].x*M,d.y=e[T].y,d.z=e[T].x*w,a.push(d.x,d.y,d.z),u.x=x/t,u.y=T/(e.length-1),o.push(u.x,u.y);const A=l[3*T+0]*M,_=l[3*T+1],S=l[3*T+0]*w;h.push(A,_,S)}}for(let x=0;x<t;x++)for(let v=0;v<e.length-1;v++){const M=v+x*e.length,w=M,T=M+e.length,A=M+e.length+1,_=M+1;n.push(w,T,_),n.push(A,_,T)}this.setIndex(n),this.setAttribute("position",new Ne(a,3)),this.setAttribute("uv",new Ne(o,2)),this.setAttribute("normal",new Ne(h,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fd(e.points,e.segments,e.phiStart,e.phiLength)}}class Po extends pn{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Po(e.radius,e.detail)}}class na extends rt{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const n=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),h=o+1,c=l+1,d=e/o,u=t/l,p=[],m=[],y=[],g=[];for(let f=0;f<c;f++){const x=f*u-a;for(let v=0;v<h;v++){const M=v*d-n;m.push(M,-x,0),y.push(0,0,1),g.push(v/o),g.push(1-f/l)}}for(let f=0;f<l;f++)for(let x=0;x<o;x++){const v=x+h*f,M=x+h*(f+1),w=x+1+h*(f+1),T=x+1+h*f;p.push(v,M,T),p.push(M,w,T)}this.setIndex(p),this.setAttribute("position",new Ne(m,3)),this.setAttribute("normal",new Ne(y,3)),this.setAttribute("uv",new Ne(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new na(e.width,e.height,e.widthSegments,e.heightSegments)}}class Rh extends rt{constructor(e=.5,t=1,i=32,r=1,n=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],h=[],c=[];let d=e;const u=(t-e)/r,p=new R,m=new te;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){const f=n+g/i*a;p.x=d*Math.cos(f),p.y=d*Math.sin(f),l.push(p.x,p.y,p.z),h.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,c.push(m.x,m.y)}d+=u}for(let y=0;y<r;y++){const g=y*(i+1);for(let f=0;f<i;f++){const x=f+g,v=x,M=x+i+1,w=x+i+2,T=x+1;o.push(v,M,T),o.push(M,w,T)}}this.setIndex(o),this.setAttribute("position",new Ne(l,3)),this.setAttribute("normal",new Ne(h,3)),this.setAttribute("uv",new Ne(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rh(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class zd extends rt{constructor(e=new Zr([new te(0,.5),new te(-.5,-.5),new te(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],n=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)h(e);else for(let c=0;c<e.length;c++)h(e[c]),this.addGroup(o,l,c),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new Ne(r,3)),this.setAttribute("normal",new Ne(n,3)),this.setAttribute("uv",new Ne(a,2));function h(c){const d=r.length/3,u=c.extractPoints(t);let p=u.shape;const m=u.holes;ys.isClockWise(p)===!1&&(p=p.reverse());for(let g=0,f=m.length;g<f;g++){const x=m[g];ys.isClockWise(x)===!0&&(m[g]=x.reverse())}const y=ys.triangulateShape(p,m);for(let g=0,f=m.length;g<f;g++){const x=m[g];p=p.concat(x)}for(let g=0,f=p.length;g<f;g++){const x=p[g];r.push(x.x,x.y,0),n.push(0,0,1),a.push(x.x,x.y)}for(let g=0,f=y.length;g<f;g++){const x=y[g],v=x[0]+d,M=x[1]+d,w=x[2]+d;i.push(v,M,w),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return gS(t,e)}static fromJSON(e,t){const i=[];for(let r=0,n=e.shapes.length;r<n;r++){const a=t[e.shapes[r]];i.push(a)}return new zd(i,e.curveSegments)}}function gS(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,i=s.length;t<i;t++){const r=s[t];e.shapes.push(r.uuid)}else e.shapes.push(s.uuid);return e}class Lo extends rt{constructor(e=1,t=32,i=16,r=0,n=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:n,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let h=0;const c=[],d=new R,u=new R,p=[],m=[],y=[],g=[];for(let f=0;f<=i;f++){const x=[],v=f/i;let M=0;f===0&&a===0?M=.5/t:f===i&&l===Math.PI&&(M=-.5/t);for(let w=0;w<=t;w++){const T=w/t;d.x=-e*Math.cos(r+T*n)*Math.sin(a+v*o),d.y=e*Math.cos(a+v*o),d.z=e*Math.sin(r+T*n)*Math.sin(a+v*o),m.push(d.x,d.y,d.z),u.copy(d).normalize(),y.push(u.x,u.y,u.z),g.push(T+M,1-v),x.push(h++)}c.push(x)}for(let f=0;f<i;f++)for(let x=0;x<t;x++){const v=c[f][x+1],M=c[f][x],w=c[f+1][x],T=c[f+1][x+1];(f!==0||a>0)&&p.push(v,M,T),(f!==i-1||l<Math.PI)&&p.push(M,w,T)}this.setIndex(p),this.setAttribute("position",new Ne(m,3)),this.setAttribute("normal",new Ne(y,3)),this.setAttribute("uv",new Ne(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Bd extends pn{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Bd(e.radius,e.detail)}}class Ih extends rt{constructor(e=1,t=.4,i=12,r=48,n=Math.PI*2,a=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:n,thetaStart:a,thetaLength:o},i=Math.floor(i),r=Math.floor(r);const l=[],h=[],c=[],d=[],u=new R,p=new R,m=new R;for(let y=0;y<=i;y++){const g=a+y/i*o;for(let f=0;f<=r;f++){const x=f/r*n;p.x=(e+t*Math.cos(g))*Math.cos(x),p.y=(e+t*Math.cos(g))*Math.sin(x),p.z=t*Math.sin(g),h.push(p.x,p.y,p.z),u.x=e*Math.cos(x),u.y=e*Math.sin(x),m.subVectors(p,u).normalize(),c.push(m.x,m.y,m.z),d.push(f/r),d.push(y/i)}}for(let y=1;y<=i;y++)for(let g=1;g<=r;g++){const f=(r+1)*y+g-1,x=(r+1)*(y-1)+g-1,v=(r+1)*(y-1)+g,M=(r+1)*y+g;l.push(f,x,M),l.push(x,v,M)}this.setIndex(l),this.setAttribute("position",new Ne(h,3)),this.setAttribute("normal",new Ne(c,3)),this.setAttribute("uv",new Ne(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ih(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Vd extends rt{constructor(e=1,t=.4,i=64,r=8,n=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:n,q:a},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],h=[],c=[],d=new R,u=new R,p=new R,m=new R,y=new R,g=new R,f=new R;for(let v=0;v<=i;++v){const M=v/i*n*Math.PI*2;x(M,n,a,e,p),x(M+.01,n,a,e,m),g.subVectors(m,p),f.addVectors(m,p),y.crossVectors(g,f),f.crossVectors(y,g),y.normalize(),f.normalize();for(let w=0;w<=r;++w){const T=w/r*Math.PI*2,A=-t*Math.cos(T),_=t*Math.sin(T);d.x=p.x+(A*f.x+_*y.x),d.y=p.y+(A*f.y+_*y.y),d.z=p.z+(A*f.z+_*y.z),l.push(d.x,d.y,d.z),u.subVectors(d,p).normalize(),h.push(u.x,u.y,u.z),c.push(v/i),c.push(w/r)}}for(let v=1;v<=i;v++)for(let M=1;M<=r;M++){const w=(r+1)*(v-1)+(M-1),T=(r+1)*v+(M-1),A=(r+1)*v+M,_=(r+1)*(v-1)+M;o.push(w,T,_),o.push(T,A,_)}this.setIndex(o),this.setAttribute("position",new Ne(l,3)),this.setAttribute("normal",new Ne(h,3)),this.setAttribute("uv",new Ne(c,2));function x(v,M,w,T,A){const _=Math.cos(v),S=Math.sin(v),P=w/M*v,C=Math.cos(P);A.x=T*(2+C)*.5*_,A.y=T*(2+C)*S*.5,A.z=T*Math.sin(P)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class kd extends rt{constructor(e=new hm(new R(-1,-1,0),new R(-1,1,0),new R(1,1,0)),t=64,i=1,r=8,n=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n};const a=e.computeFrenetFrames(t,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new R,l=new R,h=new te;let c=new R;const d=[],u=[],p=[],m=[];y(),this.setIndex(m),this.setAttribute("position",new Ne(d,3)),this.setAttribute("normal",new Ne(u,3)),this.setAttribute("uv",new Ne(p,2));function y(){for(let v=0;v<t;v++)g(v);g(n===!1?t:0),x(),f()}function g(v){c=e.getPointAt(v/t,c);const M=a.normals[v],w=a.binormals[v];for(let T=0;T<=r;T++){const A=T/r*Math.PI*2,_=Math.sin(A),S=-Math.cos(A);l.x=S*M.x+_*w.x,l.y=S*M.y+_*w.y,l.z=S*M.z+_*w.z,l.normalize(),u.push(l.x,l.y,l.z),o.x=c.x+i*l.x,o.y=c.y+i*l.y,o.z=c.z+i*l.z,d.push(o.x,o.y,o.z)}}function f(){for(let v=1;v<=t;v++)for(let M=1;M<=r;M++){const w=(r+1)*(v-1)+(M-1),T=(r+1)*v+(M-1),A=(r+1)*v+M,_=(r+1)*(v-1)+M;m.push(w,T,_),m.push(T,A,_)}}function x(){for(let v=0;v<=t;v++)for(let M=0;M<=r;M++)h.x=v/t,h.y=M/r,p.push(h.x,h.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new kd(new ru[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class pm extends rt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new R,n=new R;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let h=0,c=l.length;h<c;++h){const d=l[h],u=d.start,p=d.count;for(let m=u,y=u+p;m<y;m+=3)for(let g=0;g<3;g++){const f=o.getX(m+g),x=o.getX(m+(g+1)%3);r.fromBufferAttribute(a,f),n.fromBufferAttribute(a,x),Xy(r,n,i)===!0&&(t.push(r.x,r.y,r.z),t.push(n.x,n.y,n.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let h=0;h<3;h++){const c=3*o+h,d=3*o+(h+1)%3;r.fromBufferAttribute(a,c),n.fromBufferAttribute(a,d),Xy(r,n,i)===!0&&(t.push(r.x,r.y,r.z),t.push(n.x,n.y,n.z))}}this.setAttribute("position",new Ne(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Xy(s,e,t){const i=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var qy=Object.freeze({__proto__:null,BoxGeometry:dn,CapsuleGeometry:Ld,CircleGeometry:Dd,ConeGeometry:Nh,CylinderGeometry:Io,DodecahedronGeometry:Od,EdgesGeometry:em,ExtrudeGeometry:Ch,IcosahedronGeometry:Ud,LatheGeometry:Fd,OctahedronGeometry:Po,PlaneGeometry:na,PolyhedronGeometry:pn,RingGeometry:Rh,ShapeGeometry:zd,SphereGeometry:Lo,TetrahedronGeometry:Bd,TorusGeometry:Ih,TorusKnotGeometry:Vd,TubeGeometry:kd,WireframeGeometry:pm});class mm extends pi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new we(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}function Ha(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const r=s[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(ge("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Di(s){const e={};for(let t=0;t<s.length;t++){const i=Ha(s[t]);for(const r in i)e[r]=i[r]}return e}function yS(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Yy(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:mt.workingColorSpace}const fm={clone:Ha,merge:Di};var xS=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,vS=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`;class $i extends pi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=xS,this.fragmentShader=vS,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ga(e.uniforms),this.uniformsGroups=yS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const n=this.uniforms[r].value;n&&n.isTexture?t.uniforms[r]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[r]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[r]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[r]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[r]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[r]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[r]={type:"m4",value:n.toArray()}:t.uniforms[r]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class lu extends $i{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class hu extends pi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new we(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 we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(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 ns,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ym extends hu{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ke(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new we(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 we(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new we(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(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class xm extends pi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new we(16777215),this.specular=new we(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ns,this.combine=Ho,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Zy extends pi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new we(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class vm extends pi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class _m extends pi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new we(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ns,this.combine=Ho,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class cu extends pi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=cp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Mm extends pi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Jy extends pi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new we(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(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(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ky extends Ti{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Fn(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function $y(s){function e(r,n){return s[r]-s[n]}const t=s.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function bm(s,e,t){const i=s.length,r=new s.constructor(i);for(let n=0,a=0;a!==i;++n){const o=t[n]*e;for(let l=0;l!==e;++l)r[a++]=s[o+l]}return r}function Sm(s,e,t,i){let r=1,n=s[0];for(;n!==void 0&&n[i]===void 0;)n=s[r++];if(n===void 0)return;let a=n[i];if(a!==void 0)if(Array.isArray(a))do a=n[i],a!==void 0&&(e.push(n.time),t.push(...a)),n=s[r++];while(n!==void 0);else if(a.toArray!==void 0)do a=n[i],a!==void 0&&(e.push(n.time),a.toArray(t,t.length)),n=s[r++];while(n!==void 0);else do a=n[i],a!==void 0&&(e.push(n.time),t.push(a)),n=s[r++];while(n!==void 0)}function _S(s,e,t,i,r=30){const n=s.clone();n.name=e;const a=[];for(let l=0;l<n.tracks.length;++l){const h=n.tracks[l],c=h.getValueSize(),d=[],u=[];for(let p=0;p<h.times.length;++p){const m=h.times[p]*r;if(!(m<t||m>=i)){d.push(h.times[p]);for(let y=0;y<c;++y)u.push(h.values[p*c+y])}}d.length!==0&&(h.times=Fn(d,h.times.constructor),h.values=Fn(u,h.values.constructor),a.push(h))}n.tracks=a;let o=1/0;for(let l=0;l<n.tracks.length;++l)o>n.tracks[l].times[0]&&(o=n.tracks[l].times[0]);for(let l=0;l<n.tracks.length;++l)n.tracks[l].shift(-1*o);return n.resetDuration(),n}function MS(s,e=0,t=s,i=30){i<=0&&(i=30);const r=t.tracks.length,n=e/i;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const h=s.tracks.find(function(f){return f.name===o.name&&f.ValueTypeName===l});if(h===void 0)continue;let c=0;const d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=d/3);let u=0;const p=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=p/3);const m=o.times.length-1;let y;if(n<=o.times[0]){const f=c,x=d-c;y=o.values.slice(f,x)}else if(n>=o.times[m]){const f=m*d+c,x=f+d-c;y=o.values.slice(f,x)}else{const f=o.createInterpolant(),x=c,v=d-c;f.evaluate(n),y=f.resultBuffer.slice(x,v)}l==="quaternion"&&new Mi().fromArray(y).normalize().conjugate().toArray(y);const g=h.times.length;for(let f=0;f<g;++f){const x=f*p+u;if(l==="quaternion")Mi.multiplyQuaternionsFlat(h.values,x,y,0,h.values,x);else{const v=p-u*2;for(let M=0;M<v;++M)h.values[x+M]-=y[M]}}}return s.blendMode=hp,s}class bS{static convertArray(e,t){return Fn(e,t)}static isTypedArray(e){return G0(e)}static getKeyframeOrder(e){return $y(e)}static sortedArray(e,t,i){return bm(e,t,i)}static flattenJSON(e,t,i,r){Sm(e,t,i,r)}static subclip(e,t,i,r,n=30){return _S(e,t,i,r,n)}static makeClipAdditive(e,t=0,i=e,r=30){return MS(e,t,i,r)}}class zn{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{let a;i:{s:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<n)break s;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(n=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=n)){const o=t[1];e<o&&(i=2,n=o);for(let l=i-2;;){if(n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=n,n=t[--i-1],e>=n)break t}a=i,i=0;break i}break e}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],n=t[i-1],n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=e*r;for(let a=0;a!==r;++a)t[a]=i[n+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Qy extends zn{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Mn,endingEnd:Mn}}intervalChanged_(e,t,i){const r=this.parameterPositions;let n=e-2,a=e+1,o=r[n],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case bn:n=e,o=2*t-i;break;case pl:n=r.length-2,o=t+r[n]-r[n+1];break;default:n=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case bn:a=e,l=2*i-t;break;case pl:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const h=(i-t)*.5,c=this.valueSize;this._weightPrev=h/(t-o),this._weightNext=h/(l-i),this._offsetPrev=n*c,this._offsetNext=a*c}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,h=l-o,c=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),y=m*m,g=y*m,f=-u*g+2*u*y-u*m,x=(1+u)*g+(-1.5-2*u)*y+(-.5+u)*m+1,v=(-1-p)*g+(1.5+p)*y+.5*m,M=p*g-p*y;for(let w=0;w!==o;++w)n[w]=f*a[c+w]+x*a[h+w]+v*a[l+w]+M*a[d+w];return n}}class Tm extends zn{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,h=l-o,c=(i-t)/(r-t),d=1-c;for(let u=0;u!==o;++u)n[u]=a[h+u]*d+a[l+u]*c;return n}}class ex extends zn{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class tx extends zn{interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,h=l-o,c=this.settings||this.DefaultSettings_,d=c.inTangents,u=c.outTangents;if(!d||!u){const y=(i-t)/(r-t),g=1-y;for(let f=0;f!==o;++f)n[f]=a[h+f]*g+a[l+f]*y;return n}const p=o*2,m=e-1;for(let y=0;y!==o;++y){const g=a[h+y],f=a[l+y],x=m*p+y*2,v=u[x],M=u[x+1],w=e*p+y*2,T=d[w],A=d[w+1];let _=(i-t)/(r-t),S,P,C,L,U;for(let V=0;V<8;V++){S=_*_,P=S*_,C=1-_,L=C*C,U=L*C;const B=U*t+3*L*_*v+3*C*S*T+P*r-i;if(Math.abs(B)<1e-10)break;const k=3*L*(v-t)+6*C*_*(T-v)+3*S*(r-T);if(Math.abs(k)<1e-10)break;_=_-B/k,_=Math.max(0,Math.min(1,_))}n[y]=U*g+3*L*_*M+3*C*S*A+P*f}return n}}class Qi{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Fn(t,this.TimeBufferType),this.values=Fn(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Fn(e.times,Array),values:Fn(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new ex(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Tm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Qy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new tx(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case _a:t=this.InterpolantFactoryMethodDiscrete;break;case dl:t=this.InterpolantFactoryMethodLinear;break;case cc:t=this.InterpolantFactoryMethodSmooth;break;case lp:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return ge("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return _a;case this.InterpolantFactoryMethodLinear:return dl;case this.InterpolantFactoryMethodSmooth:return cc;case this.InterpolantFactoryMethodBezier:return lp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let n=0,a=r-1;for(;n!==r&&i[n]<e;)++n;for(;a!==-1&&i[a]>t;)--a;if(++a,n!==0||a!==r){n>=a&&(a=Math.max(a,1),n=a-1);const o=this.getValueSize();this.times=i.slice(n,a),this.values=this.values.slice(n*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Ve("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,n=i.length;n===0&&(Ve("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==n;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){Ve("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Ve("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&G0(r))for(let o=0,l=r.length;o!==l;++o){const h=r[o];if(isNaN(h)){Ve("KeyframeTrack: Value is not a valid number.",this,o,h),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===cc,n=e.length-1;let a=1;for(let o=1;o<n;++o){let l=!1;const h=e[o],c=e[o+1];if(h!==c&&(o!==1||h!==e[0]))if(r)l=!0;else{const d=o*i,u=d-i,p=d+i;for(let m=0;m!==i;++m){const y=t[d+m];if(y!==t[u+m]||y!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*i,u=a*i;for(let p=0;p!==i;++p)t[u+p]=t[d+p]}++a}}if(n>0){e[a]=e[n];for(let o=n*i,l=a*i,h=0;h!==i;++h)t[l+h]=t[o+h];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Qi.prototype.ValueTypeName="",Qi.prototype.TimeBufferType=Float32Array,Qi.prototype.ValueBufferType=Float32Array,Qi.prototype.DefaultInterpolation=dl;class Jr extends Qi{constructor(e,t,i){super(e,t,i)}}Jr.prototype.ValueTypeName="bool",Jr.prototype.ValueBufferType=Array,Jr.prototype.DefaultInterpolation=_a,Jr.prototype.InterpolantFactoryMethodLinear=void 0,Jr.prototype.InterpolantFactoryMethodSmooth=void 0;class uu extends Qi{constructor(e,t,i,r){super(e,t,i,r)}}uu.prototype.ValueTypeName="color";class Ha extends Qi{constructor(e,t,i,r){super(e,t,i,r)}}Ha.prototype.ValueTypeName="number";class ix extends zn{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let h=e*o;for(let c=h+o;h!==c;h+=4)Mi.slerpFlat(n,0,a,h-o,a,h,l);return n}}class Wa extends Qi{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new ix(this.times,this.values,this.getValueSize(),e)}}Wa.prototype.ValueTypeName="quaternion",Wa.prototype.InterpolantFactoryMethodSmooth=void 0;class Bn extends Qi{constructor(e,t,i){super(e,t,i)}}Bn.prototype.ValueTypeName="string",Bn.prototype.ValueBufferType=Array,Bn.prototype.DefaultInterpolation=_a,Bn.prototype.InterpolantFactoryMethodLinear=void 0,Bn.prototype.InterpolantFactoryMethodSmooth=void 0;class ja extends Qi{constructor(e,t,i,r){super(e,t,i,r)}}ja.prototype.ValueTypeName="vector";class Xa{constructor(e="",t=-1,i=[],r=uc){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Zi(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(TS(i[a]).scale(r));const n=new this(e.name,e.duration,t,e.blendMode);return n.uuid=e.uuid,n.userData=JSON.parse(e.userData||"{}"),n}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let n=0,a=i.length;n!==a;++n)t.push(Qi.toJSON(i[n]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const n=t.length,a=[];for(let o=0;o<n;o++){let l=[],h=[];l.push((o+n-1)%n,o,(o+1)%n),h.push(0,1,0);const c=$y(l);l=bm(l,1,c),h=bm(h,1,c),!r&&l[0]===0&&(l.push(n),h.push(h[0])),a.push(new Ha(".morphTargetInfluences["+t[o].name+"]",l,h).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},n=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const h=e[o],c=h.name.match(n);if(c&&c.length>1){const d=c[1];let u=r[d];u||(r[d]=u=[]),u.push(h)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(ge("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Ve("AnimationClip: No animation in JSONLoader data."),null;const i=function(c,d,u,p,m){if(u.length!==0){const y=[],g=[];Sm(u,y,g,p),y.length!==0&&m.push(new c(d,y,g))}},r=[],n=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const h=e.hierarchy||[];for(let c=0;c<h.length;c++){const d=h[c].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const u={};let p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)u[d[p].morphTargets[m]]=-1;for(const m in u){const y=[],g=[];for(let f=0;f!==d[p].morphTargets.length;++f){const x=d[p];y.push(x.time),g.push(x.morphTarget===m?1:0)}r.push(new Ha(".morphTargetInfluence["+m+"]",y,g))}l=u.length*a}else{const u=".bones["+t[c].name+"]";i(ja,u+".position",d,"pos",r),i(Wa,u+".quaternion",d,"rot",r),i(ja,u+".scale",d,"scl",r)}}return r.length===0?null:new this(n,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const n=this.tracks[i];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function SS(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ha;case"vector":case"vector2":case"vector3":case"vector4":return ja;case"color":return uu;case"quaternion":return Wa;case"bool":case"boolean":return Jr;case"string":return Bn}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function TS(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=SS(s.type);if(s.times===void 0){const t=[],i=[];Sm(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Is={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(sx(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!sx(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function sx(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class du{constructor(e,t,i){const r=this;let n=!1,a=0,o=0,l;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(c){o++,n===!1&&r.onStart!==void 0&&r.onStart(c,a,o),n=!0},this.itemEnd=function(c){a++,r.onProgress!==void 0&&r.onProgress(c,a,o),a===o&&(n=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(c){r.onError!==void 0&&r.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return h.push(c,d),this},this.removeHandler=function(c){const d=h.indexOf(c);return d!==-1&&h.splice(d,2),this},this.getHandler=function(c){for(let d=0,u=h.length;d<u;d+=2){const p=h[d],m=h[d+1];if(p.global&&(p.lastIndex=0),p.test(c))return m}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 wm=new du;class Oi{constructor(e){this.manager=e!==void 0?e:wm,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(e,t){const i=this;return new Promise(function(r,n){i.load(e,r,t,n)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Oi.DEFAULT_MATERIAL_NAME="__DEFAULT";const Tr={};class wS extends Error{constructor(e,t){super(e),this.response=t}}class js extends Oi{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=Is.get(`file:${e}`);if(n!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(n),this.manager.itemEnd(e)},0),n;if(Tr[e]!==void 0){Tr[e].push({onLoad:t,onProgress:i,onError:r});return}Tr[e]=[],Tr[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{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}),o=this.mimeType,l=this.responseType;fetch(a).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&ge("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const c=Tr[e],d=h.body.getReader(),u=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),p=u?parseInt(u):0,m=p!==0;let y=0;const g=new ReadableStream({start(f){x();function x(){d.read().then(({done:v,value:M})=>{if(v)f.close();else{y+=M.byteLength;const w=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:p});for(let T=0,A=c.length;T<A;T++){const _=c[T];_.onProgress&&_.onProgress(w)}f.enqueue(M),x()}},v=>{f.error(v)})}}});return new Response(g)}else throw new wS(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(l){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(c=>new DOMParser().parseFromString(c,o));case"json":return h.json();default:if(o==="")return h.text();{const c=/charset="?([^;"\s]*)"?/i.exec(o),d=c&&c[1]?c[1].toLowerCase():void 0,u=new TextDecoder(d);return h.arrayBuffer().then(p=>u.decode(p))}}}).then(h=>{Is.add(`file:${e}`,h);const c=Tr[e];delete Tr[e];for(let d=0,u=c.length;d<u;d++){const p=c[d];p.onLoad&&p.onLoad(h)}}).catch(h=>{const c=Tr[e];if(c===void 0)throw this.manager.itemError(e),h;delete Tr[e];for(let d=0,u=c.length;d<u;d++){const p=c[d];p.onError&&p.onError(h)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class ES extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new js(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(n.parse(JSON.parse(o)))}catch(l){r?r(l):Ve(l),n.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=Xa.parse(e[i]);t.push(r)}return t}}class AS extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=[],o=new Ol,l=new js(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(n.withCredentials);let h=0;function c(d){l.load(e[d],function(u){const p=n.parse(u,!0);a[d]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},h+=1,h===6&&(p.mipmapCount===1&&(o.minFilter=Rt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let d=0,u=e.length;d<u;++d)c(d);else l.load(e,function(d){const u=n.parse(d,!0);if(u.isCubemap){const p=u.mipmaps.length/u.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let y=0;y<u.mipmapCount;y++)a[m].mipmaps.push(u.mipmaps[m*u.mipmapCount+y]),a[m].format=u.format,a[m].width=u.width,a[m].height=u.height}o.image=a}else o.image.width=u.width,o.image.height=u.height,o.mipmaps=u.mipmaps;u.mipmapCount===1&&(o.minFilter=Rt),o.format=u.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}const qa=new WeakMap;class Gl extends Oi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=Is.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)n.manager.itemStart(e),setTimeout(function(){t&&t(a),n.manager.itemEnd(e)},0);else{let d=qa.get(a);d===void 0&&(d=[],qa.set(a,d)),d.push({onLoad:t,onError:r})}return a}const o=gl("img");function l(){c(),t&&t(this);const d=qa.get(this)||[];for(let u=0;u<d.length;u++){const p=d[u];p.onLoad&&p.onLoad(this)}qa.delete(this),n.manager.itemEnd(e)}function h(d){c(),r&&r(d),Is.remove(`image:${e}`);const u=qa.get(this)||[];for(let p=0;p<u.length;p++){const m=u[p];m.onError&&m.onError(d)}qa.delete(this),n.manager.itemError(e),n.manager.itemEnd(e)}function c(){o.removeEventListener("load",l,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Is.add(`image:${e}`,o),n.manager.itemStart(e),o.src=e,o}}class NS extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=new Va;n.colorSpace=Ii;const a=new Gl(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(h){a.load(e[h],function(c){n.images[h]=c,o++,o===6&&(n.needsUpdate=!0,t&&t(n))},void 0,r)}for(let h=0;h<e.length;++h)l(h);return n}}class rx extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new os,o=new js(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(n.withCredentials),o.load(e,function(l){let h;try{h=n.parse(l)}catch(c){if(r!==void 0)r(c);else{c(c);return}}h.image!==void 0?a.image=h.image:h.data!==void 0&&(a.image.width=h.width,a.image.height=h.height,a.image.data=h.data),a.wrapS=h.wrapS!==void 0?h.wrapS:Ci,a.wrapT=h.wrapT!==void 0?h.wrapT:Ci,a.magFilter=h.magFilter!==void 0?h.magFilter:Rt,a.minFilter=h.minFilter!==void 0?h.minFilter:Rt,a.anisotropy=h.anisotropy!==void 0?h.anisotropy:1,h.colorSpace!==void 0&&(a.colorSpace=h.colorSpace),h.flipY!==void 0&&(a.flipY=h.flipY),h.format!==void 0&&(a.format=h.format),h.type!==void 0&&(a.type=h.type),h.mipmaps!==void 0&&(a.mipmaps=h.mipmaps,a.minFilter=Ss),h.mipmapCount===1&&(a.minFilter=Rt),h.generateMipmaps!==void 0&&(a.generateMipmaps=h.generateMipmaps),a.needsUpdate=!0,t&&t(a,h)},i,r),a}}class nx extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=new ei,a=new Gl(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){n.image=o,n.needsUpdate=!0,t!==void 0&&t(n)},i,r),n}}let Kr=class extends _t{constructor(s,e=1){super(),this.isLight=!0,this.type="Light",this.color=new we(s),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(s,e){return super.copy(s,e),this.color.copy(s.color),this.intensity=s.intensity,this}toJSON(s){const e=super.toJSON(s);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}},Em=class extends Kr{constructor(s,e,t){super(s,t),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new we(e)}copy(s,e){return super.copy(s,e),this.groundColor.copy(s.groundColor),this}toJSON(s){const e=super.toJSON(s);return e.object.groundColor=this.groundColor.getHex(),e}};const Am=new et,ax=new R,ox=new R;let Nm=class{constructor(s){this.camera=s,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new te(512,512),this.mapType=Ri,this.map=null,this.mapPass=null,this.matrix=new et,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Pn,this._frameExtents=new te(1,1),this._viewportCount=1,this._viewports=[new It(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(s){const e=this.camera,t=this.matrix;ax.setFromMatrixPosition(s.matrixWorld),e.position.copy(ax),ox.setFromMatrixPosition(s.target.matrixWorld),e.lookAt(ox),e.updateMatrixWorld(),Am.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Am,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Sn||e.reversedDepth?t.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):t.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),t.multiply(Am)}getViewport(s){return this._viewports[s]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(s){return this.camera=s.camera.clone(),this.intensity=s.intensity,this.bias=s.bias,this.radius=s.radius,this.autoUpdate=s.autoUpdate,this.needsUpdate=s.needsUpdate,this.normalBias=s.normalBias,this.blurSamples=s.blurSamples,this.mapSize.copy(s.mapSize),this.biasNode=s.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const s={};return this.intensity!==1&&(s.intensity=this.intensity),this.bias!==0&&(s.bias=this.bias),this.normalBias!==0&&(s.normalBias=this.normalBias),this.radius!==1&&(s.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(s.mapSize=this.mapSize.toArray()),s.camera=this.camera.toJSON(!1).object,delete s.camera.matrix,s}};const pu=new R,mu=new Mi,Xs=new R;let Hl=class extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new et,this.projectionMatrix=new et,this.projectionMatrixInverse=new et,this.coordinateSystem=Yi,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(s,e){return super.copy(s,e),this.matrixWorldInverse.copy(s.matrixWorldInverse),this.projectionMatrix.copy(s.projectionMatrix),this.projectionMatrixInverse.copy(s.projectionMatrixInverse),this.coordinateSystem=s.coordinateSystem,this}getWorldDirection(s){return super.getWorldDirection(s).negate()}updateMatrixWorld(s){super.updateMatrixWorld(s),this.matrixWorld.decompose(pu,mu,Xs),Xs.x===1&&Xs.y===1&&Xs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pu,mu,Xs.set(1,1,1)).invert()}updateWorldMatrix(s,e){super.updateWorldMatrix(s,e),this.matrixWorld.decompose(pu,mu,Xs),Xs.x===1&&Xs.y===1&&Xs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pu,mu,Xs.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};const $r=new R,lx=new te,hx=new te;let li=class extends Hl{constructor(s=50,e=1,t=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=s,this.zoom=1,this.near=t,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(s,e){return super.copy(s,e),this.fov=s.fov,this.zoom=s.zoom,this.near=s.near,this.far=s.far,this.focus=s.focus,this.aspect=s.aspect,this.view=s.view===null?null:Object.assign({},s.view),this.filmGauge=s.filmGauge,this.filmOffset=s.filmOffset,this}setFocalLength(s){const e=.5*this.getFilmHeight()/s;this.fov=ba*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const s=Math.tan(Tn*.5*this.fov);return .5*this.getFilmHeight()/s}getEffectiveFOV(){return ba*2*Math.atan(Math.tan(Tn*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(s,e,t){$r.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set($r.x,$r.y).multiplyScalar(-s/$r.z),$r.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),t.set($r.x,$r.y).multiplyScalar(-s/$r.z)}getViewSize(s,e){return this.getViewBounds(s,lx,hx),e.subVectors(hx,lx)}setViewOffset(s,e,t,i,r,n){this.aspect=s/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=s,this.view.fullHeight=e,this.view.offsetX=t,this.view.offsetY=i,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const s=this.near;let e=s*Math.tan(Tn*.5*this.fov)/this.zoom,t=2*e,i=this.aspect*t,r=-.5*i;const n=this.view;if(this.view!==null&&this.view.enabled){const o=n.fullWidth,l=n.fullHeight;r+=n.offsetX*i/o,e-=n.offsetY*t/l,i*=n.width/o,t*=n.height/l}const a=this.filmOffset;a!==0&&(r+=s*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-t,s,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(s){const e=super.toJSON(s);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}},CS=class extends Nm{constructor(){super(new li(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(s){const e=this.camera,t=ba*2*s.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=s.distance||e.far;(t!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=t,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(s)}copy(s){return super.copy(s),this.focus=s.focus,this}},Cm=class extends Kr{constructor(s,e,t=0,i=Math.PI/3,r=0,n=2){super(s,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=t,this.angle=i,this.penumbra=r,this.decay=n,this.map=null,this.shadow=new CS}get power(){return this.intensity*Math.PI}set power(s){this.intensity=s/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(s,e){return super.copy(s,e),this.distance=s.distance,this.angle=s.angle,this.penumbra=s.penumbra,this.decay=s.decay,this.target=s.target.clone(),this.map=s.map,this.shadow=s.shadow.clone(),this}toJSON(s){const e=super.toJSON(s);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(s).uuid),e.object.shadow=this.shadow.toJSON(),e}},RS=class extends Nm{constructor(){super(new li(90,1,.5,500)),this.isPointLightShadow=!0}},Rm=class extends Kr{constructor(s,e,t=0,i=2){super(s,e),this.isPointLight=!0,this.type="PointLight",this.distance=t,this.decay=i,this.shadow=new RS}get power(){return this.intensity*4*Math.PI}set power(s){this.intensity=s/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(s,e){return super.copy(s,e),this.distance=s.distance,this.decay=s.decay,this.shadow=s.shadow.clone(),this}toJSON(s){const e=super.toJSON(s);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}},Ya=class extends Hl{constructor(s=-1,e=1,t=1,i=-1,r=.1,n=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=s,this.right=e,this.top=t,this.bottom=i,this.near=r,this.far=n,this.updateProjectionMatrix()}copy(s,e){return super.copy(s,e),this.left=s.left,this.right=s.right,this.top=s.top,this.bottom=s.bottom,this.near=s.near,this.far=s.far,this.zoom=s.zoom,this.view=s.view===null?null:Object.assign({},s.view),this}setViewOffset(s,e,t,i,r,n){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=s,this.view.fullHeight=e,this.view.offsetX=t,this.view.offsetY=i,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const s=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),t=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=t-s,n=t+s,a=i+e,o=i-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,n=r+l*this.view.width,a-=h*this.view.offsetY,o=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,n,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(s){const e=super.toJSON(s);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}},IS=class extends Nm{constructor(){super(new Ya(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Im=class extends Kr{constructor(s,e){super(s,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new IS}dispose(){super.dispose(),this.shadow.dispose()}copy(s){return super.copy(s),this.target=s.target.clone(),this.shadow=s.shadow.clone(),this}toJSON(s){const e=super.toJSON(s);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}},Pm=class extends Kr{constructor(s,e){super(s,e),this.isAmbientLight=!0,this.type="AmbientLight"}},cx=class extends Kr{constructor(s,e,t=10,i=10){super(s,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=t,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(s){this.intensity=s/(this.width*this.height*Math.PI)}copy(s){return super.copy(s),this.width=s.width,this.height=s.height,this}toJSON(s){const e=super.toJSON(s);return e.object.width=this.width,e.object.height=this.height,e}},Lm=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let s=0;s<9;s++)this.coefficients.push(new R)}set(s){for(let e=0;e<9;e++)this.coefficients[e].copy(s[e]);return this}zero(){for(let s=0;s<9;s++)this.coefficients[s].set(0,0,0);return this}getAt(s,e){const t=s.x,i=s.y,r=s.z,n=this.coefficients;return e.copy(n[0]).multiplyScalar(.282095),e.addScaledVector(n[1],.488603*i),e.addScaledVector(n[2],.488603*r),e.addScaledVector(n[3],.488603*t),e.addScaledVector(n[4],1.092548*(t*i)),e.addScaledVector(n[5],1.092548*(i*r)),e.addScaledVector(n[6],.315392*(3*r*r-1)),e.addScaledVector(n[7],1.092548*(t*r)),e.addScaledVector(n[8],.546274*(t*t-i*i)),e}getIrradianceAt(s,e){const t=s.x,i=s.y,r=s.z,n=this.coefficients;return e.copy(n[0]).multiplyScalar(.886227),e.addScaledVector(n[1],2*.511664*i),e.addScaledVector(n[2],2*.511664*r),e.addScaledVector(n[3],2*.511664*t),e.addScaledVector(n[4],2*.429043*t*i),e.addScaledVector(n[5],2*.429043*i*r),e.addScaledVector(n[6],.743125*r*r-.247708),e.addScaledVector(n[7],2*.429043*t*r),e.addScaledVector(n[8],.429043*(t*t-i*i)),e}add(s){for(let e=0;e<9;e++)this.coefficients[e].add(s.coefficients[e]);return this}addScaledSH(s,e){for(let t=0;t<9;t++)this.coefficients[t].addScaledVector(s.coefficients[t],e);return this}scale(s){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(s);return this}lerp(s,e){for(let t=0;t<9;t++)this.coefficients[t].lerp(s.coefficients[t],e);return this}equals(s){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(s.coefficients[e]))return!1;return!0}copy(s){return this.set(s.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(s,e=0){const t=this.coefficients;for(let i=0;i<9;i++)t[i].fromArray(s,e+i*3);return this}toArray(s=[],e=0){const t=this.coefficients;for(let i=0;i<9;i++)t[i].toArray(s,e+i*3);return s}static getBasisAt(s,e){const t=s.x,i=s.y,r=s.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*t,e[4]=1.092548*t*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*t*r,e[8]=.546274*(t*t-i*i)}},ux=class extends Kr{constructor(s=new Lm,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=s}copy(s){return super.copy(s),this.sh.copy(s.sh),this}toJSON(s){const e=super.toJSON(s);return e.object.sh=this.sh.toArray(),e}};class Gd extends Oi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const n=this,a=new js(n.manager);a.setPath(n.path),a.setRequestHeader(n.requestHeader),a.setWithCredentials(n.withCredentials),a.load(e,function(o){try{t(n.parse(JSON.parse(o)))}catch(l){r?r(l):Ve(l),n.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(n){return t[n]===void 0&&ge("MaterialLoader: Undefined texture",n),t[n]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new we().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(r.allowOverride=e.allowOverride),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const n in e.uniforms){const a=e.uniforms[n];switch(r.uniforms[n]={},a.type){case"t":r.uniforms[n].value=i(a.value);break;case"c":r.uniforms[n].value=new we().setHex(a.value);break;case"v2":r.uniforms[n].value=new te().fromArray(a.value);break;case"v3":r.uniforms[n].value=new R().fromArray(a.value);break;case"v4":r.uniforms[n].value=new It().fromArray(a.value);break;case"m3":r.uniforms[n].value=new at().fromArray(a.value);break;case"m4":r.uniforms[n].value=new et().fromArray(a.value);break;default:r.uniforms[n].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)r.extensions[n]=e.extensions[n];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),r.normalScale=new te().fromArray(n)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return Gd.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:fm,SpriteMaterial:Ec,RawShaderMaterial:lu,ShaderMaterial:$i,PointsMaterial:Jc,MeshPhysicalMaterial:ym,MeshStandardMaterial:hu,MeshPhongMaterial:xm,MeshToonMaterial:Zy,MeshNormalMaterial:vm,MeshLambertMaterial:_m,MeshDepthMaterial:cu,MeshDistanceMaterial:Mm,MeshBasicMaterial:Mr,MeshMatcapMaterial:Jy,LineDashedMaterial:Ky,LineBasicMaterial:Ti,Material:pi};return new t[e]}}class fu{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Dm extends rt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class dx extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new js(n.manager);a.setPath(n.path),a.setRequestHeader(n.requestHeader),a.setWithCredentials(n.withCredentials),a.load(e,function(o){try{t(n.parse(JSON.parse(o)))}catch(l){r?r(l):Ve(l),n.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(u,p){if(t[p]!==void 0)return t[p];const m=u.interleavedBuffers[p],y=n(u,m.buffer),g=Ma(m.type,y),f=new Al(g,m.stride);return f.uuid=m.uuid,t[p]=f,f}function n(u,p){if(i[p]!==void 0)return i[p];const m=u.arrayBuffers[p],y=new Uint32Array(m).buffer;return i[p]=y,y}const a=e.isInstancedBufferGeometry?new Dm:new rt,o=e.data.index;if(o!==void 0){const u=Ma(o.type,o.array);a.setIndex(new bt(u,1))}const l=e.data.attributes;for(const u in l){const p=l[u];let m;if(p.isInterleavedBufferAttribute){const y=r(e.data,p.data);m=new Da(y,p.itemSize,p.offset,p.normalized)}else{const y=Ma(p.type,p.array),g=p.isInstancedBufferAttribute?Rn:bt;m=new g(y,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),a.setAttribute(u,m)}const h=e.data.morphAttributes;if(h)for(const u in h){const p=h[u],m=[];for(let y=0,g=p.length;y<g;y++){const f=p[y];let x;if(f.isInterleavedBufferAttribute){const v=r(e.data,f.data);x=new Da(v,f.itemSize,f.offset,f.normalized)}else{const v=Ma(f.type,f.array);x=new bt(v,f.itemSize,f.normalized)}f.name!==void 0&&(x.name=f.name),m.push(x)}a.morphAttributes[u]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const c=e.data.groups||e.data.drawcalls||e.data.offsets;if(c!==void 0)for(let u=0,p=c.length;u!==p;++u){const m=c[u];a.addGroup(m.start,m.count,m.materialIndex)}const d=e.data.boundingSphere;return d!==void 0&&(a.boundingSphere=new ai().fromJSON(d)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class PS extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=this.path===""?fu.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new js(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let h=null;try{h=JSON.parse(l)}catch(d){r!==void 0&&r(d),d("ObjectLoader: Can't parse "+e+".",d.message);return}const c=h.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),Ve("ObjectLoader: Can't load "+e);return}n.parse(h,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?fu.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const n=new js(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const a=await n.loadAsync(e,t);let o;try{o=JSON.parse(a)}catch(h){throw new Error("ObjectLoader: Can't parse "+e+". "+h.message)}const l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(h)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),h=this.parseObject(e.object,n,l,o,i),c=this.parseSkeletons(e.skeletons,h);if(this.bindSkeletons(h,c),this.bindLightTargets(h),t!==void 0){let d=!1;for(const u in a)if(a[u].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(h)}return h}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),n=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,n),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),h=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,h),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const n=new Zr().fromJSON(e[i]);t[n.uuid]=n}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(n){n.isBone&&(r[n.uuid]=n)}),e!==void 0)for(let n=0,a=e.length;n<a;n++){const o=new Ah().fromJSON(e[n],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new dx;for(let n=0,a=e.length;n<a;n++){let o;const l=e[n];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in qy?o=qy[l.type].fromJSON(l,t):ge(`ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const n=new Gd;n.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=n.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],n=Xa.parse(r);t[n.uuid]=n}return t}parseImages(e,t){const i=this,r={};let n;function a(l){return i.manager.itemStart(l),n.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const h=l,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h)?h:i.resourcePath+h;return a(c)}else return l.data?{data:Ma(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new du(t);n=new Gl(l),n.setCrossOrigin(this.crossOrigin);for(let h=0,c=e.length;h<c;h++){const d=e[h],u=d.url;if(Array.isArray(u)){const p=[];for(let m=0,y=u.length;m<y;m++){const g=u[m],f=o(g);f!==null&&(f instanceof HTMLImageElement?p.push(f):p.push(new os(f.data,f.width,f.height)))}r[d.uuid]=new pr(p)}else{const p=o(d.url);r[d.uuid]=new pr(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function n(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:Ma(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Gl(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],h=l.url;if(Array.isArray(h)){const c=[];for(let d=0,u=h.length;d<u;d++){const p=h[d],m=await n(p);m!==null&&(m instanceof HTMLImageElement?c.push(m):c.push(new os(m.data,m.width,m.height)))}i[l.uuid]=new pr(c)}else{const c=await n(l.url);i[l.uuid]=new pr(c)}}}return i}parseTextures(e,t){function i(n,a){return typeof n=="number"?n:(ge("ObjectLoader.parseTexture: Constant should be in numeric form.",n),a[n])}const r={};if(e!==void 0)for(let n=0,a=e.length;n<a;n++){const o=e[n];o.image===void 0&&ge('ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&ge("ObjectLoader: Undefined image",o.image);const l=t[o.image],h=l.data;let c;Array.isArray(h)?(c=new Va,h.length===6&&(c.needsUpdate=!0)):(h&&h.data?c=new os:c=new ei,h&&(c.needsUpdate=!0)),c.source=l,c.uuid=o.uuid,o.name!==void 0&&(c.name=o.name),o.mapping!==void 0&&(c.mapping=i(o.mapping,LS)),o.channel!==void 0&&(c.channel=o.channel),o.offset!==void 0&&c.offset.fromArray(o.offset),o.repeat!==void 0&&c.repeat.fromArray(o.repeat),o.center!==void 0&&c.center.fromArray(o.center),o.rotation!==void 0&&(c.rotation=o.rotation),o.wrap!==void 0&&(c.wrapS=i(o.wrap[0],px),c.wrapT=i(o.wrap[1],px)),o.format!==void 0&&(c.format=o.format),o.internalFormat!==void 0&&(c.internalFormat=o.internalFormat),o.type!==void 0&&(c.type=o.type),o.colorSpace!==void 0&&(c.colorSpace=o.colorSpace),o.minFilter!==void 0&&(c.minFilter=i(o.minFilter,mx)),o.magFilter!==void 0&&(c.magFilter=i(o.magFilter,mx)),o.anisotropy!==void 0&&(c.anisotropy=o.anisotropy),o.flipY!==void 0&&(c.flipY=o.flipY),o.generateMipmaps!==void 0&&(c.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(c.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(c.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(c.compareFunction=o.compareFunction),o.userData!==void 0&&(c.userData=o.userData),r[o.uuid]=c}return r}parseObject(e,t,i,r,n){let a;function o(u){return t[u]===void 0&&ge("ObjectLoader: Undefined geometry",u),t[u]}function l(u){if(u!==void 0){if(Array.isArray(u)){const p=[];for(let m=0,y=u.length;m<y;m++){const g=u[m];i[g]===void 0&&ge("ObjectLoader: Undefined material",g),p.push(i[g])}return p}return i[u]===void 0&&ge("ObjectLoader: Undefined material",u),i[u]}}function h(u){return r[u]===void 0&&ge("ObjectLoader: Undefined texture",u),r[u]}let c,d;switch(e.type){case"Scene":a=new Mp,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new we(e.background):a.background=h(e.background)),e.environment!==void 0&&(a.environment=h(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new _p(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Id(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new li(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Ya(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new Pm(e.color,e.intensity);break;case"DirectionalLight":a=new Im(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Rm(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new cx(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Cm(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new Em(e.color,e.groundColor,e.intensity);break;case"LightProbe":const u=new Lm().fromArray(e.sh);a=new ux(u,e.intensity);break;case"SkinnedMesh":c=o(e.geometry),d=l(e.material),a=new Gp(c,d),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":c=o(e.geometry),d=l(e.material),a=new Xt(c,d);break;case"InstancedMesh":c=o(e.geometry),d=l(e.material);const p=e.count,m=e.instanceMatrix,y=e.instanceColor;a=new Hp(c,d,p),a.instanceMatrix=new Rn(new Float32Array(m.array),16),y!==void 0&&(a.instanceColor=new Rn(new Float32Array(y.array),y.itemSize));break;case"BatchedMesh":c=o(e.geometry),d=l(e.material),a=new qp(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,d),a.geometry=c,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(g=>{let f=null,x=null;return g.boundingBox!==void 0&&(f=new di().fromJSON(g.boundingBox)),g.boundingSphere!==void 0&&(x=new ai().fromJSON(g.boundingSphere)),{...g,boundingBox:f,boundingSphere:x}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=h(e.matricesTexture.uuid),a._indirectTexture=h(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=h(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new ai().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new di().fromJSON(e.boundingBox));break;case"LOD":a=new Op;break;case"Line":a=new Sr(o(e.geometry),l(e.material));break;case"LineLoop":a=new Zp(o(e.geometry),l(e.material));break;case"LineSegments":a=new Rs(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new Kp(o(e.geometry),l(e.material));break;case"Sprite":a=new Dp(l(e.material));break;case"Group":a=new wn;break;case"Bone":a=new kc;break;default:a=new _t}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.pivot!==void 0&&(a.pivot=new R().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const u=e.children;for(let p=0;p<u.length;p++)a.add(this.parseObject(u[p],t,i,r,n))}if(e.animations!==void 0){const u=e.animations;for(let p=0;p<u.length;p++){const m=u[p];a.animations.push(n[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const u=e.levels;for(let p=0;p<u.length;p++){const m=u[p],y=a.getObjectByProperty("uuid",m.object);y!==void 0&&a.addLevel(y,m.distance,m.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?ge("ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new _t}})}}const LS={UVMapping:Gh,CubeReflectionMapping:ks,CubeRefractionMapping:zr,EquirectangularReflectionMapping:ca,EquirectangularRefractionMapping:ua,CubeUVReflectionMapping:xn},px={RepeatWrapping:da,ClampToEdgeWrapping:Ci,MirroredRepeatWrapping:pa},mx={NearestFilter:Ht,NearestMipmapNearestFilter:Hh,NearestMipmapLinearFilter:vn,LinearFilter:Rt,LinearMipmapNearestFilter:ma,LinearMipmapLinearFilter:Ss},Om=new WeakMap;class fx extends Oi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&ge("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&ge("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=Is.get(`image-bitmap:${e}`);if(a!==void 0){if(n.manager.itemStart(e),a.then){a.then(h=>{if(Om.has(a)===!0)r&&r(Om.get(a)),n.manager.itemError(e),n.manager.itemEnd(e);else return t&&t(h),n.manager.itemEnd(e),h});return}return setTimeout(function(){t&&t(a),n.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(h){return Is.add(`image-bitmap:${e}`,h),t&&t(h),n.manager.itemEnd(e),h}).catch(function(h){r&&r(h),Om.set(l,h),Is.remove(`image-bitmap:${e}`),n.manager.itemError(e),n.manager.itemEnd(e)});Is.add(`image-bitmap:${e}`,l),n.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let gu;class yu{static getContext(){return gu===void 0&&(gu=new(window.AudioContext||window.webkitAudioContext)),gu}static setContext(e){gu=e}}class gx extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new js(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const h=l.slice(0);yu.getContext().decodeAudioData(h,function(c){t(c)}).catch(o)}catch(h){o(h)}},i,r);function o(l){r?r(l):Ve(l),n.manager.itemError(e)}}}const yx=new et,xx=new et,Vn=new et;class DS{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new li,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new li,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Vn.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,n=t.near*Math.tan(Tn*t.fov*.5)/t.zoom;let a,o;xx.elements[12]=-i,yx.elements[12]=i,a=-n*t.aspect+r,o=n*t.aspect+r,Vn.elements[0]=2*t.near/(o-a),Vn.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Vn),a=-n*t.aspect-r,o=n*t.aspect-r,Vn.elements[0]=2*t.near/(o-a),Vn.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Vn)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(xx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(yx)}}const Za=-90,Ja=1;class Um extends _t{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new li(Za,Ja,e,t);r.layers=this.layers,this.add(r);const n=new li(Za,Ja,e,t);n.layers=this.layers,this.add(n);const a=new li(Za,Ja,e,t);a.layers=this.layers,this.add(a);const o=new li(Za,Ja,e,t);o.layers=this.layers,this.add(o);const l=new li(Za,Ja,e,t);l.layers=this.layers,this.add(l);const h=new li(Za,Ja,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,n,a,o,l]=t;for(const h of t)this.remove(h);if(e===Yi)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),n.up.set(0,0,-1),n.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Sn)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),n.up.set(0,0,1),n.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.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: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[n,a,o,l,h,c]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,n),e.setRenderTarget(i,1,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(d,u,p),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}}class Fm extends li{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}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(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=OS.bind(this),e.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(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function OS(){this._document.hidden===!1&&this.reset()}const qs=new R,Bm=new Mi,US=new R,kn=new R,Gn=new R;let vx=class extends _t{constructor(){super(),this.type="AudioListener",this.context=yu.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(s){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=s,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(s){return this.gain.gain.setTargetAtTime(s,this.context.currentTime,.01),this}updateMatrixWorld(s){super.updateMatrixWorld(s),this._timer.update();const e=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(qs,Bm,US),!(!Number.isFinite(qs.x)||!Number.isFinite(qs.y)||!Number.isFinite(qs.z)))if(kn.set(0,0,-1).applyQuaternion(Bm),Gn.set(0,1,0).applyQuaternion(Bm),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(qs.x,t),e.positionY.linearRampToValueAtTime(qs.y,t),e.positionZ.linearRampToValueAtTime(qs.z,t),e.forwardX.linearRampToValueAtTime(kn.x,t),e.forwardY.linearRampToValueAtTime(kn.y,t),e.forwardZ.linearRampToValueAtTime(kn.z,t),e.upX.linearRampToValueAtTime(Gn.x,t),e.upY.linearRampToValueAtTime(Gn.y,t),e.upZ.linearRampToValueAtTime(Gn.z,t)}else e.setPosition(qs.x,qs.y,qs.z),e.setOrientation(kn.x,kn.y,kn.z,Gn.x,Gn.y,Gn.z)}};class Vm extends _t{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){ge("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){ge("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){ge("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(e=0){if(this.hasPlaybackControl===!1){ge("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,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(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){ge("Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(ge("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){ge("Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(ge("Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const Hn=new R,_x=new Mi,FS=new R,Wn=new R;class Mx extends Vm{constructor(e){super(e),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(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Hn,_x,FS),Wn.set(0,0,1).applyQuaternion(_x);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Hn.x,i),t.positionY.linearRampToValueAtTime(Hn.y,i),t.positionZ.linearRampToValueAtTime(Hn.z,i),t.orientationX.linearRampToValueAtTime(Wn.x,i),t.orientationY.linearRampToValueAtTime(Wn.y,i),t.orientationZ.linearRampToValueAtTime(Wn.z,i)}else t.setPosition(Hn.x,Hn.y,Hn.z),t.setOrientation(Wn.x,Wn.y,Wn.z)}}class zS{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class bx{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,n,a;switch(t){case"quaternion":r=this._slerp,n=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,n=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,n=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=n,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,n=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[n+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,n,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,n=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,n<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-n,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,h=t+t;l!==h;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let n=i,a=r;n!==a;++n)t[n]=t[r+n%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,n){if(r>=.5)for(let a=0;a!==n;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){Mi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,n){const a=this._workIndex*n;Mi.multiplyQuaternionsFlat(e,a,e,t,e,i),Mi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,n){const a=1-r;for(let o=0;o!==n;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,n){for(let a=0;a!==n;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const km="\\[\\]\\.:\\/",BS=new RegExp("["+km+"]","g"),Gm="[^"+km+"]",VS="[^"+km.replace("\\.","")+"]",kS=/((?:WC+[\/:])*)/.source.replace("WC",Gm),GS=/(WCOD+)?/.source.replace("WCOD",VS),HS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Gm),WS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Gm),jS=new RegExp("^"+kS+GS+HS+WS+"$"),XS=["material","materials","bones","map"];class qS{constructor(e,t,i){const r=i||gt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class gt{constructor(e,t,i){this.path=t,this.parsedPath=i||gt.parseTrackName(t),this.node=gt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new gt.Composite(e,t,i):new gt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(BS,"")}static parseTrackName(e){const t=jS.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const n=i.nodeName.substring(r+1);XS.indexOf(n)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=n)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(n,a){for(let o=0;o<n.length;o++){const l=n[o];if(!a&&(l.name===t||l.uuid===t)||a&&l.userData&&l.userData.name===t)return l;const h=i(l.children,a);if(h)return h}return null},r=i(e.children);if(r)return r;{const n=i(e.children,!0);if(n)return n}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let n=t.propertyIndex;if(e||(e=gt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){ge("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let h=t.objectIndex;switch(i){case"materials":if(!e.material){Ve("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ve("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ve("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===h){h=c;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ve("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ve("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Ve("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(h!==void 0){if(e[h]===void 0){Ve("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}const a=e[r];if(a===void 0){const h=t.nodeName;Ve("PropertyBinding: Trying to update property for track: "+h+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(n!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){Ve("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ve("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[n]!==void 0&&(n=e.morphTargetDictionary[n])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=n}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}gt.Composite=qS,gt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},gt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},gt.prototype.GetterByBindingType=[gt.prototype._getValue_direct,gt.prototype._getValue_array,gt.prototype._getValue_arrayElement,gt.prototype._getValue_toArray],gt.prototype.SetterByBindingTypeAndVersioning=[[gt.prototype._setValue_direct,gt.prototype._setValue_direct_setNeedsUpdate,gt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_array,gt.prototype._setValue_array_setNeedsUpdate,gt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_arrayElement,gt.prototype._setValue_arrayElement_setNeedsUpdate,gt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_fromArray,gt.prototype._setValue_fromArray_setNeedsUpdate,gt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class YS{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Zi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,n=this._bindings,a=n.length;let o,l=e.length,h=this.nCachedObjects_;for(let c=0,d=arguments.length;c!==d;++c){const u=arguments[c],p=u.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(u);for(let y=0,g=a;y!==g;++y)n[y].push(new gt(u,i[y],r[y]))}else if(m<h){o=e[m];const y=--h,g=e[y];t[g.uuid]=m,e[m]=g,t[p]=y,e[y]=u;for(let f=0,x=a;f!==x;++f){const v=n[f],M=v[y];let w=v[m];v[m]=M,w===void 0&&(w=new gt(u,i[f],r[f])),v[y]=w}}else e[m]!==o&&Ve("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let n=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],h=l.uuid,c=t[h];if(c!==void 0&&c>=n){const d=n++,u=e[d];t[u.uuid]=c,e[c]=u,t[h]=d,e[d]=l;for(let p=0,m=r;p!==m;++p){const y=i[p],g=y[d],f=y[c];y[c]=g,y[d]=f}}}this.nCachedObjects_=n}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let n=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const h=arguments[o],c=h.uuid,d=t[c];if(d!==void 0)if(delete t[c],d<n){const u=--n,p=e[u],m=--a,y=e[m];t[p.uuid]=d,e[d]=p,t[y.uuid]=u,e[u]=y,e.pop();for(let g=0,f=r;g!==f;++g){const x=i[g],v=x[u],M=x[m];x[d]=v,x[u]=M,x.pop()}}else{const u=--a,p=e[u];u>0&&(t[p.uuid]=d),e[d]=p,e.pop();for(let m=0,y=r;m!==y;++m){const g=i[m];g[d]=g[u],g.pop()}}}this.nCachedObjects_=n}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const n=this._bindings;if(r!==void 0)return n[r];const a=this._paths,o=this._parsedPaths,l=this._objects,h=l.length,c=this.nCachedObjects_,d=new Array(h);r=n.length,i[e]=r,a.push(e),o.push(t),n.push(d);for(let u=c,p=l.length;u!==p;++u){const m=l[u];d[u]=new gt(m,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,n=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],h=e[o];t[h]=i,a[i]=l,a.pop(),n[i]=n[o],n.pop(),r[i]=r[o],r.pop()}}}class Sx{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const n=t.tracks,a=n.length,o=new Array(a),l={endingStart:Mn,endingEnd:Mn};for(let h=0;h!==a;++h){const c=n[h].createInterpolant(null);o[h]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=op,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const r=this._clip.duration,n=e._clip.duration,a=n/r,o=r/n;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,n=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,h=o.sampleValues;return l[0]=n,l[1]=n+i,h[0]=e/a,h[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const n=this._startTime;if(n!==null){const l=(e-n)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case hp:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(a),h[c].accumulateAdditive(o);break;case uc:default:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(a),h[c].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,n=this._loopCount;const a=i===f0;if(e===0)return n===-1?r:a&&(n&1)===1?t-r:r;if(i===ap){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(n===-1&&(e>=0?(n=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,n+=Math.abs(o);const l=this.repetitions-n;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const h=e<0;this._setEndings(h,!h,a)}else this._setEndings(!1,!1,a);this._loopCount=n,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(n&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=bn,r.endingEnd=bn):(e?r.endingStart=this.zeroSlopeAtStart?bn:Mn:r.endingStart=pl,t?r.endingEnd=this.zeroSlopeAtEnd?bn:Mn:r.endingEnd=pl)}_scheduleFading(e,t,i){const r=this._mixer,n=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=n,l[0]=t,o[1]=n+e,l[1]=i,this}}const ZS=new Float32Array(1);class Tx extends Es{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,n=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,h=this._bindingsByRootAndName;let c=h[l];c===void 0&&(c={},h[l]=c);for(let d=0;d!==n;++d){const u=r[d],p=u.name;let m=c[p];if(m!==void 0)++m.referenceCount,a[d]=m;else{if(m=a[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const y=t&&t._propertyBindings[d].binding.parsedPath;m=new bx(gt.create(i,p,y),u.ValueTypeName,u.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[d]=m}o[d].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,n=this._actionsByClip[r];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const n=t[i];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const n=t[i];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,n=this._actionsByClip;let a=n[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const n=e._clip.uuid,a=this._actionsByClip,o=a[n],l=o.knownActions,h=l[l.length-1],c=e._byClipCacheIndex;h._byClipCacheIndex=c,l[c]=h,l.pop(),e._byClipCacheIndex=null;const d=o.actionByRoot,u=(e._localRoot||this._root).uuid;delete d[u],l.length===0&&delete a[n],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const n=t[i];--n.referenceCount===0&&this._removeInactiveBinding(n)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,n=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=n.length,n.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,n=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],h=e._cacheIndex;l._cacheIndex=h,t[h]=l,t.pop(),delete o[n],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Tm(new Float32Array(2),new Float32Array(2),1,ZS),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,n=t[r];e.__cacheIndex=r,t[r]=e,n.__cacheIndex=i,t[i]=n}clipAction(e,t,i){const r=t||this._root,n=r.uuid;let a=typeof e=="string"?Xa.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let h=null;if(i===void 0&&(a!==null?i=a.blendMode:i=uc),l!==void 0){const d=l.actionByRoot[n];if(d!==void 0&&d.blendMode===i)return d;h=l.knownActions[0],a===null&&(a=h._clip)}if(a===null)return null;const c=new Sx(this,a,t,i);return this._bindAction(c,h),this._addInactiveAction(c,o,n),c}existingAction(e,t){const i=t||this._root,r=i.uuid,n=typeof e=="string"?Xa.findByName(i,e):e,a=n?n.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,n=Math.sign(e),a=this._accuIndex^=1;for(let h=0;h!==i;++h)t[h]._update(r,e,n,a);const o=this._bindings,l=this._nActiveBindings;for(let h=0;h!==l;++h)o[h].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,n=r[i];if(n!==void 0){const a=n.knownActions;for(let o=0,l=a.length;o!==l;++o){const h=a[o];this._deactivateAction(h);const c=h._cacheIndex,d=t[t.length-1];h._cacheIndex=null,h._byClipCacheIndex=null,d._cacheIndex=c,t[c]=d,t.pop(),this._removeInactiveBindingsForAction(h)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,n=r[t];if(n!==void 0)for(const a in n){const o=n[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class JS extends yp{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=i,this.texture=new _l(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class Hd{constructor(e){this.value=e}clone(){return new Hd(this.value.clone===void 0?this.value:this.value.clone())}}let KS=0;class $S extends Es{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:KS++}),this.name="",this.usage=fl,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const n=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<n.length;a++)this.uniforms.push(n[a].clone())}return this}clone(){return new this.constructor().copy(this)}}let wx=class extends Al{constructor(s,e,t=1){super(s,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=t}copy(s){return super.copy(s),this.meshPerAttribute=s.meshPerAttribute,this}clone(s){const e=super.clone(s);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(s){const e=super.toJSON(s);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}};class QS{constructor(e,t,i,r,n,a=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=n,this.normalized=a,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const Ex=new et;class Ax{constructor(e,t,i=0,r=1/0){this.ray=new Nn(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Ml,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Ve("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Ex.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ex),this}intersectObject(e,t=!0,i=[]){return Hm(e,this,i,t),i.sort(Nx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,n=e.length;r<n;r++)Hm(e[r],this,i,t);return i.sort(Nx),i}}function Nx(s,e){return s.distance-e.distance}function Hm(s,e,t,i){let r=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const n=s.children;for(let a=0,o=n.length;a<o;a++)Hm(n[a],e,t,!0)}}class eT{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,ge("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 e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}class Cx{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ke(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Ke(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class tT{constructor(e=1,t=0,i=0){this.radius=e,this.theta=t,this.y=i}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}let iT=class nM{constructor(e,t,i,r){nM.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const n=this.elements;return n[0]=e,n[2]=t,n[1]=i,n[3]=r,this}};const Rx=new te;class sT{constructor(e=new te(1/0,1/0),t=new te(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Rx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Rx).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ix=new R,xu=new R,Ka=new R,$a=new R,Wm=new R,rT=new R,nT=new R;class Px{constructor(e=new R,t=new R){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Ix.subVectors(e,this.start),xu.subVectors(this.end,this.start);const i=xu.dot(xu);let r=xu.dot(Ix)/i;return t&&(r=Ke(r,0,1)),r}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=rT,i=nT){const r=10000000000000001e-32;let n,a;const o=this.start,l=e.start,h=this.end,c=e.end;Ka.subVectors(h,o),$a.subVectors(c,l),Wm.subVectors(o,l);const d=Ka.dot(Ka),u=$a.dot($a),p=$a.dot(Wm);if(d<=r&&u<=r)return t.copy(o),i.copy(l),t.sub(i),t.dot(t);if(d<=r)n=0,a=p/u,a=Ke(a,0,1);else{const m=Ka.dot(Wm);if(u<=r)a=0,n=Ke(-m/d,0,1);else{const y=Ka.dot($a),g=d*u-y*y;g!==0?n=Ke((y*p-m*u)/g,0,1):n=0,a=(y*n+p)/u,a<0?(a=0,n=Ke(-m/d,0,1)):a>1&&(a=1,n=Ke((y-m)/d,0,1))}}return t.copy(o).addScaledVector(Ka,n),i.copy(l).addScaledVector($a,a),t.distanceToSquared(i)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Lx=new R;class aT extends _t{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new rt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const h=a/l*Math.PI*2,c=o/l*Math.PI*2;r.push(Math.cos(h),Math.sin(h),1,Math.cos(c),Math.sin(c),1)}i.setAttribute("position",new Ne(r,3));const n=new Ti({fog:!1,toneMapped:!1});this.cone=new Rs(i,n),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 e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Lx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Lx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Qr=new R,vu=new et,jm=new et;class oT extends Rs{constructor(e){const t=Dx(e),i=new rt,r=[],n=[];for(let h=0;h<t.length;h++){const c=t[h];c.parent&&c.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),n.push(0,0,0),n.push(0,0,0))}i.setAttribute("position",new Ne(r,3)),i.setAttribute("color",new Ne(n,3));const a=new Ti({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,a),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const o=new we(255),l=new we(65280);this.setColors(o,l)}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");jm.copy(this.root.matrixWorld).invert();for(let n=0,a=0;n<t.length;n++){const o=t[n];o.parent&&o.parent.isBone&&(vu.multiplyMatrices(jm,o.matrixWorld),Qr.setFromMatrixPosition(vu),r.setXYZ(a,Qr.x,Qr.y,Qr.z),vu.multiplyMatrices(jm,o.parent.matrixWorld),Qr.setFromMatrixPosition(vu),r.setXYZ(a+1,Qr.x,Qr.y,Qr.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const i=this.geometry.getAttribute("color");for(let r=0;r<i.count;r+=2)i.setXYZ(r,e.r,e.g,e.b),i.setXYZ(r+1,t.r,t.g,t.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function Dx(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push(...Dx(s.children[t]));return e}class lT extends Xt{constructor(e,t,i){const r=new Po(t,4,2),n=new Mr({wireframe:!0,fog:!1,toneMapped:!1});super(r,n),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const hT=new R,Ox=new we,Ux=new we;class cT extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new Io(t);r.rotateY(Math.PI*.5),this.material=new Mr({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const n=r.getAttribute("position"),a=new Float32Array(n.count*3);r.setAttribute("color",new bt(a,3)),this.add(new Xt(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Ox.copy(this.light.color),Ux.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const n=i<r/2?Ox:Ux;t.setXYZ(i,n.r,n.g,n.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(hT.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Fx=class extends Rs{constructor(s=10,e=10,t=4473924,i=8947848){t=new we(t),i=new we(i);const r=e/2,n=s/e,a=s/2,o=[],l=[];for(let d=0,u=0,p=-a;d<=e;d++,p+=n){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=d===r?t:i;m.toArray(l,u),u+=3,m.toArray(l,u),u+=3,m.toArray(l,u),u+=3,m.toArray(l,u),u+=3}const h=new rt;h.setAttribute("position",new Ne(o,3)),h.setAttribute("color",new Ne(l,3));const c=new Ti({vertexColors:!0,toneMapped:!1});super(h,c),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class uT extends Rs{constructor(e=10,t=16,i=8,r=64,n=4473924,a=8947848){n=new we(n),a=new we(a);const o=[],l=[];if(t>1)for(let d=0;d<t;d++){const u=d/t*(Math.PI*2),p=Math.sin(u)*e,m=Math.cos(u)*e;o.push(0,0,0),o.push(p,0,m);const y=d&1?n:a;l.push(y.r,y.g,y.b),l.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){const u=d&1?n:a,p=e-e/i*d;for(let m=0;m<r;m++){let y=m/r*(Math.PI*2),g=Math.sin(y)*p,f=Math.cos(y)*p;o.push(g,0,f),l.push(u.r,u.g,u.b),y=(m+1)/r*(Math.PI*2),g=Math.sin(y)*p,f=Math.cos(y)*p,o.push(g,0,f),l.push(u.r,u.g,u.b)}}const h=new rt;h.setAttribute("position",new Ne(o,3)),h.setAttribute("color",new Ne(l,3));const c=new Ti({vertexColors:!0,toneMapped:!1});super(h,c),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const zx=new R,_u=new R,Bx=new R;class Vx extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new rt;r.setAttribute("position",new Ne([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const n=new Ti({fog:!1,toneMapped:!1});this.lightPlane=new Sr(r,n),this.add(this.lightPlane),r=new rt,r.setAttribute("position",new Ne([0,0,0,0,0,1],3)),this.targetLine=new Sr(r,n),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),zx.setFromMatrixPosition(this.light.matrixWorld),_u.setFromMatrixPosition(this.light.target.matrixWorld),Bx.subVectors(_u,zx),this.lightPlane.lookAt(_u),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(_u),this.targetLine.scale.z=Bx.length()}}const Mu=new R,Wt=new Hl;class kx extends Rs{constructor(e){const t=new rt,i=new Ti({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],n=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(m,y){l(m),l(y)}function l(m){r.push(0,0,0),n.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new Ne(r,3)),t.setAttribute("color",new Ne(n,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const h=new we(16755200),c=new we(16711680),d=new we(43775),u=new we(16777215),p=new we(3355443);this.setColors(h,c,d,u,p)}setColors(e,t,i,r,n){const a=this.geometry.getAttribute("color");return a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,n.r,n.g,n.b),a.setXYZ(41,n.r,n.g,n.b),a.setXYZ(42,n.r,n.g,n.b),a.setXYZ(43,n.r,n.g,n.b),a.setXYZ(44,n.r,n.g,n.b),a.setXYZ(45,n.r,n.g,n.b),a.setXYZ(46,n.r,n.g,n.b),a.setXYZ(47,n.r,n.g,n.b),a.setXYZ(48,n.r,n.g,n.b),a.setXYZ(49,n.r,n.g,n.b),a.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;let n,a;if(Wt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)n=1,a=0;else if(this.camera.coordinateSystem===Yi)n=-1,a=1;else if(this.camera.coordinateSystem===Sn)n=0,a=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);qt("c",t,e,Wt,0,0,n),qt("t",t,e,Wt,0,0,a),qt("n1",t,e,Wt,-i,-r,n),qt("n2",t,e,Wt,i,-r,n),qt("n3",t,e,Wt,-i,r,n),qt("n4",t,e,Wt,i,r,n),qt("f1",t,e,Wt,-i,-r,a),qt("f2",t,e,Wt,i,-r,a),qt("f3",t,e,Wt,-i,r,a),qt("f4",t,e,Wt,i,r,a),qt("u1",t,e,Wt,i*.7,r*1.1,n),qt("u2",t,e,Wt,-i*.7,r*1.1,n),qt("u3",t,e,Wt,0,r*2,n),qt("cf1",t,e,Wt,-i,0,a),qt("cf2",t,e,Wt,i,0,a),qt("cf3",t,e,Wt,0,-r,a),qt("cf4",t,e,Wt,0,r,a),qt("cn1",t,e,Wt,-i,0,n),qt("cn2",t,e,Wt,i,0,n),qt("cn3",t,e,Wt,0,-r,n),qt("cn4",t,e,Wt,0,r,n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function qt(s,e,t,i,r,n,a){Mu.set(r,n,a).unproject(i);const o=e[s];if(o!==void 0){const l=t.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],Mu.x,Mu.y,Mu.z)}}const bu=new di;class Gx extends Rs{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),n=new rt;n.setIndex(new bt(i,1)),n.setAttribute("position",new bt(r,3)),super(n,new Ti({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&bu.setFromObject(this.object),bu.isEmpty())return;const e=bu.min,t=bu.max,i=this.geometry.attributes.position,r=i.array;r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Hx extends Rs{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],n=new rt;n.setIndex(new bt(i,1)),n.setAttribute("position",new Ne(r,3)),super(n,new Ti({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class dT extends Sr{constructor(e,t=1,i=16776960){const r=i,n=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new rt;a.setAttribute("position",new Ne(n,3)),a.computeBoundingSphere(),super(a,new Ti({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new rt;l.setAttribute("position",new Ne(o,3)),l.computeBoundingSphere(),this.add(new Xt(l,new Mr({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Wx=new R;let Su,Xm;class pT extends _t{constructor(e=new R(0,0,1),t=new R(0,0,0),i=1,r=16776960,n=i*.2,a=n*.2){super(),this.type="ArrowHelper",Su===void 0&&(Su=new rt,Su.setAttribute("position",new Ne([0,0,0,0,1,0],3)),Xm=new Nh(.5,1,5,1),Xm.translate(0,-.5,0)),this.position.copy(t),this.line=new Sr(Su,new Ti({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Xt(Xm,new Mr({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,n,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Wx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Wx,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let jx=class extends Rs{constructor(s=1){const e=[0,0,0,s,0,0,0,0,0,0,s,0,0,0,0,0,0,s],t=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new rt;i.setAttribute("position",new Ne(e,3)),i.setAttribute("color",new Ne(t,3));const r=new Ti({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(s,e,t){const i=new we,r=this.geometry.attributes.color.array;return i.set(s),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(t),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class Xx{constructor(){this.type="ShapePath",this.color=new we,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new nu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,a){return this.currentPath.bezierCurveTo(e,t,i,r,n,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(f){const x=[];for(let v=0,M=f.length;v<M;v++){const w=f[v],T=new Zr;T.curves=w.curves,x.push(T)}return x}function i(f,x){const v=x.length;let M=!1;for(let w=v-1,T=0;T<v;w=T++){let A=x[w],_=x[T],S=_.x-A.x,P=_.y-A.y;if(Math.abs(P)>Number.EPSILON){if(P<0&&(A=x[T],S=-S,_=x[w],P=-P),f.y<A.y||f.y>_.y)continue;if(f.y===A.y){if(f.x===A.x)return!0}else{const C=P*(f.x-A.x)-S*(f.y-A.y);if(C===0)return!0;if(C<0)continue;M=!M}}else{if(f.y!==A.y)continue;if(_.x<=f.x&&f.x<=A.x||A.x<=f.x&&f.x<=_.x)return!0}}return M}const r=ys.isClockWise,n=this.subPaths;if(n.length===0)return[];let a,o,l;const h=[];if(n.length===1)return o=n[0],l=new Zr,l.curves=o.curves,h.push(l),h;let c=!r(n[0].getPoints());c=e?!c:c;const d=[],u=[];let p=[],m=0,y;u[m]=void 0,p[m]=[];for(let f=0,x=n.length;f<x;f++)o=n[f],y=o.getPoints(),a=r(y),a=e?!a:a,a?(!c&&u[m]&&m++,u[m]={s:new Zr,p:y},u[m].s.curves=o.curves,c&&m++,p[m]=[]):p[m].push({h:o,p:y[0]});if(!u[0])return t(n);if(u.length>1){let f=!1,x=0;for(let v=0,M=u.length;v<M;v++)d[v]=[];for(let v=0,M=u.length;v<M;v++){const w=p[v];for(let T=0;T<w.length;T++){const A=w[T];let _=!0;for(let S=0;S<u.length;S++)i(A.p,u[S].p)&&(v!==S&&x++,_?(_=!1,d[S].push(A)):f=!0);_&&d[v].push(A)}}x>0&&f===!1&&(p=d)}let g;for(let f=0,x=u.length;f<x;f++){l=u[f].s,h.push(l),g=p[f];for(let v=0,M=g.length;v<M;v++)l.holes.push(g[v].h)}return h}}class qx extends Es{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){ge("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function mT(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function fT(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function gT(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function qm(s,e,t,i){const r=yT(i);switch(t){case np:return s*e;case Wo:return s*e/r.components*r.byteLength;case ga:return s*e/r.components*r.byteLength;case Br:return s*e*2/r.components*r.byteLength;case jo:return s*e*2/r.components*r.byteLength;case Zh:return s*e*3/r.components*r.byteLength;case vi:return s*e*4/r.components*r.byteLength;case Xo:return s*e*4/r.components*r.byteLength;case ya:case xa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case qo:case va:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Jh:case Jo:return Math.max(s,16)*Math.max(e,8)/4;case Yo:case Zo:return Math.max(s,8)*Math.max(e,8)/2;case Ko:case $o:case el:case tl:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Qo:case il:case sl:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case rl:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Kh:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case $h:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Qh:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case nl:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case ec:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case tc:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case ic:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case sc:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case rc:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case nc:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case ac:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case oc:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case lc:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case al:case hc:case ol:return Math.ceil(s/4)*Math.ceil(e/4)*16;case ll:case hl:return Math.ceil(s/4)*Math.ceil(e/4)*8;case cl:case ul:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function yT(s){switch(s){case Ri:case sp:return{byteLength:1,components:1};case fa:case rp:case Ts:return{byteLength:2,components:1};case jh:case Xh:return{byteLength:2,components:4};case qi:case Wh:case xi:return{byteLength:4,components:1};case qh:case Yh:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}class xT{static contain(e,t){return mT(e,t)}static cover(e,t){return fT(e,t)}static fill(e){return gT(e)}static getByteLength(e,t,i,r){return qm(e,t,i,r)}}if(typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:yn}})),typeof window<"u"){try{import.meta&&(window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:import.meta.url,revision:yn}))}catch{}window.__THREE__?(ge("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+yn),console.warn("THREE imports:",window.__THREE__IMPORTS__)):window.__THREE__=yn}function Yx(){let s=null,e=!1,t=null,i=null;function r(n,a){t(n,a),i=s.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=s.requestAnimationFrame(r),e=!0)},stop:function(){s.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(n){t=n},setContext:function(n){s=n}}}function vT(s){const e=new WeakMap;function t(o,l){const h=o.array,c=o.usage,d=h.byteLength,u=s.createBuffer();s.bindBuffer(l,u),s.bufferData(l,h,c),o.onUploadCallback();let p;if(h instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array<"u"&&h instanceof Float16Array)p=s.HALF_FLOAT;else if(h instanceof Uint16Array)o.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(h instanceof Int16Array)p=s.SHORT;else if(h instanceof Uint32Array)p=s.UNSIGNED_INT;else if(h instanceof Int32Array)p=s.INT;else if(h instanceof Int8Array)p=s.BYTE;else if(h instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:u,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,h){const c=l.array,d=l.updateRanges;if(s.bindBuffer(h,o),d.length===0)s.bufferSubData(h,0,c);else{d.sort((p,m)=>p.start-m.start);let u=0;for(let p=1;p<d.length;p++){const m=d[u],y=d[p];y.start<=m.start+m.count+1?m.count=Math.max(m.count,y.start+y.count-m.start):(++u,d[u]=y)}d.length=u+1;for(let p=0,m=d.length;p<m;p++){const y=d[p];s.bufferSubData(h,y.start*c.BYTES_PER_ELEMENT,c,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function n(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const c=e.get(o);(!c||c.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const h=e.get(o);if(h===void 0)e.set(o,t(o,l));else if(h.version<o.version){if(h.size!==o.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.");i(h.buffer,o,l),h.version=o.version}}return{get:r,remove:n,update:a}}var _T=`#ifdef USE_ALPHAHASH
|
|
5
|
+
}`;class $i extends pi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=xS,this.fragmentShader=vS,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ha(e.uniforms),this.uniformsGroups=yS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const n=this.uniforms[r].value;n&&n.isTexture?t.uniforms[r]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[r]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[r]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[r]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[r]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[r]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[r]={type:"m4",value:n.toArray()}:t.uniforms[r]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class lu extends $i{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class hu extends pi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new we(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 we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(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 ns,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class gm extends hu{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ke(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new we(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 we(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new we(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(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class ym extends pi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new we(16777215),this.specular=new we(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ns,this.combine=Ho,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Zy extends pi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new we(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class xm extends pi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class vm extends pi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new we(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new we(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ns,this.combine=Ho,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class cu extends pi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=hp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class _m extends pi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Jy extends pi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new we(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vr,this.normalScale=new te(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(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ky extends Ti{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Fn(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function $y(s){function e(r,n){return s[r]-s[n]}const t=s.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Mm(s,e,t){const i=s.length,r=new s.constructor(i);for(let n=0,a=0;a!==i;++n){const o=t[n]*e;for(let l=0;l!==e;++l)r[a++]=s[o+l]}return r}function bm(s,e,t,i){let r=1,n=s[0];for(;n!==void 0&&n[i]===void 0;)n=s[r++];if(n===void 0)return;let a=n[i];if(a!==void 0)if(Array.isArray(a))do a=n[i],a!==void 0&&(e.push(n.time),t.push(...a)),n=s[r++];while(n!==void 0);else if(a.toArray!==void 0)do a=n[i],a!==void 0&&(e.push(n.time),a.toArray(t,t.length)),n=s[r++];while(n!==void 0);else do a=n[i],a!==void 0&&(e.push(n.time),t.push(a)),n=s[r++];while(n!==void 0)}function _S(s,e,t,i,r=30){const n=s.clone();n.name=e;const a=[];for(let l=0;l<n.tracks.length;++l){const h=n.tracks[l],c=h.getValueSize(),d=[],u=[];for(let p=0;p<h.times.length;++p){const m=h.times[p]*r;if(!(m<t||m>=i)){d.push(h.times[p]);for(let y=0;y<c;++y)u.push(h.values[p*c+y])}}d.length!==0&&(h.times=Fn(d,h.times.constructor),h.values=Fn(u,h.values.constructor),a.push(h))}n.tracks=a;let o=1/0;for(let l=0;l<n.tracks.length;++l)o>n.tracks[l].times[0]&&(o=n.tracks[l].times[0]);for(let l=0;l<n.tracks.length;++l)n.tracks[l].shift(-1*o);return n.resetDuration(),n}function MS(s,e=0,t=s,i=30){i<=0&&(i=30);const r=t.tracks.length,n=e/i;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const h=s.tracks.find(function(f){return f.name===o.name&&f.ValueTypeName===l});if(h===void 0)continue;let c=0;const d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=d/3);let u=0;const p=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=p/3);const m=o.times.length-1;let y;if(n<=o.times[0]){const f=c,x=d-c;y=o.values.slice(f,x)}else if(n>=o.times[m]){const f=m*d+c,x=f+d-c;y=o.values.slice(f,x)}else{const f=o.createInterpolant(),x=c,v=d-c;f.evaluate(n),y=f.resultBuffer.slice(x,v)}l==="quaternion"&&new Mi().fromArray(y).normalize().conjugate().toArray(y);const g=h.times.length;for(let f=0;f<g;++f){const x=f*p+u;if(l==="quaternion")Mi.multiplyQuaternionsFlat(h.values,x,y,0,h.values,x);else{const v=p-u*2;for(let M=0;M<v;++M)h.values[x+M]-=y[M]}}}return s.blendMode=lp,s}class bS{static convertArray(e,t){return Fn(e,t)}static isTypedArray(e){return G0(e)}static getKeyframeOrder(e){return $y(e)}static sortedArray(e,t,i){return Mm(e,t,i)}static flattenJSON(e,t,i,r){bm(e,t,i,r)}static subclip(e,t,i,r,n=30){return _S(e,t,i,r,n)}static makeClipAdditive(e,t=0,i=e,r=30){return MS(e,t,i,r)}}class zn{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{let a;i:{s:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<n)break s;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(n=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=n)){const o=t[1];e<o&&(i=2,n=o);for(let l=i-2;;){if(n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=n,n=t[--i-1],e>=n)break t}a=i,i=0;break i}break e}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],n=t[i-1],n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=e*r;for(let a=0;a!==r;++a)t[a]=i[n+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Qy extends zn{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Mn,endingEnd:Mn}}intervalChanged_(e,t,i){const r=this.parameterPositions;let n=e-2,a=e+1,o=r[n],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case bn:n=e,o=2*t-i;break;case pl:n=r.length-2,o=t+r[n]-r[n+1];break;default:n=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case bn:a=e,l=2*i-t;break;case pl:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const h=(i-t)*.5,c=this.valueSize;this._weightPrev=h/(t-o),this._weightNext=h/(l-i),this._offsetPrev=n*c,this._offsetNext=a*c}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,h=l-o,c=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),y=m*m,g=y*m,f=-u*g+2*u*y-u*m,x=(1+u)*g+(-1.5-2*u)*y+(-.5+u)*m+1,v=(-1-p)*g+(1.5+p)*y+.5*m,M=p*g-p*y;for(let w=0;w!==o;++w)n[w]=f*a[c+w]+x*a[h+w]+v*a[l+w]+M*a[d+w];return n}}class Sm extends zn{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,h=l-o,c=(i-t)/(r-t),d=1-c;for(let u=0;u!==o;++u)n[u]=a[h+u]*d+a[l+u]*c;return n}}class ex extends zn{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class tx extends zn{interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,h=l-o,c=this.settings||this.DefaultSettings_,d=c.inTangents,u=c.outTangents;if(!d||!u){const y=(i-t)/(r-t),g=1-y;for(let f=0;f!==o;++f)n[f]=a[h+f]*g+a[l+f]*y;return n}const p=o*2,m=e-1;for(let y=0;y!==o;++y){const g=a[h+y],f=a[l+y],x=m*p+y*2,v=u[x],M=u[x+1],w=e*p+y*2,T=d[w],A=d[w+1];let _=(i-t)/(r-t),S,P,C,L,U;for(let V=0;V<8;V++){S=_*_,P=S*_,C=1-_,L=C*C,U=L*C;const B=U*t+3*L*_*v+3*C*S*T+P*r-i;if(Math.abs(B)<1e-10)break;const k=3*L*(v-t)+6*C*_*(T-v)+3*S*(r-T);if(Math.abs(k)<1e-10)break;_=_-B/k,_=Math.max(0,Math.min(1,_))}n[y]=U*g+3*L*_*M+3*C*S*A+P*f}return n}}class Qi{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Fn(t,this.TimeBufferType),this.values=Fn(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Fn(e.times,Array),values:Fn(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new ex(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Sm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Qy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new tx(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case Ma:t=this.InterpolantFactoryMethodDiscrete;break;case dl:t=this.InterpolantFactoryMethodLinear;break;case cc:t=this.InterpolantFactoryMethodSmooth;break;case op:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return ge("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ma;case this.InterpolantFactoryMethodLinear:return dl;case this.InterpolantFactoryMethodSmooth:return cc;case this.InterpolantFactoryMethodBezier:return op}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let n=0,a=r-1;for(;n!==r&&i[n]<e;)++n;for(;a!==-1&&i[a]>t;)--a;if(++a,n!==0||a!==r){n>=a&&(a=Math.max(a,1),n=a-1);const o=this.getValueSize();this.times=i.slice(n,a),this.values=this.values.slice(n*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Ve("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,n=i.length;n===0&&(Ve("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==n;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){Ve("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Ve("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&G0(r))for(let o=0,l=r.length;o!==l;++o){const h=r[o];if(isNaN(h)){Ve("KeyframeTrack: Value is not a valid number.",this,o,h),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===cc,n=e.length-1;let a=1;for(let o=1;o<n;++o){let l=!1;const h=e[o],c=e[o+1];if(h!==c&&(o!==1||h!==e[0]))if(r)l=!0;else{const d=o*i,u=d-i,p=d+i;for(let m=0;m!==i;++m){const y=t[d+m];if(y!==t[u+m]||y!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*i,u=a*i;for(let p=0;p!==i;++p)t[u+p]=t[d+p]}++a}}if(n>0){e[a]=e[n];for(let o=n*i,l=a*i,h=0;h!==i;++h)t[l+h]=t[o+h];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Qi.prototype.ValueTypeName="",Qi.prototype.TimeBufferType=Float32Array,Qi.prototype.ValueBufferType=Float32Array,Qi.prototype.DefaultInterpolation=dl;class Jr extends Qi{constructor(e,t,i){super(e,t,i)}}Jr.prototype.ValueTypeName="bool",Jr.prototype.ValueBufferType=Array,Jr.prototype.DefaultInterpolation=Ma,Jr.prototype.InterpolantFactoryMethodLinear=void 0,Jr.prototype.InterpolantFactoryMethodSmooth=void 0;class uu extends Qi{constructor(e,t,i,r){super(e,t,i,r)}}uu.prototype.ValueTypeName="color";class Wa extends Qi{constructor(e,t,i,r){super(e,t,i,r)}}Wa.prototype.ValueTypeName="number";class ix extends zn{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let h=e*o;for(let c=h+o;h!==c;h+=4)Mi.slerpFlat(n,0,a,h-o,a,h,l);return n}}class ja extends Qi{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new ix(this.times,this.values,this.getValueSize(),e)}}ja.prototype.ValueTypeName="quaternion",ja.prototype.InterpolantFactoryMethodSmooth=void 0;class Bn extends Qi{constructor(e,t,i){super(e,t,i)}}Bn.prototype.ValueTypeName="string",Bn.prototype.ValueBufferType=Array,Bn.prototype.DefaultInterpolation=Ma,Bn.prototype.InterpolantFactoryMethodLinear=void 0,Bn.prototype.InterpolantFactoryMethodSmooth=void 0;class Xa extends Qi{constructor(e,t,i,r){super(e,t,i,r)}}Xa.prototype.ValueTypeName="vector";class qa{constructor(e="",t=-1,i=[],r=uc){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Zi(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(TS(i[a]).scale(r));const n=new this(e.name,e.duration,t,e.blendMode);return n.uuid=e.uuid,n.userData=JSON.parse(e.userData||"{}"),n}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let n=0,a=i.length;n!==a;++n)t.push(Qi.toJSON(i[n]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const n=t.length,a=[];for(let o=0;o<n;o++){let l=[],h=[];l.push((o+n-1)%n,o,(o+1)%n),h.push(0,1,0);const c=$y(l);l=Mm(l,1,c),h=Mm(h,1,c),!r&&l[0]===0&&(l.push(n),h.push(h[0])),a.push(new Wa(".morphTargetInfluences["+t[o].name+"]",l,h).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},n=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const h=e[o],c=h.name.match(n);if(c&&c.length>1){const d=c[1];let u=r[d];u||(r[d]=u=[]),u.push(h)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(ge("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Ve("AnimationClip: No animation in JSONLoader data."),null;const i=function(c,d,u,p,m){if(u.length!==0){const y=[],g=[];bm(u,y,g,p),y.length!==0&&m.push(new c(d,y,g))}},r=[],n=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const h=e.hierarchy||[];for(let c=0;c<h.length;c++){const d=h[c].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const u={};let p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)u[d[p].morphTargets[m]]=-1;for(const m in u){const y=[],g=[];for(let f=0;f!==d[p].morphTargets.length;++f){const x=d[p];y.push(x.time),g.push(x.morphTarget===m?1:0)}r.push(new Wa(".morphTargetInfluence["+m+"]",y,g))}l=u.length*a}else{const u=".bones["+t[c].name+"]";i(Xa,u+".position",d,"pos",r),i(ja,u+".quaternion",d,"rot",r),i(Xa,u+".scale",d,"scl",r)}}return r.length===0?null:new this(n,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const n=this.tracks[i];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function SS(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Wa;case"vector":case"vector2":case"vector3":case"vector4":return Xa;case"color":return uu;case"quaternion":return ja;case"bool":case"boolean":return Jr;case"string":return Bn}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function TS(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=SS(s.type);if(s.times===void 0){const t=[],i=[];bm(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Is={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(sx(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!sx(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function sx(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class du{constructor(e,t,i){const r=this;let n=!1,a=0,o=0,l;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(c){o++,n===!1&&r.onStart!==void 0&&r.onStart(c,a,o),n=!0},this.itemEnd=function(c){a++,r.onProgress!==void 0&&r.onProgress(c,a,o),a===o&&(n=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(c){r.onError!==void 0&&r.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return h.push(c,d),this},this.removeHandler=function(c){const d=h.indexOf(c);return d!==-1&&h.splice(d,2),this},this.getHandler=function(c){for(let d=0,u=h.length;d<u;d+=2){const p=h[d],m=h[d+1];if(p.global&&(p.lastIndex=0),p.test(c))return m}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 Tm=new du;class Oi{constructor(e){this.manager=e!==void 0?e:Tm,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(e,t){const i=this;return new Promise(function(r,n){i.load(e,r,t,n)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Oi.DEFAULT_MATERIAL_NAME="__DEFAULT";const Tr={};class wS extends Error{constructor(e,t){super(e),this.response=t}}class js extends Oi{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=Is.get(`file:${e}`);if(n!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(n),this.manager.itemEnd(e)},0),n;if(Tr[e]!==void 0){Tr[e].push({onLoad:t,onProgress:i,onError:r});return}Tr[e]=[],Tr[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{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}),o=this.mimeType,l=this.responseType;fetch(a).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&ge("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const c=Tr[e],d=h.body.getReader(),u=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),p=u?parseInt(u):0,m=p!==0;let y=0;const g=new ReadableStream({start(f){x();function x(){d.read().then(({done:v,value:M})=>{if(v)f.close();else{y+=M.byteLength;const w=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:p});for(let T=0,A=c.length;T<A;T++){const _=c[T];_.onProgress&&_.onProgress(w)}f.enqueue(M),x()}},v=>{f.error(v)})}}});return new Response(g)}else throw new wS(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(l){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(c=>new DOMParser().parseFromString(c,o));case"json":return h.json();default:if(o==="")return h.text();{const c=/charset="?([^;"\s]*)"?/i.exec(o),d=c&&c[1]?c[1].toLowerCase():void 0,u=new TextDecoder(d);return h.arrayBuffer().then(p=>u.decode(p))}}}).then(h=>{Is.add(`file:${e}`,h);const c=Tr[e];delete Tr[e];for(let d=0,u=c.length;d<u;d++){const p=c[d];p.onLoad&&p.onLoad(h)}}).catch(h=>{const c=Tr[e];if(c===void 0)throw this.manager.itemError(e),h;delete Tr[e];for(let d=0,u=c.length;d<u;d++){const p=c[d];p.onError&&p.onError(h)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class ES extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new js(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(n.parse(JSON.parse(o)))}catch(l){r?r(l):Ve(l),n.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=qa.parse(e[i]);t.push(r)}return t}}class AS extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=[],o=new Ol,l=new js(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(n.withCredentials);let h=0;function c(d){l.load(e[d],function(u){const p=n.parse(u,!0);a[d]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},h+=1,h===6&&(p.mipmapCount===1&&(o.minFilter=Rt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let d=0,u=e.length;d<u;++d)c(d);else l.load(e,function(d){const u=n.parse(d,!0);if(u.isCubemap){const p=u.mipmaps.length/u.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let y=0;y<u.mipmapCount;y++)a[m].mipmaps.push(u.mipmaps[m*u.mipmapCount+y]),a[m].format=u.format,a[m].width=u.width,a[m].height=u.height}o.image=a}else o.image.width=u.width,o.image.height=u.height,o.mipmaps=u.mipmaps;u.mipmapCount===1&&(o.minFilter=Rt),o.format=u.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}const Ya=new WeakMap;class Gl extends Oi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=Is.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)n.manager.itemStart(e),setTimeout(function(){t&&t(a),n.manager.itemEnd(e)},0);else{let d=Ya.get(a);d===void 0&&(d=[],Ya.set(a,d)),d.push({onLoad:t,onError:r})}return a}const o=gl("img");function l(){c(),t&&t(this);const d=Ya.get(this)||[];for(let u=0;u<d.length;u++){const p=d[u];p.onLoad&&p.onLoad(this)}Ya.delete(this),n.manager.itemEnd(e)}function h(d){c(),r&&r(d),Is.remove(`image:${e}`);const u=Ya.get(this)||[];for(let p=0;p<u.length;p++){const m=u[p];m.onError&&m.onError(d)}Ya.delete(this),n.manager.itemError(e),n.manager.itemEnd(e)}function c(){o.removeEventListener("load",l,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Is.add(`image:${e}`,o),n.manager.itemStart(e),o.src=e,o}}class NS extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=new ka;n.colorSpace=Ii;const a=new Gl(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(h){a.load(e[h],function(c){n.images[h]=c,o++,o===6&&(n.needsUpdate=!0,t&&t(n))},void 0,r)}for(let h=0;h<e.length;++h)l(h);return n}}class rx extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new os,o=new js(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(n.withCredentials),o.load(e,function(l){let h;try{h=n.parse(l)}catch(c){if(r!==void 0)r(c);else{c(c);return}}h.image!==void 0?a.image=h.image:h.data!==void 0&&(a.image.width=h.width,a.image.height=h.height,a.image.data=h.data),a.wrapS=h.wrapS!==void 0?h.wrapS:Ci,a.wrapT=h.wrapT!==void 0?h.wrapT:Ci,a.magFilter=h.magFilter!==void 0?h.magFilter:Rt,a.minFilter=h.minFilter!==void 0?h.minFilter:Rt,a.anisotropy=h.anisotropy!==void 0?h.anisotropy:1,h.colorSpace!==void 0&&(a.colorSpace=h.colorSpace),h.flipY!==void 0&&(a.flipY=h.flipY),h.format!==void 0&&(a.format=h.format),h.type!==void 0&&(a.type=h.type),h.mipmaps!==void 0&&(a.mipmaps=h.mipmaps,a.minFilter=Ss),h.mipmapCount===1&&(a.minFilter=Rt),h.generateMipmaps!==void 0&&(a.generateMipmaps=h.generateMipmaps),a.needsUpdate=!0,t&&t(a,h)},i,r),a}}class nx extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=new ei,a=new Gl(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){n.image=o,n.needsUpdate=!0,t!==void 0&&t(n)},i,r),n}}let Kr=class extends _t{constructor(s,e=1){super(),this.isLight=!0,this.type="Light",this.color=new we(s),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(s,e){return super.copy(s,e),this.color.copy(s.color),this.intensity=s.intensity,this}toJSON(s){const e=super.toJSON(s);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}},wm=class extends Kr{constructor(s,e,t){super(s,t),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new we(e)}copy(s,e){return super.copy(s,e),this.groundColor.copy(s.groundColor),this}toJSON(s){const e=super.toJSON(s);return e.object.groundColor=this.groundColor.getHex(),e}};const Em=new et,ax=new R,ox=new R;let Am=class{constructor(s){this.camera=s,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new te(512,512),this.mapType=Ri,this.map=null,this.mapPass=null,this.matrix=new et,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Pn,this._frameExtents=new te(1,1),this._viewportCount=1,this._viewports=[new It(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(s){const e=this.camera,t=this.matrix;ax.setFromMatrixPosition(s.matrixWorld),e.position.copy(ax),ox.setFromMatrixPosition(s.target.matrixWorld),e.lookAt(ox),e.updateMatrixWorld(),Em.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Em,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Sn||e.reversedDepth?t.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):t.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),t.multiply(Em)}getViewport(s){return this._viewports[s]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(s){return this.camera=s.camera.clone(),this.intensity=s.intensity,this.bias=s.bias,this.radius=s.radius,this.autoUpdate=s.autoUpdate,this.needsUpdate=s.needsUpdate,this.normalBias=s.normalBias,this.blurSamples=s.blurSamples,this.mapSize.copy(s.mapSize),this.biasNode=s.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const s={};return this.intensity!==1&&(s.intensity=this.intensity),this.bias!==0&&(s.bias=this.bias),this.normalBias!==0&&(s.normalBias=this.normalBias),this.radius!==1&&(s.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(s.mapSize=this.mapSize.toArray()),s.camera=this.camera.toJSON(!1).object,delete s.camera.matrix,s}};const pu=new R,mu=new Mi,Xs=new R;let Hl=class extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new et,this.projectionMatrix=new et,this.projectionMatrixInverse=new et,this.coordinateSystem=Yi,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(s,e){return super.copy(s,e),this.matrixWorldInverse.copy(s.matrixWorldInverse),this.projectionMatrix.copy(s.projectionMatrix),this.projectionMatrixInverse.copy(s.projectionMatrixInverse),this.coordinateSystem=s.coordinateSystem,this}getWorldDirection(s){return super.getWorldDirection(s).negate()}updateMatrixWorld(s){super.updateMatrixWorld(s),this.matrixWorld.decompose(pu,mu,Xs),Xs.x===1&&Xs.y===1&&Xs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pu,mu,Xs.set(1,1,1)).invert()}updateWorldMatrix(s,e){super.updateWorldMatrix(s,e),this.matrixWorld.decompose(pu,mu,Xs),Xs.x===1&&Xs.y===1&&Xs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pu,mu,Xs.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};const $r=new R,lx=new te,hx=new te;let li=class extends Hl{constructor(s=50,e=1,t=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=s,this.zoom=1,this.near=t,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(s,e){return super.copy(s,e),this.fov=s.fov,this.zoom=s.zoom,this.near=s.near,this.far=s.far,this.focus=s.focus,this.aspect=s.aspect,this.view=s.view===null?null:Object.assign({},s.view),this.filmGauge=s.filmGauge,this.filmOffset=s.filmOffset,this}setFocalLength(s){const e=.5*this.getFilmHeight()/s;this.fov=Sa*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const s=Math.tan(Tn*.5*this.fov);return .5*this.getFilmHeight()/s}getEffectiveFOV(){return Sa*2*Math.atan(Math.tan(Tn*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(s,e,t){$r.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set($r.x,$r.y).multiplyScalar(-s/$r.z),$r.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),t.set($r.x,$r.y).multiplyScalar(-s/$r.z)}getViewSize(s,e){return this.getViewBounds(s,lx,hx),e.subVectors(hx,lx)}setViewOffset(s,e,t,i,r,n){this.aspect=s/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=s,this.view.fullHeight=e,this.view.offsetX=t,this.view.offsetY=i,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const s=this.near;let e=s*Math.tan(Tn*.5*this.fov)/this.zoom,t=2*e,i=this.aspect*t,r=-.5*i;const n=this.view;if(this.view!==null&&this.view.enabled){const o=n.fullWidth,l=n.fullHeight;r+=n.offsetX*i/o,e-=n.offsetY*t/l,i*=n.width/o,t*=n.height/l}const a=this.filmOffset;a!==0&&(r+=s*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-t,s,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(s){const e=super.toJSON(s);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}},CS=class extends Am{constructor(){super(new li(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(s){const e=this.camera,t=Sa*2*s.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=s.distance||e.far;(t!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=t,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(s)}copy(s){return super.copy(s),this.focus=s.focus,this}},Nm=class extends Kr{constructor(s,e,t=0,i=Math.PI/3,r=0,n=2){super(s,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=t,this.angle=i,this.penumbra=r,this.decay=n,this.map=null,this.shadow=new CS}get power(){return this.intensity*Math.PI}set power(s){this.intensity=s/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(s,e){return super.copy(s,e),this.distance=s.distance,this.angle=s.angle,this.penumbra=s.penumbra,this.decay=s.decay,this.target=s.target.clone(),this.map=s.map,this.shadow=s.shadow.clone(),this}toJSON(s){const e=super.toJSON(s);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(s).uuid),e.object.shadow=this.shadow.toJSON(),e}},RS=class extends Am{constructor(){super(new li(90,1,.5,500)),this.isPointLightShadow=!0}},Cm=class extends Kr{constructor(s,e,t=0,i=2){super(s,e),this.isPointLight=!0,this.type="PointLight",this.distance=t,this.decay=i,this.shadow=new RS}get power(){return this.intensity*4*Math.PI}set power(s){this.intensity=s/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(s,e){return super.copy(s,e),this.distance=s.distance,this.decay=s.decay,this.shadow=s.shadow.clone(),this}toJSON(s){const e=super.toJSON(s);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}},Za=class extends Hl{constructor(s=-1,e=1,t=1,i=-1,r=.1,n=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=s,this.right=e,this.top=t,this.bottom=i,this.near=r,this.far=n,this.updateProjectionMatrix()}copy(s,e){return super.copy(s,e),this.left=s.left,this.right=s.right,this.top=s.top,this.bottom=s.bottom,this.near=s.near,this.far=s.far,this.zoom=s.zoom,this.view=s.view===null?null:Object.assign({},s.view),this}setViewOffset(s,e,t,i,r,n){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=s,this.view.fullHeight=e,this.view.offsetX=t,this.view.offsetY=i,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const s=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),t=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=t-s,n=t+s,a=i+e,o=i-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,n=r+l*this.view.width,a-=h*this.view.offsetY,o=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,n,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(s){const e=super.toJSON(s);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}},IS=class extends Am{constructor(){super(new Za(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Rm=class extends Kr{constructor(s,e){super(s,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new IS}dispose(){super.dispose(),this.shadow.dispose()}copy(s){return super.copy(s),this.target=s.target.clone(),this.shadow=s.shadow.clone(),this}toJSON(s){const e=super.toJSON(s);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}},Im=class extends Kr{constructor(s,e){super(s,e),this.isAmbientLight=!0,this.type="AmbientLight"}},cx=class extends Kr{constructor(s,e,t=10,i=10){super(s,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=t,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(s){this.intensity=s/(this.width*this.height*Math.PI)}copy(s){return super.copy(s),this.width=s.width,this.height=s.height,this}toJSON(s){const e=super.toJSON(s);return e.object.width=this.width,e.object.height=this.height,e}},Pm=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let s=0;s<9;s++)this.coefficients.push(new R)}set(s){for(let e=0;e<9;e++)this.coefficients[e].copy(s[e]);return this}zero(){for(let s=0;s<9;s++)this.coefficients[s].set(0,0,0);return this}getAt(s,e){const t=s.x,i=s.y,r=s.z,n=this.coefficients;return e.copy(n[0]).multiplyScalar(.282095),e.addScaledVector(n[1],.488603*i),e.addScaledVector(n[2],.488603*r),e.addScaledVector(n[3],.488603*t),e.addScaledVector(n[4],1.092548*(t*i)),e.addScaledVector(n[5],1.092548*(i*r)),e.addScaledVector(n[6],.315392*(3*r*r-1)),e.addScaledVector(n[7],1.092548*(t*r)),e.addScaledVector(n[8],.546274*(t*t-i*i)),e}getIrradianceAt(s,e){const t=s.x,i=s.y,r=s.z,n=this.coefficients;return e.copy(n[0]).multiplyScalar(.886227),e.addScaledVector(n[1],2*.511664*i),e.addScaledVector(n[2],2*.511664*r),e.addScaledVector(n[3],2*.511664*t),e.addScaledVector(n[4],2*.429043*t*i),e.addScaledVector(n[5],2*.429043*i*r),e.addScaledVector(n[6],.743125*r*r-.247708),e.addScaledVector(n[7],2*.429043*t*r),e.addScaledVector(n[8],.429043*(t*t-i*i)),e}add(s){for(let e=0;e<9;e++)this.coefficients[e].add(s.coefficients[e]);return this}addScaledSH(s,e){for(let t=0;t<9;t++)this.coefficients[t].addScaledVector(s.coefficients[t],e);return this}scale(s){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(s);return this}lerp(s,e){for(let t=0;t<9;t++)this.coefficients[t].lerp(s.coefficients[t],e);return this}equals(s){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(s.coefficients[e]))return!1;return!0}copy(s){return this.set(s.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(s,e=0){const t=this.coefficients;for(let i=0;i<9;i++)t[i].fromArray(s,e+i*3);return this}toArray(s=[],e=0){const t=this.coefficients;for(let i=0;i<9;i++)t[i].toArray(s,e+i*3);return s}static getBasisAt(s,e){const t=s.x,i=s.y,r=s.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*t,e[4]=1.092548*t*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*t*r,e[8]=.546274*(t*t-i*i)}},ux=class extends Kr{constructor(s=new Pm,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=s}copy(s){return super.copy(s),this.sh.copy(s.sh),this}toJSON(s){const e=super.toJSON(s);return e.object.sh=this.sh.toArray(),e}};class Gd extends Oi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const n=this,a=new js(n.manager);a.setPath(n.path),a.setRequestHeader(n.requestHeader),a.setWithCredentials(n.withCredentials),a.load(e,function(o){try{t(n.parse(JSON.parse(o)))}catch(l){r?r(l):Ve(l),n.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(n){return t[n]===void 0&&ge("MaterialLoader: Undefined texture",n),t[n]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new we().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(r.allowOverride=e.allowOverride),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const n in e.uniforms){const a=e.uniforms[n];switch(r.uniforms[n]={},a.type){case"t":r.uniforms[n].value=i(a.value);break;case"c":r.uniforms[n].value=new we().setHex(a.value);break;case"v2":r.uniforms[n].value=new te().fromArray(a.value);break;case"v3":r.uniforms[n].value=new R().fromArray(a.value);break;case"v4":r.uniforms[n].value=new It().fromArray(a.value);break;case"m3":r.uniforms[n].value=new at().fromArray(a.value);break;case"m4":r.uniforms[n].value=new et().fromArray(a.value);break;default:r.uniforms[n].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)r.extensions[n]=e.extensions[n];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),r.normalScale=new te().fromArray(n)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return Gd.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:mm,SpriteMaterial:Ec,RawShaderMaterial:lu,ShaderMaterial:$i,PointsMaterial:Jc,MeshPhysicalMaterial:gm,MeshStandardMaterial:hu,MeshPhongMaterial:ym,MeshToonMaterial:Zy,MeshNormalMaterial:xm,MeshLambertMaterial:vm,MeshDepthMaterial:cu,MeshDistanceMaterial:_m,MeshBasicMaterial:Mr,MeshMatcapMaterial:Jy,LineDashedMaterial:Ky,LineBasicMaterial:Ti,Material:pi};return new t[e]}}class fu{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Lm extends rt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class dx extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new js(n.manager);a.setPath(n.path),a.setRequestHeader(n.requestHeader),a.setWithCredentials(n.withCredentials),a.load(e,function(o){try{t(n.parse(JSON.parse(o)))}catch(l){r?r(l):Ve(l),n.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(u,p){if(t[p]!==void 0)return t[p];const m=u.interleavedBuffers[p],y=n(u,m.buffer),g=ba(m.type,y),f=new Al(g,m.stride);return f.uuid=m.uuid,t[p]=f,f}function n(u,p){if(i[p]!==void 0)return i[p];const m=u.arrayBuffers[p],y=new Uint32Array(m).buffer;return i[p]=y,y}const a=e.isInstancedBufferGeometry?new Lm:new rt,o=e.data.index;if(o!==void 0){const u=ba(o.type,o.array);a.setIndex(new bt(u,1))}const l=e.data.attributes;for(const u in l){const p=l[u];let m;if(p.isInterleavedBufferAttribute){const y=r(e.data,p.data);m=new Oa(y,p.itemSize,p.offset,p.normalized)}else{const y=ba(p.type,p.array),g=p.isInstancedBufferAttribute?Rn:bt;m=new g(y,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),a.setAttribute(u,m)}const h=e.data.morphAttributes;if(h)for(const u in h){const p=h[u],m=[];for(let y=0,g=p.length;y<g;y++){const f=p[y];let x;if(f.isInterleavedBufferAttribute){const v=r(e.data,f.data);x=new Oa(v,f.itemSize,f.offset,f.normalized)}else{const v=ba(f.type,f.array);x=new bt(v,f.itemSize,f.normalized)}f.name!==void 0&&(x.name=f.name),m.push(x)}a.morphAttributes[u]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const c=e.data.groups||e.data.drawcalls||e.data.offsets;if(c!==void 0)for(let u=0,p=c.length;u!==p;++u){const m=c[u];a.addGroup(m.start,m.count,m.materialIndex)}const d=e.data.boundingSphere;return d!==void 0&&(a.boundingSphere=new ai().fromJSON(d)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class PS extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=this.path===""?fu.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new js(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let h=null;try{h=JSON.parse(l)}catch(d){r!==void 0&&r(d),d("ObjectLoader: Can't parse "+e+".",d.message);return}const c=h.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),Ve("ObjectLoader: Can't load "+e);return}n.parse(h,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?fu.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const n=new js(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const a=await n.loadAsync(e,t);let o;try{o=JSON.parse(a)}catch(h){throw new Error("ObjectLoader: Can't parse "+e+". "+h.message)}const l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(h)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),h=this.parseObject(e.object,n,l,o,i),c=this.parseSkeletons(e.skeletons,h);if(this.bindSkeletons(h,c),this.bindLightTargets(h),t!==void 0){let d=!1;for(const u in a)if(a[u].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(h)}return h}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),n=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,n),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),h=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,h),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const n=new Zr().fromJSON(e[i]);t[n.uuid]=n}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(n){n.isBone&&(r[n.uuid]=n)}),e!==void 0)for(let n=0,a=e.length;n<a;n++){const o=new Ah().fromJSON(e[n],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new dx;for(let n=0,a=e.length;n<a;n++){let o;const l=e[n];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in qy?o=qy[l.type].fromJSON(l,t):ge(`ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const n=new Gd;n.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=n.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],n=qa.parse(r);t[n.uuid]=n}return t}parseImages(e,t){const i=this,r={};let n;function a(l){return i.manager.itemStart(l),n.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const h=l,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h)?h:i.resourcePath+h;return a(c)}else return l.data?{data:ba(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new du(t);n=new Gl(l),n.setCrossOrigin(this.crossOrigin);for(let h=0,c=e.length;h<c;h++){const d=e[h],u=d.url;if(Array.isArray(u)){const p=[];for(let m=0,y=u.length;m<y;m++){const g=u[m],f=o(g);f!==null&&(f instanceof HTMLImageElement?p.push(f):p.push(new os(f.data,f.width,f.height)))}r[d.uuid]=new pr(p)}else{const p=o(d.url);r[d.uuid]=new pr(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function n(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:ba(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Gl(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],h=l.url;if(Array.isArray(h)){const c=[];for(let d=0,u=h.length;d<u;d++){const p=h[d],m=await n(p);m!==null&&(m instanceof HTMLImageElement?c.push(m):c.push(new os(m.data,m.width,m.height)))}i[l.uuid]=new pr(c)}else{const c=await n(l.url);i[l.uuid]=new pr(c)}}}return i}parseTextures(e,t){function i(n,a){return typeof n=="number"?n:(ge("ObjectLoader.parseTexture: Constant should be in numeric form.",n),a[n])}const r={};if(e!==void 0)for(let n=0,a=e.length;n<a;n++){const o=e[n];o.image===void 0&&ge('ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&ge("ObjectLoader: Undefined image",o.image);const l=t[o.image],h=l.data;let c;Array.isArray(h)?(c=new ka,h.length===6&&(c.needsUpdate=!0)):(h&&h.data?c=new os:c=new ei,h&&(c.needsUpdate=!0)),c.source=l,c.uuid=o.uuid,o.name!==void 0&&(c.name=o.name),o.mapping!==void 0&&(c.mapping=i(o.mapping,LS)),o.channel!==void 0&&(c.channel=o.channel),o.offset!==void 0&&c.offset.fromArray(o.offset),o.repeat!==void 0&&c.repeat.fromArray(o.repeat),o.center!==void 0&&c.center.fromArray(o.center),o.rotation!==void 0&&(c.rotation=o.rotation),o.wrap!==void 0&&(c.wrapS=i(o.wrap[0],px),c.wrapT=i(o.wrap[1],px)),o.format!==void 0&&(c.format=o.format),o.internalFormat!==void 0&&(c.internalFormat=o.internalFormat),o.type!==void 0&&(c.type=o.type),o.colorSpace!==void 0&&(c.colorSpace=o.colorSpace),o.minFilter!==void 0&&(c.minFilter=i(o.minFilter,mx)),o.magFilter!==void 0&&(c.magFilter=i(o.magFilter,mx)),o.anisotropy!==void 0&&(c.anisotropy=o.anisotropy),o.flipY!==void 0&&(c.flipY=o.flipY),o.generateMipmaps!==void 0&&(c.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(c.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(c.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(c.compareFunction=o.compareFunction),o.userData!==void 0&&(c.userData=o.userData),r[o.uuid]=c}return r}parseObject(e,t,i,r,n){let a;function o(u){return t[u]===void 0&&ge("ObjectLoader: Undefined geometry",u),t[u]}function l(u){if(u!==void 0){if(Array.isArray(u)){const p=[];for(let m=0,y=u.length;m<y;m++){const g=u[m];i[g]===void 0&&ge("ObjectLoader: Undefined material",g),p.push(i[g])}return p}return i[u]===void 0&&ge("ObjectLoader: Undefined material",u),i[u]}}function h(u){return r[u]===void 0&&ge("ObjectLoader: Undefined texture",u),r[u]}let c,d;switch(e.type){case"Scene":a=new _p,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new we(e.background):a.background=h(e.background)),e.environment!==void 0&&(a.environment=h(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new vp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Id(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new li(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Za(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new Im(e.color,e.intensity);break;case"DirectionalLight":a=new Rm(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Cm(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new cx(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Nm(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new wm(e.color,e.groundColor,e.intensity);break;case"LightProbe":const u=new Pm().fromArray(e.sh);a=new ux(u,e.intensity);break;case"SkinnedMesh":c=o(e.geometry),d=l(e.material),a=new kp(c,d),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":c=o(e.geometry),d=l(e.material),a=new Xt(c,d);break;case"InstancedMesh":c=o(e.geometry),d=l(e.material);const p=e.count,m=e.instanceMatrix,y=e.instanceColor;a=new Gp(c,d,p),a.instanceMatrix=new Rn(new Float32Array(m.array),16),y!==void 0&&(a.instanceColor=new Rn(new Float32Array(y.array),y.itemSize));break;case"BatchedMesh":c=o(e.geometry),d=l(e.material),a=new Xp(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,d),a.geometry=c,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(g=>{let f=null,x=null;return g.boundingBox!==void 0&&(f=new di().fromJSON(g.boundingBox)),g.boundingSphere!==void 0&&(x=new ai().fromJSON(g.boundingSphere)),{...g,boundingBox:f,boundingSphere:x}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=h(e.matricesTexture.uuid),a._indirectTexture=h(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=h(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new ai().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new di().fromJSON(e.boundingBox));break;case"LOD":a=new Dp;break;case"Line":a=new Sr(o(e.geometry),l(e.material));break;case"LineLoop":a=new Yp(o(e.geometry),l(e.material));break;case"LineSegments":a=new Rs(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new Jp(o(e.geometry),l(e.material));break;case"Sprite":a=new Lp(l(e.material));break;case"Group":a=new wn;break;case"Bone":a=new kc;break;default:a=new _t}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.pivot!==void 0&&(a.pivot=new R().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const u=e.children;for(let p=0;p<u.length;p++)a.add(this.parseObject(u[p],t,i,r,n))}if(e.animations!==void 0){const u=e.animations;for(let p=0;p<u.length;p++){const m=u[p];a.animations.push(n[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const u=e.levels;for(let p=0;p<u.length;p++){const m=u[p],y=a.getObjectByProperty("uuid",m.object);y!==void 0&&a.addLevel(y,m.distance,m.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?ge("ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new _t}})}}const LS={UVMapping:Gh,CubeReflectionMapping:ks,CubeRefractionMapping:zr,EquirectangularReflectionMapping:ua,EquirectangularRefractionMapping:da,CubeUVReflectionMapping:xn},px={RepeatWrapping:pa,ClampToEdgeWrapping:Ci,MirroredRepeatWrapping:ma},mx={NearestFilter:Ht,NearestMipmapNearestFilter:Hh,NearestMipmapLinearFilter:vn,LinearFilter:Rt,LinearMipmapNearestFilter:fa,LinearMipmapLinearFilter:Ss},Dm=new WeakMap;class fx extends Oi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&ge("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&ge("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=Is.get(`image-bitmap:${e}`);if(a!==void 0){if(n.manager.itemStart(e),a.then){a.then(h=>{if(Dm.has(a)===!0)r&&r(Dm.get(a)),n.manager.itemError(e),n.manager.itemEnd(e);else return t&&t(h),n.manager.itemEnd(e),h});return}return setTimeout(function(){t&&t(a),n.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(h){return Is.add(`image-bitmap:${e}`,h),t&&t(h),n.manager.itemEnd(e),h}).catch(function(h){r&&r(h),Dm.set(l,h),Is.remove(`image-bitmap:${e}`),n.manager.itemError(e),n.manager.itemEnd(e)});Is.add(`image-bitmap:${e}`,l),n.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let gu;class yu{static getContext(){return gu===void 0&&(gu=new(window.AudioContext||window.webkitAudioContext)),gu}static setContext(e){gu=e}}class gx extends Oi{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new js(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const h=l.slice(0);yu.getContext().decodeAudioData(h,function(c){t(c)}).catch(o)}catch(h){o(h)}},i,r);function o(l){r?r(l):Ve(l),n.manager.itemError(e)}}}const yx=new et,xx=new et,Vn=new et;class DS{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new li,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new li,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Vn.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,n=t.near*Math.tan(Tn*t.fov*.5)/t.zoom;let a,o;xx.elements[12]=-i,yx.elements[12]=i,a=-n*t.aspect+r,o=n*t.aspect+r,Vn.elements[0]=2*t.near/(o-a),Vn.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Vn),a=-n*t.aspect-r,o=n*t.aspect-r,Vn.elements[0]=2*t.near/(o-a),Vn.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Vn)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(xx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(yx)}}const Ja=-90,Ka=1;class Om extends _t{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new li(Ja,Ka,e,t);r.layers=this.layers,this.add(r);const n=new li(Ja,Ka,e,t);n.layers=this.layers,this.add(n);const a=new li(Ja,Ka,e,t);a.layers=this.layers,this.add(a);const o=new li(Ja,Ka,e,t);o.layers=this.layers,this.add(o);const l=new li(Ja,Ka,e,t);l.layers=this.layers,this.add(l);const h=new li(Ja,Ka,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,n,a,o,l]=t;for(const h of t)this.remove(h);if(e===Yi)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),n.up.set(0,0,-1),n.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Sn)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),n.up.set(0,0,1),n.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.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: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[n,a,o,l,h,c]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,n),e.setRenderTarget(i,1,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(d,u,p),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}}class Um extends li{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Fm{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(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=OS.bind(this),e.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(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function OS(){this._document.hidden===!1&&this.reset()}const qs=new R,zm=new Mi,US=new R,kn=new R,Gn=new R;let vx=class extends _t{constructor(){super(),this.type="AudioListener",this.context=yu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new Fm}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(s){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=s,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(s){return this.gain.gain.setTargetAtTime(s,this.context.currentTime,.01),this}updateMatrixWorld(s){super.updateMatrixWorld(s),this._timer.update();const e=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(qs,zm,US),!(!Number.isFinite(qs.x)||!Number.isFinite(qs.y)||!Number.isFinite(qs.z)))if(kn.set(0,0,-1).applyQuaternion(zm),Gn.set(0,1,0).applyQuaternion(zm),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(qs.x,t),e.positionY.linearRampToValueAtTime(qs.y,t),e.positionZ.linearRampToValueAtTime(qs.z,t),e.forwardX.linearRampToValueAtTime(kn.x,t),e.forwardY.linearRampToValueAtTime(kn.y,t),e.forwardZ.linearRampToValueAtTime(kn.z,t),e.upX.linearRampToValueAtTime(Gn.x,t),e.upY.linearRampToValueAtTime(Gn.y,t),e.upZ.linearRampToValueAtTime(Gn.z,t)}else e.setPosition(qs.x,qs.y,qs.z),e.setOrientation(kn.x,kn.y,kn.z,Gn.x,Gn.y,Gn.z)}};class Bm extends _t{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){ge("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){ge("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){ge("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(e=0){if(this.hasPlaybackControl===!1){ge("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,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(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){ge("Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(ge("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){ge("Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(ge("Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const Hn=new R,_x=new Mi,FS=new R,Wn=new R;class Mx extends Bm{constructor(e){super(e),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(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Hn,_x,FS),Wn.set(0,0,1).applyQuaternion(_x);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Hn.x,i),t.positionY.linearRampToValueAtTime(Hn.y,i),t.positionZ.linearRampToValueAtTime(Hn.z,i),t.orientationX.linearRampToValueAtTime(Wn.x,i),t.orientationY.linearRampToValueAtTime(Wn.y,i),t.orientationZ.linearRampToValueAtTime(Wn.z,i)}else t.setPosition(Hn.x,Hn.y,Hn.z),t.setOrientation(Wn.x,Wn.y,Wn.z)}}class zS{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class bx{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,n,a;switch(t){case"quaternion":r=this._slerp,n=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,n=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,n=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=n,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,n=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[n+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,n,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,n=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,n<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-n,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,h=t+t;l!==h;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let n=i,a=r;n!==a;++n)t[n]=t[r+n%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,n){if(r>=.5)for(let a=0;a!==n;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){Mi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,n){const a=this._workIndex*n;Mi.multiplyQuaternionsFlat(e,a,e,t,e,i),Mi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,n){const a=1-r;for(let o=0;o!==n;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,n){for(let a=0;a!==n;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const Vm="\\[\\]\\.:\\/",BS=new RegExp("["+Vm+"]","g"),km="[^"+Vm+"]",VS="[^"+Vm.replace("\\.","")+"]",kS=/((?:WC+[\/:])*)/.source.replace("WC",km),GS=/(WCOD+)?/.source.replace("WCOD",VS),HS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",km),WS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",km),jS=new RegExp("^"+kS+GS+HS+WS+"$"),XS=["material","materials","bones","map"];class qS{constructor(e,t,i){const r=i||gt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class gt{constructor(e,t,i){this.path=t,this.parsedPath=i||gt.parseTrackName(t),this.node=gt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new gt.Composite(e,t,i):new gt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(BS,"")}static parseTrackName(e){const t=jS.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const n=i.nodeName.substring(r+1);XS.indexOf(n)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=n)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(n,a){for(let o=0;o<n.length;o++){const l=n[o];if(!a&&(l.name===t||l.uuid===t)||a&&l.userData&&l.userData.name===t)return l;const h=i(l.children,a);if(h)return h}return null},r=i(e.children);if(r)return r;{const n=i(e.children,!0);if(n)return n}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let n=t.propertyIndex;if(e||(e=gt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){ge("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let h=t.objectIndex;switch(i){case"materials":if(!e.material){Ve("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ve("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ve("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===h){h=c;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ve("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ve("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Ve("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(h!==void 0){if(e[h]===void 0){Ve("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}const a=e[r];if(a===void 0){const h=t.nodeName;Ve("PropertyBinding: Trying to update property for track: "+h+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(n!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){Ve("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ve("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[n]!==void 0&&(n=e.morphTargetDictionary[n])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=n}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}gt.Composite=qS,gt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},gt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},gt.prototype.GetterByBindingType=[gt.prototype._getValue_direct,gt.prototype._getValue_array,gt.prototype._getValue_arrayElement,gt.prototype._getValue_toArray],gt.prototype.SetterByBindingTypeAndVersioning=[[gt.prototype._setValue_direct,gt.prototype._setValue_direct_setNeedsUpdate,gt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_array,gt.prototype._setValue_array_setNeedsUpdate,gt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_arrayElement,gt.prototype._setValue_arrayElement_setNeedsUpdate,gt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[gt.prototype._setValue_fromArray,gt.prototype._setValue_fromArray_setNeedsUpdate,gt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class YS{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Zi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,n=this._bindings,a=n.length;let o,l=e.length,h=this.nCachedObjects_;for(let c=0,d=arguments.length;c!==d;++c){const u=arguments[c],p=u.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(u);for(let y=0,g=a;y!==g;++y)n[y].push(new gt(u,i[y],r[y]))}else if(m<h){o=e[m];const y=--h,g=e[y];t[g.uuid]=m,e[m]=g,t[p]=y,e[y]=u;for(let f=0,x=a;f!==x;++f){const v=n[f],M=v[y];let w=v[m];v[m]=M,w===void 0&&(w=new gt(u,i[f],r[f])),v[y]=w}}else e[m]!==o&&Ve("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let n=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],h=l.uuid,c=t[h];if(c!==void 0&&c>=n){const d=n++,u=e[d];t[u.uuid]=c,e[c]=u,t[h]=d,e[d]=l;for(let p=0,m=r;p!==m;++p){const y=i[p],g=y[d],f=y[c];y[c]=g,y[d]=f}}}this.nCachedObjects_=n}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let n=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const h=arguments[o],c=h.uuid,d=t[c];if(d!==void 0)if(delete t[c],d<n){const u=--n,p=e[u],m=--a,y=e[m];t[p.uuid]=d,e[d]=p,t[y.uuid]=u,e[u]=y,e.pop();for(let g=0,f=r;g!==f;++g){const x=i[g],v=x[u],M=x[m];x[d]=v,x[u]=M,x.pop()}}else{const u=--a,p=e[u];u>0&&(t[p.uuid]=d),e[d]=p,e.pop();for(let m=0,y=r;m!==y;++m){const g=i[m];g[d]=g[u],g.pop()}}}this.nCachedObjects_=n}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const n=this._bindings;if(r!==void 0)return n[r];const a=this._paths,o=this._parsedPaths,l=this._objects,h=l.length,c=this.nCachedObjects_,d=new Array(h);r=n.length,i[e]=r,a.push(e),o.push(t),n.push(d);for(let u=c,p=l.length;u!==p;++u){const m=l[u];d[u]=new gt(m,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,n=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],h=e[o];t[h]=i,a[i]=l,a.pop(),n[i]=n[o],n.pop(),r[i]=r[o],r.pop()}}}class Sx{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const n=t.tracks,a=n.length,o=new Array(a),l={endingStart:Mn,endingEnd:Mn};for(let h=0;h!==a;++h){const c=n[h].createInterpolant(null);o[h]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ap,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const r=this._clip.duration,n=e._clip.duration,a=n/r,o=r/n;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,n=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,h=o.sampleValues;return l[0]=n,l[1]=n+i,h[0]=e/a,h[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const n=this._startTime;if(n!==null){const l=(e-n)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case lp:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(a),h[c].accumulateAdditive(o);break;case uc:default:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(a),h[c].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,n=this._loopCount;const a=i===f0;if(e===0)return n===-1?r:a&&(n&1)===1?t-r:r;if(i===np){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(n===-1&&(e>=0?(n=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,n+=Math.abs(o);const l=this.repetitions-n;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const h=e<0;this._setEndings(h,!h,a)}else this._setEndings(!1,!1,a);this._loopCount=n,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(n&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=bn,r.endingEnd=bn):(e?r.endingStart=this.zeroSlopeAtStart?bn:Mn:r.endingStart=pl,t?r.endingEnd=this.zeroSlopeAtEnd?bn:Mn:r.endingEnd=pl)}_scheduleFading(e,t,i){const r=this._mixer,n=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=n,l[0]=t,o[1]=n+e,l[1]=i,this}}const ZS=new Float32Array(1);class Tx extends Es{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,n=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,h=this._bindingsByRootAndName;let c=h[l];c===void 0&&(c={},h[l]=c);for(let d=0;d!==n;++d){const u=r[d],p=u.name;let m=c[p];if(m!==void 0)++m.referenceCount,a[d]=m;else{if(m=a[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const y=t&&t._propertyBindings[d].binding.parsedPath;m=new bx(gt.create(i,p,y),u.ValueTypeName,u.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[d]=m}o[d].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,n=this._actionsByClip[r];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const n=t[i];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const n=t[i];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,n=this._actionsByClip;let a=n[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const n=e._clip.uuid,a=this._actionsByClip,o=a[n],l=o.knownActions,h=l[l.length-1],c=e._byClipCacheIndex;h._byClipCacheIndex=c,l[c]=h,l.pop(),e._byClipCacheIndex=null;const d=o.actionByRoot,u=(e._localRoot||this._root).uuid;delete d[u],l.length===0&&delete a[n],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const n=t[i];--n.referenceCount===0&&this._removeInactiveBinding(n)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,n=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=n.length,n.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,n=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],h=e._cacheIndex;l._cacheIndex=h,t[h]=l,t.pop(),delete o[n],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Sm(new Float32Array(2),new Float32Array(2),1,ZS),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,n=t[r];e.__cacheIndex=r,t[r]=e,n.__cacheIndex=i,t[i]=n}clipAction(e,t,i){const r=t||this._root,n=r.uuid;let a=typeof e=="string"?qa.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let h=null;if(i===void 0&&(a!==null?i=a.blendMode:i=uc),l!==void 0){const d=l.actionByRoot[n];if(d!==void 0&&d.blendMode===i)return d;h=l.knownActions[0],a===null&&(a=h._clip)}if(a===null)return null;const c=new Sx(this,a,t,i);return this._bindAction(c,h),this._addInactiveAction(c,o,n),c}existingAction(e,t){const i=t||this._root,r=i.uuid,n=typeof e=="string"?qa.findByName(i,e):e,a=n?n.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,n=Math.sign(e),a=this._accuIndex^=1;for(let h=0;h!==i;++h)t[h]._update(r,e,n,a);const o=this._bindings,l=this._nActiveBindings;for(let h=0;h!==l;++h)o[h].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,n=r[i];if(n!==void 0){const a=n.knownActions;for(let o=0,l=a.length;o!==l;++o){const h=a[o];this._deactivateAction(h);const c=h._cacheIndex,d=t[t.length-1];h._cacheIndex=null,h._byClipCacheIndex=null,d._cacheIndex=c,t[c]=d,t.pop(),this._removeInactiveBindingsForAction(h)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,n=r[t];if(n!==void 0)for(const a in n){const o=n[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class JS extends gp{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=i,this.texture=new _l(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class Hd{constructor(e){this.value=e}clone(){return new Hd(this.value.clone===void 0?this.value:this.value.clone())}}let KS=0;class $S extends Es{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:KS++}),this.name="",this.usage=fl,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const n=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<n.length;a++)this.uniforms.push(n[a].clone())}return this}clone(){return new this.constructor().copy(this)}}let wx=class extends Al{constructor(s,e,t=1){super(s,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=t}copy(s){return super.copy(s),this.meshPerAttribute=s.meshPerAttribute,this}clone(s){const e=super.clone(s);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(s){const e=super.toJSON(s);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}};class QS{constructor(e,t,i,r,n,a=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=n,this.normalized=a,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const Ex=new et;class Ax{constructor(e,t,i=0,r=1/0){this.ray=new Nn(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Ml,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Ve("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Ex.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ex),this}intersectObject(e,t=!0,i=[]){return Gm(e,this,i,t),i.sort(Nx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,n=e.length;r<n;r++)Gm(e[r],this,i,t);return i.sort(Nx),i}}function Nx(s,e){return s.distance-e.distance}function Gm(s,e,t,i){let r=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const n=s.children;for(let a=0,o=n.length;a<o;a++)Gm(n[a],e,t,!0)}}class eT{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,ge("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 e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}class Cx{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ke(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Ke(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class tT{constructor(e=1,t=0,i=0){this.radius=e,this.theta=t,this.y=i}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}let iT=class nM{constructor(e,t,i,r){nM.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const n=this.elements;return n[0]=e,n[2]=t,n[1]=i,n[3]=r,this}};const Rx=new te;class sT{constructor(e=new te(1/0,1/0),t=new te(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Rx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Rx).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ix=new R,xu=new R,$a=new R,Qa=new R,Hm=new R,rT=new R,nT=new R;class Px{constructor(e=new R,t=new R){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Ix.subVectors(e,this.start),xu.subVectors(this.end,this.start);const i=xu.dot(xu);let r=xu.dot(Ix)/i;return t&&(r=Ke(r,0,1)),r}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=rT,i=nT){const r=10000000000000001e-32;let n,a;const o=this.start,l=e.start,h=this.end,c=e.end;$a.subVectors(h,o),Qa.subVectors(c,l),Hm.subVectors(o,l);const d=$a.dot($a),u=Qa.dot(Qa),p=Qa.dot(Hm);if(d<=r&&u<=r)return t.copy(o),i.copy(l),t.sub(i),t.dot(t);if(d<=r)n=0,a=p/u,a=Ke(a,0,1);else{const m=$a.dot(Hm);if(u<=r)a=0,n=Ke(-m/d,0,1);else{const y=$a.dot(Qa),g=d*u-y*y;g!==0?n=Ke((y*p-m*u)/g,0,1):n=0,a=(y*n+p)/u,a<0?(a=0,n=Ke(-m/d,0,1)):a>1&&(a=1,n=Ke((y-m)/d,0,1))}}return t.copy(o).addScaledVector($a,n),i.copy(l).addScaledVector(Qa,a),t.distanceToSquared(i)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Lx=new R;class aT extends _t{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new rt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const h=a/l*Math.PI*2,c=o/l*Math.PI*2;r.push(Math.cos(h),Math.sin(h),1,Math.cos(c),Math.sin(c),1)}i.setAttribute("position",new Ne(r,3));const n=new Ti({fog:!1,toneMapped:!1});this.cone=new Rs(i,n),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 e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Lx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Lx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Qr=new R,vu=new et,Wm=new et;class oT extends Rs{constructor(e){const t=Dx(e),i=new rt,r=[],n=[];for(let h=0;h<t.length;h++){const c=t[h];c.parent&&c.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),n.push(0,0,0),n.push(0,0,0))}i.setAttribute("position",new Ne(r,3)),i.setAttribute("color",new Ne(n,3));const a=new Ti({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,a),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const o=new we(255),l=new we(65280);this.setColors(o,l)}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");Wm.copy(this.root.matrixWorld).invert();for(let n=0,a=0;n<t.length;n++){const o=t[n];o.parent&&o.parent.isBone&&(vu.multiplyMatrices(Wm,o.matrixWorld),Qr.setFromMatrixPosition(vu),r.setXYZ(a,Qr.x,Qr.y,Qr.z),vu.multiplyMatrices(Wm,o.parent.matrixWorld),Qr.setFromMatrixPosition(vu),r.setXYZ(a+1,Qr.x,Qr.y,Qr.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const i=this.geometry.getAttribute("color");for(let r=0;r<i.count;r+=2)i.setXYZ(r,e.r,e.g,e.b),i.setXYZ(r+1,t.r,t.g,t.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function Dx(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push(...Dx(s.children[t]));return e}class lT extends Xt{constructor(e,t,i){const r=new Lo(t,4,2),n=new Mr({wireframe:!0,fog:!1,toneMapped:!1});super(r,n),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const hT=new R,Ox=new we,Ux=new we;class cT extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new Po(t);r.rotateY(Math.PI*.5),this.material=new Mr({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const n=r.getAttribute("position"),a=new Float32Array(n.count*3);r.setAttribute("color",new bt(a,3)),this.add(new Xt(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Ox.copy(this.light.color),Ux.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const n=i<r/2?Ox:Ux;t.setXYZ(i,n.r,n.g,n.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(hT.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Fx=class extends Rs{constructor(s=10,e=10,t=4473924,i=8947848){t=new we(t),i=new we(i);const r=e/2,n=s/e,a=s/2,o=[],l=[];for(let d=0,u=0,p=-a;d<=e;d++,p+=n){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=d===r?t:i;m.toArray(l,u),u+=3,m.toArray(l,u),u+=3,m.toArray(l,u),u+=3,m.toArray(l,u),u+=3}const h=new rt;h.setAttribute("position",new Ne(o,3)),h.setAttribute("color",new Ne(l,3));const c=new Ti({vertexColors:!0,toneMapped:!1});super(h,c),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class uT extends Rs{constructor(e=10,t=16,i=8,r=64,n=4473924,a=8947848){n=new we(n),a=new we(a);const o=[],l=[];if(t>1)for(let d=0;d<t;d++){const u=d/t*(Math.PI*2),p=Math.sin(u)*e,m=Math.cos(u)*e;o.push(0,0,0),o.push(p,0,m);const y=d&1?n:a;l.push(y.r,y.g,y.b),l.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){const u=d&1?n:a,p=e-e/i*d;for(let m=0;m<r;m++){let y=m/r*(Math.PI*2),g=Math.sin(y)*p,f=Math.cos(y)*p;o.push(g,0,f),l.push(u.r,u.g,u.b),y=(m+1)/r*(Math.PI*2),g=Math.sin(y)*p,f=Math.cos(y)*p,o.push(g,0,f),l.push(u.r,u.g,u.b)}}const h=new rt;h.setAttribute("position",new Ne(o,3)),h.setAttribute("color",new Ne(l,3));const c=new Ti({vertexColors:!0,toneMapped:!1});super(h,c),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const zx=new R,_u=new R,Bx=new R;class Vx extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new rt;r.setAttribute("position",new Ne([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const n=new Ti({fog:!1,toneMapped:!1});this.lightPlane=new Sr(r,n),this.add(this.lightPlane),r=new rt,r.setAttribute("position",new Ne([0,0,0,0,0,1],3)),this.targetLine=new Sr(r,n),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),zx.setFromMatrixPosition(this.light.matrixWorld),_u.setFromMatrixPosition(this.light.target.matrixWorld),Bx.subVectors(_u,zx),this.lightPlane.lookAt(_u),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(_u),this.targetLine.scale.z=Bx.length()}}const Mu=new R,Wt=new Hl;class kx extends Rs{constructor(e){const t=new rt,i=new Ti({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],n=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(m,y){l(m),l(y)}function l(m){r.push(0,0,0),n.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new Ne(r,3)),t.setAttribute("color",new Ne(n,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const h=new we(16755200),c=new we(16711680),d=new we(43775),u=new we(16777215),p=new we(3355443);this.setColors(h,c,d,u,p)}setColors(e,t,i,r,n){const a=this.geometry.getAttribute("color");return a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,n.r,n.g,n.b),a.setXYZ(41,n.r,n.g,n.b),a.setXYZ(42,n.r,n.g,n.b),a.setXYZ(43,n.r,n.g,n.b),a.setXYZ(44,n.r,n.g,n.b),a.setXYZ(45,n.r,n.g,n.b),a.setXYZ(46,n.r,n.g,n.b),a.setXYZ(47,n.r,n.g,n.b),a.setXYZ(48,n.r,n.g,n.b),a.setXYZ(49,n.r,n.g,n.b),a.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;let n,a;if(Wt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)n=1,a=0;else if(this.camera.coordinateSystem===Yi)n=-1,a=1;else if(this.camera.coordinateSystem===Sn)n=0,a=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);qt("c",t,e,Wt,0,0,n),qt("t",t,e,Wt,0,0,a),qt("n1",t,e,Wt,-i,-r,n),qt("n2",t,e,Wt,i,-r,n),qt("n3",t,e,Wt,-i,r,n),qt("n4",t,e,Wt,i,r,n),qt("f1",t,e,Wt,-i,-r,a),qt("f2",t,e,Wt,i,-r,a),qt("f3",t,e,Wt,-i,r,a),qt("f4",t,e,Wt,i,r,a),qt("u1",t,e,Wt,i*.7,r*1.1,n),qt("u2",t,e,Wt,-i*.7,r*1.1,n),qt("u3",t,e,Wt,0,r*2,n),qt("cf1",t,e,Wt,-i,0,a),qt("cf2",t,e,Wt,i,0,a),qt("cf3",t,e,Wt,0,-r,a),qt("cf4",t,e,Wt,0,r,a),qt("cn1",t,e,Wt,-i,0,n),qt("cn2",t,e,Wt,i,0,n),qt("cn3",t,e,Wt,0,-r,n),qt("cn4",t,e,Wt,0,r,n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function qt(s,e,t,i,r,n,a){Mu.set(r,n,a).unproject(i);const o=e[s];if(o!==void 0){const l=t.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],Mu.x,Mu.y,Mu.z)}}const bu=new di;class Gx extends Rs{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),n=new rt;n.setIndex(new bt(i,1)),n.setAttribute("position",new bt(r,3)),super(n,new Ti({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&bu.setFromObject(this.object),bu.isEmpty())return;const e=bu.min,t=bu.max,i=this.geometry.attributes.position,r=i.array;r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Hx extends Rs{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],n=new rt;n.setIndex(new bt(i,1)),n.setAttribute("position",new Ne(r,3)),super(n,new Ti({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class dT extends Sr{constructor(e,t=1,i=16776960){const r=i,n=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new rt;a.setAttribute("position",new Ne(n,3)),a.computeBoundingSphere(),super(a,new Ti({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new rt;l.setAttribute("position",new Ne(o,3)),l.computeBoundingSphere(),this.add(new Xt(l,new Mr({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Wx=new R;let Su,jm;class pT extends _t{constructor(e=new R(0,0,1),t=new R(0,0,0),i=1,r=16776960,n=i*.2,a=n*.2){super(),this.type="ArrowHelper",Su===void 0&&(Su=new rt,Su.setAttribute("position",new Ne([0,0,0,0,1,0],3)),jm=new Nh(.5,1,5,1),jm.translate(0,-.5,0)),this.position.copy(t),this.line=new Sr(Su,new Ti({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Xt(jm,new Mr({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,n,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Wx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Wx,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let jx=class extends Rs{constructor(s=1){const e=[0,0,0,s,0,0,0,0,0,0,s,0,0,0,0,0,0,s],t=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new rt;i.setAttribute("position",new Ne(e,3)),i.setAttribute("color",new Ne(t,3));const r=new Ti({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(s,e,t){const i=new we,r=this.geometry.attributes.color.array;return i.set(s),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(t),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class Xx{constructor(){this.type="ShapePath",this.color=new we,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new nu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,a){return this.currentPath.bezierCurveTo(e,t,i,r,n,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(f){const x=[];for(let v=0,M=f.length;v<M;v++){const w=f[v],T=new Zr;T.curves=w.curves,x.push(T)}return x}function i(f,x){const v=x.length;let M=!1;for(let w=v-1,T=0;T<v;w=T++){let A=x[w],_=x[T],S=_.x-A.x,P=_.y-A.y;if(Math.abs(P)>Number.EPSILON){if(P<0&&(A=x[T],S=-S,_=x[w],P=-P),f.y<A.y||f.y>_.y)continue;if(f.y===A.y){if(f.x===A.x)return!0}else{const C=P*(f.x-A.x)-S*(f.y-A.y);if(C===0)return!0;if(C<0)continue;M=!M}}else{if(f.y!==A.y)continue;if(_.x<=f.x&&f.x<=A.x||A.x<=f.x&&f.x<=_.x)return!0}}return M}const r=ys.isClockWise,n=this.subPaths;if(n.length===0)return[];let a,o,l;const h=[];if(n.length===1)return o=n[0],l=new Zr,l.curves=o.curves,h.push(l),h;let c=!r(n[0].getPoints());c=e?!c:c;const d=[],u=[];let p=[],m=0,y;u[m]=void 0,p[m]=[];for(let f=0,x=n.length;f<x;f++)o=n[f],y=o.getPoints(),a=r(y),a=e?!a:a,a?(!c&&u[m]&&m++,u[m]={s:new Zr,p:y},u[m].s.curves=o.curves,c&&m++,p[m]=[]):p[m].push({h:o,p:y[0]});if(!u[0])return t(n);if(u.length>1){let f=!1,x=0;for(let v=0,M=u.length;v<M;v++)d[v]=[];for(let v=0,M=u.length;v<M;v++){const w=p[v];for(let T=0;T<w.length;T++){const A=w[T];let _=!0;for(let S=0;S<u.length;S++)i(A.p,u[S].p)&&(v!==S&&x++,_?(_=!1,d[S].push(A)):f=!0);_&&d[v].push(A)}}x>0&&f===!1&&(p=d)}let g;for(let f=0,x=u.length;f<x;f++){l=u[f].s,h.push(l),g=p[f];for(let v=0,M=g.length;v<M;v++)l.holes.push(g[v].h)}return h}}class qx extends Es{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){ge("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function mT(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function fT(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function gT(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function Xm(s,e,t,i){const r=yT(i);switch(t){case rp:return s*e;case Wo:return s*e/r.components*r.byteLength;case ya:return s*e/r.components*r.byteLength;case Br:return s*e*2/r.components*r.byteLength;case jo:return s*e*2/r.components*r.byteLength;case Zh:return s*e*3/r.components*r.byteLength;case vi:return s*e*4/r.components*r.byteLength;case Xo:return s*e*4/r.components*r.byteLength;case xa:case va:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case qo:case _a:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Jh:case Jo:return Math.max(s,16)*Math.max(e,8)/4;case Yo:case Zo:return Math.max(s,8)*Math.max(e,8)/2;case Ko:case $o:case el:case tl:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Qo:case il:case sl:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case rl:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Kh:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case $h:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Qh:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case nl:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case ec:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case tc:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case ic:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case sc:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case rc:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case nc:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case ac:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case oc:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case lc:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case al:case hc:case ol:return Math.ceil(s/4)*Math.ceil(e/4)*16;case ll:case hl:return Math.ceil(s/4)*Math.ceil(e/4)*8;case cl:case ul:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function yT(s){switch(s){case Ri:case ip:return{byteLength:1,components:1};case ga:case sp:case Ts:return{byteLength:2,components:1};case jh:case Xh:return{byteLength:2,components:4};case qi:case Wh:case xi:return{byteLength:4,components:1};case qh:case Yh:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}class xT{static contain(e,t){return mT(e,t)}static cover(e,t){return fT(e,t)}static fill(e){return gT(e)}static getByteLength(e,t,i,r){return Xm(e,t,i,r)}}if(typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:yn}})),typeof window<"u"){try{import.meta&&(window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:import.meta.url,revision:yn}))}catch{}window.__THREE__?(ge("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+yn),console.warn("THREE imports:",window.__THREE__IMPORTS__)):window.__THREE__=yn}function Yx(){let s=null,e=!1,t=null,i=null;function r(n,a){t(n,a),i=s.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=s.requestAnimationFrame(r),e=!0)},stop:function(){s.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(n){t=n},setContext:function(n){s=n}}}function vT(s){const e=new WeakMap;function t(o,l){const h=o.array,c=o.usage,d=h.byteLength,u=s.createBuffer();s.bindBuffer(l,u),s.bufferData(l,h,c),o.onUploadCallback();let p;if(h instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array<"u"&&h instanceof Float16Array)p=s.HALF_FLOAT;else if(h instanceof Uint16Array)o.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(h instanceof Int16Array)p=s.SHORT;else if(h instanceof Uint32Array)p=s.UNSIGNED_INT;else if(h instanceof Int32Array)p=s.INT;else if(h instanceof Int8Array)p=s.BYTE;else if(h instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:u,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,h){const c=l.array,d=l.updateRanges;if(s.bindBuffer(h,o),d.length===0)s.bufferSubData(h,0,c);else{d.sort((p,m)=>p.start-m.start);let u=0;for(let p=1;p<d.length;p++){const m=d[u],y=d[p];y.start<=m.start+m.count+1?m.count=Math.max(m.count,y.start+y.count-m.start):(++u,d[u]=y)}d.length=u+1;for(let p=0,m=d.length;p<m;p++){const y=d[p];s.bufferSubData(h,y.start*c.BYTES_PER_ELEMENT,c,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function n(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const c=e.get(o);(!c||c.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const h=e.get(o);if(h===void 0)e.set(o,t(o,l));else if(h.version<o.version){if(h.size!==o.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.");i(h.buffer,o,l),h.version=o.version}}return{get:r,remove:n,update:a}}var _T=`#ifdef USE_ALPHAHASH
|
|
6
6
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
7
7
|
#endif`,MT=`#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
|
-
}`,ot={alphahash_fragment:_T,alphahash_pars_fragment:MT,alphamap_fragment:bT,alphamap_pars_fragment:ST,alphatest_fragment:TT,alphatest_pars_fragment:wT,aomap_fragment:ET,aomap_pars_fragment:AT,batching_pars_vertex:NT,batching_vertex:CT,begin_vertex:RT,beginnormal_vertex:IT,bsdfs:PT,iridescence_fragment:LT,bumpmap_pars_fragment:DT,clipping_planes_fragment:OT,clipping_planes_pars_fragment:UT,clipping_planes_pars_vertex:FT,clipping_planes_vertex:zT,color_fragment:BT,color_pars_fragment:VT,color_pars_vertex:kT,color_vertex:GT,common:HT,cube_uv_reflection_fragment:WT,defaultnormal_vertex:jT,displacementmap_pars_vertex:XT,displacementmap_vertex:qT,emissivemap_fragment:YT,emissivemap_pars_fragment:ZT,colorspace_fragment:JT,colorspace_pars_fragment:KT,envmap_fragment:$T,envmap_common_pars_fragment:QT,envmap_pars_fragment:ew,envmap_pars_vertex:tw,envmap_physical_pars_fragment:dw,envmap_vertex:iw,fog_vertex:sw,fog_pars_vertex:rw,fog_fragment:nw,fog_pars_fragment:aw,gradientmap_pars_fragment:ow,lightmap_pars_fragment:lw,lights_lambert_fragment:hw,lights_lambert_pars_fragment:cw,lights_pars_begin:uw,lights_toon_fragment:pw,lights_toon_pars_fragment:mw,lights_phong_fragment:fw,lights_phong_pars_fragment:gw,lights_physical_fragment:yw,lights_physical_pars_fragment:xw,lights_fragment_begin:vw,lights_fragment_maps:_w,lights_fragment_end:Mw,logdepthbuf_fragment:bw,logdepthbuf_pars_fragment:Sw,logdepthbuf_pars_vertex:Tw,logdepthbuf_vertex:ww,map_fragment:Ew,map_pars_fragment:Aw,map_particle_fragment:Nw,map_particle_pars_fragment:Cw,metalnessmap_fragment:Rw,metalnessmap_pars_fragment:Iw,morphinstance_vertex:Pw,morphcolor_vertex:Lw,morphnormal_vertex:Dw,morphtarget_pars_vertex:Ow,morphtarget_vertex:Uw,normal_fragment_begin:Fw,normal_fragment_maps:zw,normal_pars_fragment:Bw,normal_pars_vertex:Vw,normal_vertex:kw,normalmap_pars_fragment:Gw,clearcoat_normal_fragment_begin:Hw,clearcoat_normal_fragment_maps:Ww,clearcoat_pars_fragment:jw,iridescence_pars_fragment:Xw,opaque_fragment:qw,packing:Yw,premultiplied_alpha_fragment:Zw,project_vertex:Jw,dithering_fragment:Kw,dithering_pars_fragment:$w,roughnessmap_fragment:Qw,roughnessmap_pars_fragment:eE,shadowmap_pars_fragment:tE,shadowmap_pars_vertex:iE,shadowmap_vertex:sE,shadowmask_pars_fragment:rE,skinbase_vertex:nE,skinning_pars_vertex:aE,skinning_vertex:oE,skinnormal_vertex:lE,specularmap_fragment:hE,specularmap_pars_fragment:cE,tonemapping_fragment:uE,tonemapping_pars_fragment:dE,transmission_fragment:pE,transmission_pars_fragment:mE,uv_pars_fragment:fE,uv_pars_vertex:gE,uv_vertex:yE,worldpos_vertex:xE,background_vert:vE,background_frag:_E,backgroundCube_vert:ME,backgroundCube_frag:bE,cube_vert:SE,cube_frag:TE,depth_vert:wE,depth_frag:EE,distance_vert:AE,distance_frag:NE,equirect_vert:CE,equirect_frag:RE,linedashed_vert:IE,linedashed_frag:PE,meshbasic_vert:LE,meshbasic_frag:DE,meshlambert_vert:OE,meshlambert_frag:UE,meshmatcap_vert:FE,meshmatcap_frag:zE,meshnormal_vert:BE,meshnormal_frag:VE,meshphong_vert:kE,meshphong_frag:GE,meshphysical_vert:HE,meshphysical_frag:WE,meshtoon_vert:jE,meshtoon_frag:XE,points_vert:qE,points_frag:YE,shadow_vert:ZE,shadow_frag:JE,sprite_vert:KE,sprite_frag:$E},ye={common:{diffuse:{value:new we(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new at},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new at}},envmap:{envMap:{value:null},envMapRotation:{value:new at},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 at}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new at}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new at},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new at},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new at},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new at}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new at}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new at}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new we(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 we(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0},uvTransform:{value:new at}},sprite:{diffuse:{value:new we(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new at},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0}}},hs={basic:{uniforms:Di([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.fog]),vertexShader:ot.meshbasic_vert,fragmentShader:ot.meshbasic_frag},lambert:{uniforms:Di([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new we(0)},envMapIntensity:{value:1}}]),vertexShader:ot.meshlambert_vert,fragmentShader:ot.meshlambert_frag},phong:{uniforms:Di([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new we(0)},specular:{value:new we(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ot.meshphong_vert,fragmentShader:ot.meshphong_frag},standard:{uniforms:Di([ye.common,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.roughnessmap,ye.metalnessmap,ye.fog,ye.lights,{emissive:{value:new we(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag},toon:{uniforms:Di([ye.common,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.gradientmap,ye.fog,ye.lights,{emissive:{value:new we(0)}}]),vertexShader:ot.meshtoon_vert,fragmentShader:ot.meshtoon_frag},matcap:{uniforms:Di([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,{matcap:{value:null}}]),vertexShader:ot.meshmatcap_vert,fragmentShader:ot.meshmatcap_frag},points:{uniforms:Di([ye.points,ye.fog]),vertexShader:ot.points_vert,fragmentShader:ot.points_frag},dashed:{uniforms:Di([ye.common,ye.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ot.linedashed_vert,fragmentShader:ot.linedashed_frag},depth:{uniforms:Di([ye.common,ye.displacementmap]),vertexShader:ot.depth_vert,fragmentShader:ot.depth_frag},normal:{uniforms:Di([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,{opacity:{value:1}}]),vertexShader:ot.meshnormal_vert,fragmentShader:ot.meshnormal_frag},sprite:{uniforms:Di([ye.sprite,ye.fog]),vertexShader:ot.sprite_vert,fragmentShader:ot.sprite_frag},background:{uniforms:{uvTransform:{value:new at},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ot.background_vert,fragmentShader:ot.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new at}},vertexShader:ot.backgroundCube_vert,fragmentShader:ot.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ot.cube_vert,fragmentShader:ot.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ot.equirect_vert,fragmentShader:ot.equirect_frag},distance:{uniforms:Di([ye.common,ye.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ot.distance_vert,fragmentShader:ot.distance_frag},shadow:{uniforms:Di([ye.lights,ye.fog,{color:{value:new we(0)},opacity:{value:1}}]),vertexShader:ot.shadow_vert,fragmentShader:ot.shadow_frag}};hs.physical={uniforms:Di([hs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new at},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new at},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new at},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new at},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new at},sheen:{value:0},sheenColor:{value:new we(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new at},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new at},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new at},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new at},attenuationDistance:{value:0},attenuationColor:{value:new we(0)},specularColor:{value:new we(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new at},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new at},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new at}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag};const Tu={r:0,b:0,g:0},jn=new ns,QE=new et;function eA(s,e,t,i,r,n){const a=new we(0);let o=r===!0?0:1,l,h,c=null,d=0,u=null;function p(x){let v=x.isScene===!0?x.background:null;if(v&&v.isTexture){const M=x.backgroundBlurriness>0;v=e.get(v,M)}return v}function m(x){let v=!1;const M=p(x);M===null?g(a,o):M&&M.isColor&&(g(M,1),v=!0);const w=s.xr.getEnvironmentBlendMode();w==="additive"?t.buffers.color.setClear(0,0,0,1,n):w==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,n),(s.autoClear||v)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function y(x,v){const M=p(v);M&&(M.isCubeTexture||M.mapping===xn)?(h===void 0&&(h=new Xt(new dn(1,1,1),new $i({name:"BackgroundCubeMaterial",uniforms:Ga(hs.backgroundCube.uniforms),vertexShader:hs.backgroundCube.vertexShader,fragmentShader:hs.backgroundCube.fragmentShader,side:yi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),jn.copy(v.backgroundRotation),jn.x*=-1,jn.y*=-1,jn.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(jn.y*=-1,jn.z*=-1),h.material.uniforms.envMap.value=M,h.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(QE.makeRotationFromEuler(jn)),h.material.toneMapped=mt.getTransfer(M.colorSpace)!==vt,(c!==M||d!==M.version||u!==s.toneMapping)&&(h.material.needsUpdate=!0,c=M,d=M.version,u=s.toneMapping),h.layers.enableAll(),x.unshift(h,h.geometry,h.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Xt(new na(2,2),new $i({name:"BackgroundMaterial",uniforms:Ga(hs.background.uniforms),vertexShader:hs.background.vertexShader,fragmentShader:hs.background.fragmentShader,side:Vs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=mt.getTransfer(M.colorSpace)!==vt,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(c!==M||d!==M.version||u!==s.toneMapping)&&(l.material.needsUpdate=!0,c=M,d=M.version,u=s.toneMapping),l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null))}function g(x,v){x.getRGB(Tu,Yy(s)),t.buffers.color.setClear(Tu.r,Tu.g,Tu.b,v,n)}function f(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(x,v=1){a.set(x),o=v,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(x){o=x,g(a,o)},render:m,addToRenderList:y,dispose:f}}function tA(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},r=u(null);let n=r,a=!1;function o(C,L,U,V,B){let k=!1;const W=d(C,V,U,L);n!==W&&(n=W,h(n.object)),k=p(C,V,U,B),k&&m(C,V,U,B),B!==null&&e.update(B,s.ELEMENT_ARRAY_BUFFER),(k||a)&&(a=!1,M(C,L,U,V),B!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return s.createVertexArray()}function h(C){return s.bindVertexArray(C)}function c(C){return s.deleteVertexArray(C)}function d(C,L,U,V){const B=V.wireframe===!0;let k=i[L.id];k===void 0&&(k={},i[L.id]=k);const W=C.isInstancedMesh===!0?C.id:0;let se=k[W];se===void 0&&(se={},k[W]=se);let ie=se[U.id];ie===void 0&&(ie={},se[U.id]=ie);let oe=ie[B];return oe===void 0&&(oe=u(l()),ie[B]=oe),oe}function u(C){const L=[],U=[],V=[];for(let B=0;B<t;B++)L[B]=0,U[B]=0,V[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:U,attributeDivisors:V,object:C,attributes:{},index:null}}function p(C,L,U,V){const B=n.attributes,k=L.attributes;let W=0;const se=U.getAttributes();for(const ie in se)if(se[ie].location>=0){const oe=B[ie];let be=k[ie];if(be===void 0&&(ie==="instanceMatrix"&&C.instanceMatrix&&(be=C.instanceMatrix),ie==="instanceColor"&&C.instanceColor&&(be=C.instanceColor)),oe===void 0||oe.attribute!==be||be&&oe.data!==be.data)return!0;W++}return n.attributesNum!==W||n.index!==V}function m(C,L,U,V){const B={},k=L.attributes;let W=0;const se=U.getAttributes();for(const ie in se)if(se[ie].location>=0){let oe=k[ie];oe===void 0&&(ie==="instanceMatrix"&&C.instanceMatrix&&(oe=C.instanceMatrix),ie==="instanceColor"&&C.instanceColor&&(oe=C.instanceColor));const be={};be.attribute=oe,oe&&oe.data&&(be.data=oe.data),B[ie]=be,W++}n.attributes=B,n.attributesNum=W,n.index=V}function y(){const C=n.newAttributes;for(let L=0,U=C.length;L<U;L++)C[L]=0}function g(C){f(C,0)}function f(C,L){const U=n.newAttributes,V=n.enabledAttributes,B=n.attributeDivisors;U[C]=1,V[C]===0&&(s.enableVertexAttribArray(C),V[C]=1),B[C]!==L&&(s.vertexAttribDivisor(C,L),B[C]=L)}function x(){const C=n.newAttributes,L=n.enabledAttributes;for(let U=0,V=L.length;U<V;U++)L[U]!==C[U]&&(s.disableVertexAttribArray(U),L[U]=0)}function v(C,L,U,V,B,k,W){W===!0?s.vertexAttribIPointer(C,L,U,B,k):s.vertexAttribPointer(C,L,U,V,B,k)}function M(C,L,U,V){y();const B=V.attributes,k=U.getAttributes(),W=L.defaultAttributeValues;for(const se in k){const ie=k[se];if(ie.location>=0){let oe=B[se];if(oe===void 0&&(se==="instanceMatrix"&&C.instanceMatrix&&(oe=C.instanceMatrix),se==="instanceColor"&&C.instanceColor&&(oe=C.instanceColor)),oe!==void 0){const be=oe.normalized,Ce=oe.itemSize,tt=e.get(oe);if(tt===void 0)continue;const wt=tt.buffer,Et=tt.type,K=tt.bytesPerElement,ae=Et===s.INT||Et===s.UNSIGNED_INT||oe.gpuType===Wh;if(oe.isInterleavedBufferAttribute){const le=oe.data,Qe=le.stride,Ye=oe.offset;if(le.isInstancedInterleavedBuffer){for(let Te=0;Te<ie.locationSize;Te++)f(ie.location+Te,le.meshPerAttribute);C.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let Te=0;Te<ie.locationSize;Te++)g(ie.location+Te);s.bindBuffer(s.ARRAY_BUFFER,wt);for(let Te=0;Te<ie.locationSize;Te++)v(ie.location+Te,Ce/ie.locationSize,Et,be,Qe*K,(Ye+Ce/ie.locationSize*Te)*K,ae)}else{if(oe.isInstancedBufferAttribute){for(let le=0;le<ie.locationSize;le++)f(ie.location+le,oe.meshPerAttribute);C.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let le=0;le<ie.locationSize;le++)g(ie.location+le);s.bindBuffer(s.ARRAY_BUFFER,wt);for(let le=0;le<ie.locationSize;le++)v(ie.location+le,Ce/ie.locationSize,Et,be,Ce*K,Ce/ie.locationSize*le*K,ae)}}else if(W!==void 0){const be=W[se];if(be!==void 0)switch(be.length){case 2:s.vertexAttrib2fv(ie.location,be);break;case 3:s.vertexAttrib3fv(ie.location,be);break;case 4:s.vertexAttrib4fv(ie.location,be);break;default:s.vertexAttrib1fv(ie.location,be)}}}}x()}function w(){S();for(const C in i){const L=i[C];for(const U in L){const V=L[U];for(const B in V){const k=V[B];for(const W in k)c(k[W].object),delete k[W];delete V[B]}}delete i[C]}}function T(C){if(i[C.id]===void 0)return;const L=i[C.id];for(const U in L){const V=L[U];for(const B in V){const k=V[B];for(const W in k)c(k[W].object),delete k[W];delete V[B]}}delete i[C.id]}function A(C){for(const L in i){const U=i[L];for(const V in U){const B=U[V];if(B[C.id]===void 0)continue;const k=B[C.id];for(const W in k)c(k[W].object),delete k[W];delete B[C.id]}}}function _(C){for(const L in i){const U=i[L],V=C.isInstancedMesh===!0?C.id:0,B=U[V];if(B!==void 0){for(const k in B){const W=B[k];for(const se in W)c(W[se].object),delete W[se];delete B[k]}delete U[V],Object.keys(U).length===0&&delete i[L]}}}function S(){P(),a=!0,n!==r&&(n=r,h(n.object))}function P(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:S,resetDefaultState:P,dispose:w,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:g,disableUnusedAttributes:x}}function iA(s,e,t){let i;function r(h){i=h}function n(h,c){s.drawArrays(i,h,c),t.update(c,i,1)}function a(h,c,d){d!==0&&(s.drawArraysInstanced(i,h,c,d),t.update(c,i,d))}function o(h,c,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,h,0,c,0,d);let u=0;for(let p=0;p<d;p++)u+=c[p];t.update(u,i,1)}function l(h,c,d,u){if(d===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<h.length;m++)a(h[m],c[m],u[m]);else{p.multiDrawArraysInstancedWEBGL(i,h,0,c,0,u,0,d);let m=0;for(let y=0;y<d;y++)m+=c[y]*u[y];t.update(m,i,1)}}this.setMode=r,this.render=n,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function sA(s,e,t,i){let r;function n(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");r=s.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){return!(A!==vi&&i.convert(A)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const _=A===Ts&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Ri&&i.convert(A)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==xi&&!_)}function l(A){if(A==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const c=l(h);c!==h&&(ge("WebGLRenderer:",h,"not supported, using",c,"instead."),h=c);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),m=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=s.getParameter(s.MAX_TEXTURE_SIZE),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),f=s.getParameter(s.MAX_VERTEX_ATTRIBS),x=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),v=s.getParameter(s.MAX_VARYING_VECTORS),M=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),w=s.getParameter(s.MAX_SAMPLES),T=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:n,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:h,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:m,maxTextureSize:y,maxCubemapSize:g,maxAttributes:f,maxVertexUniforms:x,maxVaryings:v,maxFragmentUniforms:M,maxSamples:w,samples:T}}function rA(s){const e=this;let t=null,i=0,r=!1,n=!1;const a=new br,o=new at,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const p=d.length!==0||u||i!==0||r;return r=u,i=d.length,p},this.beginShadows=function(){n=!0,c(null)},this.endShadows=function(){n=!1},this.setGlobalState=function(d,u){t=c(d,u,0)},this.setState=function(d,u,p){const m=d.clippingPlanes,y=d.clipIntersection,g=d.clipShadows,f=s.get(d);if(!r||m===null||m.length===0||n&&!g)n?c(null):h();else{const x=n?0:i,v=x*4;let M=f.clippingState||null;l.value=M,M=c(m,u,v,p);for(let w=0;w!==v;++w)M[w]=t[w];f.clippingState=M,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=x}};function h(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function c(d,u,p,m){const y=d!==null?d.length:0;let g=null;if(y!==0){if(g=l.value,m!==!0||g===null){const f=p+y*4,x=u.matrixWorldInverse;o.getNormalMatrix(x),(g===null||g.length<f)&&(g=new Float32Array(f));for(let v=0,M=p;v!==y;++v,M+=4)a.copy(d[v]).applyMatrix4(x,o),a.normal.toArray(g,M),g[M+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}const en=4,Zx=[.125,.215,.35,.446,.526,.582],Xn=20,nA=256,Wl=new Ya,Jx=new we;let Ym=null,Zm=0,Jm=0,Km=!1;const aA=new R;class wu{constructor(e){this._renderer=e,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(e,t=0,i=.1,r=100,n={}){const{size:a=256,position:o=aA}=n;Ym=this._renderer.getRenderTarget(),Zm=this._renderer.getActiveCubeFace(),Jm=this._renderer.getActiveMipmapLevel(),Km=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ev(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Qx(),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(e){this._lodMax=Math.floor(Math.log2(e)),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 e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ym,Zm,Jm),this._renderer.xr.enabled=Km,e.scissorTest=!1,Qa(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ks||e.mapping===zr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ym=this._renderer.getRenderTarget(),Zm=this._renderer.getActiveCubeFace(),Jm=this._renderer.getActiveMipmapLevel(),Km=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Rt,minFilter:Rt,generateMipmaps:!1,type:Ts,format:vi,colorSpace:kr,depthBuffer:!1},r=$x(e,t,i),{_lodMax:n}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Kx(n),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=$x(e,t,i);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Kx(a)),this._blurMaterial=lA(a,e,t),this._ggxMaterial=oA(a,e,t)}return r}_compileMaterial(e){const t=new Xt(new rt,e);this._renderer.compile(t,Wl)}_sceneToCubeUV(e,t,i,r,n){const a=new li(90,1,t,i),o=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,c=h.autoClear,d=h.toneMapping;h.getClearColor(Jx),h.toneMapping=rs,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(r),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Xt(new dn,new Mr({name:"PMREM.Background",side:yi,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,p=u.material;let m=!1;const y=e.background;y?y.isColor&&(p.color.copy(y),e.background=null,m=!0):(p.color.copy(Jx),m=!0);for(let g=0;g<6;g++){const f=g%3;f===0?(a.up.set(0,o[g],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x+l[g],n.y,n.z)):f===1?(a.up.set(0,0,o[g]),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y+l[g],n.z)):(a.up.set(0,o[g],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y,n.z+l[g]));const x=this._cubeSize;Qa(r,f*x,g>2?x:0,x,x),h.setRenderTarget(r),m&&h.render(u,a),h.render(e,a)}h.toneMapping=d,h.autoClear=c,e.background=y}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===ks||e.mapping===zr;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ev()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Qx());const n=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=n;const o=n.uniforms;o.envMap.value=e;const l=this._cubeSize;Qa(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Wl)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let n=1;n<r;n++)this._applyGGXFilter(e,n-1,n);t.autoClear=i}_applyGGXFilter(e,t,i){const r=this._renderer,n=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,h=i/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),d=Math.sqrt(h*h-c*c),u=0+h*1.25,p=d*u,{_lodMax:m}=this,y=this._sizeLods[i],g=3*y*(i>m-en?i-m+en:0),f=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=m-t,Qa(n,g,f,3*y,2*y),r.setRenderTarget(n),r.render(o,Wl),l.envMap.value=n.texture,l.roughness.value=0,l.mipInt.value=m-i,Qa(e,g,f,3*y,2*y),r.setRenderTarget(e),r.render(o,Wl)}_blur(e,t,i,r,n){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",n),this._halfBlur(a,e,i,i,r,"longitudinal",n)}_halfBlur(e,t,i,r,n,a,o){const l=this._renderer,h=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ve("blur direction must be either latitudinal or longitudinal!");const c=3,d=this._lodMeshes[r];d.material=h;const u=h.uniforms,p=this._sizeLods[i]-1,m=isFinite(n)?Math.PI/(2*p):2*Math.PI/(2*Xn-1),y=n/m,g=isFinite(n)?1+Math.floor(c*y):Xn;g>Xn&&ge(`sigmaRadians, ${n}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Xn}`);const f=[];let x=0;for(let A=0;A<Xn;++A){const _=A/y,S=Math.exp(-_*_/2);f.push(S),A===0?x+=S:A<g&&(x+=2*S)}for(let A=0;A<f.length;A++)f[A]=f[A]/x;u.envMap.value=e.texture,u.samples.value=g,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:v}=this;u.dTheta.value=m,u.mipInt.value=v-i;const M=this._sizeLods[r],w=3*M*(r>v-en?r-v+en:0),T=4*(this._cubeSize-M);Qa(t,w,T,3*M,2*M),l.setRenderTarget(t),l.render(d,Wl)}}function Kx(s){const e=[],t=[],i=[];let r=s;const n=s-en+1+Zx.length;for(let a=0;a<n;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>s-en?l=Zx[a-s+en-1]:a===0&&(l=0),t.push(l);const h=1/(o-2),c=-h,d=1+h,u=[c,c,d,c,d,d,c,c,d,d,c,d],p=6,m=6,y=3,g=2,f=1,x=new Float32Array(y*m*p),v=new Float32Array(g*m*p),M=new Float32Array(f*m*p);for(let T=0;T<p;T++){const A=T%3*2/3-1,_=T>2?0:-1,S=[A,_,0,A+2/3,_,0,A+2/3,_+1,0,A,_,0,A+2/3,_+1,0,A,_+1,0];x.set(S,y*m*T),v.set(u,g*m*T);const P=[T,T,T,T,T,T];M.set(P,f*m*T)}const w=new rt;w.setAttribute("position",new bt(x,y)),w.setAttribute("uv",new bt(v,g)),w.setAttribute("faceIndex",new bt(M,f)),i.push(new Xt(w,null)),r>en&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function $x(s,e,t){const i=new Bi(s,e,t);return i.texture.mapping=xn,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Qa(s,e,t,i,r){s.viewport.set(e,t,i,r),s.scissor.set(e,t,i,r)}function oA(s,e,t){return new $i({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:nA,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Eu(),fragmentShader:`
|
|
3620
|
+
}`,ot={alphahash_fragment:_T,alphahash_pars_fragment:MT,alphamap_fragment:bT,alphamap_pars_fragment:ST,alphatest_fragment:TT,alphatest_pars_fragment:wT,aomap_fragment:ET,aomap_pars_fragment:AT,batching_pars_vertex:NT,batching_vertex:CT,begin_vertex:RT,beginnormal_vertex:IT,bsdfs:PT,iridescence_fragment:LT,bumpmap_pars_fragment:DT,clipping_planes_fragment:OT,clipping_planes_pars_fragment:UT,clipping_planes_pars_vertex:FT,clipping_planes_vertex:zT,color_fragment:BT,color_pars_fragment:VT,color_pars_vertex:kT,color_vertex:GT,common:HT,cube_uv_reflection_fragment:WT,defaultnormal_vertex:jT,displacementmap_pars_vertex:XT,displacementmap_vertex:qT,emissivemap_fragment:YT,emissivemap_pars_fragment:ZT,colorspace_fragment:JT,colorspace_pars_fragment:KT,envmap_fragment:$T,envmap_common_pars_fragment:QT,envmap_pars_fragment:ew,envmap_pars_vertex:tw,envmap_physical_pars_fragment:dw,envmap_vertex:iw,fog_vertex:sw,fog_pars_vertex:rw,fog_fragment:nw,fog_pars_fragment:aw,gradientmap_pars_fragment:ow,lightmap_pars_fragment:lw,lights_lambert_fragment:hw,lights_lambert_pars_fragment:cw,lights_pars_begin:uw,lights_toon_fragment:pw,lights_toon_pars_fragment:mw,lights_phong_fragment:fw,lights_phong_pars_fragment:gw,lights_physical_fragment:yw,lights_physical_pars_fragment:xw,lights_fragment_begin:vw,lights_fragment_maps:_w,lights_fragment_end:Mw,logdepthbuf_fragment:bw,logdepthbuf_pars_fragment:Sw,logdepthbuf_pars_vertex:Tw,logdepthbuf_vertex:ww,map_fragment:Ew,map_pars_fragment:Aw,map_particle_fragment:Nw,map_particle_pars_fragment:Cw,metalnessmap_fragment:Rw,metalnessmap_pars_fragment:Iw,morphinstance_vertex:Pw,morphcolor_vertex:Lw,morphnormal_vertex:Dw,morphtarget_pars_vertex:Ow,morphtarget_vertex:Uw,normal_fragment_begin:Fw,normal_fragment_maps:zw,normal_pars_fragment:Bw,normal_pars_vertex:Vw,normal_vertex:kw,normalmap_pars_fragment:Gw,clearcoat_normal_fragment_begin:Hw,clearcoat_normal_fragment_maps:Ww,clearcoat_pars_fragment:jw,iridescence_pars_fragment:Xw,opaque_fragment:qw,packing:Yw,premultiplied_alpha_fragment:Zw,project_vertex:Jw,dithering_fragment:Kw,dithering_pars_fragment:$w,roughnessmap_fragment:Qw,roughnessmap_pars_fragment:eE,shadowmap_pars_fragment:tE,shadowmap_pars_vertex:iE,shadowmap_vertex:sE,shadowmask_pars_fragment:rE,skinbase_vertex:nE,skinning_pars_vertex:aE,skinning_vertex:oE,skinnormal_vertex:lE,specularmap_fragment:hE,specularmap_pars_fragment:cE,tonemapping_fragment:uE,tonemapping_pars_fragment:dE,transmission_fragment:pE,transmission_pars_fragment:mE,uv_pars_fragment:fE,uv_pars_vertex:gE,uv_vertex:yE,worldpos_vertex:xE,background_vert:vE,background_frag:_E,backgroundCube_vert:ME,backgroundCube_frag:bE,cube_vert:SE,cube_frag:TE,depth_vert:wE,depth_frag:EE,distance_vert:AE,distance_frag:NE,equirect_vert:CE,equirect_frag:RE,linedashed_vert:IE,linedashed_frag:PE,meshbasic_vert:LE,meshbasic_frag:DE,meshlambert_vert:OE,meshlambert_frag:UE,meshmatcap_vert:FE,meshmatcap_frag:zE,meshnormal_vert:BE,meshnormal_frag:VE,meshphong_vert:kE,meshphong_frag:GE,meshphysical_vert:HE,meshphysical_frag:WE,meshtoon_vert:jE,meshtoon_frag:XE,points_vert:qE,points_frag:YE,shadow_vert:ZE,shadow_frag:JE,sprite_vert:KE,sprite_frag:$E},ye={common:{diffuse:{value:new we(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new at},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new at}},envmap:{envMap:{value:null},envMapRotation:{value:new at},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 at}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new at}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new at},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new at},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new at},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new at}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new at}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new at}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new we(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 we(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0},uvTransform:{value:new at}},sprite:{diffuse:{value:new we(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new at},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0}}},hs={basic:{uniforms:Di([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.fog]),vertexShader:ot.meshbasic_vert,fragmentShader:ot.meshbasic_frag},lambert:{uniforms:Di([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new we(0)},envMapIntensity:{value:1}}]),vertexShader:ot.meshlambert_vert,fragmentShader:ot.meshlambert_frag},phong:{uniforms:Di([ye.common,ye.specularmap,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,ye.lights,{emissive:{value:new we(0)},specular:{value:new we(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ot.meshphong_vert,fragmentShader:ot.meshphong_frag},standard:{uniforms:Di([ye.common,ye.envmap,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.roughnessmap,ye.metalnessmap,ye.fog,ye.lights,{emissive:{value:new we(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag},toon:{uniforms:Di([ye.common,ye.aomap,ye.lightmap,ye.emissivemap,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.gradientmap,ye.fog,ye.lights,{emissive:{value:new we(0)}}]),vertexShader:ot.meshtoon_vert,fragmentShader:ot.meshtoon_frag},matcap:{uniforms:Di([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,ye.fog,{matcap:{value:null}}]),vertexShader:ot.meshmatcap_vert,fragmentShader:ot.meshmatcap_frag},points:{uniforms:Di([ye.points,ye.fog]),vertexShader:ot.points_vert,fragmentShader:ot.points_frag},dashed:{uniforms:Di([ye.common,ye.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ot.linedashed_vert,fragmentShader:ot.linedashed_frag},depth:{uniforms:Di([ye.common,ye.displacementmap]),vertexShader:ot.depth_vert,fragmentShader:ot.depth_frag},normal:{uniforms:Di([ye.common,ye.bumpmap,ye.normalmap,ye.displacementmap,{opacity:{value:1}}]),vertexShader:ot.meshnormal_vert,fragmentShader:ot.meshnormal_frag},sprite:{uniforms:Di([ye.sprite,ye.fog]),vertexShader:ot.sprite_vert,fragmentShader:ot.sprite_frag},background:{uniforms:{uvTransform:{value:new at},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ot.background_vert,fragmentShader:ot.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new at}},vertexShader:ot.backgroundCube_vert,fragmentShader:ot.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ot.cube_vert,fragmentShader:ot.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ot.equirect_vert,fragmentShader:ot.equirect_frag},distance:{uniforms:Di([ye.common,ye.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ot.distance_vert,fragmentShader:ot.distance_frag},shadow:{uniforms:Di([ye.lights,ye.fog,{color:{value:new we(0)},opacity:{value:1}}]),vertexShader:ot.shadow_vert,fragmentShader:ot.shadow_frag}};hs.physical={uniforms:Di([hs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new at},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new at},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new at},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new at},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new at},sheen:{value:0},sheenColor:{value:new we(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new at},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new at},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new at},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new at},attenuationDistance:{value:0},attenuationColor:{value:new we(0)},specularColor:{value:new we(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new at},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new at},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new at}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag};const Tu={r:0,b:0,g:0},jn=new ns,QE=new et;function eA(s,e,t,i,r,n){const a=new we(0);let o=r===!0?0:1,l,h,c=null,d=0,u=null;function p(x){let v=x.isScene===!0?x.background:null;if(v&&v.isTexture){const M=x.backgroundBlurriness>0;v=e.get(v,M)}return v}function m(x){let v=!1;const M=p(x);M===null?g(a,o):M&&M.isColor&&(g(M,1),v=!0);const w=s.xr.getEnvironmentBlendMode();w==="additive"?t.buffers.color.setClear(0,0,0,1,n):w==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,n),(s.autoClear||v)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function y(x,v){const M=p(v);M&&(M.isCubeTexture||M.mapping===xn)?(h===void 0&&(h=new Xt(new dn(1,1,1),new $i({name:"BackgroundCubeMaterial",uniforms:Ha(hs.backgroundCube.uniforms),vertexShader:hs.backgroundCube.vertexShader,fragmentShader:hs.backgroundCube.fragmentShader,side:yi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),jn.copy(v.backgroundRotation),jn.x*=-1,jn.y*=-1,jn.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(jn.y*=-1,jn.z*=-1),h.material.uniforms.envMap.value=M,h.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(QE.makeRotationFromEuler(jn)),h.material.toneMapped=mt.getTransfer(M.colorSpace)!==vt,(c!==M||d!==M.version||u!==s.toneMapping)&&(h.material.needsUpdate=!0,c=M,d=M.version,u=s.toneMapping),h.layers.enableAll(),x.unshift(h,h.geometry,h.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Xt(new na(2,2),new $i({name:"BackgroundMaterial",uniforms:Ha(hs.background.uniforms),vertexShader:hs.background.vertexShader,fragmentShader:hs.background.fragmentShader,side:Vs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=mt.getTransfer(M.colorSpace)!==vt,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(c!==M||d!==M.version||u!==s.toneMapping)&&(l.material.needsUpdate=!0,c=M,d=M.version,u=s.toneMapping),l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null))}function g(x,v){x.getRGB(Tu,Yy(s)),t.buffers.color.setClear(Tu.r,Tu.g,Tu.b,v,n)}function f(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(x,v=1){a.set(x),o=v,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(x){o=x,g(a,o)},render:m,addToRenderList:y,dispose:f}}function tA(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},r=u(null);let n=r,a=!1;function o(C,L,U,V,B){let k=!1;const W=d(C,V,U,L);n!==W&&(n=W,h(n.object)),k=p(C,V,U,B),k&&m(C,V,U,B),B!==null&&e.update(B,s.ELEMENT_ARRAY_BUFFER),(k||a)&&(a=!1,M(C,L,U,V),B!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return s.createVertexArray()}function h(C){return s.bindVertexArray(C)}function c(C){return s.deleteVertexArray(C)}function d(C,L,U,V){const B=V.wireframe===!0;let k=i[L.id];k===void 0&&(k={},i[L.id]=k);const W=C.isInstancedMesh===!0?C.id:0;let se=k[W];se===void 0&&(se={},k[W]=se);let ie=se[U.id];ie===void 0&&(ie={},se[U.id]=ie);let oe=ie[B];return oe===void 0&&(oe=u(l()),ie[B]=oe),oe}function u(C){const L=[],U=[],V=[];for(let B=0;B<t;B++)L[B]=0,U[B]=0,V[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:U,attributeDivisors:V,object:C,attributes:{},index:null}}function p(C,L,U,V){const B=n.attributes,k=L.attributes;let W=0;const se=U.getAttributes();for(const ie in se)if(se[ie].location>=0){const oe=B[ie];let be=k[ie];if(be===void 0&&(ie==="instanceMatrix"&&C.instanceMatrix&&(be=C.instanceMatrix),ie==="instanceColor"&&C.instanceColor&&(be=C.instanceColor)),oe===void 0||oe.attribute!==be||be&&oe.data!==be.data)return!0;W++}return n.attributesNum!==W||n.index!==V}function m(C,L,U,V){const B={},k=L.attributes;let W=0;const se=U.getAttributes();for(const ie in se)if(se[ie].location>=0){let oe=k[ie];oe===void 0&&(ie==="instanceMatrix"&&C.instanceMatrix&&(oe=C.instanceMatrix),ie==="instanceColor"&&C.instanceColor&&(oe=C.instanceColor));const be={};be.attribute=oe,oe&&oe.data&&(be.data=oe.data),B[ie]=be,W++}n.attributes=B,n.attributesNum=W,n.index=V}function y(){const C=n.newAttributes;for(let L=0,U=C.length;L<U;L++)C[L]=0}function g(C){f(C,0)}function f(C,L){const U=n.newAttributes,V=n.enabledAttributes,B=n.attributeDivisors;U[C]=1,V[C]===0&&(s.enableVertexAttribArray(C),V[C]=1),B[C]!==L&&(s.vertexAttribDivisor(C,L),B[C]=L)}function x(){const C=n.newAttributes,L=n.enabledAttributes;for(let U=0,V=L.length;U<V;U++)L[U]!==C[U]&&(s.disableVertexAttribArray(U),L[U]=0)}function v(C,L,U,V,B,k,W){W===!0?s.vertexAttribIPointer(C,L,U,B,k):s.vertexAttribPointer(C,L,U,V,B,k)}function M(C,L,U,V){y();const B=V.attributes,k=U.getAttributes(),W=L.defaultAttributeValues;for(const se in k){const ie=k[se];if(ie.location>=0){let oe=B[se];if(oe===void 0&&(se==="instanceMatrix"&&C.instanceMatrix&&(oe=C.instanceMatrix),se==="instanceColor"&&C.instanceColor&&(oe=C.instanceColor)),oe!==void 0){const be=oe.normalized,Ce=oe.itemSize,tt=e.get(oe);if(tt===void 0)continue;const wt=tt.buffer,Et=tt.type,K=tt.bytesPerElement,ae=Et===s.INT||Et===s.UNSIGNED_INT||oe.gpuType===Wh;if(oe.isInterleavedBufferAttribute){const le=oe.data,Qe=le.stride,Ye=oe.offset;if(le.isInstancedInterleavedBuffer){for(let Te=0;Te<ie.locationSize;Te++)f(ie.location+Te,le.meshPerAttribute);C.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let Te=0;Te<ie.locationSize;Te++)g(ie.location+Te);s.bindBuffer(s.ARRAY_BUFFER,wt);for(let Te=0;Te<ie.locationSize;Te++)v(ie.location+Te,Ce/ie.locationSize,Et,be,Qe*K,(Ye+Ce/ie.locationSize*Te)*K,ae)}else{if(oe.isInstancedBufferAttribute){for(let le=0;le<ie.locationSize;le++)f(ie.location+le,oe.meshPerAttribute);C.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let le=0;le<ie.locationSize;le++)g(ie.location+le);s.bindBuffer(s.ARRAY_BUFFER,wt);for(let le=0;le<ie.locationSize;le++)v(ie.location+le,Ce/ie.locationSize,Et,be,Ce*K,Ce/ie.locationSize*le*K,ae)}}else if(W!==void 0){const be=W[se];if(be!==void 0)switch(be.length){case 2:s.vertexAttrib2fv(ie.location,be);break;case 3:s.vertexAttrib3fv(ie.location,be);break;case 4:s.vertexAttrib4fv(ie.location,be);break;default:s.vertexAttrib1fv(ie.location,be)}}}}x()}function w(){S();for(const C in i){const L=i[C];for(const U in L){const V=L[U];for(const B in V){const k=V[B];for(const W in k)c(k[W].object),delete k[W];delete V[B]}}delete i[C]}}function T(C){if(i[C.id]===void 0)return;const L=i[C.id];for(const U in L){const V=L[U];for(const B in V){const k=V[B];for(const W in k)c(k[W].object),delete k[W];delete V[B]}}delete i[C.id]}function A(C){for(const L in i){const U=i[L];for(const V in U){const B=U[V];if(B[C.id]===void 0)continue;const k=B[C.id];for(const W in k)c(k[W].object),delete k[W];delete B[C.id]}}}function _(C){for(const L in i){const U=i[L],V=C.isInstancedMesh===!0?C.id:0,B=U[V];if(B!==void 0){for(const k in B){const W=B[k];for(const se in W)c(W[se].object),delete W[se];delete B[k]}delete U[V],Object.keys(U).length===0&&delete i[L]}}}function S(){P(),a=!0,n!==r&&(n=r,h(n.object))}function P(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:S,resetDefaultState:P,dispose:w,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:g,disableUnusedAttributes:x}}function iA(s,e,t){let i;function r(h){i=h}function n(h,c){s.drawArrays(i,h,c),t.update(c,i,1)}function a(h,c,d){d!==0&&(s.drawArraysInstanced(i,h,c,d),t.update(c,i,d))}function o(h,c,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,h,0,c,0,d);let u=0;for(let p=0;p<d;p++)u+=c[p];t.update(u,i,1)}function l(h,c,d,u){if(d===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<h.length;m++)a(h[m],c[m],u[m]);else{p.multiDrawArraysInstancedWEBGL(i,h,0,c,0,u,0,d);let m=0;for(let y=0;y<d;y++)m+=c[y]*u[y];t.update(m,i,1)}}this.setMode=r,this.render=n,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function sA(s,e,t,i){let r;function n(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");r=s.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){return!(A!==vi&&i.convert(A)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const _=A===Ts&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Ri&&i.convert(A)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==xi&&!_)}function l(A){if(A==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const c=l(h);c!==h&&(ge("WebGLRenderer:",h,"not supported, using",c,"instead."),h=c);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),m=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=s.getParameter(s.MAX_TEXTURE_SIZE),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),f=s.getParameter(s.MAX_VERTEX_ATTRIBS),x=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),v=s.getParameter(s.MAX_VARYING_VECTORS),M=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),w=s.getParameter(s.MAX_SAMPLES),T=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:n,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:h,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:m,maxTextureSize:y,maxCubemapSize:g,maxAttributes:f,maxVertexUniforms:x,maxVaryings:v,maxFragmentUniforms:M,maxSamples:w,samples:T}}function rA(s){const e=this;let t=null,i=0,r=!1,n=!1;const a=new br,o=new at,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const p=d.length!==0||u||i!==0||r;return r=u,i=d.length,p},this.beginShadows=function(){n=!0,c(null)},this.endShadows=function(){n=!1},this.setGlobalState=function(d,u){t=c(d,u,0)},this.setState=function(d,u,p){const m=d.clippingPlanes,y=d.clipIntersection,g=d.clipShadows,f=s.get(d);if(!r||m===null||m.length===0||n&&!g)n?c(null):h();else{const x=n?0:i,v=x*4;let M=f.clippingState||null;l.value=M,M=c(m,u,v,p);for(let w=0;w!==v;++w)M[w]=t[w];f.clippingState=M,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=x}};function h(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function c(d,u,p,m){const y=d!==null?d.length:0;let g=null;if(y!==0){if(g=l.value,m!==!0||g===null){const f=p+y*4,x=u.matrixWorldInverse;o.getNormalMatrix(x),(g===null||g.length<f)&&(g=new Float32Array(f));for(let v=0,M=p;v!==y;++v,M+=4)a.copy(d[v]).applyMatrix4(x,o),a.normal.toArray(g,M),g[M+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}const en=4,Zx=[.125,.215,.35,.446,.526,.582],Xn=20,nA=256,Wl=new Za,Jx=new we;let qm=null,Ym=0,Zm=0,Jm=!1;const aA=new R;class wu{constructor(e){this._renderer=e,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(e,t=0,i=.1,r=100,n={}){const{size:a=256,position:o=aA}=n;qm=this._renderer.getRenderTarget(),Ym=this._renderer.getActiveCubeFace(),Zm=this._renderer.getActiveMipmapLevel(),Jm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ev(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Qx(),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(e){this._lodMax=Math.floor(Math.log2(e)),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 e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(qm,Ym,Zm),this._renderer.xr.enabled=Jm,e.scissorTest=!1,eo(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ks||e.mapping===zr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),qm=this._renderer.getRenderTarget(),Ym=this._renderer.getActiveCubeFace(),Zm=this._renderer.getActiveMipmapLevel(),Jm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Rt,minFilter:Rt,generateMipmaps:!1,type:Ts,format:vi,colorSpace:kr,depthBuffer:!1},r=$x(e,t,i),{_lodMax:n}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Kx(n),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=$x(e,t,i);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Kx(a)),this._blurMaterial=lA(a,e,t),this._ggxMaterial=oA(a,e,t)}return r}_compileMaterial(e){const t=new Xt(new rt,e);this._renderer.compile(t,Wl)}_sceneToCubeUV(e,t,i,r,n){const a=new li(90,1,t,i),o=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,c=h.autoClear,d=h.toneMapping;h.getClearColor(Jx),h.toneMapping=rs,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(r),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Xt(new dn,new Mr({name:"PMREM.Background",side:yi,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,p=u.material;let m=!1;const y=e.background;y?y.isColor&&(p.color.copy(y),e.background=null,m=!0):(p.color.copy(Jx),m=!0);for(let g=0;g<6;g++){const f=g%3;f===0?(a.up.set(0,o[g],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x+l[g],n.y,n.z)):f===1?(a.up.set(0,0,o[g]),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y+l[g],n.z)):(a.up.set(0,o[g],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y,n.z+l[g]));const x=this._cubeSize;eo(r,f*x,g>2?x:0,x,x),h.setRenderTarget(r),m&&h.render(u,a),h.render(e,a)}h.toneMapping=d,h.autoClear=c,e.background=y}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===ks||e.mapping===zr;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ev()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Qx());const n=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=n;const o=n.uniforms;o.envMap.value=e;const l=this._cubeSize;eo(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Wl)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let n=1;n<r;n++)this._applyGGXFilter(e,n-1,n);t.autoClear=i}_applyGGXFilter(e,t,i){const r=this._renderer,n=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,h=i/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),d=Math.sqrt(h*h-c*c),u=0+h*1.25,p=d*u,{_lodMax:m}=this,y=this._sizeLods[i],g=3*y*(i>m-en?i-m+en:0),f=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=m-t,eo(n,g,f,3*y,2*y),r.setRenderTarget(n),r.render(o,Wl),l.envMap.value=n.texture,l.roughness.value=0,l.mipInt.value=m-i,eo(e,g,f,3*y,2*y),r.setRenderTarget(e),r.render(o,Wl)}_blur(e,t,i,r,n){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",n),this._halfBlur(a,e,i,i,r,"longitudinal",n)}_halfBlur(e,t,i,r,n,a,o){const l=this._renderer,h=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ve("blur direction must be either latitudinal or longitudinal!");const c=3,d=this._lodMeshes[r];d.material=h;const u=h.uniforms,p=this._sizeLods[i]-1,m=isFinite(n)?Math.PI/(2*p):2*Math.PI/(2*Xn-1),y=n/m,g=isFinite(n)?1+Math.floor(c*y):Xn;g>Xn&&ge(`sigmaRadians, ${n}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Xn}`);const f=[];let x=0;for(let A=0;A<Xn;++A){const _=A/y,S=Math.exp(-_*_/2);f.push(S),A===0?x+=S:A<g&&(x+=2*S)}for(let A=0;A<f.length;A++)f[A]=f[A]/x;u.envMap.value=e.texture,u.samples.value=g,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:v}=this;u.dTheta.value=m,u.mipInt.value=v-i;const M=this._sizeLods[r],w=3*M*(r>v-en?r-v+en:0),T=4*(this._cubeSize-M);eo(t,w,T,3*M,2*M),l.setRenderTarget(t),l.render(d,Wl)}}function Kx(s){const e=[],t=[],i=[];let r=s;const n=s-en+1+Zx.length;for(let a=0;a<n;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>s-en?l=Zx[a-s+en-1]:a===0&&(l=0),t.push(l);const h=1/(o-2),c=-h,d=1+h,u=[c,c,d,c,d,d,c,c,d,d,c,d],p=6,m=6,y=3,g=2,f=1,x=new Float32Array(y*m*p),v=new Float32Array(g*m*p),M=new Float32Array(f*m*p);for(let T=0;T<p;T++){const A=T%3*2/3-1,_=T>2?0:-1,S=[A,_,0,A+2/3,_,0,A+2/3,_+1,0,A,_,0,A+2/3,_+1,0,A,_+1,0];x.set(S,y*m*T),v.set(u,g*m*T);const P=[T,T,T,T,T,T];M.set(P,f*m*T)}const w=new rt;w.setAttribute("position",new bt(x,y)),w.setAttribute("uv",new bt(v,g)),w.setAttribute("faceIndex",new bt(M,f)),i.push(new Xt(w,null)),r>en&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function $x(s,e,t){const i=new Bi(s,e,t);return i.texture.mapping=xn,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function eo(s,e,t,i,r){s.viewport.set(e,t,i,r),s.scissor.set(e,t,i,r)}function oA(s,e,t){return new $i({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:nA,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Eu(),fragmentShader:`
|
|
3621
3621
|
|
|
3622
3622
|
precision highp float;
|
|
3623
3623
|
precision highp int;
|
|
@@ -3871,7 +3871,7 @@ void main() {
|
|
|
3871
3871
|
gl_Position = vec4( position, 1.0 );
|
|
3872
3872
|
|
|
3873
3873
|
}
|
|
3874
|
-
`}class Au extends Bi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new
|
|
3874
|
+
`}class Au extends Bi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new ka(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={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
|
-
`},r=new dn(5,5,5),n=new $i({name:"CubemapFromEquirect",uniforms:
|
|
3909
|
+
`},r=new dn(5,5,5),n=new $i({name:"CubemapFromEquirect",uniforms:Ha(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:yi,blending:bs});n.uniforms.tEquirect.value=t;const a=new Xt(r,n),o=t.minFilter;return t.minFilter===Ss&&(t.minFilter=Rt),new Om(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const n=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(n)}}function hA(s){let e=new WeakMap,t=new WeakMap,i=null;function r(u,p=!1){return u==null?null:p?a(u):n(u)}function n(u){if(u&&u.isTexture){const p=u.mapping;if(p===ua||p===da)if(e.has(u)){const m=e.get(u).texture;return o(m,u.mapping)}else{const m=u.image;if(m&&m.height>0){const y=new Au(m.height);return y.fromEquirectangularTexture(s,u),e.set(u,y),u.addEventListener("dispose",h),o(y.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture){const p=u.mapping,m=p===ua||p===da,y=p===ks||p===zr;if(m||y){let g=t.get(u);const f=g!==void 0?g.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==f)return i===null&&(i=new wu(s)),g=m?i.fromEquirectangular(u,g):i.fromCubemap(u,g),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),g.texture;if(g!==void 0)return g.texture;{const x=u.image;return m&&x&&x.height>0||y&&x&&l(x)?(i===null&&(i=new wu(s)),g=m?i.fromEquirectangular(u):i.fromCubemap(u),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),u.addEventListener("dispose",c),g.texture):null}}}return u}function o(u,p){return p===ua?u.mapping=ks:p===da&&(u.mapping=zr),u}function l(u){let p=0;const m=6;for(let y=0;y<m;y++)u[y]!==void 0&&p++;return p===m}function h(u){const p=u.target;p.removeEventListener("dispose",h);const m=e.get(p);m!==void 0&&(e.delete(p),m.dispose())}function c(u){const p=u.target;p.removeEventListener("dispose",c);const m=t.get(p);m!==void 0&&(t.delete(p),m.dispose())}function d(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:r,dispose:d}}function cA(s){const e={};function t(i){if(e[i]!==void 0)return e[i];const r=s.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&xl("WebGLRenderer: "+i+" extension not supported."),r}}}function uA(s,e,t,i){const r={},n=new WeakMap;function a(d){const u=d.target;u.index!==null&&e.remove(u.index);for(const m in u.attributes)e.remove(u.attributes[m]);u.removeEventListener("dispose",a),delete r[u.id];const p=n.get(u);p&&(e.remove(p),n.delete(u)),i.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function o(d,u){return r[u.id]===!0||(u.addEventListener("dispose",a),r[u.id]=!0,t.memory.geometries++),u}function l(d){const u=d.attributes;for(const p in u)e.update(u[p],s.ARRAY_BUFFER)}function h(d){const u=[],p=d.index,m=d.attributes.position;let y=0;if(m===void 0)return;if(p!==null){const x=p.array;y=p.version;for(let v=0,M=x.length;v<M;v+=3){const w=x[v+0],T=x[v+1],A=x[v+2];u.push(w,T,T,A,A,w)}}else{const x=m.array;y=m.version;for(let v=0,M=x.length/3-1;v<M;v+=3){const w=v+0,T=v+1,A=v+2;u.push(w,T,T,A,A,w)}}const g=new(m.count>=65535?Cp:wc)(u,1);g.version=y;const f=n.get(d);f&&e.remove(f),n.set(d,g)}function c(d){const u=n.get(d);if(u){const p=d.index;p!==null&&u.version<p.version&&h(d)}else h(d);return n.get(d)}return{get:o,update:l,getWireframeAttribute:c}}function dA(s,e,t){let i;function r(u){i=u}let n,a;function o(u){n=u.type,a=u.bytesPerElement}function l(u,p){s.drawElements(i,p,n,u*a),t.update(p,i,1)}function h(u,p,m){m!==0&&(s.drawElementsInstanced(i,p,n,u*a,m),t.update(p,i,m))}function c(u,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,n,u,0,m);let y=0;for(let g=0;g<m;g++)y+=p[g];t.update(y,i,1)}function d(u,p,m,y){if(m===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let f=0;f<u.length;f++)h(u[f]/a,p[f],y[f]);else{g.multiDrawElementsInstancedWEBGL(i,p,0,n,u,0,y,0,m);let f=0;for(let x=0;x<m;x++)f+=p[x]*y[x];t.update(f,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=h,this.renderMultiDraw=c,this.renderMultiDrawInstances=d}function pA(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(n,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(n/3);break;case s.LINES:t.lines+=o*(n/2);break;case s.LINE_STRIP:t.lines+=o*(n-1);break;case s.LINE_LOOP:t.lines+=o*n;break;case s.POINTS:t.points+=o*n;break;default:Ve("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function mA(s,e,t){const i=new WeakMap,r=new It;function n(a,o,l){const h=a.morphTargetInfluences,c=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=c!==void 0?c.length:0;let u=i.get(o);if(u===void 0||u.count!==d){let p=function(){_.dispose(),i.delete(o),o.removeEventListener("dispose",p)};u!==void 0&&u.texture.dispose();const m=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,g=o.morphAttributes.color!==void 0,f=o.morphAttributes.position||[],x=o.morphAttributes.normal||[],v=o.morphAttributes.color||[];let M=0;m===!0&&(M=1),y===!0&&(M=2),g===!0&&(M=3);let w=o.attributes.position.count*M,T=1;w>e.maxTextureSize&&(T=Math.ceil(w/e.maxTextureSize),w=e.maxTextureSize);const A=new Float32Array(w*T*4*d),_=new gc(A,w,T,d);_.type=xi,_.needsUpdate=!0;const S=M*4;for(let P=0;P<d;P++){const C=f[P],L=x[P],U=v[P],V=w*T*4*P;for(let B=0;B<C.count;B++){const k=B*S;m===!0&&(r.fromBufferAttribute(C,B),A[V+k+0]=r.x,A[V+k+1]=r.y,A[V+k+2]=r.z,A[V+k+3]=0),y===!0&&(r.fromBufferAttribute(L,B),A[V+k+4]=r.x,A[V+k+5]=r.y,A[V+k+6]=r.z,A[V+k+7]=0),g===!0&&(r.fromBufferAttribute(U,B),A[V+k+8]=r.x,A[V+k+9]=r.y,A[V+k+10]=r.z,A[V+k+11]=U.itemSize===4?r.w:1)}}u={count:d,texture:_,size:new te(w,T)},i.set(o,u),o.addEventListener("dispose",p)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let p=0;for(let y=0;y<h.length;y++)p+=h[y];const m=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(s,"morphTargetBaseInfluence",m),l.getUniforms().setValue(s,"morphTargetInfluences",h)}l.getUniforms().setValue(s,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",u.size)}return{update:n}}function fA(s,e,t,i,r){let n=new WeakMap;function a(h){const c=r.render.frame,d=h.geometry,u=e.get(h,d);if(n.get(u)!==c&&(e.update(u),n.set(u,c)),h.isInstancedMesh&&(h.hasEventListener("dispose",l)===!1&&h.addEventListener("dispose",l),n.get(h)!==c&&(t.update(h.instanceMatrix,s.ARRAY_BUFFER),h.instanceColor!==null&&t.update(h.instanceColor,s.ARRAY_BUFFER),n.set(h,c))),h.isSkinnedMesh){const p=h.skeleton;n.get(p)!==c&&(p.update(),n.set(p,c))}return u}function o(){n=new WeakMap}function l(h){const c=h.target;c.removeEventListener("dispose",l),i.releaseStatesOfObject(c),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:a,dispose:o}}const gA={[Fh]:"LINEAR_TONE_MAPPING",[zh]:"REINHARD_TONE_MAPPING",[Qd]:"CINEON_TONE_MAPPING",[Bh]:"ACES_FILMIC_TONE_MAPPING",[Vh]:"AGX_TONE_MAPPING",[kh]:"NEUTRAL_TONE_MAPPING",[ep]:"CUSTOM_TONE_MAPPING"};function yA(s,e,t,i,r){const n=new Bi(e,t,{type:s,depthBuffer:i,stencilBuffer:r}),a=new Bi(e,t,{type:Ts,depthBuffer:!1,stencilBuffer:!1}),o=new rt;o.setAttribute("position",new Ne([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new Ne([0,2,0,0,2,0],2));const l=new lu({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}),h=new Xt(o,l),c=new
|
|
3955
|
+
}`,depthTest:!1,depthWrite:!1}),h=new Xt(o,l),c=new Za(-1,1,1,-1,0,1);let d=null,u=null,p=!1,m,y=null,g=[],f=!1;this.setSize=function(x,v){n.setSize(x,v),a.setSize(x,v);for(let M=0;M<g.length;M++){const w=g[M];w.setSize&&w.setSize(x,v)}},this.setEffects=function(x){g=x,f=g.length>0&&g[0].isRenderPass===!0;const v=n.width,M=n.height;for(let w=0;w<g.length;w++){const T=g[w];T.setSize&&T.setSize(v,M)}},this.begin=function(x,v){if(p||x.toneMapping===rs&&g.length===0)return!1;if(y=v,v!==null){const M=v.width,w=v.height;(n.width!==M||n.height!==w)&&this.setSize(M,w)}return f===!1&&x.setRenderTarget(n),m=x.toneMapping,x.toneMapping=rs,!0},this.hasRenderPass=function(){return f},this.end=function(x,v){x.toneMapping=m,p=!0;let M=n,w=a;for(let T=0;T<g.length;T++){const A=g[T];if(A.enabled!==!1&&(A.render(x,w,M,v),A.needsSwap!==!1)){const _=M;M=w,w=_}}if(d!==x.outputColorSpace||u!==x.toneMapping){d=x.outputColorSpace,u=x.toneMapping,l.defines={},mt.getTransfer(d)===vt&&(l.defines.SRGB_TRANSFER="");const T=gA[u];T&&(l.defines[T]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=M.texture,x.setRenderTarget(y),x.render(h,c),y=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){n.dispose(),a.dispose(),o.dispose(),l.dispose()}}const tv=new ei,Km=new On(1,1),iv=new gc,sv=new _l,rv=new ka,nv=[],av=[],ov=new Float32Array(16),lv=new Float32Array(9),hv=new Float32Array(4);function to(s,e,t){const i=s[0];if(i<=0||i>0)return s;const r=e*t;let n=nv[r];if(n===void 0&&(n=new Float32Array(r),nv[r]=n),e!==0){i.toArray(n,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(n,o)}return n}function ti(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t<i;t++)if(s[t]!==e[t])return!1;return!0}function ii(s,e){for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}function Nu(s,e){let t=av[e];t===void 0&&(t=new Int32Array(e),av[e]=t);for(let i=0;i!==e;++i)t[i]=s.allocateTextureUnit();return t}function xA(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function vA(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ti(t,e))return;s.uniform2fv(this.addr,e),ii(t,e)}}function _A(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(ti(t,e))return;s.uniform3fv(this.addr,e),ii(t,e)}}function MA(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ti(t,e))return;s.uniform4fv(this.addr,e),ii(t,e)}}function bA(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(ti(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),ii(t,e)}else{if(ti(t,i))return;hv.set(i),s.uniformMatrix2fv(this.addr,!1,hv),ii(t,i)}}function SA(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(ti(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),ii(t,e)}else{if(ti(t,i))return;lv.set(i),s.uniformMatrix3fv(this.addr,!1,lv),ii(t,i)}}function TA(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(ti(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),ii(t,e)}else{if(ti(t,i))return;ov.set(i),s.uniformMatrix4fv(this.addr,!1,ov),ii(t,i)}}function wA(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function EA(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ti(t,e))return;s.uniform2iv(this.addr,e),ii(t,e)}}function AA(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ti(t,e))return;s.uniform3iv(this.addr,e),ii(t,e)}}function NA(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ti(t,e))return;s.uniform4iv(this.addr,e),ii(t,e)}}function CA(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function RA(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ti(t,e))return;s.uniform2uiv(this.addr,e),ii(t,e)}}function IA(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ti(t,e))return;s.uniform3uiv(this.addr,e),ii(t,e)}}function PA(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ti(t,e))return;s.uniform4uiv(this.addr,e),ii(t,e)}}function LA(s,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(s.uniform1i(this.addr,r),i[0]=r);let n;this.type===s.SAMPLER_2D_SHADOW?(Km.compareFunction=t.isReversedDepthBuffer()?mc:pc,n=Km):n=tv,t.setTexture2D(e||n,r)}function DA(s,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(s.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||sv,r)}function OA(s,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(s.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||rv,r)}function UA(s,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(s.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||iv,r)}function FA(s){switch(s){case 5126:return xA;case 35664:return vA;case 35665:return _A;case 35666:return MA;case 35674:return bA;case 35675:return SA;case 35676:return TA;case 5124:case 35670:return wA;case 35667:case 35671:return EA;case 35668:case 35672:return AA;case 35669:case 35673:return NA;case 5125:return CA;case 36294:return RA;case 36295:return IA;case 36296:return PA;case 35678:case 36198:case 36298:case 36306:case 35682:return LA;case 35679:case 36299:case 36307:return DA;case 35680:case 36300:case 36308:case 36293:return OA;case 36289:case 36303:case 36311:case 36292:return UA}}function zA(s,e){s.uniform1fv(this.addr,e)}function BA(s,e){const t=to(e,this.size,2);s.uniform2fv(this.addr,t)}function VA(s,e){const t=to(e,this.size,3);s.uniform3fv(this.addr,t)}function kA(s,e){const t=to(e,this.size,4);s.uniform4fv(this.addr,t)}function GA(s,e){const t=to(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function HA(s,e){const t=to(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function WA(s,e){const t=to(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function jA(s,e){s.uniform1iv(this.addr,e)}function XA(s,e){s.uniform2iv(this.addr,e)}function qA(s,e){s.uniform3iv(this.addr,e)}function YA(s,e){s.uniform4iv(this.addr,e)}function ZA(s,e){s.uniform1uiv(this.addr,e)}function JA(s,e){s.uniform2uiv(this.addr,e)}function KA(s,e){s.uniform3uiv(this.addr,e)}function $A(s,e){s.uniform4uiv(this.addr,e)}function QA(s,e,t){const i=this.cache,r=e.length,n=Nu(t,r);ti(i,n)||(s.uniform1iv(this.addr,n),ii(i,n));let a;this.type===s.SAMPLER_2D_SHADOW?a=Km:a=tv;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||a,n[o])}function eN(s,e,t){const i=this.cache,r=e.length,n=Nu(t,r);ti(i,n)||(s.uniform1iv(this.addr,n),ii(i,n));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||sv,n[a])}function tN(s,e,t){const i=this.cache,r=e.length,n=Nu(t,r);ti(i,n)||(s.uniform1iv(this.addr,n),ii(i,n));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||rv,n[a])}function iN(s,e,t){const i=this.cache,r=e.length,n=Nu(t,r);ti(i,n)||(s.uniform1iv(this.addr,n),ii(i,n));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||iv,n[a])}function sN(s){switch(s){case 5126:return zA;case 35664:return BA;case 35665:return VA;case 35666:return kA;case 35674:return GA;case 35675:return HA;case 35676:return WA;case 5124:case 35670:return jA;case 35667:case 35671:return XA;case 35668:case 35672:return qA;case 35669:case 35673:return YA;case 5125:return ZA;case 36294:return JA;case 36295:return KA;case 36296:return $A;case 35678:case 36198:case 36298:case 36306:case 35682:return QA;case 35679:case 36299:case 36307:return eN;case 35680:case 36300:case 36308:case 36293:return tN;case 36289:case 36303:case 36311:case 36292:return iN}}class rN{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=FA(t.type)}}class nN{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=sN(t.type)}}class aN{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let n=0,a=r.length;n!==a;++n){const o=r[n];o.setValue(e,t[o.id],i)}}}const $m=/(\w+)(\])?(\[|\.)?/g;function cv(s,e){s.seq.push(e),s.map[e.id]=e}function oN(s,e,t){const i=s.name,r=i.length;for($m.lastIndex=0;;){const n=$m.exec(i),a=$m.lastIndex;let o=n[1];const l=n[2]==="]",h=n[3];if(l&&(o=o|0),h===void 0||h==="["&&a+2===r){cv(t,h===void 0?new rN(o,s,e):new nN(o,s,e));break}else{let c=t.map[o];c===void 0&&(c=new aN(o),cv(t,c)),t=c}}}class Cu{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);oN(o,l,this)}const r=[],n=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):n.push(a);r.length>0&&(this.seq=r.concat(n))}setValue(e,t,i,r){const n=this.map[t];n!==void 0&&n.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let n=0,a=t.length;n!==a;++n){const o=t[n],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,n=e.length;r!==n;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function uv(s,e,t){const i=s.createShader(e);return s.shaderSource(i,t),s.compileShader(i),i}const lN=37297;let hN=0;function cN(s,e){const t=s.split(`
|
|
3956
3956
|
`),i=[],r=Math.max(e-6,0),n=Math.min(e+6,t.length);for(let a=r;a<n;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
|
3957
3957
|
`)}const dv=new at;function uN(s){mt._getMatrix(dv,mt.workingColorSpace,s);const e=`mat3( ${dv.elements.map(t=>t.toFixed(4))} )`;switch(mt.getTransfer(s)){case ml:return[e,"LinearTransferOETF"];case vt:return[e,"sRGBTransferOETF"];default:return ge("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function pv(s,e,t){const i=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const n=/ERROR: 0:(\d+)/.exec(r);if(n){const a=parseInt(n[1]);return t.toUpperCase()+`
|
|
3958
3958
|
|
|
3959
3959
|
`+r+`
|
|
3960
3960
|
|
|
3961
3961
|
`+cN(s.getShaderSource(e),a)}else return r}function dN(s,e){const t=uN(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
3962
|
-
`)}const pN={[Fh]:"Linear",[zh]:"Reinhard",[
|
|
3962
|
+
`)}const pN={[Fh]:"Linear",[zh]:"Reinhard",[Qd]:"Cineon",[Bh]:"ACESFilmic",[Vh]:"AgX",[kh]:"Neutral",[ep]:"Custom"};function mN(s,e){const t=pN[e];return t===void 0?(ge("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ru=new R;function fN(){mt.getLuminanceCoefficients(Ru);const s=Ru.x.toFixed(4),e=Ru.y.toFixed(4),t=Ru.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
3963
3963
|
`)}function gN(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(jl).join(`
|
|
3964
3964
|
`)}function yN(s){const e=[];for(const t in s){const i=s[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
3965
|
-
`)}function xN(s,e){const t={},i=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const n=s.getActiveAttrib(e,r),a=n.name;let o=1;n.type===s.FLOAT_MAT2&&(o=2),n.type===s.FLOAT_MAT3&&(o=3),n.type===s.FLOAT_MAT4&&(o=4),t[a]={type:n.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function jl(s){return s!==""}function mv(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function fv(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const vN=/^[ \t]*#include +<([\w\d./]+)>/gm;function
|
|
3965
|
+
`)}function xN(s,e){const t={},i=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const n=s.getActiveAttrib(e,r),a=n.name;let o=1;n.type===s.FLOAT_MAT2&&(o=2),n.type===s.FLOAT_MAT3&&(o=3),n.type===s.FLOAT_MAT4&&(o=4),t[a]={type:n.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function jl(s){return s!==""}function mv(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function fv(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const vN=/^[ \t]*#include +<([\w\d./]+)>/gm;function Qm(s){return s.replace(vN,MN)}const _N=new Map;function MN(s,e){let t=ot[e];if(t===void 0){const i=_N.get(e);if(i!==void 0)t=ot[i],ge('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Qm(t)}const bN=/#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 gv(s){return s.replace(bN,SN)}function SN(s,e,t,i){let r="";for(let n=parseInt(e);n<parseInt(t);n++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+n+" ]").replace(/UNROLLED_LOOP_INDEX/g,n);return r}function yv(s){let e=`precision ${s.precision} float;
|
|
3966
3966
|
precision ${s.precision} int;
|
|
3967
3967
|
precision ${s.precision} sampler2D;
|
|
3968
3968
|
precision ${s.precision} samplerCube;
|
|
@@ -3982,7 +3982,7 @@ void main() {
|
|
|
3982
3982
|
`;return s.precision==="highp"?e+=`
|
|
3983
3983
|
#define HIGH_PRECISION`:s.precision==="mediump"?e+=`
|
|
3984
3984
|
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
|
|
3985
|
-
#define LOW_PRECISION`),e}const TN={[
|
|
3985
|
+
#define LOW_PRECISION`),e}const TN={[ha]:"SHADOWMAP_TYPE_PCF",[ca]:"SHADOWMAP_TYPE_VSM"};function wN(s){return TN[s.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const EN={[ks]:"ENVMAP_TYPE_CUBE",[zr]:"ENVMAP_TYPE_CUBE",[xn]:"ENVMAP_TYPE_CUBE_UV"};function AN(s){return s.envMap===!1?"ENVMAP_TYPE_CUBE":EN[s.envMapMode]||"ENVMAP_TYPE_CUBE"}const NN={[zr]:"ENVMAP_MODE_REFRACTION"};function CN(s){return s.envMap===!1?"ENVMAP_MODE_REFLECTION":NN[s.envMapMode]||"ENVMAP_MODE_REFLECTION"}const RN={[Ho]:"ENVMAP_BLENDING_MULTIPLY",[c0]:"ENVMAP_BLENDING_MIX",[u0]:"ENVMAP_BLENDING_ADD"};function IN(s){return s.envMap===!1?"ENVMAP_BLENDING_NONE":RN[s.combine]||"ENVMAP_BLENDING_NONE"}function PN(s){const e=s.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function LN(s,e,t,i){const r=s.getContext(),n=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=wN(t),h=AN(t),c=CN(t),d=IN(t),u=PN(t),p=gN(t),m=yN(n),y=r.createProgram();let g,f,x=t.glslVersion?"#version "+t.glslVersion+`
|
|
3986
3986
|
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(jl).join(`
|
|
3987
3987
|
`),g.length>0&&(g+=`
|
|
3988
3988
|
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(jl).join(`
|
|
@@ -3991,7 +3991,7 @@ void main() {
|
|
|
3991
3991
|
`].filter(jl).join(`
|
|
3992
3992
|
`),f=[yv(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+c:"",t.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==rs?"#define TONE_MAPPING":"",t.toneMapping!==rs?ot.tonemapping_pars_fragment:"",t.toneMapping!==rs?mN("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ot.colorspace_pars_fragment,dN("linearToOutputTexel",t.outputColorSpace),fN(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
3993
3993
|
`].filter(jl).join(`
|
|
3994
|
-
`)),a=
|
|
3994
|
+
`)),a=Qm(a),a=mv(a,t),a=fv(a,t),o=Qm(o),o=mv(o,t),o=fv(o,t),a=gv(a),o=gv(o),t.isRawShaderMaterial!==!0&&(x=`#version 300 es
|
|
3995
3995
|
`,g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3996
3996
|
`)+`
|
|
3997
3997
|
`+g,f=["#define varying in",t.glslVersion===fc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===fc?"":"#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(`
|
|
@@ -4003,7 +4003,7 @@ Material Type: `+C.type+`
|
|
|
4003
4003
|
|
|
4004
4004
|
Program Info Log: `+B+`
|
|
4005
4005
|
`+oe+`
|
|
4006
|
-
`+be)}else B!==""?ge("WebGLProgram: Program Info Log:",B):(k===""||W==="")&&(ie=!1);ie&&(C.diagnostics={runnable:se,programLog:B,vertexShader:{log:k,prefix:g},fragmentShader:{log:W,prefix:f}})}r.deleteShader(w),r.deleteShader(T),_=new Cu(r,y),S=xN(r,y)}let _;this.getUniforms=function(){return _===void 0&&A(this),_};let S;this.getAttributes=function(){return S===void 0&&A(this),S};let P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=r.getProgramParameter(y,lN)),P},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=hN++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=w,this.fragmentShader=T,this}let DN=0;class ON{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),n=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(n)===!1&&(a.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new UN(e),t.set(e,i)),i}}class UN{constructor(e){this.id=DN++,this.code=e,this.usedTimes=0}}function FN(s,e,t,i,r,n){const a=new Ml,o=new ON,l=new Set,h=[],c=new Map,d=i.logarithmicDepthBuffer;let u=i.precision;const p={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 m(_){return l.add(_),_===0?"uv":`uv${_}`}function y(_,S,P,C,L){const U=C.fog,V=L.geometry,B=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?C.environment:null,k=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,W=e.get(_.envMap||B,k),se=W&&W.mapping===xn?W.image.height:null,ie=p[_.type];_.precision!==null&&(u=i.getMaxPrecision(_.precision),u!==_.precision&&ge("WebGLProgram.getParameters:",_.precision,"not supported, using",u,"instead."));const oe=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,be=oe!==void 0?oe.length:0;let Ce=0;V.morphAttributes.position!==void 0&&(Ce=1),V.morphAttributes.normal!==void 0&&(Ce=2),V.morphAttributes.color!==void 0&&(Ce=3);let tt,wt,Et,K;if(ie){const Mt=hs[ie];tt=Mt.vertexShader,wt=Mt.fragmentShader}else tt=_.vertexShader,wt=_.fragmentShader,o.update(_),Et=o.getVertexShaderID(_),K=o.getFragmentShaderID(_);const ae=s.getRenderTarget(),le=s.state.buffers.depth.getReversed(),Qe=L.isInstancedMesh===!0,Ye=L.isBatchedMesh===!0,Te=!!_.map,ct=!!_.matcap,Q=!!W,ee=!!_.aoMap,he=!!_.lightMap,_e=!!_.bumpMap,Se=!!_.normalMap,I=!!_.displacementMap,Ge=!!_.emissiveMap,We=!!_.metalnessMap,Je=!!_.roughnessMap,fe=_.anisotropy>0,N=_.clearcoat>0,b=_.dispersion>0,D=_.iridescence>0,Z=_.sheen>0,$=_.transmission>0,J=fe&&!!_.anisotropyMap,Oe=N&&!!_.clearcoatMap,pe=N&&!!_.clearcoatNormalMap,He=N&&!!_.clearcoatRoughnessMap,Be=D&&!!_.iridescenceMap,re=D&&!!_.iridescenceThicknessMap,ue=Z&&!!_.sheenColorMap,je=Z&&!!_.sheenRoughnessMap,Ue=!!_.specularMap,Ae=!!_.specularColorMap,ut=!!_.specularIntensityMap,O=$&&!!_.transmissionMap,me=$&&!!_.thicknessMap,ce=!!_.gradientMap,Le=!!_.alphaMap,ne=_.alphaTest>0,Y=!!_.alphaHash,De=!!_.extensions;let Ze=rs;_.toneMapped&&(ae===null||ae.isXRRenderTarget===!0)&&(Ze=s.toneMapping);const Qt={shaderID:ie,shaderType:_.type,shaderName:_.name,vertexShader:tt,fragmentShader:wt,defines:_.defines,customVertexShaderID:Et,customFragmentShaderID:K,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:u,batching:Ye,batchingColor:Ye&&L._colorsTexture!==null,instancing:Qe,instancingColor:Qe&&L.instanceColor!==null,instancingMorph:Qe&&L.morphTexture!==null,outputColorSpace:ae===null?s.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:kr,alphaToCoverage:!!_.alphaToCoverage,map:Te,matcap:ct,envMap:Q,envMapMode:Q&&W.mapping,envMapCubeUVHeight:se,aoMap:ee,lightMap:he,bumpMap:_e,normalMap:Se,displacementMap:I,emissiveMap:Ge,normalMapObjectSpace:Se&&_.normalMapType===_0,normalMapTangentSpace:Se&&_.normalMapType===Vr,metalnessMap:We,roughnessMap:Je,anisotropy:fe,anisotropyMap:J,clearcoat:N,clearcoatMap:Oe,clearcoatNormalMap:pe,clearcoatRoughnessMap:He,dispersion:b,iridescence:D,iridescenceMap:Be,iridescenceThicknessMap:re,sheen:Z,sheenColorMap:ue,sheenRoughnessMap:je,specularMap:Ue,specularColorMap:Ae,specularIntensityMap:ut,transmission:$,transmissionMap:O,thicknessMap:me,gradientMap:ce,opaque:_.transparent===!1&&_.blending===Or&&_.alphaToCoverage===!1,alphaMap:Le,alphaTest:ne,alphaHash:Y,combine:_.combine,mapUv:Te&&m(_.map.channel),aoMapUv:ee&&m(_.aoMap.channel),lightMapUv:he&&m(_.lightMap.channel),bumpMapUv:_e&&m(_.bumpMap.channel),normalMapUv:Se&&m(_.normalMap.channel),displacementMapUv:I&&m(_.displacementMap.channel),emissiveMapUv:Ge&&m(_.emissiveMap.channel),metalnessMapUv:We&&m(_.metalnessMap.channel),roughnessMapUv:Je&&m(_.roughnessMap.channel),anisotropyMapUv:J&&m(_.anisotropyMap.channel),clearcoatMapUv:Oe&&m(_.clearcoatMap.channel),clearcoatNormalMapUv:pe&&m(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:He&&m(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Be&&m(_.iridescenceMap.channel),iridescenceThicknessMapUv:re&&m(_.iridescenceThicknessMap.channel),sheenColorMapUv:ue&&m(_.sheenColorMap.channel),sheenRoughnessMapUv:je&&m(_.sheenRoughnessMap.channel),specularMapUv:Ue&&m(_.specularMap.channel),specularColorMapUv:Ae&&m(_.specularColorMap.channel),specularIntensityMapUv:ut&&m(_.specularIntensityMap.channel),transmissionMapUv:O&&m(_.transmissionMap.channel),thicknessMapUv:me&&m(_.thicknessMap.channel),alphaMapUv:Le&&m(_.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(Se||fe),vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!V.attributes.uv&&(Te||Le),fog:!!U,useFog:_.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||V.attributes.normal===void 0&&Se===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:le,skinning:L.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:be,morphTextureStride:Ce,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:n.numPlanes,numClipIntersection:n.numIntersection,dithering:_.dithering,shadowMapEnabled:s.shadowMap.enabled&&P.length>0,shadowMapType:s.shadowMap.type,toneMapping:Ze,decodeVideoTexture:Te&&_.map.isVideoTexture===!0&&mt.getTransfer(_.map.colorSpace)===vt,decodeVideoTextureEmissive:Ge&&_.emissiveMap.isVideoTexture===!0&&mt.getTransfer(_.emissiveMap.colorSpace)===vt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Ms,flipSided:_.side===yi,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:De&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(De&&_.extensions.multiDraw===!0||Ye)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Qt.vertexUv1s=l.has(1),Qt.vertexUv2s=l.has(2),Qt.vertexUv3s=l.has(3),l.clear(),Qt}function g(_){const S=[];if(_.shaderID?S.push(_.shaderID):(S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID)),_.defines!==void 0)for(const P in _.defines)S.push(P),S.push(_.defines[P]);return _.isRawShaderMaterial===!1&&(f(S,_),x(S,_),S.push(s.outputColorSpace)),S.push(_.customProgramCacheKey),S.join()}function f(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function x(_,S){a.disableAll(),S.instancing&&a.enable(0),S.instancingColor&&a.enable(1),S.instancingMorph&&a.enable(2),S.matcap&&a.enable(3),S.envMap&&a.enable(4),S.normalMapObjectSpace&&a.enable(5),S.normalMapTangentSpace&&a.enable(6),S.clearcoat&&a.enable(7),S.iridescence&&a.enable(8),S.alphaTest&&a.enable(9),S.vertexColors&&a.enable(10),S.vertexAlphas&&a.enable(11),S.vertexUv1s&&a.enable(12),S.vertexUv2s&&a.enable(13),S.vertexUv3s&&a.enable(14),S.vertexTangents&&a.enable(15),S.anisotropy&&a.enable(16),S.alphaHash&&a.enable(17),S.batching&&a.enable(18),S.dispersion&&a.enable(19),S.batchingColor&&a.enable(20),S.gradientMap&&a.enable(21),_.push(a.mask),a.disableAll(),S.fog&&a.enable(0),S.useFog&&a.enable(1),S.flatShading&&a.enable(2),S.logarithmicDepthBuffer&&a.enable(3),S.reversedDepthBuffer&&a.enable(4),S.skinning&&a.enable(5),S.morphTargets&&a.enable(6),S.morphNormals&&a.enable(7),S.morphColors&&a.enable(8),S.premultipliedAlpha&&a.enable(9),S.shadowMapEnabled&&a.enable(10),S.doubleSided&&a.enable(11),S.flipSided&&a.enable(12),S.useDepthPacking&&a.enable(13),S.dithering&&a.enable(14),S.transmission&&a.enable(15),S.sheen&&a.enable(16),S.opaque&&a.enable(17),S.pointsUvs&&a.enable(18),S.decodeVideoTexture&&a.enable(19),S.decodeVideoTextureEmissive&&a.enable(20),S.alphaToCoverage&&a.enable(21),_.push(a.mask)}function v(_){const S=p[_.type];let P;if(S){const C=hs[S];P=gm.clone(C.uniforms)}else P=_.uniforms;return P}function M(_,S){let P=c.get(S);return P!==void 0?++P.usedTimes:(P=new LN(s,S,_,r),h.push(P),c.set(S,P)),P}function w(_){if(--_.usedTimes===0){const S=h.indexOf(_);h[S]=h[h.length-1],h.pop(),c.delete(_.cacheKey),_.destroy()}}function T(_){o.remove(_)}function A(){o.dispose()}return{getParameters:y,getProgramCacheKey:g,getUniforms:v,acquireProgram:M,releaseProgram:w,releaseShaderCache:T,programs:h,dispose:A}}function zN(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function i(a){s.delete(a)}function r(a,o,l){s.get(a)[o]=l}function n(){s=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:n}}function BN(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function xv(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function vv(){const s=[];let e=0;const t=[],i=[],r=[];function n(){e=0,t.length=0,i.length=0,r.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,m,y,g,f){let x=s[e];return x===void 0?(x={id:u.id,object:u,geometry:p,material:m,materialVariant:a(u),groupOrder:y,renderOrder:u.renderOrder,z:g,group:f},s[e]=x):(x.id=u.id,x.object=u,x.geometry=p,x.material=m,x.materialVariant=a(u),x.groupOrder=y,x.renderOrder=u.renderOrder,x.z=g,x.group=f),e++,x}function l(u,p,m,y,g,f){const x=o(u,p,m,y,g,f);u.onBeforeRenderListPush?.(u,p,m,f),m.transmission>0?i.push(x):m.transparent===!0?r.push(x):t.push(x),u.onAfterRenderListPush?.(u,p,m,f)}function h(u,p,m,y,g,f){const x=o(u,p,m,y,g,f);m.transmission>0?i.unshift(x):m.transparent===!0?r.unshift(x):t.unshift(x)}function c(u,p){t.length>1&&t.sort(u||BN),i.length>1&&i.sort(p||xv),r.length>1&&r.sort(p||xv)}function d(){for(let u=e,p=s.length;u<p;u++){const m=s[u];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:r,init:n,push:l,unshift:h,finish:d,sort:c}}function VN(){let s=new WeakMap;function e(i,r){const n=s.get(i);let a;return n===void 0?(a=new vv,s.set(i,[a])):r>=n.length?(a=new vv,n.push(a)):a=n[r],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function kN(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new we};break;case"SpotLight":t={position:new R,direction:new R,color:new we,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new we,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new we,groundColor:new we};break;case"RectAreaLight":t={color:new we,position:new R,halfWidth:new R,halfHeight:new R};break}return s[e.id]=t,t}}}function GN(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let HN=0;function WN(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function jN(s){const e=new kN,t=GN(),i={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 h=0;h<9;h++)i.probe.push(new R);const r=new R,n=new et,a=new et;function o(h){let c=0,d=0,u=0;for(let S=0;S<9;S++)i.probe[S].set(0,0,0);let p=0,m=0,y=0,g=0,f=0,x=0,v=0,M=0,w=0,T=0,A=0;h.sort(WN);for(let S=0,P=h.length;S<P;S++){const C=h[S],L=C.color,U=C.intensity,V=C.distance;let B=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Br?B=C.shadow.map.texture:B=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)c+=L.r*U,d+=L.g*U,u+=L.b*U;else if(C.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(C.sh.coefficients[k],U);A++}else if(C.isDirectionalLight){const k=e.get(C);if(k.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const W=C.shadow,se=t.get(C);se.shadowIntensity=W.intensity,se.shadowBias=W.bias,se.shadowNormalBias=W.normalBias,se.shadowRadius=W.radius,se.shadowMapSize=W.mapSize,i.directionalShadow[p]=se,i.directionalShadowMap[p]=B,i.directionalShadowMatrix[p]=C.shadow.matrix,x++}i.directional[p]=k,p++}else if(C.isSpotLight){const k=e.get(C);k.position.setFromMatrixPosition(C.matrixWorld),k.color.copy(L).multiplyScalar(U),k.distance=V,k.coneCos=Math.cos(C.angle),k.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),k.decay=C.decay,i.spot[y]=k;const W=C.shadow;if(C.map&&(i.spotLightMap[w]=C.map,w++,W.updateMatrices(C),C.castShadow&&T++),i.spotLightMatrix[y]=W.matrix,C.castShadow){const se=t.get(C);se.shadowIntensity=W.intensity,se.shadowBias=W.bias,se.shadowNormalBias=W.normalBias,se.shadowRadius=W.radius,se.shadowMapSize=W.mapSize,i.spotShadow[y]=se,i.spotShadowMap[y]=B,M++}y++}else if(C.isRectAreaLight){const k=e.get(C);k.color.copy(L).multiplyScalar(U),k.halfWidth.set(C.width*.5,0,0),k.halfHeight.set(0,C.height*.5,0),i.rectArea[g]=k,g++}else if(C.isPointLight){const k=e.get(C);if(k.color.copy(C.color).multiplyScalar(C.intensity),k.distance=C.distance,k.decay=C.decay,C.castShadow){const W=C.shadow,se=t.get(C);se.shadowIntensity=W.intensity,se.shadowBias=W.bias,se.shadowNormalBias=W.normalBias,se.shadowRadius=W.radius,se.shadowMapSize=W.mapSize,se.shadowCameraNear=W.camera.near,se.shadowCameraFar=W.camera.far,i.pointShadow[m]=se,i.pointShadowMap[m]=B,i.pointShadowMatrix[m]=C.shadow.matrix,v++}i.point[m]=k,m++}else if(C.isHemisphereLight){const k=e.get(C);k.skyColor.copy(C.color).multiplyScalar(U),k.groundColor.copy(C.groundColor).multiplyScalar(U),i.hemi[f]=k,f++}}g>0&&(s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ye.LTC_FLOAT_1,i.rectAreaLTC2=ye.LTC_FLOAT_2):(i.rectAreaLTC1=ye.LTC_HALF_1,i.rectAreaLTC2=ye.LTC_HALF_2)),i.ambient[0]=c,i.ambient[1]=d,i.ambient[2]=u;const _=i.hash;(_.directionalLength!==p||_.pointLength!==m||_.spotLength!==y||_.rectAreaLength!==g||_.hemiLength!==f||_.numDirectionalShadows!==x||_.numPointShadows!==v||_.numSpotShadows!==M||_.numSpotMaps!==w||_.numLightProbes!==A)&&(i.directional.length=p,i.spot.length=y,i.rectArea.length=g,i.point.length=m,i.hemi.length=f,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=v,i.pointShadowMap.length=v,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=v,i.spotLightMatrix.length=M+w-T,i.spotLightMap.length=w,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=A,_.directionalLength=p,_.pointLength=m,_.spotLength=y,_.rectAreaLength=g,_.hemiLength=f,_.numDirectionalShadows=x,_.numPointShadows=v,_.numSpotShadows=M,_.numSpotMaps=w,_.numLightProbes=A,i.version=HN++)}function l(h,c){let d=0,u=0,p=0,m=0,y=0;const g=c.matrixWorldInverse;for(let f=0,x=h.length;f<x;f++){const v=h[f];if(v.isDirectionalLight){const M=i.directional[d];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),d++}else if(v.isSpotLight){const M=i.spot[p];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),p++}else if(v.isRectAreaLight){const M=i.rectArea[m];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),a.identity(),n.copy(v.matrixWorld),n.premultiply(g),a.extractRotation(n),M.halfWidth.set(v.width*.5,0,0),M.halfHeight.set(0,v.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),m++}else if(v.isPointLight){const M=i.point[u];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),u++}else if(v.isHemisphereLight){const M=i.hemi[y];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(g),y++}}}return{setup:o,setupView:l,state:i}}function _v(s){const e=new jN(s),t=[],i=[];function r(c){h.camera=c,t.length=0,i.length=0}function n(c){t.push(c)}function a(c){i.push(c)}function o(){e.setup(t)}function l(c){e.setupView(t,c)}const h={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:h,setupLights:o,setupLightsView:l,pushLight:n,pushShadow:a}}function XN(s){let e=new WeakMap;function t(r,n=0){const a=e.get(r);let o;return a===void 0?(o=new _v(s),e.set(r,[o])):n>=a.length?(o=new _v(s),a.push(o)):o=a[n],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const qN=`void main() {
|
|
4006
|
+
`+be)}else B!==""?ge("WebGLProgram: Program Info Log:",B):(k===""||W==="")&&(ie=!1);ie&&(C.diagnostics={runnable:se,programLog:B,vertexShader:{log:k,prefix:g},fragmentShader:{log:W,prefix:f}})}r.deleteShader(w),r.deleteShader(T),_=new Cu(r,y),S=xN(r,y)}let _;this.getUniforms=function(){return _===void 0&&A(this),_};let S;this.getAttributes=function(){return S===void 0&&A(this),S};let P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=r.getProgramParameter(y,lN)),P},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=hN++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=w,this.fragmentShader=T,this}let DN=0;class ON{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),n=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(n)===!1&&(a.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new UN(e),t.set(e,i)),i}}class UN{constructor(e){this.id=DN++,this.code=e,this.usedTimes=0}}function FN(s,e,t,i,r,n){const a=new Ml,o=new ON,l=new Set,h=[],c=new Map,d=i.logarithmicDepthBuffer;let u=i.precision;const p={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 m(_){return l.add(_),_===0?"uv":`uv${_}`}function y(_,S,P,C,L){const U=C.fog,V=L.geometry,B=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?C.environment:null,k=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,W=e.get(_.envMap||B,k),se=W&&W.mapping===xn?W.image.height:null,ie=p[_.type];_.precision!==null&&(u=i.getMaxPrecision(_.precision),u!==_.precision&&ge("WebGLProgram.getParameters:",_.precision,"not supported, using",u,"instead."));const oe=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,be=oe!==void 0?oe.length:0;let Ce=0;V.morphAttributes.position!==void 0&&(Ce=1),V.morphAttributes.normal!==void 0&&(Ce=2),V.morphAttributes.color!==void 0&&(Ce=3);let tt,wt,Et,K;if(ie){const Mt=hs[ie];tt=Mt.vertexShader,wt=Mt.fragmentShader}else tt=_.vertexShader,wt=_.fragmentShader,o.update(_),Et=o.getVertexShaderID(_),K=o.getFragmentShaderID(_);const ae=s.getRenderTarget(),le=s.state.buffers.depth.getReversed(),Qe=L.isInstancedMesh===!0,Ye=L.isBatchedMesh===!0,Te=!!_.map,ct=!!_.matcap,Q=!!W,ee=!!_.aoMap,he=!!_.lightMap,_e=!!_.bumpMap,Se=!!_.normalMap,I=!!_.displacementMap,Ge=!!_.emissiveMap,We=!!_.metalnessMap,Je=!!_.roughnessMap,fe=_.anisotropy>0,N=_.clearcoat>0,b=_.dispersion>0,D=_.iridescence>0,Z=_.sheen>0,$=_.transmission>0,J=fe&&!!_.anisotropyMap,Oe=N&&!!_.clearcoatMap,pe=N&&!!_.clearcoatNormalMap,He=N&&!!_.clearcoatRoughnessMap,Be=D&&!!_.iridescenceMap,re=D&&!!_.iridescenceThicknessMap,ue=Z&&!!_.sheenColorMap,je=Z&&!!_.sheenRoughnessMap,Ue=!!_.specularMap,Ae=!!_.specularColorMap,ut=!!_.specularIntensityMap,O=$&&!!_.transmissionMap,me=$&&!!_.thicknessMap,ce=!!_.gradientMap,Le=!!_.alphaMap,ne=_.alphaTest>0,Y=!!_.alphaHash,De=!!_.extensions;let Ze=rs;_.toneMapped&&(ae===null||ae.isXRRenderTarget===!0)&&(Ze=s.toneMapping);const Qt={shaderID:ie,shaderType:_.type,shaderName:_.name,vertexShader:tt,fragmentShader:wt,defines:_.defines,customVertexShaderID:Et,customFragmentShaderID:K,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:u,batching:Ye,batchingColor:Ye&&L._colorsTexture!==null,instancing:Qe,instancingColor:Qe&&L.instanceColor!==null,instancingMorph:Qe&&L.morphTexture!==null,outputColorSpace:ae===null?s.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:kr,alphaToCoverage:!!_.alphaToCoverage,map:Te,matcap:ct,envMap:Q,envMapMode:Q&&W.mapping,envMapCubeUVHeight:se,aoMap:ee,lightMap:he,bumpMap:_e,normalMap:Se,displacementMap:I,emissiveMap:Ge,normalMapObjectSpace:Se&&_.normalMapType===_0,normalMapTangentSpace:Se&&_.normalMapType===Vr,metalnessMap:We,roughnessMap:Je,anisotropy:fe,anisotropyMap:J,clearcoat:N,clearcoatMap:Oe,clearcoatNormalMap:pe,clearcoatRoughnessMap:He,dispersion:b,iridescence:D,iridescenceMap:Be,iridescenceThicknessMap:re,sheen:Z,sheenColorMap:ue,sheenRoughnessMap:je,specularMap:Ue,specularColorMap:Ae,specularIntensityMap:ut,transmission:$,transmissionMap:O,thicknessMap:me,gradientMap:ce,opaque:_.transparent===!1&&_.blending===Or&&_.alphaToCoverage===!1,alphaMap:Le,alphaTest:ne,alphaHash:Y,combine:_.combine,mapUv:Te&&m(_.map.channel),aoMapUv:ee&&m(_.aoMap.channel),lightMapUv:he&&m(_.lightMap.channel),bumpMapUv:_e&&m(_.bumpMap.channel),normalMapUv:Se&&m(_.normalMap.channel),displacementMapUv:I&&m(_.displacementMap.channel),emissiveMapUv:Ge&&m(_.emissiveMap.channel),metalnessMapUv:We&&m(_.metalnessMap.channel),roughnessMapUv:Je&&m(_.roughnessMap.channel),anisotropyMapUv:J&&m(_.anisotropyMap.channel),clearcoatMapUv:Oe&&m(_.clearcoatMap.channel),clearcoatNormalMapUv:pe&&m(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:He&&m(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Be&&m(_.iridescenceMap.channel),iridescenceThicknessMapUv:re&&m(_.iridescenceThicknessMap.channel),sheenColorMapUv:ue&&m(_.sheenColorMap.channel),sheenRoughnessMapUv:je&&m(_.sheenRoughnessMap.channel),specularMapUv:Ue&&m(_.specularMap.channel),specularColorMapUv:Ae&&m(_.specularColorMap.channel),specularIntensityMapUv:ut&&m(_.specularIntensityMap.channel),transmissionMapUv:O&&m(_.transmissionMap.channel),thicknessMapUv:me&&m(_.thicknessMap.channel),alphaMapUv:Le&&m(_.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(Se||fe),vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!V.attributes.uv&&(Te||Le),fog:!!U,useFog:_.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||V.attributes.normal===void 0&&Se===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:le,skinning:L.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:be,morphTextureStride:Ce,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:n.numPlanes,numClipIntersection:n.numIntersection,dithering:_.dithering,shadowMapEnabled:s.shadowMap.enabled&&P.length>0,shadowMapType:s.shadowMap.type,toneMapping:Ze,decodeVideoTexture:Te&&_.map.isVideoTexture===!0&&mt.getTransfer(_.map.colorSpace)===vt,decodeVideoTextureEmissive:Ge&&_.emissiveMap.isVideoTexture===!0&&mt.getTransfer(_.emissiveMap.colorSpace)===vt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Ms,flipSided:_.side===yi,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:De&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(De&&_.extensions.multiDraw===!0||Ye)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Qt.vertexUv1s=l.has(1),Qt.vertexUv2s=l.has(2),Qt.vertexUv3s=l.has(3),l.clear(),Qt}function g(_){const S=[];if(_.shaderID?S.push(_.shaderID):(S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID)),_.defines!==void 0)for(const P in _.defines)S.push(P),S.push(_.defines[P]);return _.isRawShaderMaterial===!1&&(f(S,_),x(S,_),S.push(s.outputColorSpace)),S.push(_.customProgramCacheKey),S.join()}function f(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function x(_,S){a.disableAll(),S.instancing&&a.enable(0),S.instancingColor&&a.enable(1),S.instancingMorph&&a.enable(2),S.matcap&&a.enable(3),S.envMap&&a.enable(4),S.normalMapObjectSpace&&a.enable(5),S.normalMapTangentSpace&&a.enable(6),S.clearcoat&&a.enable(7),S.iridescence&&a.enable(8),S.alphaTest&&a.enable(9),S.vertexColors&&a.enable(10),S.vertexAlphas&&a.enable(11),S.vertexUv1s&&a.enable(12),S.vertexUv2s&&a.enable(13),S.vertexUv3s&&a.enable(14),S.vertexTangents&&a.enable(15),S.anisotropy&&a.enable(16),S.alphaHash&&a.enable(17),S.batching&&a.enable(18),S.dispersion&&a.enable(19),S.batchingColor&&a.enable(20),S.gradientMap&&a.enable(21),_.push(a.mask),a.disableAll(),S.fog&&a.enable(0),S.useFog&&a.enable(1),S.flatShading&&a.enable(2),S.logarithmicDepthBuffer&&a.enable(3),S.reversedDepthBuffer&&a.enable(4),S.skinning&&a.enable(5),S.morphTargets&&a.enable(6),S.morphNormals&&a.enable(7),S.morphColors&&a.enable(8),S.premultipliedAlpha&&a.enable(9),S.shadowMapEnabled&&a.enable(10),S.doubleSided&&a.enable(11),S.flipSided&&a.enable(12),S.useDepthPacking&&a.enable(13),S.dithering&&a.enable(14),S.transmission&&a.enable(15),S.sheen&&a.enable(16),S.opaque&&a.enable(17),S.pointsUvs&&a.enable(18),S.decodeVideoTexture&&a.enable(19),S.decodeVideoTextureEmissive&&a.enable(20),S.alphaToCoverage&&a.enable(21),_.push(a.mask)}function v(_){const S=p[_.type];let P;if(S){const C=hs[S];P=fm.clone(C.uniforms)}else P=_.uniforms;return P}function M(_,S){let P=c.get(S);return P!==void 0?++P.usedTimes:(P=new LN(s,S,_,r),h.push(P),c.set(S,P)),P}function w(_){if(--_.usedTimes===0){const S=h.indexOf(_);h[S]=h[h.length-1],h.pop(),c.delete(_.cacheKey),_.destroy()}}function T(_){o.remove(_)}function A(){o.dispose()}return{getParameters:y,getProgramCacheKey:g,getUniforms:v,acquireProgram:M,releaseProgram:w,releaseShaderCache:T,programs:h,dispose:A}}function zN(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function i(a){s.delete(a)}function r(a,o,l){s.get(a)[o]=l}function n(){s=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:n}}function BN(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function xv(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function vv(){const s=[];let e=0;const t=[],i=[],r=[];function n(){e=0,t.length=0,i.length=0,r.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,m,y,g,f){let x=s[e];return x===void 0?(x={id:u.id,object:u,geometry:p,material:m,materialVariant:a(u),groupOrder:y,renderOrder:u.renderOrder,z:g,group:f},s[e]=x):(x.id=u.id,x.object=u,x.geometry=p,x.material=m,x.materialVariant=a(u),x.groupOrder=y,x.renderOrder=u.renderOrder,x.z=g,x.group=f),e++,x}function l(u,p,m,y,g,f){const x=o(u,p,m,y,g,f);u.onBeforeRenderListPush?.(u,p,m,f),m.transmission>0?i.push(x):m.transparent===!0?r.push(x):t.push(x),u.onAfterRenderListPush?.(u,p,m,f)}function h(u,p,m,y,g,f){const x=o(u,p,m,y,g,f);m.transmission>0?i.unshift(x):m.transparent===!0?r.unshift(x):t.unshift(x)}function c(u,p){t.length>1&&t.sort(u||BN),i.length>1&&i.sort(p||xv),r.length>1&&r.sort(p||xv)}function d(){for(let u=e,p=s.length;u<p;u++){const m=s[u];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:r,init:n,push:l,unshift:h,finish:d,sort:c}}function VN(){let s=new WeakMap;function e(i,r){const n=s.get(i);let a;return n===void 0?(a=new vv,s.set(i,[a])):r>=n.length?(a=new vv,n.push(a)):a=n[r],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function kN(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new we};break;case"SpotLight":t={position:new R,direction:new R,color:new we,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new we,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new we,groundColor:new we};break;case"RectAreaLight":t={color:new we,position:new R,halfWidth:new R,halfHeight:new R};break}return s[e.id]=t,t}}}function GN(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let HN=0;function WN(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function jN(s){const e=new kN,t=GN(),i={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 h=0;h<9;h++)i.probe.push(new R);const r=new R,n=new et,a=new et;function o(h){let c=0,d=0,u=0;for(let S=0;S<9;S++)i.probe[S].set(0,0,0);let p=0,m=0,y=0,g=0,f=0,x=0,v=0,M=0,w=0,T=0,A=0;h.sort(WN);for(let S=0,P=h.length;S<P;S++){const C=h[S],L=C.color,U=C.intensity,V=C.distance;let B=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Br?B=C.shadow.map.texture:B=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)c+=L.r*U,d+=L.g*U,u+=L.b*U;else if(C.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(C.sh.coefficients[k],U);A++}else if(C.isDirectionalLight){const k=e.get(C);if(k.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const W=C.shadow,se=t.get(C);se.shadowIntensity=W.intensity,se.shadowBias=W.bias,se.shadowNormalBias=W.normalBias,se.shadowRadius=W.radius,se.shadowMapSize=W.mapSize,i.directionalShadow[p]=se,i.directionalShadowMap[p]=B,i.directionalShadowMatrix[p]=C.shadow.matrix,x++}i.directional[p]=k,p++}else if(C.isSpotLight){const k=e.get(C);k.position.setFromMatrixPosition(C.matrixWorld),k.color.copy(L).multiplyScalar(U),k.distance=V,k.coneCos=Math.cos(C.angle),k.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),k.decay=C.decay,i.spot[y]=k;const W=C.shadow;if(C.map&&(i.spotLightMap[w]=C.map,w++,W.updateMatrices(C),C.castShadow&&T++),i.spotLightMatrix[y]=W.matrix,C.castShadow){const se=t.get(C);se.shadowIntensity=W.intensity,se.shadowBias=W.bias,se.shadowNormalBias=W.normalBias,se.shadowRadius=W.radius,se.shadowMapSize=W.mapSize,i.spotShadow[y]=se,i.spotShadowMap[y]=B,M++}y++}else if(C.isRectAreaLight){const k=e.get(C);k.color.copy(L).multiplyScalar(U),k.halfWidth.set(C.width*.5,0,0),k.halfHeight.set(0,C.height*.5,0),i.rectArea[g]=k,g++}else if(C.isPointLight){const k=e.get(C);if(k.color.copy(C.color).multiplyScalar(C.intensity),k.distance=C.distance,k.decay=C.decay,C.castShadow){const W=C.shadow,se=t.get(C);se.shadowIntensity=W.intensity,se.shadowBias=W.bias,se.shadowNormalBias=W.normalBias,se.shadowRadius=W.radius,se.shadowMapSize=W.mapSize,se.shadowCameraNear=W.camera.near,se.shadowCameraFar=W.camera.far,i.pointShadow[m]=se,i.pointShadowMap[m]=B,i.pointShadowMatrix[m]=C.shadow.matrix,v++}i.point[m]=k,m++}else if(C.isHemisphereLight){const k=e.get(C);k.skyColor.copy(C.color).multiplyScalar(U),k.groundColor.copy(C.groundColor).multiplyScalar(U),i.hemi[f]=k,f++}}g>0&&(s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ye.LTC_FLOAT_1,i.rectAreaLTC2=ye.LTC_FLOAT_2):(i.rectAreaLTC1=ye.LTC_HALF_1,i.rectAreaLTC2=ye.LTC_HALF_2)),i.ambient[0]=c,i.ambient[1]=d,i.ambient[2]=u;const _=i.hash;(_.directionalLength!==p||_.pointLength!==m||_.spotLength!==y||_.rectAreaLength!==g||_.hemiLength!==f||_.numDirectionalShadows!==x||_.numPointShadows!==v||_.numSpotShadows!==M||_.numSpotMaps!==w||_.numLightProbes!==A)&&(i.directional.length=p,i.spot.length=y,i.rectArea.length=g,i.point.length=m,i.hemi.length=f,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=v,i.pointShadowMap.length=v,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=v,i.spotLightMatrix.length=M+w-T,i.spotLightMap.length=w,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=A,_.directionalLength=p,_.pointLength=m,_.spotLength=y,_.rectAreaLength=g,_.hemiLength=f,_.numDirectionalShadows=x,_.numPointShadows=v,_.numSpotShadows=M,_.numSpotMaps=w,_.numLightProbes=A,i.version=HN++)}function l(h,c){let d=0,u=0,p=0,m=0,y=0;const g=c.matrixWorldInverse;for(let f=0,x=h.length;f<x;f++){const v=h[f];if(v.isDirectionalLight){const M=i.directional[d];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),d++}else if(v.isSpotLight){const M=i.spot[p];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),p++}else if(v.isRectAreaLight){const M=i.rectArea[m];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),a.identity(),n.copy(v.matrixWorld),n.premultiply(g),a.extractRotation(n),M.halfWidth.set(v.width*.5,0,0),M.halfHeight.set(0,v.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),m++}else if(v.isPointLight){const M=i.point[u];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(g),u++}else if(v.isHemisphereLight){const M=i.hemi[y];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(g),y++}}}return{setup:o,setupView:l,state:i}}function _v(s){const e=new jN(s),t=[],i=[];function r(c){h.camera=c,t.length=0,i.length=0}function n(c){t.push(c)}function a(c){i.push(c)}function o(){e.setup(t)}function l(c){e.setupView(t,c)}const h={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:h,setupLights:o,setupLightsView:l,pushLight:n,pushShadow:a}}function XN(s){let e=new WeakMap;function t(r,n=0){const a=e.get(r);let o;return a===void 0?(o=new _v(s),e.set(r,[o])):n>=a.length?(o=new _v(s),a.push(o)):o=a[n],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const qN=`void main() {
|
|
4007
4007
|
gl_Position = vec4( position, 1.0 );
|
|
4008
4008
|
}`,YN=`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
|
-
}`,ZN=[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)],JN=[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)],Mv=new et,Xl=new R,tf=new R;function KN(s,e,t){let i=new Pn;const r=new te,n=new te,a=new It,o=new cu,l=new Mm,h={},c=t.maxTextureSize,d={[Vs]:yi,[yi]:Vs,[Ms]:Ms},u=new $i({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:qN,fragmentShader:YN}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new rt;m.setAttribute("position",new bt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Xt(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Oo;let f=this.type;this.render=function(T,A,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;this.type===Zd&&(ge("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Oo);const S=s.getRenderTarget(),P=s.getActiveCubeFace(),C=s.getActiveMipmapLevel(),L=s.state;L.setBlending(bs),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=f!==this.type;U&&A.traverse(function(V){V.material&&(Array.isArray(V.material)?V.material.forEach(B=>B.needsUpdate=!0):V.material.needsUpdate=!0)});for(let V=0,B=T.length;V<B;V++){const k=T[V],W=k.shadow;if(W===void 0){ge("WebGLShadowMap:",k,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;r.copy(W.mapSize);const se=W.getFrameExtents();r.multiply(se),n.copy(W.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(n.x=Math.floor(c/se.x),r.x=n.x*se.x,W.mapSize.x=n.x),r.y>c&&(n.y=Math.floor(c/se.y),r.y=n.y*se.y,W.mapSize.y=n.y));const ie=s.state.buffers.depth.getReversed();if(W.camera._reversedDepth=ie,W.map===null||U===!0){if(W.map!==null&&(W.map.depthTexture!==null&&(W.map.depthTexture.dispose(),W.map.depthTexture=null),W.map.dispose()),this.type===ha){if(k.isPointLight){ge("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}W.map=new Bi(r.x,r.y,{format:Br,type:Ts,minFilter:Rt,magFilter:Rt,generateMipmaps:!1}),W.map.texture.name=k.name+".shadowMap",W.map.depthTexture=new On(r.x,r.y,xi),W.map.depthTexture.name=k.name+".shadowMapDepth",W.map.depthTexture.format=ws,W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Ht,W.map.depthTexture.magFilter=Ht}else k.isPointLight?(W.map=new Au(r.x),W.map.depthTexture=new Ly(r.x,qi)):(W.map=new Bi(r.x,r.y),W.map.depthTexture=new On(r.x,r.y,qi)),W.map.depthTexture.name=k.name+".shadowMap",W.map.depthTexture.format=ws,this.type===Oo?(W.map.depthTexture.compareFunction=ie?mc:pc,W.map.depthTexture.minFilter=Rt,W.map.depthTexture.magFilter=Rt):(W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Ht,W.map.depthTexture.magFilter=Ht);W.camera.updateProjectionMatrix()}const oe=W.map.isWebGLCubeRenderTarget?6:1;for(let be=0;be<oe;be++){if(W.map.isWebGLCubeRenderTarget)s.setRenderTarget(W.map,be),s.clear();else{be===0&&(s.setRenderTarget(W.map),s.clear());const Ce=W.getViewport(be);a.set(n.x*Ce.x,n.y*Ce.y,n.x*Ce.z,n.y*Ce.w),L.viewport(a)}if(k.isPointLight){const Ce=W.camera,tt=W.matrix,wt=k.distance||Ce.far;wt!==Ce.far&&(Ce.far=wt,Ce.updateProjectionMatrix()),Xl.setFromMatrixPosition(k.matrixWorld),Ce.position.copy(Xl),tf.copy(Ce.position),tf.add(ZN[be]),Ce.up.copy(JN[be]),Ce.lookAt(tf),Ce.updateMatrixWorld(),tt.makeTranslation(-Xl.x,-Xl.y,-Xl.z),Mv.multiplyMatrices(Ce.projectionMatrix,Ce.matrixWorldInverse),W._frustum.setFromProjectionMatrix(Mv,Ce.coordinateSystem,Ce.reversedDepth)}else W.updateMatrices(k);i=W.getFrustum(),M(A,_,W.camera,k,this.type)}W.isPointLightShadow!==!0&&this.type===ha&&x(W,_),W.needsUpdate=!1}f=this.type,g.needsUpdate=!1,s.setRenderTarget(S,P,C)};function x(T,A){const _=e.update(y);u.defines.VSM_SAMPLES!==T.blurSamples&&(u.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Bi(r.x,r.y,{format:Br,type:Ts})),u.uniforms.shadow_pass.value=T.map.depthTexture,u.uniforms.resolution.value=T.mapSize,u.uniforms.radius.value=T.radius,s.setRenderTarget(T.mapPass),s.clear(),s.renderBufferDirect(A,null,_,u,y,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,s.setRenderTarget(T.map),s.clear(),s.renderBufferDirect(A,null,_,p,y,null)}function v(T,A,_,S){let P=null;const C=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(C!==void 0)P=C;else if(P=_.isPointLight===!0?l:o,s.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const L=P.uuid,U=A.uuid;let V=h[L];V===void 0&&(V={},h[L]=V);let B=V[U];B===void 0&&(B=P.clone(),V[U]=B,A.addEventListener("dispose",w)),P=B}if(P.visible=A.visible,P.wireframe=A.wireframe,S===ha?P.side=A.shadowSide!==null?A.shadowSide:A.side:P.side=A.shadowSide!==null?A.shadowSide:d[A.side],P.alphaMap=A.alphaMap,P.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,P.map=A.map,P.clipShadows=A.clipShadows,P.clippingPlanes=A.clippingPlanes,P.clipIntersection=A.clipIntersection,P.displacementMap=A.displacementMap,P.displacementScale=A.displacementScale,P.displacementBias=A.displacementBias,P.wireframeLinewidth=A.wireframeLinewidth,P.linewidth=A.linewidth,_.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const L=s.properties.get(P);L.light=_}return P}function M(T,A,_,S,P){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&P===ha)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);const L=e.update(T),U=T.material;if(Array.isArray(U)){const V=L.groups;for(let B=0,k=V.length;B<k;B++){const W=V[B],se=U[W.materialIndex];if(se&&se.visible){const ie=v(T,se,S,P);T.onBeforeShadow(s,T,A,_,L,ie,W),s.renderBufferDirect(_,null,L,ie,T,W),T.onAfterShadow(s,T,A,_,L,ie,W)}}}else if(U.visible){const V=v(T,U,S,P);T.onBeforeShadow(s,T,A,_,L,V,null),s.renderBufferDirect(_,null,L,V,T,null),T.onAfterShadow(s,T,A,_,L,V,null)}}const C=T.children;for(let L=0,U=C.length;L<U;L++)M(C[L],A,_,S,P)}function w(T){T.target.removeEventListener("dispose",w);for(const A in h){const _=h[A],S=T.target.uuid;S in _&&(_[S].dispose(),delete _[S])}}}function $N(s,e){function t(){let O=!1;const me=new It;let ce=null;const Le=new It(0,0,0,0);return{setMask:function(ne){ce!==ne&&!O&&(s.colorMask(ne,ne,ne,ne),ce=ne)},setLocked:function(ne){O=ne},setClear:function(ne,Y,De,Ze,Qt){Qt===!0&&(ne*=Ze,Y*=Ze,De*=Ze),me.set(ne,Y,De,Ze),Le.equals(me)===!1&&(s.clearColor(ne,Y,De,Ze),Le.copy(me))},reset:function(){O=!1,ce=null,Le.set(-1,0,0,0)}}}function i(){let O=!1,me=!1,ce=null,Le=null,ne=null;return{setReversed:function(Y){if(me!==Y){const De=e.get("EXT_clip_control");Y?De.clipControlEXT(De.LOWER_LEFT_EXT,De.ZERO_TO_ONE_EXT):De.clipControlEXT(De.LOWER_LEFT_EXT,De.NEGATIVE_ONE_TO_ONE_EXT),me=Y;const Ze=ne;ne=null,this.setClear(Ze)}},getReversed:function(){return me},setTest:function(Y){Y?ae(s.DEPTH_TEST):le(s.DEPTH_TEST)},setMask:function(Y){ce!==Y&&!O&&(s.depthMask(Y),ce=Y)},setFunc:function(Y){if(me&&(Y=kM[Y]),Le!==Y){switch(Y){case Uo:s.depthFunc(s.NEVER);break;case Fo:s.depthFunc(s.ALWAYS);break;case zo:s.depthFunc(s.LESS);break;case Fr:s.depthFunc(s.LEQUAL);break;case Bo:s.depthFunc(s.EQUAL);break;case Vo:s.depthFunc(s.GEQUAL);break;case ko:s.depthFunc(s.GREATER);break;case Go:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Le=Y}},setLocked:function(Y){O=Y},setClear:function(Y){ne!==Y&&(ne=Y,me&&(Y=1-Y),s.clearDepth(Y))},reset:function(){O=!1,ce=null,Le=null,ne=null,me=!1}}}function r(){let O=!1,me=null,ce=null,Le=null,ne=null,Y=null,De=null,Ze=null,Qt=null;return{setTest:function(Mt){O||(Mt?ae(s.STENCIL_TEST):le(s.STENCIL_TEST))},setMask:function(Mt){me!==Mt&&!O&&(s.stencilMask(Mt),me=Mt)},setFunc:function(Mt,hr,cr){(ce!==Mt||Le!==hr||ne!==cr)&&(s.stencilFunc(Mt,hr,cr),ce=Mt,Le=hr,ne=cr)},setOp:function(Mt,hr,cr){(Y!==Mt||De!==hr||Ze!==cr)&&(s.stencilOp(Mt,hr,cr),Y=Mt,De=hr,Ze=cr)},setLocked:function(Mt){O=Mt},setClear:function(Mt){Qt!==Mt&&(s.clearStencil(Mt),Qt=Mt)},reset:function(){O=!1,me=null,ce=null,Le=null,ne=null,Y=null,De=null,Ze=null,Qt=null}}}const n=new t,a=new i,o=new r,l=new WeakMap,h=new WeakMap;let c={},d={},u=new WeakMap,p=[],m=null,y=!1,g=null,f=null,x=null,v=null,M=null,w=null,T=null,A=new we(0,0,0),_=0,S=!1,P=null,C=null,L=null,U=null,V=null;const B=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,W=0;const se=s.getParameter(s.VERSION);se.indexOf("WebGL")!==-1?(W=parseFloat(/^WebGL (\d)/.exec(se)[1]),k=W>=1):se.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),k=W>=2);let ie=null,oe={};const be=s.getParameter(s.SCISSOR_BOX),Ce=s.getParameter(s.VIEWPORT),tt=new It().fromArray(be),wt=new It().fromArray(Ce);function Et(O,me,ce,Le){const ne=new Uint8Array(4),Y=s.createTexture();s.bindTexture(O,Y),s.texParameteri(O,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(O,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let De=0;De<ce;De++)O===s.TEXTURE_3D||O===s.TEXTURE_2D_ARRAY?s.texImage3D(me,0,s.RGBA,1,1,Le,0,s.RGBA,s.UNSIGNED_BYTE,ne):s.texImage2D(me+De,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ne);return Y}const K={};K[s.TEXTURE_2D]=Et(s.TEXTURE_2D,s.TEXTURE_2D,1),K[s.TEXTURE_CUBE_MAP]=Et(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),K[s.TEXTURE_2D_ARRAY]=Et(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),K[s.TEXTURE_3D]=Et(s.TEXTURE_3D,s.TEXTURE_3D,1,1),n.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ae(s.DEPTH_TEST),a.setFunc(Fr),_e(!1),Se(Yd),ae(s.CULL_FACE),ee(bs);function ae(O){c[O]!==!0&&(s.enable(O),c[O]=!0)}function le(O){c[O]!==!1&&(s.disable(O),c[O]=!1)}function Qe(O,me){return d[O]!==me?(s.bindFramebuffer(O,me),d[O]=me,O===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=me),O===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=me),!0):!1}function Ye(O,me){let ce=p,Le=!1;if(O){ce=u.get(me),ce===void 0&&(ce=[],u.set(me,ce));const ne=O.textures;if(ce.length!==ne.length||ce[0]!==s.COLOR_ATTACHMENT0){for(let Y=0,De=ne.length;Y<De;Y++)ce[Y]=s.COLOR_ATTACHMENT0+Y;ce.length=ne.length,Le=!0}}else ce[0]!==s.BACK&&(ce[0]=s.BACK,Le=!0);Le&&s.drawBuffers(ce)}function Te(O){return m!==O?(s.useProgram(O),m=O,!0):!1}const ct={[Ur]:s.FUNC_ADD,[Yg]:s.FUNC_SUBTRACT,[Zg]:s.FUNC_REVERSE_SUBTRACT};ct[Jg]=s.MIN,ct[Qd]=s.MAX;const Q={[Kg]:s.ZERO,[$g]:s.ONE,[Qg]:s.SRC_COLOR,[Oh]:s.SRC_ALPHA,[n0]:s.SRC_ALPHA_SATURATE,[s0]:s.DST_COLOR,[t0]:s.DST_ALPHA,[e0]:s.ONE_MINUS_SRC_COLOR,[Uh]:s.ONE_MINUS_SRC_ALPHA,[r0]:s.ONE_MINUS_DST_COLOR,[i0]:s.ONE_MINUS_DST_ALPHA,[a0]:s.CONSTANT_COLOR,[o0]:s.ONE_MINUS_CONSTANT_COLOR,[l0]:s.CONSTANT_ALPHA,[h0]:s.ONE_MINUS_CONSTANT_ALPHA};function ee(O,me,ce,Le,ne,Y,De,Ze,Qt,Mt){if(O===bs){y===!0&&(le(s.BLEND),y=!1);return}if(y===!1&&(ae(s.BLEND),y=!0),O!==$d){if(O!==g||Mt!==S){if((f!==Ur||M!==Ur)&&(s.blendEquation(s.FUNC_ADD),f=Ur,M=Ur),Mt)switch(O){case Or:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Dh:s.blendFunc(s.ONE,s.ONE);break;case Jd:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Kd:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:Ve("WebGLState: Invalid blending: ",O);break}else switch(O){case Or:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Dh:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case Jd:Ve("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Kd:Ve("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ve("WebGLState: Invalid blending: ",O);break}x=null,v=null,w=null,T=null,A.set(0,0,0),_=0,g=O,S=Mt}return}ne=ne||me,Y=Y||ce,De=De||Le,(me!==f||ne!==M)&&(s.blendEquationSeparate(ct[me],ct[ne]),f=me,M=ne),(ce!==x||Le!==v||Y!==w||De!==T)&&(s.blendFuncSeparate(Q[ce],Q[Le],Q[Y],Q[De]),x=ce,v=Le,w=Y,T=De),(Ze.equals(A)===!1||Qt!==_)&&(s.blendColor(Ze.r,Ze.g,Ze.b,Qt),A.copy(Ze),_=Qt),g=O,S=!1}function he(O,me){O.side===Ms?le(s.CULL_FACE):ae(s.CULL_FACE);let ce=O.side===yi;me&&(ce=!ce),_e(ce),O.blending===Or&&O.transparent===!1?ee(bs):ee(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),a.setFunc(O.depthFunc),a.setTest(O.depthTest),a.setMask(O.depthWrite),n.setMask(O.colorWrite);const Le=O.stencilWrite;o.setTest(Le),Le&&(o.setMask(O.stencilWriteMask),o.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),o.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),Ge(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?ae(s.SAMPLE_ALPHA_TO_COVERAGE):le(s.SAMPLE_ALPHA_TO_COVERAGE)}function _e(O){P!==O&&(O?s.frontFace(s.CW):s.frontFace(s.CCW),P=O)}function Se(O){O!==Xg?(ae(s.CULL_FACE),O!==C&&(O===Yd?s.cullFace(s.BACK):O===qg?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):le(s.CULL_FACE),C=O}function I(O){O!==L&&(k&&s.lineWidth(O),L=O)}function Ge(O,me,ce){O?(ae(s.POLYGON_OFFSET_FILL),(U!==me||V!==ce)&&(U=me,V=ce,a.getReversed()&&(me=-me),s.polygonOffset(me,ce))):le(s.POLYGON_OFFSET_FILL)}function We(O){O?ae(s.SCISSOR_TEST):le(s.SCISSOR_TEST)}function Je(O){O===void 0&&(O=s.TEXTURE0+B-1),ie!==O&&(s.activeTexture(O),ie=O)}function fe(O,me,ce){ce===void 0&&(ie===null?ce=s.TEXTURE0+B-1:ce=ie);let Le=oe[ce];Le===void 0&&(Le={type:void 0,texture:void 0},oe[ce]=Le),(Le.type!==O||Le.texture!==me)&&(ie!==ce&&(s.activeTexture(ce),ie=ce),s.bindTexture(O,me||K[O]),Le.type=O,Le.texture=me)}function N(){const O=oe[ie];O!==void 0&&O.type!==void 0&&(s.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function b(){try{s.compressedTexImage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function D(){try{s.compressedTexImage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function Z(){try{s.texSubImage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function $(){try{s.texSubImage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function J(){try{s.compressedTexSubImage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function Oe(){try{s.compressedTexSubImage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function pe(){try{s.texStorage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function He(){try{s.texStorage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function Be(){try{s.texImage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function re(){try{s.texImage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function ue(O){tt.equals(O)===!1&&(s.scissor(O.x,O.y,O.z,O.w),tt.copy(O))}function je(O){wt.equals(O)===!1&&(s.viewport(O.x,O.y,O.z,O.w),wt.copy(O))}function Ue(O,me){let ce=h.get(me);ce===void 0&&(ce=new WeakMap,h.set(me,ce));let Le=ce.get(O);Le===void 0&&(Le=s.getUniformBlockIndex(me,O.name),ce.set(O,Le))}function Ae(O,me){const ce=h.get(me).get(O);l.get(me)!==ce&&(s.uniformBlockBinding(me,ce,O.__bindingPointIndex),l.set(me,ce))}function ut(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),c={},ie=null,oe={},d={},u=new WeakMap,p=[],m=null,y=!1,g=null,f=null,x=null,v=null,M=null,w=null,T=null,A=new we(0,0,0),_=0,S=!1,P=null,C=null,L=null,U=null,V=null,tt.set(0,0,s.canvas.width,s.canvas.height),wt.set(0,0,s.canvas.width,s.canvas.height),n.reset(),a.reset(),o.reset()}return{buffers:{color:n,depth:a,stencil:o},enable:ae,disable:le,bindFramebuffer:Qe,drawBuffers:Ye,useProgram:Te,setBlending:ee,setMaterial:he,setFlipSided:_e,setCullFace:Se,setLineWidth:I,setPolygonOffset:Ge,setScissorTest:We,activeTexture:Je,bindTexture:fe,unbindTexture:N,compressedTexImage2D:b,compressedTexImage3D:D,texImage2D:Be,texImage3D:re,updateUBOMapping:Ue,uniformBlockBinding:Ae,texStorage2D:pe,texStorage3D:He,texSubImage2D:Z,texSubImage3D:$,compressedTexSubImage2D:J,compressedTexSubImage3D:Oe,scissor:ue,viewport:je,reset:ut}}function QN(s,e,t,i,r,n,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new te,c=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(N,b){return p?new OffscreenCanvas(N,b):gl("canvas")}function y(N,b,D){let Z=1;const $=fe(N);if(($.width>D||$.height>D)&&(Z=D/Math.max($.width,$.height)),Z<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){const J=Math.floor(Z*$.width),Oe=Math.floor(Z*$.height);d===void 0&&(d=m(J,Oe));const pe=b?m(J,Oe):d;return pe.width=J,pe.height=Oe,pe.getContext("2d").drawImage(N,0,0,J,Oe),ge("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+J+"x"+Oe+")."),pe}else return"data"in N&&ge("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),N;return N}function g(N){return N.generateMipmaps}function f(N){s.generateMipmap(N)}function x(N){return N.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?s.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function v(N,b,D,Z,$=!1){if(N!==null){if(s[N]!==void 0)return s[N];ge("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let J=b;if(b===s.RED&&(D===s.FLOAT&&(J=s.R32F),D===s.HALF_FLOAT&&(J=s.R16F),D===s.UNSIGNED_BYTE&&(J=s.R8)),b===s.RED_INTEGER&&(D===s.UNSIGNED_BYTE&&(J=s.R8UI),D===s.UNSIGNED_SHORT&&(J=s.R16UI),D===s.UNSIGNED_INT&&(J=s.R32UI),D===s.BYTE&&(J=s.R8I),D===s.SHORT&&(J=s.R16I),D===s.INT&&(J=s.R32I)),b===s.RG&&(D===s.FLOAT&&(J=s.RG32F),D===s.HALF_FLOAT&&(J=s.RG16F),D===s.UNSIGNED_BYTE&&(J=s.RG8)),b===s.RG_INTEGER&&(D===s.UNSIGNED_BYTE&&(J=s.RG8UI),D===s.UNSIGNED_SHORT&&(J=s.RG16UI),D===s.UNSIGNED_INT&&(J=s.RG32UI),D===s.BYTE&&(J=s.RG8I),D===s.SHORT&&(J=s.RG16I),D===s.INT&&(J=s.RG32I)),b===s.RGB_INTEGER&&(D===s.UNSIGNED_BYTE&&(J=s.RGB8UI),D===s.UNSIGNED_SHORT&&(J=s.RGB16UI),D===s.UNSIGNED_INT&&(J=s.RGB32UI),D===s.BYTE&&(J=s.RGB8I),D===s.SHORT&&(J=s.RGB16I),D===s.INT&&(J=s.RGB32I)),b===s.RGBA_INTEGER&&(D===s.UNSIGNED_BYTE&&(J=s.RGBA8UI),D===s.UNSIGNED_SHORT&&(J=s.RGBA16UI),D===s.UNSIGNED_INT&&(J=s.RGBA32UI),D===s.BYTE&&(J=s.RGBA8I),D===s.SHORT&&(J=s.RGBA16I),D===s.INT&&(J=s.RGBA32I)),b===s.RGB&&(D===s.UNSIGNED_INT_5_9_9_9_REV&&(J=s.RGB9_E5),D===s.UNSIGNED_INT_10F_11F_11F_REV&&(J=s.R11F_G11F_B10F)),b===s.RGBA){const Oe=$?ml:mt.getTransfer(Z);D===s.FLOAT&&(J=s.RGBA32F),D===s.HALF_FLOAT&&(J=s.RGBA16F),D===s.UNSIGNED_BYTE&&(J=Oe===vt?s.SRGB8_ALPHA8:s.RGBA8),D===s.UNSIGNED_SHORT_4_4_4_4&&(J=s.RGBA4),D===s.UNSIGNED_SHORT_5_5_5_1&&(J=s.RGB5_A1)}return(J===s.R16F||J===s.R32F||J===s.RG16F||J===s.RG32F||J===s.RGBA16F||J===s.RGBA32F)&&e.get("EXT_color_buffer_float"),J}function M(N,b){let D;return N?b===null||b===qi||b===_n?D=s.DEPTH24_STENCIL8:b===xi?D=s.DEPTH32F_STENCIL8:b===fa&&(D=s.DEPTH24_STENCIL8,ge("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===qi||b===_n?D=s.DEPTH_COMPONENT24:b===xi?D=s.DEPTH_COMPONENT32F:b===fa&&(D=s.DEPTH_COMPONENT16),D}function w(N,b){return g(N)===!0||N.isFramebufferTexture&&N.minFilter!==Ht&&N.minFilter!==Rt?Math.log2(Math.max(b.width,b.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?b.mipmaps.length:1}function T(N){const b=N.target;b.removeEventListener("dispose",T),_(b),b.isVideoTexture&&c.delete(b)}function A(N){const b=N.target;b.removeEventListener("dispose",A),P(b)}function _(N){const b=i.get(N);if(b.__webglInit===void 0)return;const D=N.source,Z=u.get(D);if(Z){const $=Z[b.__cacheKey];$.usedTimes--,$.usedTimes===0&&S(N),Object.keys(Z).length===0&&u.delete(D)}i.remove(N)}function S(N){const b=i.get(N);s.deleteTexture(b.__webglTexture);const D=N.source,Z=u.get(D);delete Z[b.__cacheKey],a.memory.textures--}function P(N){const b=i.get(N);if(N.depthTexture&&(N.depthTexture.dispose(),i.remove(N.depthTexture)),N.isWebGLCubeRenderTarget)for(let Z=0;Z<6;Z++){if(Array.isArray(b.__webglFramebuffer[Z]))for(let $=0;$<b.__webglFramebuffer[Z].length;$++)s.deleteFramebuffer(b.__webglFramebuffer[Z][$]);else s.deleteFramebuffer(b.__webglFramebuffer[Z]);b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer[Z])}else{if(Array.isArray(b.__webglFramebuffer))for(let Z=0;Z<b.__webglFramebuffer.length;Z++)s.deleteFramebuffer(b.__webglFramebuffer[Z]);else s.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&s.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let Z=0;Z<b.__webglColorRenderbuffer.length;Z++)b.__webglColorRenderbuffer[Z]&&s.deleteRenderbuffer(b.__webglColorRenderbuffer[Z]);b.__webglDepthRenderbuffer&&s.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const D=N.textures;for(let Z=0,$=D.length;Z<$;Z++){const J=i.get(D[Z]);J.__webglTexture&&(s.deleteTexture(J.__webglTexture),a.memory.textures--),i.remove(D[Z])}i.remove(N)}let C=0;function L(){C=0}function U(){const N=C;return N>=r.maxTextures&&ge("WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+r.maxTextures),C+=1,N}function V(N){const b=[];return b.push(N.wrapS),b.push(N.wrapT),b.push(N.wrapR||0),b.push(N.magFilter),b.push(N.minFilter),b.push(N.anisotropy),b.push(N.internalFormat),b.push(N.format),b.push(N.type),b.push(N.generateMipmaps),b.push(N.premultiplyAlpha),b.push(N.flipY),b.push(N.unpackAlignment),b.push(N.colorSpace),b.join()}function B(N,b){const D=i.get(N);if(N.isVideoTexture&&We(N),N.isRenderTargetTexture===!1&&N.isExternalTexture!==!0&&N.version>0&&D.__version!==N.version){const Z=N.image;if(Z===null)ge("WebGLRenderer: Texture marked for update but no image data found.");else if(Z.complete===!1)ge("WebGLRenderer: Texture marked for update but image is incomplete");else{K(D,N,b);return}}else N.isExternalTexture&&(D.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,D.__webglTexture,s.TEXTURE0+b)}function k(N,b){const D=i.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&D.__version!==N.version){K(D,N,b);return}else N.isExternalTexture&&(D.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,D.__webglTexture,s.TEXTURE0+b)}function W(N,b){const D=i.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&D.__version!==N.version){K(D,N,b);return}t.bindTexture(s.TEXTURE_3D,D.__webglTexture,s.TEXTURE0+b)}function se(N,b){const D=i.get(N);if(N.isCubeDepthTexture!==!0&&N.version>0&&D.__version!==N.version){ae(D,N,b);return}t.bindTexture(s.TEXTURE_CUBE_MAP,D.__webglTexture,s.TEXTURE0+b)}const ie={[da]:s.REPEAT,[Ci]:s.CLAMP_TO_EDGE,[pa]:s.MIRRORED_REPEAT},oe={[Ht]:s.NEAREST,[Hh]:s.NEAREST_MIPMAP_NEAREST,[vn]:s.NEAREST_MIPMAP_LINEAR,[Rt]:s.LINEAR,[ma]:s.LINEAR_MIPMAP_NEAREST,[Ss]:s.LINEAR_MIPMAP_LINEAR},be={[O0]:s.NEVER,[V0]:s.ALWAYS,[U0]:s.LESS,[pc]:s.LEQUAL,[F0]:s.EQUAL,[mc]:s.GEQUAL,[z0]:s.GREATER,[B0]:s.NOTEQUAL};function Ce(N,b){if(b.type===xi&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===Rt||b.magFilter===ma||b.magFilter===vn||b.magFilter===Ss||b.minFilter===Rt||b.minFilter===ma||b.minFilter===vn||b.minFilter===Ss)&&ge("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(N,s.TEXTURE_WRAP_S,ie[b.wrapS]),s.texParameteri(N,s.TEXTURE_WRAP_T,ie[b.wrapT]),(N===s.TEXTURE_3D||N===s.TEXTURE_2D_ARRAY)&&s.texParameteri(N,s.TEXTURE_WRAP_R,ie[b.wrapR]),s.texParameteri(N,s.TEXTURE_MAG_FILTER,oe[b.magFilter]),s.texParameteri(N,s.TEXTURE_MIN_FILTER,oe[b.minFilter]),b.compareFunction&&(s.texParameteri(N,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(N,s.TEXTURE_COMPARE_FUNC,be[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Ht||b.minFilter!==vn&&b.minFilter!==Ss||b.type===xi&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||i.get(b).__currentAnisotropy){const D=e.get("EXT_texture_filter_anisotropic");s.texParameterf(N,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,r.getMaxAnisotropy())),i.get(b).__currentAnisotropy=b.anisotropy}}}function tt(N,b){let D=!1;N.__webglInit===void 0&&(N.__webglInit=!0,b.addEventListener("dispose",T));const Z=b.source;let $=u.get(Z);$===void 0&&($={},u.set(Z,$));const J=V(b);if(J!==N.__cacheKey){$[J]===void 0&&($[J]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,D=!0),$[J].usedTimes++;const Oe=$[N.__cacheKey];Oe!==void 0&&($[N.__cacheKey].usedTimes--,Oe.usedTimes===0&&S(b)),N.__cacheKey=J,N.__webglTexture=$[J].texture}return D}function wt(N,b,D){return Math.floor(Math.floor(N/D)/b)}function Et(N,b,D,Z){const $=N.updateRanges;if($.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,b.width,b.height,D,Z,b.data);else{$.sort((Be,re)=>Be.start-re.start);let J=0;for(let Be=1;Be<$.length;Be++){const re=$[J],ue=$[Be],je=re.start+re.count,Ue=wt(ue.start,b.width,4),Ae=wt(re.start,b.width,4);ue.start<=je+1&&Ue===Ae&&wt(ue.start+ue.count-1,b.width,4)===Ue?re.count=Math.max(re.count,ue.start+ue.count-re.start):(++J,$[J]=ue)}$.length=J+1;const Oe=s.getParameter(s.UNPACK_ROW_LENGTH),pe=s.getParameter(s.UNPACK_SKIP_PIXELS),He=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,b.width);for(let Be=0,re=$.length;Be<re;Be++){const ue=$[Be],je=Math.floor(ue.start/4),Ue=Math.ceil(ue.count/4),Ae=je%b.width,ut=Math.floor(je/b.width),O=Ue,me=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ae),s.pixelStorei(s.UNPACK_SKIP_ROWS,ut),t.texSubImage2D(s.TEXTURE_2D,0,Ae,ut,O,me,D,Z,b.data)}N.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,Oe),s.pixelStorei(s.UNPACK_SKIP_PIXELS,pe),s.pixelStorei(s.UNPACK_SKIP_ROWS,He)}}function K(N,b,D){let Z=s.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(Z=s.TEXTURE_2D_ARRAY),b.isData3DTexture&&(Z=s.TEXTURE_3D);const $=tt(N,b),J=b.source;t.bindTexture(Z,N.__webglTexture,s.TEXTURE0+D);const Oe=i.get(J);if(J.version!==Oe.__version||$===!0){t.activeTexture(s.TEXTURE0+D);const pe=mt.getPrimaries(mt.workingColorSpace),He=b.colorSpace===Gs?null:mt.getPrimaries(b.colorSpace),Be=b.colorSpace===Gs||pe===He?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Be);let re=y(b.image,!1,r.maxTextureSize);re=Je(b,re);const ue=n.convert(b.format,b.colorSpace),je=n.convert(b.type);let Ue=v(b.internalFormat,ue,je,b.colorSpace,b.isVideoTexture);Ce(Z,b);let Ae;const ut=b.mipmaps,O=b.isVideoTexture!==!0,me=Oe.__version===void 0||$===!0,ce=J.dataReady,Le=w(b,re);if(b.isDepthTexture)Ue=M(b.format===ur,b.type),me&&(O?t.texStorage2D(s.TEXTURE_2D,1,Ue,re.width,re.height):t.texImage2D(s.TEXTURE_2D,0,Ue,re.width,re.height,0,ue,je,null));else if(b.isDataTexture)if(ut.length>0){O&&me&&t.texStorage2D(s.TEXTURE_2D,Le,Ue,ut[0].width,ut[0].height);for(let ne=0,Y=ut.length;ne<Y;ne++)Ae=ut[ne],O?ce&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,Ae.width,Ae.height,ue,je,Ae.data):t.texImage2D(s.TEXTURE_2D,ne,Ue,Ae.width,Ae.height,0,ue,je,Ae.data);b.generateMipmaps=!1}else O?(me&&t.texStorage2D(s.TEXTURE_2D,Le,Ue,re.width,re.height),ce&&Et(b,re,ue,je)):t.texImage2D(s.TEXTURE_2D,0,Ue,re.width,re.height,0,ue,je,re.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){O&&me&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Le,Ue,ut[0].width,ut[0].height,re.depth);for(let ne=0,Y=ut.length;ne<Y;ne++)if(Ae=ut[ne],b.format!==vi)if(ue!==null)if(O){if(ce)if(b.layerUpdates.size>0){const De=qm(Ae.width,Ae.height,b.format,b.type);for(const Ze of b.layerUpdates){const Qt=Ae.data.subarray(Ze*De/Ae.data.BYTES_PER_ELEMENT,(Ze+1)*De/Ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,Ze,Ae.width,Ae.height,1,ue,Qt)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,0,Ae.width,Ae.height,re.depth,ue,Ae.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ne,Ue,Ae.width,Ae.height,re.depth,0,Ae.data,0,0);else ge("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else O?ce&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,0,Ae.width,Ae.height,re.depth,ue,je,Ae.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ne,Ue,Ae.width,Ae.height,re.depth,0,ue,je,Ae.data)}else{O&&me&&t.texStorage2D(s.TEXTURE_2D,Le,Ue,ut[0].width,ut[0].height);for(let ne=0,Y=ut.length;ne<Y;ne++)Ae=ut[ne],b.format!==vi?ue!==null?O?ce&&t.compressedTexSubImage2D(s.TEXTURE_2D,ne,0,0,Ae.width,Ae.height,ue,Ae.data):t.compressedTexImage2D(s.TEXTURE_2D,ne,Ue,Ae.width,Ae.height,0,Ae.data):ge("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):O?ce&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,Ae.width,Ae.height,ue,je,Ae.data):t.texImage2D(s.TEXTURE_2D,ne,Ue,Ae.width,Ae.height,0,ue,je,Ae.data)}else if(b.isDataArrayTexture)if(O){if(me&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Le,Ue,re.width,re.height,re.depth),ce)if(b.layerUpdates.size>0){const ne=qm(re.width,re.height,b.format,b.type);for(const Y of b.layerUpdates){const De=re.data.subarray(Y*ne/re.data.BYTES_PER_ELEMENT,(Y+1)*ne/re.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Y,re.width,re.height,1,ue,je,De)}b.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,re.width,re.height,re.depth,ue,je,re.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Ue,re.width,re.height,re.depth,0,ue,je,re.data);else if(b.isData3DTexture)O?(me&&t.texStorage3D(s.TEXTURE_3D,Le,Ue,re.width,re.height,re.depth),ce&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,re.width,re.height,re.depth,ue,je,re.data)):t.texImage3D(s.TEXTURE_3D,0,Ue,re.width,re.height,re.depth,0,ue,je,re.data);else if(b.isFramebufferTexture){if(me)if(O)t.texStorage2D(s.TEXTURE_2D,Le,Ue,re.width,re.height);else{let ne=re.width,Y=re.height;for(let De=0;De<Le;De++)t.texImage2D(s.TEXTURE_2D,De,Ue,ne,Y,0,ue,je,null),ne>>=1,Y>>=1}}else if(ut.length>0){if(O&&me){const ne=fe(ut[0]);t.texStorage2D(s.TEXTURE_2D,Le,Ue,ne.width,ne.height)}for(let ne=0,Y=ut.length;ne<Y;ne++)Ae=ut[ne],O?ce&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,ue,je,Ae):t.texImage2D(s.TEXTURE_2D,ne,Ue,ue,je,Ae);b.generateMipmaps=!1}else if(O){if(me){const ne=fe(re);t.texStorage2D(s.TEXTURE_2D,Le,Ue,ne.width,ne.height)}ce&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,ue,je,re)}else t.texImage2D(s.TEXTURE_2D,0,Ue,ue,je,re);g(b)&&f(Z),Oe.__version=J.version,b.onUpdate&&b.onUpdate(b)}N.__version=b.version}function ae(N,b,D){if(b.image.length!==6)return;const Z=tt(N,b),$=b.source;t.bindTexture(s.TEXTURE_CUBE_MAP,N.__webglTexture,s.TEXTURE0+D);const J=i.get($);if($.version!==J.__version||Z===!0){t.activeTexture(s.TEXTURE0+D);const Oe=mt.getPrimaries(mt.workingColorSpace),pe=b.colorSpace===Gs?null:mt.getPrimaries(b.colorSpace),He=b.colorSpace===Gs||Oe===pe?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);const Be=b.isCompressedTexture||b.image[0].isCompressedTexture,re=b.image[0]&&b.image[0].isDataTexture,ue=[];for(let Y=0;Y<6;Y++)!Be&&!re?ue[Y]=y(b.image[Y],!0,r.maxCubemapSize):ue[Y]=re?b.image[Y].image:b.image[Y],ue[Y]=Je(b,ue[Y]);const je=ue[0],Ue=n.convert(b.format,b.colorSpace),Ae=n.convert(b.type),ut=v(b.internalFormat,Ue,Ae,b.colorSpace),O=b.isVideoTexture!==!0,me=J.__version===void 0||Z===!0,ce=$.dataReady;let Le=w(b,je);Ce(s.TEXTURE_CUBE_MAP,b);let ne;if(Be){O&&me&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Le,ut,je.width,je.height);for(let Y=0;Y<6;Y++){ne=ue[Y].mipmaps;for(let De=0;De<ne.length;De++){const Ze=ne[De];b.format!==vi?Ue!==null?O?ce&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De,0,0,Ze.width,Ze.height,Ue,Ze.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De,ut,Ze.width,Ze.height,0,Ze.data):ge("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De,0,0,Ze.width,Ze.height,Ue,Ae,Ze.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De,ut,Ze.width,Ze.height,0,Ue,Ae,Ze.data)}}}else{if(ne=b.mipmaps,O&&me){ne.length>0&&Le++;const Y=fe(ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Le,ut,Y.width,Y.height)}for(let Y=0;Y<6;Y++)if(re){O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,ue[Y].width,ue[Y].height,Ue,Ae,ue[Y].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,ut,ue[Y].width,ue[Y].height,0,Ue,Ae,ue[Y].data);for(let De=0;De<ne.length;De++){const Ze=ne[De].image[Y].image;O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De+1,0,0,Ze.width,Ze.height,Ue,Ae,Ze.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De+1,ut,Ze.width,Ze.height,0,Ue,Ae,Ze.data)}}else{O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,Ue,Ae,ue[Y]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,ut,Ue,Ae,ue[Y]);for(let De=0;De<ne.length;De++){const Ze=ne[De];O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De+1,0,0,Ue,Ae,Ze.image[Y]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De+1,ut,Ue,Ae,Ze.image[Y])}}}g(b)&&f(s.TEXTURE_CUBE_MAP),J.__version=$.version,b.onUpdate&&b.onUpdate(b)}N.__version=b.version}function le(N,b,D,Z,$,J){const Oe=n.convert(D.format,D.colorSpace),pe=n.convert(D.type),He=v(D.internalFormat,Oe,pe,D.colorSpace),Be=i.get(b),re=i.get(D);if(re.__renderTarget=b,!Be.__hasExternalTextures){const ue=Math.max(1,b.width>>J),je=Math.max(1,b.height>>J);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?t.texImage3D($,J,He,ue,je,b.depth,0,Oe,pe,null):t.texImage2D($,J,He,ue,je,0,Oe,pe,null)}t.bindFramebuffer(s.FRAMEBUFFER,N),Ge(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Z,$,re.__webglTexture,0,I(b)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,Z,$,re.__webglTexture,J),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Qe(N,b,D){if(s.bindRenderbuffer(s.RENDERBUFFER,N),b.depthBuffer){const Z=b.depthTexture,$=Z&&Z.isDepthTexture?Z.type:null,J=M(b.stencilBuffer,$),Oe=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Ge(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,I(b),J,b.width,b.height):D?s.renderbufferStorageMultisample(s.RENDERBUFFER,I(b),J,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,J,b.width,b.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,Oe,s.RENDERBUFFER,N)}else{const Z=b.textures;for(let $=0;$<Z.length;$++){const J=Z[$],Oe=n.convert(J.format,J.colorSpace),pe=n.convert(J.type),He=v(J.internalFormat,Oe,pe,J.colorSpace);Ge(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,I(b),He,b.width,b.height):D?s.renderbufferStorageMultisample(s.RENDERBUFFER,I(b),He,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,He,b.width,b.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Ye(N,b,D){const Z=b.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,N),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const $=i.get(b.depthTexture);if($.__renderTarget=b,(!$.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),Z){if($.__webglInit===void 0&&($.__webglInit=!0,b.depthTexture.addEventListener("dispose",T)),$.__webglTexture===void 0){$.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,$.__webglTexture),Ce(s.TEXTURE_CUBE_MAP,b.depthTexture);const Be=n.convert(b.depthTexture.format),re=n.convert(b.depthTexture.type);let ue;b.depthTexture.format===ws?ue=s.DEPTH_COMPONENT24:b.depthTexture.format===ur&&(ue=s.DEPTH24_STENCIL8);for(let je=0;je<6;je++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,ue,b.width,b.height,0,Be,re,null)}}else B(b.depthTexture,0);const J=$.__webglTexture,Oe=I(b),pe=Z?s.TEXTURE_CUBE_MAP_POSITIVE_X+D:s.TEXTURE_2D,He=b.depthTexture.format===ur?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(b.depthTexture.format===ws)Ge(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,He,pe,J,0,Oe):s.framebufferTexture2D(s.FRAMEBUFFER,He,pe,J,0);else if(b.depthTexture.format===ur)Ge(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,He,pe,J,0,Oe):s.framebufferTexture2D(s.FRAMEBUFFER,He,pe,J,0);else throw new Error("Unknown depthTexture format")}function Te(N){const b=i.get(N),D=N.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==N.depthTexture){const Z=N.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),Z){const $=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,Z.removeEventListener("dispose",$)};Z.addEventListener("dispose",$),b.__depthDisposeCallback=$}b.__boundDepthTexture=Z}if(N.depthTexture&&!b.__autoAllocateDepthBuffer)if(D)for(let Z=0;Z<6;Z++)Ye(b.__webglFramebuffer[Z],N,Z);else{const Z=N.texture.mipmaps;Z&&Z.length>0?Ye(b.__webglFramebuffer[0],N,0):Ye(b.__webglFramebuffer,N,0)}else if(D){b.__webglDepthbuffer=[];for(let Z=0;Z<6;Z++)if(t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[Z]),b.__webglDepthbuffer[Z]===void 0)b.__webglDepthbuffer[Z]=s.createRenderbuffer(),Qe(b.__webglDepthbuffer[Z],N,!1);else{const $=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,J=b.__webglDepthbuffer[Z];s.bindRenderbuffer(s.RENDERBUFFER,J),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,J)}}else{const Z=N.texture.mipmaps;if(Z&&Z.length>0?t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=s.createRenderbuffer(),Qe(b.__webglDepthbuffer,N,!1);else{const $=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,J=b.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,J),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,J)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function ct(N,b,D){const Z=i.get(N);b!==void 0&&le(Z.__webglFramebuffer,N,N.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),D!==void 0&&Te(N)}function Q(N){const b=N.texture,D=i.get(N),Z=i.get(b);N.addEventListener("dispose",A);const $=N.textures,J=N.isWebGLCubeRenderTarget===!0,Oe=$.length>1;if(Oe||(Z.__webglTexture===void 0&&(Z.__webglTexture=s.createTexture()),Z.__version=b.version,a.memory.textures++),J){D.__webglFramebuffer=[];for(let pe=0;pe<6;pe++)if(b.mipmaps&&b.mipmaps.length>0){D.__webglFramebuffer[pe]=[];for(let He=0;He<b.mipmaps.length;He++)D.__webglFramebuffer[pe][He]=s.createFramebuffer()}else D.__webglFramebuffer[pe]=s.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){D.__webglFramebuffer=[];for(let pe=0;pe<b.mipmaps.length;pe++)D.__webglFramebuffer[pe]=s.createFramebuffer()}else D.__webglFramebuffer=s.createFramebuffer();if(Oe)for(let pe=0,He=$.length;pe<He;pe++){const Be=i.get($[pe]);Be.__webglTexture===void 0&&(Be.__webglTexture=s.createTexture(),a.memory.textures++)}if(N.samples>0&&Ge(N)===!1){D.__webglMultisampledFramebuffer=s.createFramebuffer(),D.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,D.__webglMultisampledFramebuffer);for(let pe=0;pe<$.length;pe++){const He=$[pe];D.__webglColorRenderbuffer[pe]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,D.__webglColorRenderbuffer[pe]);const Be=n.convert(He.format,He.colorSpace),re=n.convert(He.type),ue=v(He.internalFormat,Be,re,He.colorSpace,N.isXRRenderTarget===!0),je=I(N);s.renderbufferStorageMultisample(s.RENDERBUFFER,je,ue,N.width,N.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+pe,s.RENDERBUFFER,D.__webglColorRenderbuffer[pe])}s.bindRenderbuffer(s.RENDERBUFFER,null),N.depthBuffer&&(D.__webglDepthRenderbuffer=s.createRenderbuffer(),Qe(D.__webglDepthRenderbuffer,N,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(J){t.bindTexture(s.TEXTURE_CUBE_MAP,Z.__webglTexture),Ce(s.TEXTURE_CUBE_MAP,b);for(let pe=0;pe<6;pe++)if(b.mipmaps&&b.mipmaps.length>0)for(let He=0;He<b.mipmaps.length;He++)le(D.__webglFramebuffer[pe][He],N,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+pe,He);else le(D.__webglFramebuffer[pe],N,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0);g(b)&&f(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Oe){for(let pe=0,He=$.length;pe<He;pe++){const Be=$[pe],re=i.get(Be);let ue=s.TEXTURE_2D;(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(ue=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ue,re.__webglTexture),Ce(ue,Be),le(D.__webglFramebuffer,N,Be,s.COLOR_ATTACHMENT0+pe,ue,0),g(Be)&&f(ue)}t.unbindTexture()}else{let pe=s.TEXTURE_2D;if((N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(pe=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(pe,Z.__webglTexture),Ce(pe,b),b.mipmaps&&b.mipmaps.length>0)for(let He=0;He<b.mipmaps.length;He++)le(D.__webglFramebuffer[He],N,b,s.COLOR_ATTACHMENT0,pe,He);else le(D.__webglFramebuffer,N,b,s.COLOR_ATTACHMENT0,pe,0);g(b)&&f(pe),t.unbindTexture()}N.depthBuffer&&Te(N)}function ee(N){const b=N.textures;for(let D=0,Z=b.length;D<Z;D++){const $=b[D];if(g($)){const J=x(N),Oe=i.get($).__webglTexture;t.bindTexture(J,Oe),f(J),t.unbindTexture()}}}const he=[],_e=[];function Se(N){if(N.samples>0){if(Ge(N)===!1){const b=N.textures,D=N.width,Z=N.height;let $=s.COLOR_BUFFER_BIT;const J=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Oe=i.get(N),pe=b.length>1;if(pe)for(let Be=0;Be<b.length;Be++)t.bindFramebuffer(s.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Be,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,Oe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Be,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer);const He=N.texture.mipmaps;He&&He.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer);for(let Be=0;Be<b.length;Be++){if(N.resolveDepthBuffer&&(N.depthBuffer&&($|=s.DEPTH_BUFFER_BIT),N.stencilBuffer&&N.resolveStencilBuffer&&($|=s.STENCIL_BUFFER_BIT)),pe){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,Oe.__webglColorRenderbuffer[Be]);const re=i.get(b[Be]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,re,0)}s.blitFramebuffer(0,0,D,Z,0,0,D,Z,$,s.NEAREST),l===!0&&(he.length=0,_e.length=0,he.push(s.COLOR_ATTACHMENT0+Be),N.depthBuffer&&N.resolveDepthBuffer===!1&&(he.push(J),_e.push(J),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,_e)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,he))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),pe)for(let Be=0;Be<b.length;Be++){t.bindFramebuffer(s.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Be,s.RENDERBUFFER,Oe.__webglColorRenderbuffer[Be]);const re=i.get(b[Be]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,Oe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Be,s.TEXTURE_2D,re,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer)}else if(N.depthBuffer&&N.resolveDepthBuffer===!1&&l){const b=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[b])}}}function I(N){return Math.min(r.maxSamples,N.samples)}function Ge(N){const b=i.get(N);return N.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function We(N){const b=a.render.frame;c.get(N)!==b&&(c.set(N,b),N.update())}function Je(N,b){const D=N.colorSpace,Z=N.format,$=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||D!==kr&&D!==Gs&&(mt.getTransfer(D)===vt?(Z!==vi||$!==Ri)&&ge("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ve("WebGLTextures: Unsupported texture color space:",D)),b}function fe(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(h.width=N.naturalWidth||N.width,h.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(h.width=N.displayWidth,h.height=N.displayHeight):(h.width=N.width,h.height=N.height),h}this.allocateTextureUnit=U,this.resetTextureUnits=L,this.setTexture2D=B,this.setTexture2DArray=k,this.setTexture3D=W,this.setTextureCube=se,this.rebindTextures=ct,this.setupRenderTarget=Q,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=Se,this.setupDepthRenderbuffer=Te,this.setupFrameBufferTexture=le,this.useMultisampledRTT=Ge,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function bv(s,e){function t(i,r=Gs){let n;const a=mt.getTransfer(r);if(i===Ri)return s.UNSIGNED_BYTE;if(i===jh)return s.UNSIGNED_SHORT_4_4_4_4;if(i===Xh)return s.UNSIGNED_SHORT_5_5_5_1;if(i===qh)return s.UNSIGNED_INT_5_9_9_9_REV;if(i===Yh)return s.UNSIGNED_INT_10F_11F_11F_REV;if(i===sp)return s.BYTE;if(i===rp)return s.SHORT;if(i===fa)return s.UNSIGNED_SHORT;if(i===Wh)return s.INT;if(i===qi)return s.UNSIGNED_INT;if(i===xi)return s.FLOAT;if(i===Ts)return s.HALF_FLOAT;if(i===np)return s.ALPHA;if(i===Zh)return s.RGB;if(i===vi)return s.RGBA;if(i===ws)return s.DEPTH_COMPONENT;if(i===ur)return s.DEPTH_STENCIL;if(i===Wo)return s.RED;if(i===ga)return s.RED_INTEGER;if(i===Br)return s.RG;if(i===jo)return s.RG_INTEGER;if(i===Xo)return s.RGBA_INTEGER;if(i===ya||i===xa||i===qo||i===va)if(a===vt)if(n=e.get("WEBGL_compressed_texture_s3tc_srgb"),n!==null){if(i===ya)return n.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===xa)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===qo)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===va)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(n=e.get("WEBGL_compressed_texture_s3tc"),n!==null){if(i===ya)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===xa)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===qo)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===va)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Yo||i===Jh||i===Zo||i===Jo)if(n=e.get("WEBGL_compressed_texture_pvrtc"),n!==null){if(i===Yo)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Jh)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Zo)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Jo)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Ko||i===$o||i===Qo||i===el||i===tl||i===il||i===sl)if(n=e.get("WEBGL_compressed_texture_etc"),n!==null){if(i===Ko||i===$o)return a===vt?n.COMPRESSED_SRGB8_ETC2:n.COMPRESSED_RGB8_ETC2;if(i===Qo)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:n.COMPRESSED_RGBA8_ETC2_EAC;if(i===el)return n.COMPRESSED_R11_EAC;if(i===tl)return n.COMPRESSED_SIGNED_R11_EAC;if(i===il)return n.COMPRESSED_RG11_EAC;if(i===sl)return n.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===rl||i===Kh||i===$h||i===Qh||i===nl||i===ec||i===tc||i===ic||i===sc||i===rc||i===nc||i===ac||i===oc||i===lc)if(n=e.get("WEBGL_compressed_texture_astc"),n!==null){if(i===rl)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:n.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Kh)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:n.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===$h)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:n.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Qh)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:n.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===nl)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:n.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ec)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:n.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===tc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:n.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ic)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:n.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===sc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:n.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===rc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:n.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===nc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:n.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ac)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:n.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===oc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:n.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===lc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:n.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===al||i===hc||i===ol)if(n=e.get("EXT_texture_compression_bptc"),n!==null){if(i===al)return a===vt?n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:n.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===hc)return n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ol)return n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ll||i===hl||i===cl||i===ul)if(n=e.get("EXT_texture_compression_rgtc"),n!==null){if(i===ll)return n.COMPRESSED_RED_RGTC1_EXT;if(i===hl)return n.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===cl)return n.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ul)return n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===_n?s.UNSIGNED_INT_24_8:s[i]!==void 0?s[i]:null}return{convert:t}}const eC=`
|
|
4033
|
+
}`,ZN=[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)],JN=[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)],Mv=new et,Xl=new R,ef=new R;function KN(s,e,t){let i=new Pn;const r=new te,n=new te,a=new It,o=new cu,l=new _m,h={},c=t.maxTextureSize,d={[Vs]:yi,[yi]:Vs,[Ms]:Ms},u=new $i({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:qN,fragmentShader:YN}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new rt;m.setAttribute("position",new bt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Xt(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ha;let f=this.type;this.render=function(T,A,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;this.type===qg&&(ge("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ha);const S=s.getRenderTarget(),P=s.getActiveCubeFace(),C=s.getActiveMipmapLevel(),L=s.state;L.setBlending(bs),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=f!==this.type;U&&A.traverse(function(V){V.material&&(Array.isArray(V.material)?V.material.forEach(B=>B.needsUpdate=!0):V.material.needsUpdate=!0)});for(let V=0,B=T.length;V<B;V++){const k=T[V],W=k.shadow;if(W===void 0){ge("WebGLShadowMap:",k,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;r.copy(W.mapSize);const se=W.getFrameExtents();r.multiply(se),n.copy(W.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(n.x=Math.floor(c/se.x),r.x=n.x*se.x,W.mapSize.x=n.x),r.y>c&&(n.y=Math.floor(c/se.y),r.y=n.y*se.y,W.mapSize.y=n.y));const ie=s.state.buffers.depth.getReversed();if(W.camera._reversedDepth=ie,W.map===null||U===!0){if(W.map!==null&&(W.map.depthTexture!==null&&(W.map.depthTexture.dispose(),W.map.depthTexture=null),W.map.dispose()),this.type===ca){if(k.isPointLight){ge("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}W.map=new Bi(r.x,r.y,{format:Br,type:Ts,minFilter:Rt,magFilter:Rt,generateMipmaps:!1}),W.map.texture.name=k.name+".shadowMap",W.map.depthTexture=new On(r.x,r.y,xi),W.map.depthTexture.name=k.name+".shadowMapDepth",W.map.depthTexture.format=ws,W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Ht,W.map.depthTexture.magFilter=Ht}else k.isPointLight?(W.map=new Au(r.x),W.map.depthTexture=new Ly(r.x,qi)):(W.map=new Bi(r.x,r.y),W.map.depthTexture=new On(r.x,r.y,qi)),W.map.depthTexture.name=k.name+".shadowMap",W.map.depthTexture.format=ws,this.type===ha?(W.map.depthTexture.compareFunction=ie?mc:pc,W.map.depthTexture.minFilter=Rt,W.map.depthTexture.magFilter=Rt):(W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Ht,W.map.depthTexture.magFilter=Ht);W.camera.updateProjectionMatrix()}const oe=W.map.isWebGLCubeRenderTarget?6:1;for(let be=0;be<oe;be++){if(W.map.isWebGLCubeRenderTarget)s.setRenderTarget(W.map,be),s.clear();else{be===0&&(s.setRenderTarget(W.map),s.clear());const Ce=W.getViewport(be);a.set(n.x*Ce.x,n.y*Ce.y,n.x*Ce.z,n.y*Ce.w),L.viewport(a)}if(k.isPointLight){const Ce=W.camera,tt=W.matrix,wt=k.distance||Ce.far;wt!==Ce.far&&(Ce.far=wt,Ce.updateProjectionMatrix()),Xl.setFromMatrixPosition(k.matrixWorld),Ce.position.copy(Xl),ef.copy(Ce.position),ef.add(ZN[be]),Ce.up.copy(JN[be]),Ce.lookAt(ef),Ce.updateMatrixWorld(),tt.makeTranslation(-Xl.x,-Xl.y,-Xl.z),Mv.multiplyMatrices(Ce.projectionMatrix,Ce.matrixWorldInverse),W._frustum.setFromProjectionMatrix(Mv,Ce.coordinateSystem,Ce.reversedDepth)}else W.updateMatrices(k);i=W.getFrustum(),M(A,_,W.camera,k,this.type)}W.isPointLightShadow!==!0&&this.type===ca&&x(W,_),W.needsUpdate=!1}f=this.type,g.needsUpdate=!1,s.setRenderTarget(S,P,C)};function x(T,A){const _=e.update(y);u.defines.VSM_SAMPLES!==T.blurSamples&&(u.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Bi(r.x,r.y,{format:Br,type:Ts})),u.uniforms.shadow_pass.value=T.map.depthTexture,u.uniforms.resolution.value=T.mapSize,u.uniforms.radius.value=T.radius,s.setRenderTarget(T.mapPass),s.clear(),s.renderBufferDirect(A,null,_,u,y,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,s.setRenderTarget(T.map),s.clear(),s.renderBufferDirect(A,null,_,p,y,null)}function v(T,A,_,S){let P=null;const C=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(C!==void 0)P=C;else if(P=_.isPointLight===!0?l:o,s.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const L=P.uuid,U=A.uuid;let V=h[L];V===void 0&&(V={},h[L]=V);let B=V[U];B===void 0&&(B=P.clone(),V[U]=B,A.addEventListener("dispose",w)),P=B}if(P.visible=A.visible,P.wireframe=A.wireframe,S===ca?P.side=A.shadowSide!==null?A.shadowSide:A.side:P.side=A.shadowSide!==null?A.shadowSide:d[A.side],P.alphaMap=A.alphaMap,P.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,P.map=A.map,P.clipShadows=A.clipShadows,P.clippingPlanes=A.clippingPlanes,P.clipIntersection=A.clipIntersection,P.displacementMap=A.displacementMap,P.displacementScale=A.displacementScale,P.displacementBias=A.displacementBias,P.wireframeLinewidth=A.wireframeLinewidth,P.linewidth=A.linewidth,_.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const L=s.properties.get(P);L.light=_}return P}function M(T,A,_,S,P){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&P===ca)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);const L=e.update(T),U=T.material;if(Array.isArray(U)){const V=L.groups;for(let B=0,k=V.length;B<k;B++){const W=V[B],se=U[W.materialIndex];if(se&&se.visible){const ie=v(T,se,S,P);T.onBeforeShadow(s,T,A,_,L,ie,W),s.renderBufferDirect(_,null,L,ie,T,W),T.onAfterShadow(s,T,A,_,L,ie,W)}}}else if(U.visible){const V=v(T,U,S,P);T.onBeforeShadow(s,T,A,_,L,V,null),s.renderBufferDirect(_,null,L,V,T,null),T.onAfterShadow(s,T,A,_,L,V,null)}}const C=T.children;for(let L=0,U=C.length;L<U;L++)M(C[L],A,_,S,P)}function w(T){T.target.removeEventListener("dispose",w);for(const A in h){const _=h[A],S=T.target.uuid;S in _&&(_[S].dispose(),delete _[S])}}}function $N(s,e){function t(){let O=!1;const me=new It;let ce=null;const Le=new It(0,0,0,0);return{setMask:function(ne){ce!==ne&&!O&&(s.colorMask(ne,ne,ne,ne),ce=ne)},setLocked:function(ne){O=ne},setClear:function(ne,Y,De,Ze,Qt){Qt===!0&&(ne*=Ze,Y*=Ze,De*=Ze),me.set(ne,Y,De,Ze),Le.equals(me)===!1&&(s.clearColor(ne,Y,De,Ze),Le.copy(me))},reset:function(){O=!1,ce=null,Le.set(-1,0,0,0)}}}function i(){let O=!1,me=!1,ce=null,Le=null,ne=null;return{setReversed:function(Y){if(me!==Y){const De=e.get("EXT_clip_control");Y?De.clipControlEXT(De.LOWER_LEFT_EXT,De.ZERO_TO_ONE_EXT):De.clipControlEXT(De.LOWER_LEFT_EXT,De.NEGATIVE_ONE_TO_ONE_EXT),me=Y;const Ze=ne;ne=null,this.setClear(Ze)}},getReversed:function(){return me},setTest:function(Y){Y?ae(s.DEPTH_TEST):le(s.DEPTH_TEST)},setMask:function(Y){ce!==Y&&!O&&(s.depthMask(Y),ce=Y)},setFunc:function(Y){if(me&&(Y=kM[Y]),Le!==Y){switch(Y){case Uo:s.depthFunc(s.NEVER);break;case Fo:s.depthFunc(s.ALWAYS);break;case zo:s.depthFunc(s.LESS);break;case Fr:s.depthFunc(s.LEQUAL);break;case Bo:s.depthFunc(s.EQUAL);break;case Vo:s.depthFunc(s.GEQUAL);break;case ko:s.depthFunc(s.GREATER);break;case Go:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Le=Y}},setLocked:function(Y){O=Y},setClear:function(Y){ne!==Y&&(ne=Y,me&&(Y=1-Y),s.clearDepth(Y))},reset:function(){O=!1,ce=null,Le=null,ne=null,me=!1}}}function r(){let O=!1,me=null,ce=null,Le=null,ne=null,Y=null,De=null,Ze=null,Qt=null;return{setTest:function(Mt){O||(Mt?ae(s.STENCIL_TEST):le(s.STENCIL_TEST))},setMask:function(Mt){me!==Mt&&!O&&(s.stencilMask(Mt),me=Mt)},setFunc:function(Mt,hr,cr){(ce!==Mt||Le!==hr||ne!==cr)&&(s.stencilFunc(Mt,hr,cr),ce=Mt,Le=hr,ne=cr)},setOp:function(Mt,hr,cr){(Y!==Mt||De!==hr||Ze!==cr)&&(s.stencilOp(Mt,hr,cr),Y=Mt,De=hr,Ze=cr)},setLocked:function(Mt){O=Mt},setClear:function(Mt){Qt!==Mt&&(s.clearStencil(Mt),Qt=Mt)},reset:function(){O=!1,me=null,ce=null,Le=null,ne=null,Y=null,De=null,Ze=null,Qt=null}}}const n=new t,a=new i,o=new r,l=new WeakMap,h=new WeakMap;let c={},d={},u=new WeakMap,p=[],m=null,y=!1,g=null,f=null,x=null,v=null,M=null,w=null,T=null,A=new we(0,0,0),_=0,S=!1,P=null,C=null,L=null,U=null,V=null;const B=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,W=0;const se=s.getParameter(s.VERSION);se.indexOf("WebGL")!==-1?(W=parseFloat(/^WebGL (\d)/.exec(se)[1]),k=W>=1):se.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),k=W>=2);let ie=null,oe={};const be=s.getParameter(s.SCISSOR_BOX),Ce=s.getParameter(s.VIEWPORT),tt=new It().fromArray(be),wt=new It().fromArray(Ce);function Et(O,me,ce,Le){const ne=new Uint8Array(4),Y=s.createTexture();s.bindTexture(O,Y),s.texParameteri(O,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(O,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let De=0;De<ce;De++)O===s.TEXTURE_3D||O===s.TEXTURE_2D_ARRAY?s.texImage3D(me,0,s.RGBA,1,1,Le,0,s.RGBA,s.UNSIGNED_BYTE,ne):s.texImage2D(me+De,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ne);return Y}const K={};K[s.TEXTURE_2D]=Et(s.TEXTURE_2D,s.TEXTURE_2D,1),K[s.TEXTURE_CUBE_MAP]=Et(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),K[s.TEXTURE_2D_ARRAY]=Et(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),K[s.TEXTURE_3D]=Et(s.TEXTURE_3D,s.TEXTURE_3D,1,1),n.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ae(s.DEPTH_TEST),a.setFunc(Fr),_e(!1),Se(Yd),ae(s.CULL_FACE),ee(bs);function ae(O){c[O]!==!0&&(s.enable(O),c[O]=!0)}function le(O){c[O]!==!1&&(s.disable(O),c[O]=!1)}function Qe(O,me){return d[O]!==me?(s.bindFramebuffer(O,me),d[O]=me,O===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=me),O===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=me),!0):!1}function Ye(O,me){let ce=p,Le=!1;if(O){ce=u.get(me),ce===void 0&&(ce=[],u.set(me,ce));const ne=O.textures;if(ce.length!==ne.length||ce[0]!==s.COLOR_ATTACHMENT0){for(let Y=0,De=ne.length;Y<De;Y++)ce[Y]=s.COLOR_ATTACHMENT0+Y;ce.length=ne.length,Le=!0}}else ce[0]!==s.BACK&&(ce[0]=s.BACK,Le=!0);Le&&s.drawBuffers(ce)}function Te(O){return m!==O?(s.useProgram(O),m=O,!0):!1}const ct={[Ur]:s.FUNC_ADD,[Yg]:s.FUNC_SUBTRACT,[Zg]:s.FUNC_REVERSE_SUBTRACT};ct[Jg]=s.MIN,ct[$d]=s.MAX;const Q={[Kg]:s.ZERO,[$g]:s.ONE,[Qg]:s.SRC_COLOR,[Oh]:s.SRC_ALPHA,[n0]:s.SRC_ALPHA_SATURATE,[s0]:s.DST_COLOR,[t0]:s.DST_ALPHA,[e0]:s.ONE_MINUS_SRC_COLOR,[Uh]:s.ONE_MINUS_SRC_ALPHA,[r0]:s.ONE_MINUS_DST_COLOR,[i0]:s.ONE_MINUS_DST_ALPHA,[a0]:s.CONSTANT_COLOR,[o0]:s.ONE_MINUS_CONSTANT_COLOR,[l0]:s.CONSTANT_ALPHA,[h0]:s.ONE_MINUS_CONSTANT_ALPHA};function ee(O,me,ce,Le,ne,Y,De,Ze,Qt,Mt){if(O===bs){y===!0&&(le(s.BLEND),y=!1);return}if(y===!1&&(ae(s.BLEND),y=!0),O!==Kd){if(O!==g||Mt!==S){if((f!==Ur||M!==Ur)&&(s.blendEquation(s.FUNC_ADD),f=Ur,M=Ur),Mt)switch(O){case Or:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Dh:s.blendFunc(s.ONE,s.ONE);break;case Zd:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Jd:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:Ve("WebGLState: Invalid blending: ",O);break}else switch(O){case Or:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Dh:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case Zd:Ve("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Jd:Ve("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ve("WebGLState: Invalid blending: ",O);break}x=null,v=null,w=null,T=null,A.set(0,0,0),_=0,g=O,S=Mt}return}ne=ne||me,Y=Y||ce,De=De||Le,(me!==f||ne!==M)&&(s.blendEquationSeparate(ct[me],ct[ne]),f=me,M=ne),(ce!==x||Le!==v||Y!==w||De!==T)&&(s.blendFuncSeparate(Q[ce],Q[Le],Q[Y],Q[De]),x=ce,v=Le,w=Y,T=De),(Ze.equals(A)===!1||Qt!==_)&&(s.blendColor(Ze.r,Ze.g,Ze.b,Qt),A.copy(Ze),_=Qt),g=O,S=!1}function he(O,me){O.side===Ms?le(s.CULL_FACE):ae(s.CULL_FACE);let ce=O.side===yi;me&&(ce=!ce),_e(ce),O.blending===Or&&O.transparent===!1?ee(bs):ee(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),a.setFunc(O.depthFunc),a.setTest(O.depthTest),a.setMask(O.depthWrite),n.setMask(O.colorWrite);const Le=O.stencilWrite;o.setTest(Le),Le&&(o.setMask(O.stencilWriteMask),o.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),o.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),Ge(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?ae(s.SAMPLE_ALPHA_TO_COVERAGE):le(s.SAMPLE_ALPHA_TO_COVERAGE)}function _e(O){P!==O&&(O?s.frontFace(s.CW):s.frontFace(s.CCW),P=O)}function Se(O){O!==jg?(ae(s.CULL_FACE),O!==C&&(O===Yd?s.cullFace(s.BACK):O===Xg?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):le(s.CULL_FACE),C=O}function I(O){O!==L&&(k&&s.lineWidth(O),L=O)}function Ge(O,me,ce){O?(ae(s.POLYGON_OFFSET_FILL),(U!==me||V!==ce)&&(U=me,V=ce,a.getReversed()&&(me=-me),s.polygonOffset(me,ce))):le(s.POLYGON_OFFSET_FILL)}function We(O){O?ae(s.SCISSOR_TEST):le(s.SCISSOR_TEST)}function Je(O){O===void 0&&(O=s.TEXTURE0+B-1),ie!==O&&(s.activeTexture(O),ie=O)}function fe(O,me,ce){ce===void 0&&(ie===null?ce=s.TEXTURE0+B-1:ce=ie);let Le=oe[ce];Le===void 0&&(Le={type:void 0,texture:void 0},oe[ce]=Le),(Le.type!==O||Le.texture!==me)&&(ie!==ce&&(s.activeTexture(ce),ie=ce),s.bindTexture(O,me||K[O]),Le.type=O,Le.texture=me)}function N(){const O=oe[ie];O!==void 0&&O.type!==void 0&&(s.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function b(){try{s.compressedTexImage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function D(){try{s.compressedTexImage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function Z(){try{s.texSubImage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function $(){try{s.texSubImage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function J(){try{s.compressedTexSubImage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function Oe(){try{s.compressedTexSubImage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function pe(){try{s.texStorage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function He(){try{s.texStorage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function Be(){try{s.texImage2D(...arguments)}catch(O){Ve("WebGLState:",O)}}function re(){try{s.texImage3D(...arguments)}catch(O){Ve("WebGLState:",O)}}function ue(O){tt.equals(O)===!1&&(s.scissor(O.x,O.y,O.z,O.w),tt.copy(O))}function je(O){wt.equals(O)===!1&&(s.viewport(O.x,O.y,O.z,O.w),wt.copy(O))}function Ue(O,me){let ce=h.get(me);ce===void 0&&(ce=new WeakMap,h.set(me,ce));let Le=ce.get(O);Le===void 0&&(Le=s.getUniformBlockIndex(me,O.name),ce.set(O,Le))}function Ae(O,me){const ce=h.get(me).get(O);l.get(me)!==ce&&(s.uniformBlockBinding(me,ce,O.__bindingPointIndex),l.set(me,ce))}function ut(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),c={},ie=null,oe={},d={},u=new WeakMap,p=[],m=null,y=!1,g=null,f=null,x=null,v=null,M=null,w=null,T=null,A=new we(0,0,0),_=0,S=!1,P=null,C=null,L=null,U=null,V=null,tt.set(0,0,s.canvas.width,s.canvas.height),wt.set(0,0,s.canvas.width,s.canvas.height),n.reset(),a.reset(),o.reset()}return{buffers:{color:n,depth:a,stencil:o},enable:ae,disable:le,bindFramebuffer:Qe,drawBuffers:Ye,useProgram:Te,setBlending:ee,setMaterial:he,setFlipSided:_e,setCullFace:Se,setLineWidth:I,setPolygonOffset:Ge,setScissorTest:We,activeTexture:Je,bindTexture:fe,unbindTexture:N,compressedTexImage2D:b,compressedTexImage3D:D,texImage2D:Be,texImage3D:re,updateUBOMapping:Ue,uniformBlockBinding:Ae,texStorage2D:pe,texStorage3D:He,texSubImage2D:Z,texSubImage3D:$,compressedTexSubImage2D:J,compressedTexSubImage3D:Oe,scissor:ue,viewport:je,reset:ut}}function QN(s,e,t,i,r,n,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new te,c=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(N,b){return p?new OffscreenCanvas(N,b):gl("canvas")}function y(N,b,D){let Z=1;const $=fe(N);if(($.width>D||$.height>D)&&(Z=D/Math.max($.width,$.height)),Z<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){const J=Math.floor(Z*$.width),Oe=Math.floor(Z*$.height);d===void 0&&(d=m(J,Oe));const pe=b?m(J,Oe):d;return pe.width=J,pe.height=Oe,pe.getContext("2d").drawImage(N,0,0,J,Oe),ge("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+J+"x"+Oe+")."),pe}else return"data"in N&&ge("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),N;return N}function g(N){return N.generateMipmaps}function f(N){s.generateMipmap(N)}function x(N){return N.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?s.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function v(N,b,D,Z,$=!1){if(N!==null){if(s[N]!==void 0)return s[N];ge("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let J=b;if(b===s.RED&&(D===s.FLOAT&&(J=s.R32F),D===s.HALF_FLOAT&&(J=s.R16F),D===s.UNSIGNED_BYTE&&(J=s.R8)),b===s.RED_INTEGER&&(D===s.UNSIGNED_BYTE&&(J=s.R8UI),D===s.UNSIGNED_SHORT&&(J=s.R16UI),D===s.UNSIGNED_INT&&(J=s.R32UI),D===s.BYTE&&(J=s.R8I),D===s.SHORT&&(J=s.R16I),D===s.INT&&(J=s.R32I)),b===s.RG&&(D===s.FLOAT&&(J=s.RG32F),D===s.HALF_FLOAT&&(J=s.RG16F),D===s.UNSIGNED_BYTE&&(J=s.RG8)),b===s.RG_INTEGER&&(D===s.UNSIGNED_BYTE&&(J=s.RG8UI),D===s.UNSIGNED_SHORT&&(J=s.RG16UI),D===s.UNSIGNED_INT&&(J=s.RG32UI),D===s.BYTE&&(J=s.RG8I),D===s.SHORT&&(J=s.RG16I),D===s.INT&&(J=s.RG32I)),b===s.RGB_INTEGER&&(D===s.UNSIGNED_BYTE&&(J=s.RGB8UI),D===s.UNSIGNED_SHORT&&(J=s.RGB16UI),D===s.UNSIGNED_INT&&(J=s.RGB32UI),D===s.BYTE&&(J=s.RGB8I),D===s.SHORT&&(J=s.RGB16I),D===s.INT&&(J=s.RGB32I)),b===s.RGBA_INTEGER&&(D===s.UNSIGNED_BYTE&&(J=s.RGBA8UI),D===s.UNSIGNED_SHORT&&(J=s.RGBA16UI),D===s.UNSIGNED_INT&&(J=s.RGBA32UI),D===s.BYTE&&(J=s.RGBA8I),D===s.SHORT&&(J=s.RGBA16I),D===s.INT&&(J=s.RGBA32I)),b===s.RGB&&(D===s.UNSIGNED_INT_5_9_9_9_REV&&(J=s.RGB9_E5),D===s.UNSIGNED_INT_10F_11F_11F_REV&&(J=s.R11F_G11F_B10F)),b===s.RGBA){const Oe=$?ml:mt.getTransfer(Z);D===s.FLOAT&&(J=s.RGBA32F),D===s.HALF_FLOAT&&(J=s.RGBA16F),D===s.UNSIGNED_BYTE&&(J=Oe===vt?s.SRGB8_ALPHA8:s.RGBA8),D===s.UNSIGNED_SHORT_4_4_4_4&&(J=s.RGBA4),D===s.UNSIGNED_SHORT_5_5_5_1&&(J=s.RGB5_A1)}return(J===s.R16F||J===s.R32F||J===s.RG16F||J===s.RG32F||J===s.RGBA16F||J===s.RGBA32F)&&e.get("EXT_color_buffer_float"),J}function M(N,b){let D;return N?b===null||b===qi||b===_n?D=s.DEPTH24_STENCIL8:b===xi?D=s.DEPTH32F_STENCIL8:b===ga&&(D=s.DEPTH24_STENCIL8,ge("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===qi||b===_n?D=s.DEPTH_COMPONENT24:b===xi?D=s.DEPTH_COMPONENT32F:b===ga&&(D=s.DEPTH_COMPONENT16),D}function w(N,b){return g(N)===!0||N.isFramebufferTexture&&N.minFilter!==Ht&&N.minFilter!==Rt?Math.log2(Math.max(b.width,b.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?b.mipmaps.length:1}function T(N){const b=N.target;b.removeEventListener("dispose",T),_(b),b.isVideoTexture&&c.delete(b)}function A(N){const b=N.target;b.removeEventListener("dispose",A),P(b)}function _(N){const b=i.get(N);if(b.__webglInit===void 0)return;const D=N.source,Z=u.get(D);if(Z){const $=Z[b.__cacheKey];$.usedTimes--,$.usedTimes===0&&S(N),Object.keys(Z).length===0&&u.delete(D)}i.remove(N)}function S(N){const b=i.get(N);s.deleteTexture(b.__webglTexture);const D=N.source,Z=u.get(D);delete Z[b.__cacheKey],a.memory.textures--}function P(N){const b=i.get(N);if(N.depthTexture&&(N.depthTexture.dispose(),i.remove(N.depthTexture)),N.isWebGLCubeRenderTarget)for(let Z=0;Z<6;Z++){if(Array.isArray(b.__webglFramebuffer[Z]))for(let $=0;$<b.__webglFramebuffer[Z].length;$++)s.deleteFramebuffer(b.__webglFramebuffer[Z][$]);else s.deleteFramebuffer(b.__webglFramebuffer[Z]);b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer[Z])}else{if(Array.isArray(b.__webglFramebuffer))for(let Z=0;Z<b.__webglFramebuffer.length;Z++)s.deleteFramebuffer(b.__webglFramebuffer[Z]);else s.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&s.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let Z=0;Z<b.__webglColorRenderbuffer.length;Z++)b.__webglColorRenderbuffer[Z]&&s.deleteRenderbuffer(b.__webglColorRenderbuffer[Z]);b.__webglDepthRenderbuffer&&s.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const D=N.textures;for(let Z=0,$=D.length;Z<$;Z++){const J=i.get(D[Z]);J.__webglTexture&&(s.deleteTexture(J.__webglTexture),a.memory.textures--),i.remove(D[Z])}i.remove(N)}let C=0;function L(){C=0}function U(){const N=C;return N>=r.maxTextures&&ge("WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+r.maxTextures),C+=1,N}function V(N){const b=[];return b.push(N.wrapS),b.push(N.wrapT),b.push(N.wrapR||0),b.push(N.magFilter),b.push(N.minFilter),b.push(N.anisotropy),b.push(N.internalFormat),b.push(N.format),b.push(N.type),b.push(N.generateMipmaps),b.push(N.premultiplyAlpha),b.push(N.flipY),b.push(N.unpackAlignment),b.push(N.colorSpace),b.join()}function B(N,b){const D=i.get(N);if(N.isVideoTexture&&We(N),N.isRenderTargetTexture===!1&&N.isExternalTexture!==!0&&N.version>0&&D.__version!==N.version){const Z=N.image;if(Z===null)ge("WebGLRenderer: Texture marked for update but no image data found.");else if(Z.complete===!1)ge("WebGLRenderer: Texture marked for update but image is incomplete");else{K(D,N,b);return}}else N.isExternalTexture&&(D.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,D.__webglTexture,s.TEXTURE0+b)}function k(N,b){const D=i.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&D.__version!==N.version){K(D,N,b);return}else N.isExternalTexture&&(D.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,D.__webglTexture,s.TEXTURE0+b)}function W(N,b){const D=i.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&D.__version!==N.version){K(D,N,b);return}t.bindTexture(s.TEXTURE_3D,D.__webglTexture,s.TEXTURE0+b)}function se(N,b){const D=i.get(N);if(N.isCubeDepthTexture!==!0&&N.version>0&&D.__version!==N.version){ae(D,N,b);return}t.bindTexture(s.TEXTURE_CUBE_MAP,D.__webglTexture,s.TEXTURE0+b)}const ie={[pa]:s.REPEAT,[Ci]:s.CLAMP_TO_EDGE,[ma]:s.MIRRORED_REPEAT},oe={[Ht]:s.NEAREST,[Hh]:s.NEAREST_MIPMAP_NEAREST,[vn]:s.NEAREST_MIPMAP_LINEAR,[Rt]:s.LINEAR,[fa]:s.LINEAR_MIPMAP_NEAREST,[Ss]:s.LINEAR_MIPMAP_LINEAR},be={[O0]:s.NEVER,[V0]:s.ALWAYS,[U0]:s.LESS,[pc]:s.LEQUAL,[F0]:s.EQUAL,[mc]:s.GEQUAL,[z0]:s.GREATER,[B0]:s.NOTEQUAL};function Ce(N,b){if(b.type===xi&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===Rt||b.magFilter===fa||b.magFilter===vn||b.magFilter===Ss||b.minFilter===Rt||b.minFilter===fa||b.minFilter===vn||b.minFilter===Ss)&&ge("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(N,s.TEXTURE_WRAP_S,ie[b.wrapS]),s.texParameteri(N,s.TEXTURE_WRAP_T,ie[b.wrapT]),(N===s.TEXTURE_3D||N===s.TEXTURE_2D_ARRAY)&&s.texParameteri(N,s.TEXTURE_WRAP_R,ie[b.wrapR]),s.texParameteri(N,s.TEXTURE_MAG_FILTER,oe[b.magFilter]),s.texParameteri(N,s.TEXTURE_MIN_FILTER,oe[b.minFilter]),b.compareFunction&&(s.texParameteri(N,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(N,s.TEXTURE_COMPARE_FUNC,be[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Ht||b.minFilter!==vn&&b.minFilter!==Ss||b.type===xi&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||i.get(b).__currentAnisotropy){const D=e.get("EXT_texture_filter_anisotropic");s.texParameterf(N,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,r.getMaxAnisotropy())),i.get(b).__currentAnisotropy=b.anisotropy}}}function tt(N,b){let D=!1;N.__webglInit===void 0&&(N.__webglInit=!0,b.addEventListener("dispose",T));const Z=b.source;let $=u.get(Z);$===void 0&&($={},u.set(Z,$));const J=V(b);if(J!==N.__cacheKey){$[J]===void 0&&($[J]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,D=!0),$[J].usedTimes++;const Oe=$[N.__cacheKey];Oe!==void 0&&($[N.__cacheKey].usedTimes--,Oe.usedTimes===0&&S(b)),N.__cacheKey=J,N.__webglTexture=$[J].texture}return D}function wt(N,b,D){return Math.floor(Math.floor(N/D)/b)}function Et(N,b,D,Z){const $=N.updateRanges;if($.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,b.width,b.height,D,Z,b.data);else{$.sort((Be,re)=>Be.start-re.start);let J=0;for(let Be=1;Be<$.length;Be++){const re=$[J],ue=$[Be],je=re.start+re.count,Ue=wt(ue.start,b.width,4),Ae=wt(re.start,b.width,4);ue.start<=je+1&&Ue===Ae&&wt(ue.start+ue.count-1,b.width,4)===Ue?re.count=Math.max(re.count,ue.start+ue.count-re.start):(++J,$[J]=ue)}$.length=J+1;const Oe=s.getParameter(s.UNPACK_ROW_LENGTH),pe=s.getParameter(s.UNPACK_SKIP_PIXELS),He=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,b.width);for(let Be=0,re=$.length;Be<re;Be++){const ue=$[Be],je=Math.floor(ue.start/4),Ue=Math.ceil(ue.count/4),Ae=je%b.width,ut=Math.floor(je/b.width),O=Ue,me=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ae),s.pixelStorei(s.UNPACK_SKIP_ROWS,ut),t.texSubImage2D(s.TEXTURE_2D,0,Ae,ut,O,me,D,Z,b.data)}N.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,Oe),s.pixelStorei(s.UNPACK_SKIP_PIXELS,pe),s.pixelStorei(s.UNPACK_SKIP_ROWS,He)}}function K(N,b,D){let Z=s.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(Z=s.TEXTURE_2D_ARRAY),b.isData3DTexture&&(Z=s.TEXTURE_3D);const $=tt(N,b),J=b.source;t.bindTexture(Z,N.__webglTexture,s.TEXTURE0+D);const Oe=i.get(J);if(J.version!==Oe.__version||$===!0){t.activeTexture(s.TEXTURE0+D);const pe=mt.getPrimaries(mt.workingColorSpace),He=b.colorSpace===Gs?null:mt.getPrimaries(b.colorSpace),Be=b.colorSpace===Gs||pe===He?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Be);let re=y(b.image,!1,r.maxTextureSize);re=Je(b,re);const ue=n.convert(b.format,b.colorSpace),je=n.convert(b.type);let Ue=v(b.internalFormat,ue,je,b.colorSpace,b.isVideoTexture);Ce(Z,b);let Ae;const ut=b.mipmaps,O=b.isVideoTexture!==!0,me=Oe.__version===void 0||$===!0,ce=J.dataReady,Le=w(b,re);if(b.isDepthTexture)Ue=M(b.format===ur,b.type),me&&(O?t.texStorage2D(s.TEXTURE_2D,1,Ue,re.width,re.height):t.texImage2D(s.TEXTURE_2D,0,Ue,re.width,re.height,0,ue,je,null));else if(b.isDataTexture)if(ut.length>0){O&&me&&t.texStorage2D(s.TEXTURE_2D,Le,Ue,ut[0].width,ut[0].height);for(let ne=0,Y=ut.length;ne<Y;ne++)Ae=ut[ne],O?ce&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,Ae.width,Ae.height,ue,je,Ae.data):t.texImage2D(s.TEXTURE_2D,ne,Ue,Ae.width,Ae.height,0,ue,je,Ae.data);b.generateMipmaps=!1}else O?(me&&t.texStorage2D(s.TEXTURE_2D,Le,Ue,re.width,re.height),ce&&Et(b,re,ue,je)):t.texImage2D(s.TEXTURE_2D,0,Ue,re.width,re.height,0,ue,je,re.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){O&&me&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Le,Ue,ut[0].width,ut[0].height,re.depth);for(let ne=0,Y=ut.length;ne<Y;ne++)if(Ae=ut[ne],b.format!==vi)if(ue!==null)if(O){if(ce)if(b.layerUpdates.size>0){const De=Xm(Ae.width,Ae.height,b.format,b.type);for(const Ze of b.layerUpdates){const Qt=Ae.data.subarray(Ze*De/Ae.data.BYTES_PER_ELEMENT,(Ze+1)*De/Ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,Ze,Ae.width,Ae.height,1,ue,Qt)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,0,Ae.width,Ae.height,re.depth,ue,Ae.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ne,Ue,Ae.width,Ae.height,re.depth,0,Ae.data,0,0);else ge("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else O?ce&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,0,Ae.width,Ae.height,re.depth,ue,je,Ae.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ne,Ue,Ae.width,Ae.height,re.depth,0,ue,je,Ae.data)}else{O&&me&&t.texStorage2D(s.TEXTURE_2D,Le,Ue,ut[0].width,ut[0].height);for(let ne=0,Y=ut.length;ne<Y;ne++)Ae=ut[ne],b.format!==vi?ue!==null?O?ce&&t.compressedTexSubImage2D(s.TEXTURE_2D,ne,0,0,Ae.width,Ae.height,ue,Ae.data):t.compressedTexImage2D(s.TEXTURE_2D,ne,Ue,Ae.width,Ae.height,0,Ae.data):ge("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):O?ce&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,Ae.width,Ae.height,ue,je,Ae.data):t.texImage2D(s.TEXTURE_2D,ne,Ue,Ae.width,Ae.height,0,ue,je,Ae.data)}else if(b.isDataArrayTexture)if(O){if(me&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Le,Ue,re.width,re.height,re.depth),ce)if(b.layerUpdates.size>0){const ne=Xm(re.width,re.height,b.format,b.type);for(const Y of b.layerUpdates){const De=re.data.subarray(Y*ne/re.data.BYTES_PER_ELEMENT,(Y+1)*ne/re.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Y,re.width,re.height,1,ue,je,De)}b.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,re.width,re.height,re.depth,ue,je,re.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Ue,re.width,re.height,re.depth,0,ue,je,re.data);else if(b.isData3DTexture)O?(me&&t.texStorage3D(s.TEXTURE_3D,Le,Ue,re.width,re.height,re.depth),ce&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,re.width,re.height,re.depth,ue,je,re.data)):t.texImage3D(s.TEXTURE_3D,0,Ue,re.width,re.height,re.depth,0,ue,je,re.data);else if(b.isFramebufferTexture){if(me)if(O)t.texStorage2D(s.TEXTURE_2D,Le,Ue,re.width,re.height);else{let ne=re.width,Y=re.height;for(let De=0;De<Le;De++)t.texImage2D(s.TEXTURE_2D,De,Ue,ne,Y,0,ue,je,null),ne>>=1,Y>>=1}}else if(ut.length>0){if(O&&me){const ne=fe(ut[0]);t.texStorage2D(s.TEXTURE_2D,Le,Ue,ne.width,ne.height)}for(let ne=0,Y=ut.length;ne<Y;ne++)Ae=ut[ne],O?ce&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,ue,je,Ae):t.texImage2D(s.TEXTURE_2D,ne,Ue,ue,je,Ae);b.generateMipmaps=!1}else if(O){if(me){const ne=fe(re);t.texStorage2D(s.TEXTURE_2D,Le,Ue,ne.width,ne.height)}ce&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,ue,je,re)}else t.texImage2D(s.TEXTURE_2D,0,Ue,ue,je,re);g(b)&&f(Z),Oe.__version=J.version,b.onUpdate&&b.onUpdate(b)}N.__version=b.version}function ae(N,b,D){if(b.image.length!==6)return;const Z=tt(N,b),$=b.source;t.bindTexture(s.TEXTURE_CUBE_MAP,N.__webglTexture,s.TEXTURE0+D);const J=i.get($);if($.version!==J.__version||Z===!0){t.activeTexture(s.TEXTURE0+D);const Oe=mt.getPrimaries(mt.workingColorSpace),pe=b.colorSpace===Gs?null:mt.getPrimaries(b.colorSpace),He=b.colorSpace===Gs||Oe===pe?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);const Be=b.isCompressedTexture||b.image[0].isCompressedTexture,re=b.image[0]&&b.image[0].isDataTexture,ue=[];for(let Y=0;Y<6;Y++)!Be&&!re?ue[Y]=y(b.image[Y],!0,r.maxCubemapSize):ue[Y]=re?b.image[Y].image:b.image[Y],ue[Y]=Je(b,ue[Y]);const je=ue[0],Ue=n.convert(b.format,b.colorSpace),Ae=n.convert(b.type),ut=v(b.internalFormat,Ue,Ae,b.colorSpace),O=b.isVideoTexture!==!0,me=J.__version===void 0||Z===!0,ce=$.dataReady;let Le=w(b,je);Ce(s.TEXTURE_CUBE_MAP,b);let ne;if(Be){O&&me&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Le,ut,je.width,je.height);for(let Y=0;Y<6;Y++){ne=ue[Y].mipmaps;for(let De=0;De<ne.length;De++){const Ze=ne[De];b.format!==vi?Ue!==null?O?ce&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De,0,0,Ze.width,Ze.height,Ue,Ze.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De,ut,Ze.width,Ze.height,0,Ze.data):ge("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De,0,0,Ze.width,Ze.height,Ue,Ae,Ze.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De,ut,Ze.width,Ze.height,0,Ue,Ae,Ze.data)}}}else{if(ne=b.mipmaps,O&&me){ne.length>0&&Le++;const Y=fe(ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Le,ut,Y.width,Y.height)}for(let Y=0;Y<6;Y++)if(re){O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,ue[Y].width,ue[Y].height,Ue,Ae,ue[Y].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,ut,ue[Y].width,ue[Y].height,0,Ue,Ae,ue[Y].data);for(let De=0;De<ne.length;De++){const Ze=ne[De].image[Y].image;O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De+1,0,0,Ze.width,Ze.height,Ue,Ae,Ze.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De+1,ut,Ze.width,Ze.height,0,Ue,Ae,Ze.data)}}else{O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,Ue,Ae,ue[Y]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,ut,Ue,Ae,ue[Y]);for(let De=0;De<ne.length;De++){const Ze=ne[De];O?ce&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De+1,0,0,Ue,Ae,Ze.image[Y]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Y,De+1,ut,Ue,Ae,Ze.image[Y])}}}g(b)&&f(s.TEXTURE_CUBE_MAP),J.__version=$.version,b.onUpdate&&b.onUpdate(b)}N.__version=b.version}function le(N,b,D,Z,$,J){const Oe=n.convert(D.format,D.colorSpace),pe=n.convert(D.type),He=v(D.internalFormat,Oe,pe,D.colorSpace),Be=i.get(b),re=i.get(D);if(re.__renderTarget=b,!Be.__hasExternalTextures){const ue=Math.max(1,b.width>>J),je=Math.max(1,b.height>>J);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?t.texImage3D($,J,He,ue,je,b.depth,0,Oe,pe,null):t.texImage2D($,J,He,ue,je,0,Oe,pe,null)}t.bindFramebuffer(s.FRAMEBUFFER,N),Ge(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Z,$,re.__webglTexture,0,I(b)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,Z,$,re.__webglTexture,J),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Qe(N,b,D){if(s.bindRenderbuffer(s.RENDERBUFFER,N),b.depthBuffer){const Z=b.depthTexture,$=Z&&Z.isDepthTexture?Z.type:null,J=M(b.stencilBuffer,$),Oe=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Ge(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,I(b),J,b.width,b.height):D?s.renderbufferStorageMultisample(s.RENDERBUFFER,I(b),J,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,J,b.width,b.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,Oe,s.RENDERBUFFER,N)}else{const Z=b.textures;for(let $=0;$<Z.length;$++){const J=Z[$],Oe=n.convert(J.format,J.colorSpace),pe=n.convert(J.type),He=v(J.internalFormat,Oe,pe,J.colorSpace);Ge(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,I(b),He,b.width,b.height):D?s.renderbufferStorageMultisample(s.RENDERBUFFER,I(b),He,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,He,b.width,b.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Ye(N,b,D){const Z=b.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,N),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const $=i.get(b.depthTexture);if($.__renderTarget=b,(!$.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),Z){if($.__webglInit===void 0&&($.__webglInit=!0,b.depthTexture.addEventListener("dispose",T)),$.__webglTexture===void 0){$.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,$.__webglTexture),Ce(s.TEXTURE_CUBE_MAP,b.depthTexture);const Be=n.convert(b.depthTexture.format),re=n.convert(b.depthTexture.type);let ue;b.depthTexture.format===ws?ue=s.DEPTH_COMPONENT24:b.depthTexture.format===ur&&(ue=s.DEPTH24_STENCIL8);for(let je=0;je<6;je++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,ue,b.width,b.height,0,Be,re,null)}}else B(b.depthTexture,0);const J=$.__webglTexture,Oe=I(b),pe=Z?s.TEXTURE_CUBE_MAP_POSITIVE_X+D:s.TEXTURE_2D,He=b.depthTexture.format===ur?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(b.depthTexture.format===ws)Ge(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,He,pe,J,0,Oe):s.framebufferTexture2D(s.FRAMEBUFFER,He,pe,J,0);else if(b.depthTexture.format===ur)Ge(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,He,pe,J,0,Oe):s.framebufferTexture2D(s.FRAMEBUFFER,He,pe,J,0);else throw new Error("Unknown depthTexture format")}function Te(N){const b=i.get(N),D=N.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==N.depthTexture){const Z=N.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),Z){const $=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,Z.removeEventListener("dispose",$)};Z.addEventListener("dispose",$),b.__depthDisposeCallback=$}b.__boundDepthTexture=Z}if(N.depthTexture&&!b.__autoAllocateDepthBuffer)if(D)for(let Z=0;Z<6;Z++)Ye(b.__webglFramebuffer[Z],N,Z);else{const Z=N.texture.mipmaps;Z&&Z.length>0?Ye(b.__webglFramebuffer[0],N,0):Ye(b.__webglFramebuffer,N,0)}else if(D){b.__webglDepthbuffer=[];for(let Z=0;Z<6;Z++)if(t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[Z]),b.__webglDepthbuffer[Z]===void 0)b.__webglDepthbuffer[Z]=s.createRenderbuffer(),Qe(b.__webglDepthbuffer[Z],N,!1);else{const $=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,J=b.__webglDepthbuffer[Z];s.bindRenderbuffer(s.RENDERBUFFER,J),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,J)}}else{const Z=N.texture.mipmaps;if(Z&&Z.length>0?t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=s.createRenderbuffer(),Qe(b.__webglDepthbuffer,N,!1);else{const $=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,J=b.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,J),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,J)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function ct(N,b,D){const Z=i.get(N);b!==void 0&&le(Z.__webglFramebuffer,N,N.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),D!==void 0&&Te(N)}function Q(N){const b=N.texture,D=i.get(N),Z=i.get(b);N.addEventListener("dispose",A);const $=N.textures,J=N.isWebGLCubeRenderTarget===!0,Oe=$.length>1;if(Oe||(Z.__webglTexture===void 0&&(Z.__webglTexture=s.createTexture()),Z.__version=b.version,a.memory.textures++),J){D.__webglFramebuffer=[];for(let pe=0;pe<6;pe++)if(b.mipmaps&&b.mipmaps.length>0){D.__webglFramebuffer[pe]=[];for(let He=0;He<b.mipmaps.length;He++)D.__webglFramebuffer[pe][He]=s.createFramebuffer()}else D.__webglFramebuffer[pe]=s.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){D.__webglFramebuffer=[];for(let pe=0;pe<b.mipmaps.length;pe++)D.__webglFramebuffer[pe]=s.createFramebuffer()}else D.__webglFramebuffer=s.createFramebuffer();if(Oe)for(let pe=0,He=$.length;pe<He;pe++){const Be=i.get($[pe]);Be.__webglTexture===void 0&&(Be.__webglTexture=s.createTexture(),a.memory.textures++)}if(N.samples>0&&Ge(N)===!1){D.__webglMultisampledFramebuffer=s.createFramebuffer(),D.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,D.__webglMultisampledFramebuffer);for(let pe=0;pe<$.length;pe++){const He=$[pe];D.__webglColorRenderbuffer[pe]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,D.__webglColorRenderbuffer[pe]);const Be=n.convert(He.format,He.colorSpace),re=n.convert(He.type),ue=v(He.internalFormat,Be,re,He.colorSpace,N.isXRRenderTarget===!0),je=I(N);s.renderbufferStorageMultisample(s.RENDERBUFFER,je,ue,N.width,N.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+pe,s.RENDERBUFFER,D.__webglColorRenderbuffer[pe])}s.bindRenderbuffer(s.RENDERBUFFER,null),N.depthBuffer&&(D.__webglDepthRenderbuffer=s.createRenderbuffer(),Qe(D.__webglDepthRenderbuffer,N,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(J){t.bindTexture(s.TEXTURE_CUBE_MAP,Z.__webglTexture),Ce(s.TEXTURE_CUBE_MAP,b);for(let pe=0;pe<6;pe++)if(b.mipmaps&&b.mipmaps.length>0)for(let He=0;He<b.mipmaps.length;He++)le(D.__webglFramebuffer[pe][He],N,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+pe,He);else le(D.__webglFramebuffer[pe],N,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0);g(b)&&f(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Oe){for(let pe=0,He=$.length;pe<He;pe++){const Be=$[pe],re=i.get(Be);let ue=s.TEXTURE_2D;(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(ue=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ue,re.__webglTexture),Ce(ue,Be),le(D.__webglFramebuffer,N,Be,s.COLOR_ATTACHMENT0+pe,ue,0),g(Be)&&f(ue)}t.unbindTexture()}else{let pe=s.TEXTURE_2D;if((N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(pe=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(pe,Z.__webglTexture),Ce(pe,b),b.mipmaps&&b.mipmaps.length>0)for(let He=0;He<b.mipmaps.length;He++)le(D.__webglFramebuffer[He],N,b,s.COLOR_ATTACHMENT0,pe,He);else le(D.__webglFramebuffer,N,b,s.COLOR_ATTACHMENT0,pe,0);g(b)&&f(pe),t.unbindTexture()}N.depthBuffer&&Te(N)}function ee(N){const b=N.textures;for(let D=0,Z=b.length;D<Z;D++){const $=b[D];if(g($)){const J=x(N),Oe=i.get($).__webglTexture;t.bindTexture(J,Oe),f(J),t.unbindTexture()}}}const he=[],_e=[];function Se(N){if(N.samples>0){if(Ge(N)===!1){const b=N.textures,D=N.width,Z=N.height;let $=s.COLOR_BUFFER_BIT;const J=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Oe=i.get(N),pe=b.length>1;if(pe)for(let Be=0;Be<b.length;Be++)t.bindFramebuffer(s.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Be,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,Oe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Be,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer);const He=N.texture.mipmaps;He&&He.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer);for(let Be=0;Be<b.length;Be++){if(N.resolveDepthBuffer&&(N.depthBuffer&&($|=s.DEPTH_BUFFER_BIT),N.stencilBuffer&&N.resolveStencilBuffer&&($|=s.STENCIL_BUFFER_BIT)),pe){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,Oe.__webglColorRenderbuffer[Be]);const re=i.get(b[Be]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,re,0)}s.blitFramebuffer(0,0,D,Z,0,0,D,Z,$,s.NEAREST),l===!0&&(he.length=0,_e.length=0,he.push(s.COLOR_ATTACHMENT0+Be),N.depthBuffer&&N.resolveDepthBuffer===!1&&(he.push(J),_e.push(J),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,_e)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,he))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),pe)for(let Be=0;Be<b.length;Be++){t.bindFramebuffer(s.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Be,s.RENDERBUFFER,Oe.__webglColorRenderbuffer[Be]);const re=i.get(b[Be]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,Oe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Be,s.TEXTURE_2D,re,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer)}else if(N.depthBuffer&&N.resolveDepthBuffer===!1&&l){const b=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[b])}}}function I(N){return Math.min(r.maxSamples,N.samples)}function Ge(N){const b=i.get(N);return N.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function We(N){const b=a.render.frame;c.get(N)!==b&&(c.set(N,b),N.update())}function Je(N,b){const D=N.colorSpace,Z=N.format,$=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||D!==kr&&D!==Gs&&(mt.getTransfer(D)===vt?(Z!==vi||$!==Ri)&&ge("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ve("WebGLTextures: Unsupported texture color space:",D)),b}function fe(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(h.width=N.naturalWidth||N.width,h.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(h.width=N.displayWidth,h.height=N.displayHeight):(h.width=N.width,h.height=N.height),h}this.allocateTextureUnit=U,this.resetTextureUnits=L,this.setTexture2D=B,this.setTexture2DArray=k,this.setTexture3D=W,this.setTextureCube=se,this.rebindTextures=ct,this.setupRenderTarget=Q,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=Se,this.setupDepthRenderbuffer=Te,this.setupFrameBufferTexture=le,this.useMultisampledRTT=Ge,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function bv(s,e){function t(i,r=Gs){let n;const a=mt.getTransfer(r);if(i===Ri)return s.UNSIGNED_BYTE;if(i===jh)return s.UNSIGNED_SHORT_4_4_4_4;if(i===Xh)return s.UNSIGNED_SHORT_5_5_5_1;if(i===qh)return s.UNSIGNED_INT_5_9_9_9_REV;if(i===Yh)return s.UNSIGNED_INT_10F_11F_11F_REV;if(i===ip)return s.BYTE;if(i===sp)return s.SHORT;if(i===ga)return s.UNSIGNED_SHORT;if(i===Wh)return s.INT;if(i===qi)return s.UNSIGNED_INT;if(i===xi)return s.FLOAT;if(i===Ts)return s.HALF_FLOAT;if(i===rp)return s.ALPHA;if(i===Zh)return s.RGB;if(i===vi)return s.RGBA;if(i===ws)return s.DEPTH_COMPONENT;if(i===ur)return s.DEPTH_STENCIL;if(i===Wo)return s.RED;if(i===ya)return s.RED_INTEGER;if(i===Br)return s.RG;if(i===jo)return s.RG_INTEGER;if(i===Xo)return s.RGBA_INTEGER;if(i===xa||i===va||i===qo||i===_a)if(a===vt)if(n=e.get("WEBGL_compressed_texture_s3tc_srgb"),n!==null){if(i===xa)return n.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===va)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===qo)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===_a)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(n=e.get("WEBGL_compressed_texture_s3tc"),n!==null){if(i===xa)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===va)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===qo)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===_a)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Yo||i===Jh||i===Zo||i===Jo)if(n=e.get("WEBGL_compressed_texture_pvrtc"),n!==null){if(i===Yo)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Jh)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Zo)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Jo)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Ko||i===$o||i===Qo||i===el||i===tl||i===il||i===sl)if(n=e.get("WEBGL_compressed_texture_etc"),n!==null){if(i===Ko||i===$o)return a===vt?n.COMPRESSED_SRGB8_ETC2:n.COMPRESSED_RGB8_ETC2;if(i===Qo)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:n.COMPRESSED_RGBA8_ETC2_EAC;if(i===el)return n.COMPRESSED_R11_EAC;if(i===tl)return n.COMPRESSED_SIGNED_R11_EAC;if(i===il)return n.COMPRESSED_RG11_EAC;if(i===sl)return n.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===rl||i===Kh||i===$h||i===Qh||i===nl||i===ec||i===tc||i===ic||i===sc||i===rc||i===nc||i===ac||i===oc||i===lc)if(n=e.get("WEBGL_compressed_texture_astc"),n!==null){if(i===rl)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:n.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Kh)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:n.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===$h)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:n.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Qh)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:n.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===nl)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:n.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ec)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:n.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===tc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:n.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ic)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:n.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===sc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:n.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===rc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:n.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===nc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:n.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ac)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:n.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===oc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:n.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===lc)return a===vt?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:n.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===al||i===hc||i===ol)if(n=e.get("EXT_texture_compression_bptc"),n!==null){if(i===al)return a===vt?n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:n.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===hc)return n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ol)return n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ll||i===hl||i===cl||i===ul)if(n=e.get("EXT_texture_compression_rgtc"),n!==null){if(i===ll)return n.COMPRESSED_RED_RGTC1_EXT;if(i===hl)return n.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===cl)return n.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ul)return n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===_n?s.UNSIGNED_INT_24_8:s[i]!==void 0?s[i]:null}return{convert:t}}const eC=`
|
|
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 iC{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Qp(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new $i({vertexShader:eC,fragmentShader:tC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Xt(new na(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class sC extends Es{constructor(e,t){super();const i=this;let r=null,n=1,a=null,o="local-floor",l=1,h=null,c=null,d=null,u=null,p=null,m=null;const y=typeof XRWebGLBinding<"u",g=new iC,f={},x=t.getContextAttributes();let v=null,M=null;const w=[],T=[],A=new te;let _=null;const S=new li;S.viewport=new It;const P=new li;P.viewport=new It;const C=[S,P],L=new Fm;let U=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(K){let ae=w[K];return ae===void 0&&(ae=new vc,w[K]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(K){let ae=w[K];return ae===void 0&&(ae=new vc,w[K]=ae),ae.getGripSpace()},this.getHand=function(K){let ae=w[K];return ae===void 0&&(ae=new vc,w[K]=ae),ae.getHandSpace()};function B(K){const ae=T.indexOf(K.inputSource);if(ae===-1)return;const le=w[ae];le!==void 0&&(le.update(K.inputSource,K.frame,h||a),le.dispatchEvent({type:K.type,data:K.inputSource}))}function k(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",k),r.removeEventListener("inputsourceschange",W);for(let K=0;K<w.length;K++){const ae=T[K];ae!==null&&(T[K]=null,w[K]&&w[K].disconnect(ae))}U=null,V=null,g.reset();for(const K in f)delete f[K];e.setRenderTarget(v),p=null,u=null,d=null,r=null,M=null,Et.stop(),i.isPresenting=!1,e.setPixelRatio(_),e.setSize(A.width,A.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){n=K,i.isPresenting===!0&&ge("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,i.isPresenting===!0&&ge("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||a},this.setReferenceSpace=function(K){h=K},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&y&&(d=new XRWebGLBinding(r,t)),d},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(K){if(r=K,r!==null){if(v=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",k),r.addEventListener("inputsourceschange",W),x.xrCompatible!==!0&&await t.makeXRCompatible(),_=e.getPixelRatio(),e.getSize(A),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let ae=null,le=null,Qe=null;x.depth&&(Qe=x.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ae=x.stencil?ur:ws,le=x.stencil?_n:qi);const Ye={colorFormat:t.RGBA8,depthFormat:Qe,scaleFactor:n};d=this.getBinding(),u=d.createProjectionLayer(Ye),r.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),M=new Bi(u.textureWidth,u.textureHeight,{format:vi,type:Ri,depthTexture:new On(u.textureWidth,u.textureHeight,le,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:x.stencil,colorSpace:e.outputColorSpace,samples:x.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ae={antialias:x.antialias,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:n};p=new XRWebGLLayer(r,t,ae),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),M=new Bi(p.framebufferWidth,p.framebufferHeight,{format:vi,type:Ri,colorSpace:e.outputColorSpace,stencilBuffer:x.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),h=null,a=await r.requestReferenceSpace(o),Et.setContext(r),Et.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function W(K){for(let ae=0;ae<K.removed.length;ae++){const le=K.removed[ae],Qe=T.indexOf(le);Qe>=0&&(T[Qe]=null,w[Qe]&&w[Qe].disconnect(le))}for(let ae=0;ae<K.added.length;ae++){const le=K.added[ae];let Qe=T.indexOf(le);if(Qe===-1){for(let Te=0;Te<w.length;Te++)if(Te>=T.length){T.push(le),Qe=Te;break}else if(T[Te]===null){T[Te]=le,Qe=Te;break}if(Qe===-1)break}const Ye=w[Qe];Ye&&Ye.connect(le)}}const se=new R,ie=new R;function oe(K,ae,le){se.setFromMatrixPosition(ae.matrixWorld),ie.setFromMatrixPosition(le.matrixWorld);const Qe=se.distanceTo(ie),Ye=ae.projectionMatrix.elements,Te=le.projectionMatrix.elements,ct=Ye[14]/(Ye[10]-1),Q=Ye[14]/(Ye[10]+1),ee=(Ye[9]+1)/Ye[5],he=(Ye[9]-1)/Ye[5],_e=(Ye[8]-1)/Ye[0],Se=(Te[8]+1)/Te[0],I=ct*_e,Ge=ct*Se,We=Qe/(-_e+Se),Je=We*-_e;if(ae.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Je),K.translateZ(We),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Ye[10]===-1)K.projectionMatrix.copy(ae.projectionMatrix),K.projectionMatrixInverse.copy(ae.projectionMatrixInverse);else{const fe=ct+We,N=Q+We,b=I-Je,D=Ge+(Qe-Je),Z=ee*Q/N*fe,$=he*Q/N*fe;K.projectionMatrix.makePerspective(b,D,Z,$,fe,N),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function be(K,ae){ae===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(ae.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(r===null)return;let ae=K.near,le=K.far;g.texture!==null&&(g.depthNear>0&&(ae=g.depthNear),g.depthFar>0&&(le=g.depthFar)),L.near=P.near=S.near=ae,L.far=P.far=S.far=le,(U!==L.near||V!==L.far)&&(r.updateRenderState({depthNear:L.near,depthFar:L.far}),U=L.near,V=L.far),L.layers.mask=K.layers.mask|6,S.layers.mask=L.layers.mask&-5,P.layers.mask=L.layers.mask&-3;const Qe=K.parent,Ye=L.cameras;be(L,Qe);for(let Te=0;Te<Ye.length;Te++)be(Ye[Te],Qe);Ye.length===2?oe(L,S,P):L.projectionMatrix.copy(S.projectionMatrix),Ce(K,L,Qe)};function Ce(K,ae,le){le===null?K.matrix.copy(ae.matrixWorld):(K.matrix.copy(le.matrixWorld),K.matrix.invert(),K.matrix.multiply(ae.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(ae.projectionMatrix),K.projectionMatrixInverse.copy(ae.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=ba*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function(K){l=K,u!==null&&(u.fixedFoveation=K),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=K)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(L)},this.getCameraTexture=function(K){return f[K]};let tt=null;function wt(K,ae){if(c=ae.getViewerPose(h||a),m=ae,c!==null){const le=c.views;p!==null&&(e.setRenderTargetFramebuffer(M,p.framebuffer),e.setRenderTarget(M));let Qe=!1;le.length!==L.cameras.length&&(L.cameras.length=0,Qe=!0);for(let Te=0;Te<le.length;Te++){const ct=le[Te];let Q=null;if(p!==null)Q=p.getViewport(ct);else{const he=d.getViewSubImage(u,ct);Q=he.viewport,Te===0&&(e.setRenderTargetTextures(M,he.colorTexture,he.depthStencilTexture),e.setRenderTarget(M))}let ee=C[Te];ee===void 0&&(ee=new li,ee.layers.enable(Te),ee.viewport=new It,C[Te]=ee),ee.matrix.fromArray(ct.transform.matrix),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.projectionMatrix.fromArray(ct.projectionMatrix),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert(),ee.viewport.set(Q.x,Q.y,Q.width,Q.height),Te===0&&(L.matrix.copy(ee.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),Qe===!0&&L.cameras.push(ee)}const Ye=r.enabledFeatures;if(Ye&&Ye.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){d=i.getBinding();const Te=d.getDepthInformation(le[0]);Te&&Te.isValid&&Te.texture&&g.init(Te,r.renderState)}if(Ye&&Ye.includes("camera-access")&&y){e.state.unbindTexture(),d=i.getBinding();for(let Te=0;Te<le.length;Te++){const ct=le[Te].camera;if(ct){let Q=f[ct];Q||(Q=new Qp,f[ct]=Q);const ee=d.getCameraImage(ct);Q.sourceTexture=ee}}}}if(i.controllerAutoUpdate)for(let le=0;le<w.length;le++){const Qe=T[le],Ye=w[le];Qe!==null&&Ye!==void 0&&Ye.update(Qe,ae,h||a)}tt&&tt(K,ae),ae.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ae}),m=null}const Et=new Yx;Et.setAnimationLoop(wt),this.setAnimationLoop=function(K){tt=K},this.dispose=function(){}}}const qn=new ns,rC=new et;function nC(s,e){function t(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function i(g,f){f.color.getRGB(g.fogColor.value,Yy(s)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function r(g,f,x,v,M){f.isMeshBasicMaterial?n(g,f):f.isMeshLambertMaterial?(n(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(n(g,f),d(g,f)):f.isMeshPhongMaterial?(n(g,f),c(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(n(g,f),u(g,f),f.isMeshPhysicalMaterial&&p(g,f,M)):f.isMeshMatcapMaterial?(n(g,f),m(g,f)):f.isMeshDepthMaterial?n(g,f):f.isMeshDistanceMaterial?(n(g,f),y(g,f)):f.isMeshNormalMaterial?n(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?l(g,f,x,v):f.isSpriteMaterial?h(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function n(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,t(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===yi&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,t(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===yi&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,t(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,t(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);const x=e.get(f),v=x.envMap,M=x.envMapRotation;v&&(g.envMap.value=v,qn.copy(M),qn.x*=-1,qn.y*=-1,qn.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(qn.y*=-1,qn.z*=-1),g.envMapRotation.value.setFromMatrix4(rC.makeRotationFromEuler(qn)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,g.aoMapTransform))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform))}function o(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function l(g,f,x,v){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*x,g.scale.value=v*.5,f.map&&(g.map.value=f.map,t(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function h(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function c(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function d(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function u(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function p(g,f,x){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===yi&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,f){f.matcap&&(g.matcap.value=f.matcap)}function y(g,f){const x=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function aC(s,e,t,i){let r={},n={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,v){const M=v.program;i.uniformBlockBinding(x,M)}function h(x,v){let M=r[x.id];M===void 0&&(m(x),M=c(x),r[x.id]=M,x.addEventListener("dispose",g));const w=v.program;i.updateUBOMapping(x,w);const T=e.render.frame;n[x.id]!==T&&(u(x),n[x.id]=T)}function c(x){const v=d();x.__bindingPointIndex=v;const M=s.createBuffer(),w=x.__size,T=x.usage;return s.bindBuffer(s.UNIFORM_BUFFER,M),s.bufferData(s.UNIFORM_BUFFER,w,T),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,v,M),M}function d(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return Ve("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(x){const v=r[x.id],M=x.uniforms,w=x.__cache;s.bindBuffer(s.UNIFORM_BUFFER,v);for(let T=0,A=M.length;T<A;T++){const _=Array.isArray(M[T])?M[T]:[M[T]];for(let S=0,P=_.length;S<P;S++){const C=_[S];if(p(C,T,S,w)===!0){const L=C.__offset,U=Array.isArray(C.value)?C.value:[C.value];let V=0;for(let B=0;B<U.length;B++){const k=U[B],W=y(k);typeof k=="number"||typeof k=="boolean"?(C.__data[0]=k,s.bufferSubData(s.UNIFORM_BUFFER,L+V,C.__data)):k.isMatrix3?(C.__data[0]=k.elements[0],C.__data[1]=k.elements[1],C.__data[2]=k.elements[2],C.__data[3]=0,C.__data[4]=k.elements[3],C.__data[5]=k.elements[4],C.__data[6]=k.elements[5],C.__data[7]=0,C.__data[8]=k.elements[6],C.__data[9]=k.elements[7],C.__data[10]=k.elements[8],C.__data[11]=0):(k.toArray(C.__data,V),V+=W.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,L,C.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(x,v,M,w){const T=x.value,A=v+"_"+M;if(w[A]===void 0)return typeof T=="number"||typeof T=="boolean"?w[A]=T:w[A]=T.clone(),!0;{const _=w[A];if(typeof T=="number"||typeof T=="boolean"){if(_!==T)return w[A]=T,!0}else if(_.equals(T)===!1)return _.copy(T),!0}return!1}function m(x){const v=x.uniforms;let M=0;const w=16;for(let A=0,_=v.length;A<_;A++){const S=Array.isArray(v[A])?v[A]:[v[A]];for(let P=0,C=S.length;P<C;P++){const L=S[P],U=Array.isArray(L.value)?L.value:[L.value];for(let V=0,B=U.length;V<B;V++){const k=U[V],W=y(k),se=M%w,ie=se%W.boundary,oe=se+ie;M+=ie,oe!==0&&w-oe<W.storage&&(M+=w-oe),L.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=M,M+=W.storage}}}const T=M%w;return T>0&&(M+=w-T),x.__size=M,x.__cache={},this}function y(x){const v={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?ge("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ge("WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){const v=x.target;v.removeEventListener("dispose",g);const M=a.indexOf(v.__bindingPointIndex);a.splice(M,1),s.deleteBuffer(r[v.id]),delete r[v.id],delete n[v.id]}function f(){for(const x in r)s.deleteBuffer(r[x]);a=[],r={},n={}}return{bind:l,update:h,dispose:f}}const oC=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 Ys=null;function lC(){return Ys===null&&(Ys=new os(oC,16,16,Br,Ts),Ys.name="DFG_LUT",Ys.minFilter=Rt,Ys.magFilter=Rt,Ys.wrapS=Ci,Ys.wrapT=Ci,Ys.generateMipmaps=!1,Ys.needsUpdate=!0),Ys}class Sv{constructor(e={}){const{canvas:t=H0(),context:i=null,depth:r=!0,stencil:n=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=Ri}=e;this.isWebGLRenderer=!0;let m;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=i.getContextAttributes().alpha}else m=a;const y=p,g=new Set([Xo,jo,ga]),f=new Set([Ri,qi,fa,_n,jh,Xh]),x=new Uint32Array(4),v=new Int32Array(4);let M=null,w=null;const T=[],A=[];let _=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=rs,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const S=this;let P=!1;this._outputColorSpace=Ii;let C=0,L=0,U=null,V=-1,B=null;const k=new It,W=new It;let se=null;const ie=new we(0);let oe=0,be=t.width,Ce=t.height,tt=1,wt=null,Et=null;const K=new It(0,0,be,Ce),ae=new It(0,0,be,Ce);let le=!1;const Qe=new Pn;let Ye=!1,Te=!1;const ct=new et,Q=new R,ee=new It,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let _e=!1;function Se(){return U===null?tt:1}let I=i;function Ge(E,F){return t.getContext(E,F)}try{const E={alpha:!0,depth:r,stencil:n,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${yn}`),t.addEventListener("webglcontextlost",De,!1),t.addEventListener("webglcontextrestored",Ze,!1),t.addEventListener("webglcontextcreationerror",Qt,!1),I===null){const F="webgl2";if(I=Ge(F,E),I===null)throw Ge(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw Ve("WebGLRenderer: "+E.message),E}let We,Je,fe,N,b,D,Z,$,J,Oe,pe,He,Be,re,ue,je,Ue,Ae,ut,O,me,ce,Le;function ne(){We=new cA(I),We.init(),me=new bv(I,We),Je=new sA(I,We,e,me),fe=new $N(I,We),Je.reversedDepthBuffer&&u&&fe.buffers.depth.setReversed(!0),N=new pA(I),b=new zN,D=new QN(I,We,fe,b,Je,me,N),Z=new hA(S),$=new vT(I),ce=new tA(I,$),J=new uA(I,$,N,ce),Oe=new fA(I,J,$,ce,N),Ae=new mA(I,Je,D),ue=new rA(b),pe=new FN(S,Z,We,Je,ce,ue),He=new nC(S,b),Be=new VN,re=new XN(We),Ue=new eA(S,Z,fe,Oe,m,l),je=new KN(S,Oe,Je),Le=new aC(I,N,Je,fe),ut=new iA(I,We,N),O=new dA(I,We,N),N.programs=pe.programs,S.capabilities=Je,S.extensions=We,S.properties=b,S.renderLists=Be,S.shadowMap=je,S.state=fe,S.info=N}ne(),y!==Ri&&(_=new yA(y,t.width,t.height,r,n));const Y=new sC(S,I);this.xr=Y,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const E=We.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=We.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return tt},this.setPixelRatio=function(E){E!==void 0&&(tt=E,this.setSize(be,Ce,!1))},this.getSize=function(E){return E.set(be,Ce)},this.setSize=function(E,F,X=!0){if(Y.isPresenting){ge("WebGLRenderer: Can't change size while VR device is presenting.");return}be=E,Ce=F,t.width=Math.floor(E*tt),t.height=Math.floor(F*tt),X===!0&&(t.style.width=E+"px",t.style.height=F+"px"),_!==null&&_.setSize(t.width,t.height),this.setViewport(0,0,E,F)},this.getDrawingBufferSize=function(E){return E.set(be*tt,Ce*tt).floor()},this.setDrawingBufferSize=function(E,F,X){be=E,Ce=F,tt=X,t.width=Math.floor(E*X),t.height=Math.floor(F*X),this.setViewport(0,0,E,F)},this.setEffects=function(E){if(y===Ri){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let F=0;F<E.length;F++)if(E[F].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(k)},this.getViewport=function(E){return E.copy(K)},this.setViewport=function(E,F,X,j){E.isVector4?K.set(E.x,E.y,E.z,E.w):K.set(E,F,X,j),fe.viewport(k.copy(K).multiplyScalar(tt).round())},this.getScissor=function(E){return E.copy(ae)},this.setScissor=function(E,F,X,j){E.isVector4?ae.set(E.x,E.y,E.z,E.w):ae.set(E,F,X,j),fe.scissor(W.copy(ae).multiplyScalar(tt).round())},this.getScissorTest=function(){return le},this.setScissorTest=function(E){fe.setScissorTest(le=E)},this.setOpaqueSort=function(E){wt=E},this.setTransparentSort=function(E){Et=E},this.getClearColor=function(E){return E.copy(Ue.getClearColor())},this.setClearColor=function(){Ue.setClearColor(...arguments)},this.getClearAlpha=function(){return Ue.getClearAlpha()},this.setClearAlpha=function(){Ue.setClearAlpha(...arguments)},this.clear=function(E=!0,F=!0,X=!0){let j=0;if(E){let G=!1;if(U!==null){const de=U.texture.format;G=g.has(de)}if(G){const de=U.texture.type,Me=f.has(de),Ie=Ue.getClearColor(),Pe=Ue.getClearAlpha(),$e=Ie.r,lt=Ie.g,pt=Ie.b;Me?(x[0]=$e,x[1]=lt,x[2]=pt,x[3]=Pe,I.clearBufferuiv(I.COLOR,0,x)):(v[0]=$e,v[1]=lt,v[2]=pt,v[3]=Pe,I.clearBufferiv(I.COLOR,0,v))}else j|=I.COLOR_BUFFER_BIT}F&&(j|=I.DEPTH_BUFFER_BIT),X&&(j|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),j!==0&&I.clear(j)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",De,!1),t.removeEventListener("webglcontextrestored",Ze,!1),t.removeEventListener("webglcontextcreationerror",Qt,!1),Ue.dispose(),Be.dispose(),re.dispose(),b.dispose(),Z.dispose(),Oe.dispose(),ce.dispose(),Le.dispose(),pe.dispose(),Y.dispose(),Y.removeEventListener("sessionstart",Ug),Y.removeEventListener("sessionend",Fg),mn.stop()};function De(E){E.preventDefault(),yl("WebGLRenderer: Context Lost."),P=!0}function Ze(){yl("WebGLRenderer: Context Restored."),P=!1;const E=N.autoReset,F=je.enabled,X=je.autoUpdate,j=je.needsUpdate,G=je.type;ne(),N.autoReset=E,je.enabled=F,je.autoUpdate=X,je.needsUpdate=j,je.type=G}function Qt(E){Ve("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Mt(E){const F=E.target;F.removeEventListener("dispose",Mt),hr(F)}function hr(E){cr(E),b.remove(E)}function cr(E){const F=b.get(E).programs;F!==void 0&&(F.forEach(function(X){pe.releaseProgram(X)}),E.isShaderMaterial&&pe.releaseShaderCache(E))}this.renderBufferDirect=function(E,F,X,j,G,de){F===null&&(F=he);const Me=G.isMesh&&G.matrixWorld.determinant()<0,Ie=oM(E,F,X,j,G);fe.setMaterial(j,Me);let Pe=X.index,$e=1;if(j.wireframe===!0){if(Pe=J.getWireframeAttribute(X),Pe===void 0)return;$e=2}const lt=X.drawRange,pt=X.attributes.position;let qe=lt.start*$e,Ct=(lt.start+lt.count)*$e;de!==null&&(qe=Math.max(qe,de.start*$e),Ct=Math.min(Ct,(de.start+de.count)*$e)),Pe!==null?(qe=Math.max(qe,0),Ct=Math.min(Ct,Pe.count)):pt!=null&&(qe=Math.max(qe,0),Ct=Math.min(Ct,pt.count));const jt=Ct-qe;if(jt<0||jt===1/0)return;ce.setup(G,j,Ie,X,Pe);let Ut,At=ut;if(Pe!==null&&(Ut=$.get(Pe),At=O,At.setIndex(Ut)),G.isMesh)j.wireframe===!0?(fe.setLineWidth(j.wireframeLinewidth*Se()),At.setMode(I.LINES)):At.setMode(I.TRIANGLES);else if(G.isLine){let Gt=j.linewidth;Gt===void 0&&(Gt=1),fe.setLineWidth(Gt*Se()),G.isLineSegments?At.setMode(I.LINES):G.isLineLoop?At.setMode(I.LINE_LOOP):At.setMode(I.LINE_STRIP)}else G.isPoints?At.setMode(I.POINTS):G.isSprite&&At.setMode(I.TRIANGLES);if(G.isBatchedMesh)if(G._multiDrawInstances!==null)xl("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),At.renderMultiDrawInstances(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount,G._multiDrawInstances);else if(We.get("WEBGL_multi_draw"))At.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const Gt=G._multiDrawStarts,Xe=G._multiDrawCounts,Xi=G._multiDrawCount,fn=Pe?$.get(Pe).bytesPerElement:1,_s=b.get(j).currentProgram.getUniforms();for(let Bs=0;Bs<Xi;Bs++)_s.setValue(I,"_gl_DrawID",Bs),At.render(Gt[Bs]/fn,Xe[Bs])}else if(G.isInstancedMesh)At.renderInstances(qe,jt,G.count);else if(X.isInstancedBufferGeometry){const Gt=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Xe=Math.min(X.instanceCount,Gt);At.renderInstances(qe,jt,Xe)}else At.render(qe,jt)};function Og(E,F,X){E.transparent===!0&&E.side===Ms&&E.forceSinglePass===!1?(E.side=yi,E.needsUpdate=!0,Lh(E,F,X),E.side=Vs,E.needsUpdate=!0,Lh(E,F,X),E.side=Ms):Lh(E,F,X)}this.compile=function(E,F,X=null){X===null&&(X=E),w=re.get(X),w.init(F),A.push(w),X.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),E!==X&&E.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),w.setupLights();const j=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;const de=G.material;if(de)if(Array.isArray(de))for(let Me=0;Me<de.length;Me++){const Ie=de[Me];Og(Ie,X,G),j.add(Ie)}else Og(de,X,G),j.add(de)}),w=A.pop(),j},this.compileAsync=function(E,F,X=null){const j=this.compile(E,F,X);return new Promise(G=>{function de(){if(j.forEach(function(Me){b.get(Me).currentProgram.isReady()&&j.delete(Me)}),j.size===0){G(E);return}setTimeout(de,10)}We.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let Xd=null;function aM(E){Xd&&Xd(E)}function Ug(){mn.stop()}function Fg(){mn.start()}const mn=new Yx;mn.setAnimationLoop(aM),typeof self<"u"&&mn.setContext(self),this.setAnimationLoop=function(E){Xd=E,Y.setAnimationLoop(E),E===null?mn.stop():mn.start()},Y.addEventListener("sessionstart",Ug),Y.addEventListener("sessionend",Fg),this.render=function(E,F){if(F!==void 0&&F.isCamera!==!0){Ve("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;const X=Y.enabled===!0&&Y.isPresenting===!0,j=_!==null&&(U===null||X)&&_.begin(S,U);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),Y.enabled===!0&&Y.isPresenting===!0&&(_===null||_.isCompositing()===!1)&&(Y.cameraAutoUpdate===!0&&Y.updateCamera(F),F=Y.getCamera()),E.isScene===!0&&E.onBeforeRender(S,E,F,U),w=re.get(E,A.length),w.init(F),A.push(w),ct.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Qe.setFromProjectionMatrix(ct,Yi,F.reversedDepth),Te=this.localClippingEnabled,Ye=ue.init(this.clippingPlanes,Te),M=Be.get(E,T.length),M.init(),T.push(M),Y.enabled===!0&&Y.isPresenting===!0){const de=S.xr.getDepthSensingMesh();de!==null&&qd(de,F,-1/0,S.sortObjects)}qd(E,F,0,S.sortObjects),M.finish(),S.sortObjects===!0&&M.sort(wt,Et),_e=Y.enabled===!1||Y.isPresenting===!1||Y.hasDepthSensing()===!1,_e&&Ue.addToRenderList(M,E),this.info.render.frame++,Ye===!0&&ue.beginShadows();const G=w.state.shadowsArray;if(je.render(G,E,F),Ye===!0&&ue.endShadows(),this.info.autoReset===!0&&this.info.reset(),(j&&_.hasRenderPass())===!1){const de=M.opaque,Me=M.transmissive;if(w.setupLights(),F.isArrayCamera){const Ie=F.cameras;if(Me.length>0)for(let Pe=0,$e=Ie.length;Pe<$e;Pe++){const lt=Ie[Pe];Bg(de,Me,E,lt)}_e&&Ue.render(E);for(let Pe=0,$e=Ie.length;Pe<$e;Pe++){const lt=Ie[Pe];zg(M,E,lt,lt.viewport)}}else Me.length>0&&Bg(de,Me,E,F),_e&&Ue.render(E),zg(M,E,F)}U!==null&&L===0&&(D.updateMultisampleRenderTarget(U),D.updateRenderTargetMipmap(U)),j&&_.end(S),E.isScene===!0&&E.onAfterRender(S,E,F),ce.resetDefaultState(),V=-1,B=null,A.pop(),A.length>0?(w=A[A.length-1],Ye===!0&&ue.setGlobalState(S.clippingPlanes,w.state.camera)):w=null,T.pop(),T.length>0?M=T[T.length-1]:M=null};function qd(E,F,X,j){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)X=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);else if(E.isLight)w.pushLight(E),E.castShadow&&w.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Qe.intersectsSprite(E)){j&&ee.setFromMatrixPosition(E.matrixWorld).applyMatrix4(ct);const de=Oe.update(E),Me=E.material;Me.visible&&M.push(E,de,Me,X,ee.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Qe.intersectsObject(E))){const de=Oe.update(E),Me=E.material;if(j&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),ee.copy(E.boundingSphere.center)):(de.boundingSphere===null&&de.computeBoundingSphere(),ee.copy(de.boundingSphere.center)),ee.applyMatrix4(E.matrixWorld).applyMatrix4(ct)),Array.isArray(Me)){const Ie=de.groups;for(let Pe=0,$e=Ie.length;Pe<$e;Pe++){const lt=Ie[Pe],pt=Me[lt.materialIndex];pt&&pt.visible&&M.push(E,de,pt,X,ee.z,lt)}}else Me.visible&&M.push(E,de,Me,X,ee.z,null)}}const G=E.children;for(let de=0,Me=G.length;de<Me;de++)qd(G[de],F,X,j)}function zg(E,F,X,j){const{opaque:G,transmissive:de,transparent:Me}=E;w.setupLightsView(X),Ye===!0&&ue.setGlobalState(S.clippingPlanes,X),j&&fe.viewport(k.copy(j)),G.length>0&&Ph(G,F,X),de.length>0&&Ph(de,F,X),Me.length>0&&Ph(Me,F,X),fe.buffers.depth.setTest(!0),fe.buffers.depth.setMask(!0),fe.buffers.color.setMask(!0),fe.setPolygonOffset(!1)}function Bg(E,F,X,j){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[j.id]===void 0){const pt=We.has("EXT_color_buffer_half_float")||We.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[j.id]=new Bi(1,1,{generateMipmaps:!0,type:pt?Ts:Ri,minFilter:Ss,samples:Math.max(4,Je.samples),stencilBuffer:n,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:mt.workingColorSpace})}const G=w.state.transmissionRenderTarget[j.id],de=j.viewport||k;G.setSize(de.z*S.transmissionResolutionScale,de.w*S.transmissionResolutionScale);const Me=S.getRenderTarget(),Ie=S.getActiveCubeFace(),Pe=S.getActiveMipmapLevel();S.setRenderTarget(G),S.getClearColor(ie),oe=S.getClearAlpha(),oe<1&&S.setClearColor(16777215,.5),S.clear(),_e&&Ue.render(X);const $e=S.toneMapping;S.toneMapping=rs;const lt=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),w.setupLightsView(j),Ye===!0&&ue.setGlobalState(S.clippingPlanes,j),Ph(E,X,j),D.updateMultisampleRenderTarget(G),D.updateRenderTargetMipmap(G),We.has("WEBGL_multisampled_render_to_texture")===!1){let pt=!1;for(let qe=0,Ct=F.length;qe<Ct;qe++){const jt=F[qe],{object:Ut,geometry:At,material:Gt,group:Xe}=jt;if(Gt.side===Ms&&Ut.layers.test(j.layers)){const Xi=Gt.side;Gt.side=yi,Gt.needsUpdate=!0,Vg(Ut,X,j,At,Gt,Xe),Gt.side=Xi,Gt.needsUpdate=!0,pt=!0}}pt===!0&&(D.updateMultisampleRenderTarget(G),D.updateRenderTargetMipmap(G))}S.setRenderTarget(Me,Ie,Pe),S.setClearColor(ie,oe),lt!==void 0&&(j.viewport=lt),S.toneMapping=$e}function Ph(E,F,X){const j=F.isScene===!0?F.overrideMaterial:null;for(let G=0,de=E.length;G<de;G++){const Me=E[G],{object:Ie,geometry:Pe,group:$e}=Me;let lt=Me.material;lt.allowOverride===!0&&j!==null&&(lt=j),Ie.layers.test(X.layers)&&Vg(Ie,F,X,Pe,lt,$e)}}function Vg(E,F,X,j,G,de){E.onBeforeRender(S,F,X,j,G,de),E.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(S,F,X,j,E,de),G.transparent===!0&&G.side===Ms&&G.forceSinglePass===!1?(G.side=yi,G.needsUpdate=!0,S.renderBufferDirect(X,F,j,G,E,de),G.side=Vs,G.needsUpdate=!0,S.renderBufferDirect(X,F,j,G,E,de),G.side=Ms):S.renderBufferDirect(X,F,j,G,E,de),E.onAfterRender(S,F,X,j,G,de)}function Lh(E,F,X){F.isScene!==!0&&(F=he);const j=b.get(E),G=w.state.lights,de=w.state.shadowsArray,Me=G.state.version,Ie=pe.getParameters(E,G.state,de,F,X),Pe=pe.getProgramCacheKey(Ie);let $e=j.programs;j.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?F.environment:null,j.fog=F.fog;const lt=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;j.envMap=Z.get(E.envMap||j.environment,lt),j.envMapRotation=j.environment!==null&&E.envMap===null?F.environmentRotation:E.envMapRotation,$e===void 0&&(E.addEventListener("dispose",Mt),$e=new Map,j.programs=$e);let pt=$e.get(Pe);if(pt!==void 0){if(j.currentProgram===pt&&j.lightsStateVersion===Me)return Gg(E,Ie),pt}else Ie.uniforms=pe.getUniforms(E),E.onBuild(X,Ie,S),E.onBeforeCompile(Ie,S),pt=pe.acquireProgram(Ie,Pe),$e.set(Pe,pt),j.uniforms=Ie.uniforms;const qe=j.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(qe.clippingPlanes=ue.uniform),Gg(E,Ie),j.needsLights=hM(E),j.lightsStateVersion=Me,j.needsLights&&(qe.ambientLightColor.value=G.state.ambient,qe.lightProbe.value=G.state.probe,qe.directionalLights.value=G.state.directional,qe.directionalLightShadows.value=G.state.directionalShadow,qe.spotLights.value=G.state.spot,qe.spotLightShadows.value=G.state.spotShadow,qe.rectAreaLights.value=G.state.rectArea,qe.ltc_1.value=G.state.rectAreaLTC1,qe.ltc_2.value=G.state.rectAreaLTC2,qe.pointLights.value=G.state.point,qe.pointLightShadows.value=G.state.pointShadow,qe.hemisphereLights.value=G.state.hemi,qe.directionalShadowMatrix.value=G.state.directionalShadowMatrix,qe.spotLightMatrix.value=G.state.spotLightMatrix,qe.spotLightMap.value=G.state.spotLightMap,qe.pointShadowMatrix.value=G.state.pointShadowMatrix),j.currentProgram=pt,j.uniformsList=null,pt}function kg(E){if(E.uniformsList===null){const F=E.currentProgram.getUniforms();E.uniformsList=Cu.seqWithValue(F.seq,E.uniforms)}return E.uniformsList}function Gg(E,F){const X=b.get(E);X.outputColorSpace=F.outputColorSpace,X.batching=F.batching,X.batchingColor=F.batchingColor,X.instancing=F.instancing,X.instancingColor=F.instancingColor,X.instancingMorph=F.instancingMorph,X.skinning=F.skinning,X.morphTargets=F.morphTargets,X.morphNormals=F.morphNormals,X.morphColors=F.morphColors,X.morphTargetsCount=F.morphTargetsCount,X.numClippingPlanes=F.numClippingPlanes,X.numIntersection=F.numClipIntersection,X.vertexAlphas=F.vertexAlphas,X.vertexTangents=F.vertexTangents,X.toneMapping=F.toneMapping}function oM(E,F,X,j,G){F.isScene!==!0&&(F=he),D.resetTextureUnits();const de=F.fog,Me=j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial?F.environment:null,Ie=U===null?S.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:kr,Pe=j.isMeshStandardMaterial||j.isMeshLambertMaterial&&!j.envMap||j.isMeshPhongMaterial&&!j.envMap,$e=Z.get(j.envMap||Me,Pe),lt=j.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,pt=!!X.attributes.tangent&&(!!j.normalMap||j.anisotropy>0),qe=!!X.morphAttributes.position,Ct=!!X.morphAttributes.normal,jt=!!X.morphAttributes.color;let Ut=rs;j.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(Ut=S.toneMapping);const At=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Gt=At!==void 0?At.length:0,Xe=b.get(j),Xi=w.state.lights;if(Ye===!0&&(Te===!0||E!==B)){const Yt=E===B&&j.id===V;ue.setState(j,E,Yt)}let fn=!1;j.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Xi.state.version||Xe.outputColorSpace!==Ie||G.isBatchedMesh&&Xe.batching===!1||!G.isBatchedMesh&&Xe.batching===!0||G.isBatchedMesh&&Xe.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&Xe.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&Xe.instancing===!1||!G.isInstancedMesh&&Xe.instancing===!0||G.isSkinnedMesh&&Xe.skinning===!1||!G.isSkinnedMesh&&Xe.skinning===!0||G.isInstancedMesh&&Xe.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Xe.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Xe.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Xe.instancingMorph===!1&&G.morphTexture!==null||Xe.envMap!==$e||j.fog===!0&&Xe.fog!==de||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==ue.numPlanes||Xe.numIntersection!==ue.numIntersection)||Xe.vertexAlphas!==lt||Xe.vertexTangents!==pt||Xe.morphTargets!==qe||Xe.morphNormals!==Ct||Xe.morphColors!==jt||Xe.toneMapping!==Ut||Xe.morphTargetsCount!==Gt)&&(fn=!0):(fn=!0,Xe.__version=j.version);let _s=Xe.currentProgram;fn===!0&&(_s=Lh(j,F,G));let Bs=!1,gn=!1,oa=!1;const Nt=_s.getUniforms(),ui=Xe.uniforms;if(fe.useProgram(_s.program)&&(Bs=!0,gn=!0,oa=!0),(j.id!==V||j._forceRefresh)&&(V=j.id,gn=!0,j._forceRefresh=!1),Bs||B!==E){fe.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Nt.setValue(I,"projectionMatrix",E.projectionMatrix),Nt.setValue(I,"viewMatrix",E.matrixWorldInverse);const Yt=Nt.map.cameraPosition;Yt!==void 0&&Yt.setValue(I,Q.setFromMatrixPosition(E.matrixWorld)),Je.logarithmicDepthBuffer&&Nt.setValue(I,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&Nt.setValue(I,"isOrthographic",E.isOrthographicCamera===!0),B!==E&&(B=E,gn=!0,oa=!0)}if(Xe.needsLights&&(Xi.state.directionalShadowMap.length>0&&Nt.setValue(I,"directionalShadowMap",Xi.state.directionalShadowMap,D),Xi.state.spotShadowMap.length>0&&Nt.setValue(I,"spotShadowMap",Xi.state.spotShadowMap,D),Xi.state.pointShadowMap.length>0&&Nt.setValue(I,"pointShadowMap",Xi.state.pointShadowMap,D)),G.isSkinnedMesh){Nt.setOptional(I,G,"bindMatrix"),Nt.setOptional(I,G,"bindMatrixInverse");const Yt=G.skeleton;Yt&&(Yt.boneTexture===null&&Yt.computeBoneTexture(),Nt.setValue(I,"boneTexture",Yt.boneTexture,D))}G.isBatchedMesh&&(Nt.setOptional(I,G,"batchingTexture"),Nt.setValue(I,"batchingTexture",G._matricesTexture,D),Nt.setOptional(I,G,"batchingIdTexture"),Nt.setValue(I,"batchingIdTexture",G._indirectTexture,D),Nt.setOptional(I,G,"batchingColorTexture"),G._colorsTexture!==null&&Nt.setValue(I,"batchingColorTexture",G._colorsTexture,D));const Dr=X.morphAttributes;if((Dr.position!==void 0||Dr.normal!==void 0||Dr.color!==void 0)&&Ae.update(G,X,_s),(gn||Xe.receiveShadow!==G.receiveShadow)&&(Xe.receiveShadow=G.receiveShadow,Nt.setValue(I,"receiveShadow",G.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&F.environment!==null&&(ui.envMapIntensity.value=F.environmentIntensity),ui.dfgLUT!==void 0&&(ui.dfgLUT.value=lC()),gn&&(Nt.setValue(I,"toneMappingExposure",S.toneMappingExposure),Xe.needsLights&&lM(ui,oa),de&&j.fog===!0&&He.refreshFogUniforms(ui,de),He.refreshMaterialUniforms(ui,j,tt,Ce,w.state.transmissionRenderTarget[E.id]),Cu.upload(I,kg(Xe),ui,D)),j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Cu.upload(I,kg(Xe),ui,D),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&Nt.setValue(I,"center",G.center),Nt.setValue(I,"modelViewMatrix",G.modelViewMatrix),Nt.setValue(I,"normalMatrix",G.normalMatrix),Nt.setValue(I,"modelMatrix",G.matrixWorld),j.isShaderMaterial||j.isRawShaderMaterial){const Yt=j.uniformsGroups;for(let Do=0,la=Yt.length;Do<la;Do++){const Hg=Yt[Do];Le.update(Hg,_s),Le.bind(Hg,_s)}}return _s}function lM(E,F){E.ambientLightColor.needsUpdate=F,E.lightProbe.needsUpdate=F,E.directionalLights.needsUpdate=F,E.directionalLightShadows.needsUpdate=F,E.pointLights.needsUpdate=F,E.pointLightShadows.needsUpdate=F,E.spotLights.needsUpdate=F,E.spotLightShadows.needsUpdate=F,E.rectAreaLights.needsUpdate=F,E.hemisphereLights.needsUpdate=F}function hM(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(E,F,X){const j=b.get(E);j.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,j.__autoAllocateDepthBuffer===!1&&(j.__useRenderToTexture=!1),b.get(E.texture).__webglTexture=F,b.get(E.depthTexture).__webglTexture=j.__autoAllocateDepthBuffer?void 0:X,j.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,F){const X=b.get(E);X.__webglFramebuffer=F,X.__useDefaultFramebuffer=F===void 0};const cM=I.createFramebuffer();this.setRenderTarget=function(E,F=0,X=0){U=E,C=F,L=X;let j=null,G=!1,de=!1;if(E){const Me=b.get(E);if(Me.__useDefaultFramebuffer!==void 0){fe.bindFramebuffer(I.FRAMEBUFFER,Me.__webglFramebuffer),k.copy(E.viewport),W.copy(E.scissor),se=E.scissorTest,fe.viewport(k),fe.scissor(W),fe.setScissorTest(se),V=-1;return}else if(Me.__webglFramebuffer===void 0)D.setupRenderTarget(E);else if(Me.__hasExternalTextures)D.rebindTextures(E,b.get(E.texture).__webglTexture,b.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const $e=E.depthTexture;if(Me.__boundDepthTexture!==$e){if($e!==null&&b.has($e)&&(E.width!==$e.image.width||E.height!==$e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");D.setupDepthRenderbuffer(E)}}const Ie=E.texture;(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(de=!0);const Pe=b.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Pe[F])?j=Pe[F][X]:j=Pe[F],G=!0):E.samples>0&&D.useMultisampledRTT(E)===!1?j=b.get(E).__webglMultisampledFramebuffer:Array.isArray(Pe)?j=Pe[X]:j=Pe,k.copy(E.viewport),W.copy(E.scissor),se=E.scissorTest}else k.copy(K).multiplyScalar(tt).floor(),W.copy(ae).multiplyScalar(tt).floor(),se=le;if(X!==0&&(j=cM),fe.bindFramebuffer(I.FRAMEBUFFER,j)&&fe.drawBuffers(E,j),fe.viewport(k),fe.scissor(W),fe.setScissorTest(se),G){const Me=b.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+F,Me.__webglTexture,X)}else if(de){const Me=F;for(let Ie=0;Ie<E.textures.length;Ie++){const Pe=b.get(E.textures[Ie]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+Ie,Pe.__webglTexture,X,Me)}}else if(E!==null&&X!==0){const Me=b.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Me.__webglTexture,X)}V=-1},this.readRenderTargetPixels=function(E,F,X,j,G,de,Me,Ie=0){if(!(E&&E.isWebGLRenderTarget)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=b.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Me!==void 0&&(Pe=Pe[Me]),Pe){fe.bindFramebuffer(I.FRAMEBUFFER,Pe);try{const $e=E.textures[Ie],lt=$e.format,pt=$e.type;if(E.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Ie),!Je.textureFormatReadable(lt)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Je.textureTypeReadable(pt)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=E.width-j&&X>=0&&X<=E.height-G&&I.readPixels(F,X,j,G,me.convert(lt),me.convert(pt),de)}finally{const $e=U!==null?b.get(U).__webglFramebuffer:null;fe.bindFramebuffer(I.FRAMEBUFFER,$e)}}},this.readRenderTargetPixelsAsync=async function(E,F,X,j,G,de,Me,Ie=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pe=b.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Me!==void 0&&(Pe=Pe[Me]),Pe)if(F>=0&&F<=E.width-j&&X>=0&&X<=E.height-G){fe.bindFramebuffer(I.FRAMEBUFFER,Pe);const $e=E.textures[Ie],lt=$e.format,pt=$e.type;if(E.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Ie),!Je.textureFormatReadable(lt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Je.textureTypeReadable(pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qe=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,qe),I.bufferData(I.PIXEL_PACK_BUFFER,de.byteLength,I.STREAM_READ),I.readPixels(F,X,j,G,me.convert(lt),me.convert(pt),0);const Ct=U!==null?b.get(U).__webglFramebuffer:null;fe.bindFramebuffer(I.FRAMEBUFFER,Ct);const jt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await VM(I,jt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,qe),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,de),I.deleteBuffer(qe),I.deleteSync(jt),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,F=null,X=0){const j=Math.pow(2,-X),G=Math.floor(E.image.width*j),de=Math.floor(E.image.height*j),Me=F!==null?F.x:0,Ie=F!==null?F.y:0;D.setTexture2D(E,0),I.copyTexSubImage2D(I.TEXTURE_2D,X,0,0,Me,Ie,G,de),fe.unbindTexture()};const uM=I.createFramebuffer(),dM=I.createFramebuffer();this.copyTextureToTexture=function(E,F,X=null,j=null,G=0,de=0){let Me,Ie,Pe,$e,lt,pt,qe,Ct,jt;const Ut=E.isCompressedTexture?E.mipmaps[de]:E.image;if(X!==null)Me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Pe=X.isBox3?X.max.z-X.min.z:1,$e=X.min.x,lt=X.min.y,pt=X.isBox3?X.min.z:0;else{const ui=Math.pow(2,-G);Me=Math.floor(Ut.width*ui),Ie=Math.floor(Ut.height*ui),E.isDataArrayTexture?Pe=Ut.depth:E.isData3DTexture?Pe=Math.floor(Ut.depth*ui):Pe=1,$e=0,lt=0,pt=0}j!==null?(qe=j.x,Ct=j.y,jt=j.z):(qe=0,Ct=0,jt=0);const At=me.convert(F.format),Gt=me.convert(F.type);let Xe;F.isData3DTexture?(D.setTexture3D(F,0),Xe=I.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(D.setTexture2DArray(F,0),Xe=I.TEXTURE_2D_ARRAY):(D.setTexture2D(F,0),Xe=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,F.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,F.unpackAlignment);const Xi=I.getParameter(I.UNPACK_ROW_LENGTH),fn=I.getParameter(I.UNPACK_IMAGE_HEIGHT),_s=I.getParameter(I.UNPACK_SKIP_PIXELS),Bs=I.getParameter(I.UNPACK_SKIP_ROWS),gn=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,Ut.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Ut.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,$e),I.pixelStorei(I.UNPACK_SKIP_ROWS,lt),I.pixelStorei(I.UNPACK_SKIP_IMAGES,pt);const oa=E.isDataArrayTexture||E.isData3DTexture,Nt=F.isDataArrayTexture||F.isData3DTexture;if(E.isDepthTexture){const ui=b.get(E),Dr=b.get(F),Yt=b.get(ui.__renderTarget),Do=b.get(Dr.__renderTarget);fe.bindFramebuffer(I.READ_FRAMEBUFFER,Yt.__webglFramebuffer),fe.bindFramebuffer(I.DRAW_FRAMEBUFFER,Do.__webglFramebuffer);for(let la=0;la<Pe;la++)oa&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,b.get(E).__webglTexture,G,pt+la),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,b.get(F).__webglTexture,de,jt+la)),I.blitFramebuffer($e,lt,Me,Ie,qe,Ct,Me,Ie,I.DEPTH_BUFFER_BIT,I.NEAREST);fe.bindFramebuffer(I.READ_FRAMEBUFFER,null),fe.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(G!==0||E.isRenderTargetTexture||b.has(E)){const ui=b.get(E),Dr=b.get(F);fe.bindFramebuffer(I.READ_FRAMEBUFFER,uM),fe.bindFramebuffer(I.DRAW_FRAMEBUFFER,dM);for(let Yt=0;Yt<Pe;Yt++)oa?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,ui.__webglTexture,G,pt+Yt):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,ui.__webglTexture,G),Nt?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Dr.__webglTexture,de,jt+Yt):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Dr.__webglTexture,de),G!==0?I.blitFramebuffer($e,lt,Me,Ie,qe,Ct,Me,Ie,I.COLOR_BUFFER_BIT,I.NEAREST):Nt?I.copyTexSubImage3D(Xe,de,qe,Ct,jt+Yt,$e,lt,Me,Ie):I.copyTexSubImage2D(Xe,de,qe,Ct,$e,lt,Me,Ie);fe.bindFramebuffer(I.READ_FRAMEBUFFER,null),fe.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else Nt?E.isDataTexture||E.isData3DTexture?I.texSubImage3D(Xe,de,qe,Ct,jt,Me,Ie,Pe,At,Gt,Ut.data):F.isCompressedArrayTexture?I.compressedTexSubImage3D(Xe,de,qe,Ct,jt,Me,Ie,Pe,At,Ut.data):I.texSubImage3D(Xe,de,qe,Ct,jt,Me,Ie,Pe,At,Gt,Ut):E.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,de,qe,Ct,Me,Ie,At,Gt,Ut.data):E.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,de,qe,Ct,Ut.width,Ut.height,At,Ut.data):I.texSubImage2D(I.TEXTURE_2D,de,qe,Ct,Me,Ie,At,Gt,Ut);I.pixelStorei(I.UNPACK_ROW_LENGTH,Xi),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,fn),I.pixelStorei(I.UNPACK_SKIP_PIXELS,_s),I.pixelStorei(I.UNPACK_SKIP_ROWS,Bs),I.pixelStorei(I.UNPACK_SKIP_IMAGES,gn),de===0&&F.generateMipmaps&&I.generateMipmap(Xe),fe.unbindTexture()},this.initRenderTarget=function(E){b.get(E).__webglFramebuffer===void 0&&D.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?D.setTextureCube(E,0):E.isData3DTexture?D.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?D.setTexture2DArray(E,0):D.setTexture2D(E,0),fe.unbindTexture()},this.resetState=function(){C=0,L=0,U=null,fe.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Yi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=mt._getDrawingBufferColorSpace(e),t.unpackColorSpace=mt._getUnpackColorSpace()}}const hC=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Bh,AddEquation:Ur,AddOperation:u0,AdditiveAnimationBlendMode:hp,AdditiveBlending:Dh,AgXToneMapping:Vh,AlphaFormat:np,AlwaysCompare:V0,AlwaysDepth:Fo,AlwaysStencilFunc:dc,AmbientLight:Pm,AnimationAction:Sx,AnimationClip:Xa,AnimationLoader:ES,AnimationMixer:Tx,AnimationObjectGroup:YS,AnimationUtils:bS,ArcCurve:Dy,ArrayCamera:Fm,ArrowHelper:pT,AttachedBindMode:ip,Audio:Vm,AudioAnalyser:zS,AudioContext:yu,AudioListener:vx,AudioLoader:gx,AxesHelper:jx,BackSide:yi,BasicDepthPacking:cp,BasicShadowMap:mM,BatchedMesh:qp,BezierInterpolant:tx,Bone:kc,BooleanKeyframeTrack:Jr,Box2:sT,Box3:di,Box3Helper:Hx,BoxGeometry:dn,BoxHelper:Gx,BufferAttribute:bt,BufferGeometry:rt,BufferGeometryLoader:dx,ByteType:sp,Cache:Is,Camera:Hl,CameraHelper:kx,CanvasTexture:Py,CapsuleGeometry:Ld,CatmullRomCurve3:am,CineonToneMapping:ep,CircleGeometry:Dd,ClampToEdgeWrapping:Ci,Clock:eT,Color:we,ColorKeyframeTrack:uu,ColorManagement:mt,Compatibility:OM,CompressedArrayTexture:Ry,CompressedCubeTexture:Iy,CompressedTexture:Ol,CompressedTextureLoader:AS,ConeGeometry:Nh,ConstantAlphaFactor:l0,ConstantColorFactor:a0,Controls:qx,CubeCamera:Um,CubeDepthTexture:Ly,CubeReflectionMapping:ks,CubeRefractionMapping:zr,CubeTexture:Va,CubeTextureLoader:NS,CubeUVReflectionMapping:xn,CubicBezierCurve:om,CubicBezierCurve3:Uy,CubicInterpolant:Qy,CullFaceBack:Yd,CullFaceFront:qg,CullFaceFrontBack:pM,CullFaceNone:Xg,Curve:ls,CurvePath:zy,CustomBlending:$d,CustomToneMapping:tp,CylinderGeometry:Ro,Cylindrical:tT,Data3DTexture:_l,DataArrayTexture:gc,DataTexture:os,DataTextureLoader:rx,DataUtils:ay,DecrementStencilOp:T0,DecrementWrapStencilOp:E0,DefaultLoadingManager:wm,DepthFormat:ws,DepthStencilFormat:ur,DepthTexture:On,DetachedBindMode:d0,DirectionalLight:Im,DirectionalLightHelper:Vx,DiscreteInterpolant:ex,DodecahedronGeometry:Od,DoubleSide:Ms,DstAlphaFactor:t0,DstColorFactor:s0,DynamicCopyUsage:CM,DynamicDrawUsage:k0,DynamicReadUsage:EM,EdgesGeometry:tm,EllipseCurve:iu,EqualCompare:F0,EqualDepth:Bo,EqualStencilFunc:R0,EquirectangularReflectionMapping:ca,EquirectangularRefractionMapping:ua,Euler:ns,EventDispatcher:Es,ExternalTexture:Qp,ExtrudeGeometry:Ch,FileLoader:js,Float16BufferAttribute:Sb,Float32BufferAttribute:Ne,FloatType:xi,Fog:_p,FogExp2:Id,FramebufferTexture:Gb,FrontSide:Vs,Frustum:Pn,FrustumArray:Pd,GLBufferAttribute:QS,GLSL1:IM,GLSL3:fc,GreaterCompare:z0,GreaterDepth:ko,GreaterEqualCompare:mc,GreaterEqualDepth:Vo,GreaterEqualStencilFunc:D0,GreaterStencilFunc:P0,GridHelper:Fx,Group:wn,HalfFloatType:Ts,HemisphereLight:Em,HemisphereLightHelper:cT,IcosahedronGeometry:Ud,ImageBitmapLoader:fx,ImageLoader:Gl,ImageUtils:mp,IncrementStencilOp:S0,IncrementWrapStencilOp:w0,InstancedBufferAttribute:Rn,InstancedBufferGeometry:Dm,InstancedInterleavedBuffer:wx,InstancedMesh:Hp,Int16BufferAttribute:Mb,Int32BufferAttribute:bb,Int8BufferAttribute:xb,IntType:Wh,InterleavedBuffer:Al,InterleavedBufferAttribute:Da,Interpolant:zn,InterpolateBezier:lp,InterpolateDiscrete:_a,InterpolateLinear:dl,InterpolateSmooth:cc,InterpolationSamplingMode:DM,InterpolationSamplingType:LM,InvertStencilOp:A0,KeepStencilOp:Gr,KeyframeTrack:Qi,LOD:Op,LatheGeometry:Fd,Layers:Ml,LessCompare:U0,LessDepth:zo,LessEqualCompare:pc,LessEqualDepth:Fr,LessEqualStencilFunc:I0,LessStencilFunc:C0,Light:Kr,LightProbe:ux,Line:Sr,Line3:Px,LineBasicMaterial:Ti,LineCurve:lm,LineCurve3:Fy,LineDashedMaterial:Ky,LineLoop:Zp,LineSegments:Rs,LinearFilter:Rt,LinearInterpolant:Tm,LinearMipMapLinearFilter:m0,LinearMipMapNearestFilter:yM,LinearMipmapLinearFilter:Ss,LinearMipmapNearestFilter:ma,LinearSRGBColorSpace:kr,LinearToneMapping:Fh,LinearTransfer:ml,Loader:Oi,LoaderUtils:fu,LoadingManager:du,LoopOnce:ap,LoopPingPong:f0,LoopRepeat:op,MOUSE:Wg,Material:pi,MaterialBlending:fM,MaterialLoader:Gd,MathUtils:q0,Matrix2:iT,Matrix3:at,Matrix4:et,MaxEquation:Qd,Mesh:Xt,MeshBasicMaterial:Mr,MeshDepthMaterial:cu,MeshDistanceMaterial:Mm,MeshLambertMaterial:_m,MeshMatcapMaterial:Jy,MeshNormalMaterial:vm,MeshPhongMaterial:xm,MeshPhysicalMaterial:ym,MeshStandardMaterial:hu,MeshToonMaterial:Zy,MinEquation:Jg,MirroredRepeatWrapping:pa,MixOperation:c0,MultiplyBlending:Kd,MultiplyOperation:Ho,NearestFilter:Ht,NearestMipMapLinearFilter:gM,NearestMipMapNearestFilter:p0,NearestMipmapLinearFilter:vn,NearestMipmapNearestFilter:Hh,NeutralToneMapping:kh,NeverCompare:O0,NeverDepth:Uo,NeverStencilFunc:N0,NoBlending:bs,NoColorSpace:Gs,NoNormalPacking:MM,NoToneMapping:rs,NormalAnimationBlendMode:uc,NormalBlending:Or,NormalGAPacking:SM,NormalRGPacking:bM,NotEqualCompare:B0,NotEqualDepth:Go,NotEqualStencilFunc:L0,NumberKeyframeTrack:Ha,Object3D:_t,ObjectLoader:PS,ObjectSpaceNormalMap:_0,OctahedronGeometry:Io,OneFactor:$g,OneMinusConstantAlphaFactor:h0,OneMinusConstantColorFactor:o0,OneMinusDstAlphaFactor:i0,OneMinusDstColorFactor:r0,OneMinusSrcAlphaFactor:Uh,OneMinusSrcColorFactor:e0,OrthographicCamera:Ya,PCFShadowMap:Oo,PCFSoftShadowMap:Zd,PMREMGenerator:wu,Path:nu,PerspectiveCamera:li,Plane:br,PlaneGeometry:na,PlaneHelper:dT,PointLight:Rm,PointLightHelper:lT,Points:Kp,PointsMaterial:Jc,PolarGridHelper:uT,PolyhedronGeometry:pn,PositionalAudio:Mx,PropertyBinding:gt,PropertyMixer:bx,QuadraticBezierCurve:hm,QuadraticBezierCurve3:cm,Quaternion:Mi,QuaternionKeyframeTrack:Wa,QuaternionLinearInterpolant:ix,R11_EAC_Format:el,RED_GREEN_RGTC2_Format:cl,RED_RGTC1_Format:ll,REVISION:yn,RG11_EAC_Format:il,RGBADepthPacking:v0,RGBAFormat:vi,RGBAIntegerFormat:Xo,RGBA_ASTC_10x10_Format:ac,RGBA_ASTC_10x5_Format:sc,RGBA_ASTC_10x6_Format:rc,RGBA_ASTC_10x8_Format:nc,RGBA_ASTC_12x10_Format:oc,RGBA_ASTC_12x12_Format:lc,RGBA_ASTC_4x4_Format:rl,RGBA_ASTC_5x4_Format:Kh,RGBA_ASTC_5x5_Format:$h,RGBA_ASTC_6x5_Format:Qh,RGBA_ASTC_6x6_Format:nl,RGBA_ASTC_8x5_Format:ec,RGBA_ASTC_8x6_Format:tc,RGBA_ASTC_8x8_Format:ic,RGBA_BPTC_Format:al,RGBA_ETC2_EAC_Format:Qo,RGBA_PVRTC_2BPPV1_Format:Jo,RGBA_PVRTC_4BPPV1_Format:Zo,RGBA_S3TC_DXT1_Format:xa,RGBA_S3TC_DXT3_Format:qo,RGBA_S3TC_DXT5_Format:va,RGBDepthPacking:vM,RGBFormat:Zh,RGBIntegerFormat:xM,RGB_BPTC_SIGNED_Format:hc,RGB_BPTC_UNSIGNED_Format:ol,RGB_ETC1_Format:Ko,RGB_ETC2_Format:$o,RGB_PVRTC_2BPPV1_Format:Jh,RGB_PVRTC_4BPPV1_Format:Yo,RGB_S3TC_DXT1_Format:ya,RGDepthPacking:_M,RGFormat:Br,RGIntegerFormat:jo,RawShaderMaterial:lu,Ray:Nn,Raycaster:Ax,RectAreaLight:cx,RedFormat:Wo,RedIntegerFormat:ga,ReinhardToneMapping:zh,RenderTarget:yp,RenderTarget3D:JS,RepeatWrapping:da,ReplaceStencilOp:b0,ReverseSubtractEquation:Zg,RingGeometry:Rh,SIGNED_R11_EAC_Format:tl,SIGNED_RED_GREEN_RGTC2_Format:ul,SIGNED_RED_RGTC1_Format:hl,SIGNED_RG11_EAC_Format:sl,SRGBColorSpace:Ii,SRGBTransfer:vt,Scene:Mp,ShaderChunk:ot,ShaderLib:hs,ShaderMaterial:$i,ShadowMaterial:fm,Shape:Zr,ShapeGeometry:zd,ShapePath:Xx,ShapeUtils:ys,ShortType:rp,Skeleton:Ah,SkeletonHelper:oT,SkinnedMesh:Gp,Source:pr,Sphere:ai,SphereGeometry:Po,Spherical:Cx,SphericalHarmonics3:Lm,SplineCurve:um,SpotLight:Cm,SpotLightHelper:aT,Sprite:Dp,SpriteMaterial:Ec,SrcAlphaFactor:Oh,SrcAlphaSaturateFactor:n0,SrcColorFactor:Qg,StaticCopyUsage:NM,StaticDrawUsage:fl,StaticReadUsage:wM,StereoCamera:DS,StreamCopyUsage:RM,StreamDrawUsage:TM,StreamReadUsage:AM,StringKeyframeTrack:Bn,SubtractEquation:Yg,SubtractiveBlending:Jd,TOUCH:jg,TangentSpaceNormalMap:Vr,TetrahedronGeometry:Bd,Texture:ei,TextureLoader:nx,TextureUtils:xT,Timer:zm,TimestampQuery:PM,TorusGeometry:Ih,TorusKnotGeometry:Vd,Triangle:yr,TriangleFanDrawMode:x0,TriangleStripDrawMode:y0,TrianglesDrawMode:g0,TubeGeometry:kd,UVMapping:Gh,Uint16BufferAttribute:wc,Uint32BufferAttribute:Rp,Uint8BufferAttribute:vb,Uint8ClampedBufferAttribute:_b,Uniform:Hd,UniformsGroup:$S,UniformsLib:ye,UniformsUtils:gm,UnsignedByteType:Ri,UnsignedInt101111Type:Yh,UnsignedInt248Type:_n,UnsignedInt5999Type:qh,UnsignedIntType:qi,UnsignedShort4444Type:jh,UnsignedShort5551Type:Xh,UnsignedShortType:fa,VSMShadowMap:ha,Vector2:te,Vector3:R,Vector4:It,VectorKeyframeTrack:ja,VideoFrameTexture:kb,VideoTexture:$p,WebGL3DRenderTarget:lb,WebGLArrayRenderTarget:ob,WebGLCoordinateSystem:Yi,WebGLCubeRenderTarget:Au,WebGLRenderTarget:Bi,WebGLRenderer:Sv,WebGLUtils:bv,WebGPUCoordinateSystem:Sn,WebXRController:vc,WireframeGeometry:mm,WrapAroundEnding:pl,ZeroCurvatureEnding:Mn,ZeroFactor:Kg,ZeroSlopeEnding:bn,ZeroStencilOp:M0,createCanvasElement:H0,error:Ve,getConsoleFunction:BM,log:yl,setConsoleFunction:zM,warn:ge,warnOnce:xl},Symbol.toStringTag,{value:"Module"})),Iu={VERTEX:"vertex"},ht={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Tv={READ_ONLY:"readOnly",READ_WRITE:"readWrite"},ql=["x","y","z","w"],cC=0,uC=1,dC=2,Pu=3,sf=0,rf=1,pC=2,mC=0,wv=1,Ev=100,Av=204,Nv=205,Cv=3,fC=0,nf=0,gC=1,yC=2,xC=3,vC=4,_C=6,MC=7,Rv=300,af=301,bC=302,Iv=1e3,Yl=1001,Pv=1002,cs=1003,Zl=1006,Lv=1008,Dv=1009,SC=1013,of=1014,Ov=1015,Jl=1016,TC=1023,lf=1026,wC=1027,Kl=1030,EC=37490,AC=36285,hf=0,NC=1,Lu="",Ps="srgb",Uv="srgb-linear",Fv="linear",$l="srgb",cf="",zv="rg",CC="ga",to=7680,Bv=519,RC=513,uf=515,Vv=516,Du=518,io=35044,df=35048,Zs=2e3,tn=2001,kv={TEXTURE_COMPARE:"depthTextureCompare"};function IC(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function Gv(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}const Hv={};function pf(...s){const e="THREE."+s.shift();console.log(e,...s)}function Wv(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function st(...s){s=Wv(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function Tt(...s){s=Wv(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function so(...s){const e=s.join(" ");e in Hv||(Hv[e]=!0,st(...s))}const wi=["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 jv=1234567;const Ql=Math.PI/180,eh=180/Math.PI;function wr(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(wi[s&255]+wi[s>>8&255]+wi[s>>16&255]+wi[s>>24&255]+"-"+wi[e&255]+wi[e>>8&255]+"-"+wi[e>>16&15|64]+wi[e>>24&255]+"-"+wi[t&63|128]+wi[t>>8&255]+"-"+wi[t>>16&255]+wi[t>>24&255]+wi[i&255]+wi[i>>8&255]+wi[i>>16&255]+wi[i>>24&255]).toLowerCase()}function ft(s,e,t){return Math.max(e,Math.min(t,s))}function mf(s,e){return(s%e+e)%e}function PC(s,e,t,i,r){return i+(s-e)*(r-i)/(t-e)}function LC(s,e,t){return s!==e?(t-s)/(e-s):0}function th(s,e,t){return(1-t)*s+t*e}function DC(s,e,t,i){return th(s,e,1-Math.exp(-t*i))}function OC(s,e=1){return e-Math.abs(mf(s,e*2)-e)}function UC(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function FC(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function zC(s,e){return s+Math.floor(Math.random()*(e-s+1))}function BC(s,e){return s+Math.random()*(e-s)}function VC(s){return s*(.5-Math.random())}function kC(s){s!==void 0&&(jv=s);let e=jv+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function GC(s){return s*Ql}function HC(s){return s*eh}function WC(s){return(s&s-1)===0&&s!==0}function jC(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function XC(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function qC(s,e,t,i,r){const n=Math.cos,a=Math.sin,o=n(t/2),l=a(t/2),h=n((e+i)/2),c=a((e+i)/2),d=n((e-i)/2),u=a((e-i)/2),p=n((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":s.set(o*c,l*d,l*u,o*h);break;case"YZY":s.set(l*u,o*c,l*d,o*h);break;case"ZXZ":s.set(l*d,l*u,o*c,o*h);break;case"XZX":s.set(o*c,l*m,l*p,o*h);break;case"YXY":s.set(l*p,o*c,l*m,o*h);break;case"ZYZ":s.set(l*m,l*p,o*c,o*h);break;default:st("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ls(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function St(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const YC={DEG2RAD:Ql,RAD2DEG:eh,generateUUID:wr,clamp:ft,euclideanModulo:mf,mapLinear:PC,inverseLerp:LC,lerp:th,damp:DC,pingpong:OC,smoothstep:UC,smootherstep:FC,randInt:zC,randFloat:BC,randFloatSpread:VC,seededRandom:kC,degToRad:GC,radToDeg:HC,isPowerOfTwo:WC,ceilPowerOfTwo:jC,floorPowerOfTwo:XC,setQuaternionFromProperEuler:qC,normalize:St,denormalize:Ls};class xs{constructor(e,t,i,r,n,a,o,l,h){xs.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,h)}set(e,t,i,r,n,a,o,l,h){const c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=t,c[4]=n,c[5]=l,c[6]=i,c[7]=a,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[3],l=i[6],h=i[1],c=i[4],d=i[7],u=i[2],p=i[5],m=i[8],y=r[0],g=r[3],f=r[6],x=r[1],v=r[4],M=r[7],w=r[2],T=r[5],A=r[8];return n[0]=a*y+o*x+l*w,n[3]=a*g+o*v+l*T,n[6]=a*f+o*M+l*A,n[1]=h*y+c*x+d*w,n[4]=h*g+c*v+d*T,n[7]=h*f+c*M+d*A,n[2]=u*y+p*x+m*w,n[5]=u*g+p*v+m*T,n[8]=u*f+p*M+m*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8];return t*a*c-t*o*h-i*n*c+i*o*l+r*n*h-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],d=c*a-o*h,u=o*l-c*n,p=h*n-a*l,m=t*d+i*u+r*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return e[0]=d*y,e[1]=(r*h-c*i)*y,e[2]=(o*i-r*a)*y,e[3]=u*y,e[4]=(c*t-r*l)*y,e[5]=(r*n-o*t)*y,e[6]=p*y,e[7]=(i*l-h*t)*y,e[8]=(a*t-i*n)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,n,a,o){const l=Math.cos(n),h=Math.sin(n);return this.set(i*l,i*h,-i*(l*a+h*o)+a+e,-r*h,r*l,-r*(-h*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ff.makeScale(e,t)),this}rotate(e){return this.premultiply(ff.makeRotation(-e)),this}translate(e,t){return this.premultiply(ff.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const ff=new xs,Xv=new xs().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),qv=new xs().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ZC(){const s={enabled:!0,workingColorSpace:Uv,spaces:{},convert:function(r,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===$l&&(r.r=Er(r.r),r.g=Er(r.g),r.b=Er(r.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[n].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===$l&&(r.r=ro(r.r),r.g=ro(r.g),r.b=ro(r.b))),r},workingToColorSpace:function(r,n){return this.convert(r,this.workingColorSpace,n)},colorSpaceToWorking:function(r,n){return this.convert(r,n,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Lu?Fv:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,n=this.workingColorSpace){return r.fromArray(this.spaces[n].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,n,a){return r.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,n){return so("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(r,n)},toWorkingColorSpace:function(r,n){return so("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(r,n)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[Uv]:{primaries:e,whitePoint:i,transfer:Fv,toXYZ:Xv,fromXYZ:qv,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ps},outputColorSpaceConfig:{drawingBufferColorSpace:Ps}},[Ps]:{primaries:e,whitePoint:i,transfer:$l,toXYZ:Xv,fromXYZ:qv,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ps}}}),s}const si=ZC();function Er(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function ro(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.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},sn={h:0,s:0,l:0},Ou={h:0,s:0,l:0};function gf(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Ds{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ps){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,si.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=si.workingColorSpace){return this.r=e,this.g=t,this.b=i,si.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=si.workingColorSpace){if(e=mf(e,1),t=ft(t,0,1),i=ft(i,0,1),t===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,a=2*i-n;this.r=gf(a,n,e+1/3),this.g=gf(a,n,e),this.b=gf(a,n,e-1/3)}return si.colorSpaceToWorking(this,r),this}setStyle(e,t=Ps){function i(n){n!==void 0&&parseFloat(n)<1&&st("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let n;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,t);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,t);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,t);break;default:st("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=r[1],a=n.length;if(a===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(n,16),t);st("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ps){const i=Yv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):st("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Er(e.r),this.g=Er(e.g),this.b=Er(e.b),this}copyLinearToSRGB(e){return this.r=ro(e.r),this.g=ro(e.g),this.b=ro(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ps){return si.workingToColorSpace(Ei.copy(this),e),Math.round(ft(Ei.r*255,0,255))*65536+Math.round(ft(Ei.g*255,0,255))*256+Math.round(ft(Ei.b*255,0,255))}getHexString(e=Ps){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=si.workingColorSpace){si.workingToColorSpace(Ei.copy(this),t);const i=Ei.r,r=Ei.g,n=Ei.b,a=Math.max(i,r,n),o=Math.min(i,r,n);let l,h;const c=(o+a)/2;if(o===a)l=0,h=0;else{const d=a-o;switch(h=c<=.5?d/(a+o):d/(2-a-o),a){case i:l=(r-n)/d+(r<n?6:0);break;case r:l=(n-i)/d+2;break;case n:l=(i-r)/d+4;break}l/=6}return e.h=l,e.s=h,e.l=c,e}getRGB(e,t=si.workingColorSpace){return si.workingToColorSpace(Ei.copy(this),t),e.r=Ei.r,e.g=Ei.g,e.b=Ei.b,e}getStyle(e=Ps){si.workingToColorSpace(Ei.copy(this),e);const t=Ei.r,i=Ei.g,r=Ei.b;return e!==Ps?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(sn),this.setHSL(sn.h+e,sn.s+t,sn.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(sn),e.getHSL(Ou);const i=th(sn.h,Ou.h,t),r=th(sn.s,Ou.s,t),n=th(sn.l,Ou.l,t);return this.setHSL(i,r,n),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,n=e.elements;return this.r=n[0]*t+n[3]*i+n[6]*r,this.g=n[1]*t+n[4]*i+n[7]*r,this.b=n[2]*t+n[5]*i+n[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ei=new Ds;Ds.NAMES=Yv;class Lg{constructor(e,t,i,r){Lg.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const n=this.elements;return n[0]=e,n[2]=t,n[1]=i,n[3]=r,this}}class no{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,n,a,o){let l=i[r+0],h=i[r+1],c=i[r+2],d=i[r+3],u=n[a+0],p=n[a+1],m=n[a+2],y=n[a+3];if(d!==y||l!==u||h!==p||c!==m){let g=l*u+h*p+c*m+d*y;g<0&&(u=-u,p=-p,m=-m,y=-y,g=-g);let f=1-o;if(g<.9995){const x=Math.acos(g),v=Math.sin(x);f=Math.sin(f*x)/v,o=Math.sin(o*x)/v,l=l*f+u*o,h=h*f+p*o,c=c*f+m*o,d=d*f+y*o}else{l=l*f+u*o,h=h*f+p*o,c=c*f+m*o,d=d*f+y*o;const x=1/Math.sqrt(l*l+h*h+c*c+d*d);l*=x,h*=x,c*=x,d*=x}}e[t]=l,e[t+1]=h,e[t+2]=c,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,n,a){const o=i[r],l=i[r+1],h=i[r+2],c=i[r+3],d=n[a],u=n[a+1],p=n[a+2],m=n[a+3];return e[t]=o*m+c*d+l*p-h*u,e[t+1]=l*m+c*u+h*d-o*p,e[t+2]=h*m+c*p+o*u-l*d,e[t+3]=c*m-o*d-l*u-h*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,n=e._z,a=e._order,o=Math.cos,l=Math.sin,h=o(i/2),c=o(r/2),d=o(n/2),u=l(i/2),p=l(r/2),m=l(n/2);switch(a){case"XYZ":this._x=u*c*d+h*p*m,this._y=h*p*d-u*c*m,this._z=h*c*m+u*p*d,this._w=h*c*d-u*p*m;break;case"YXZ":this._x=u*c*d+h*p*m,this._y=h*p*d-u*c*m,this._z=h*c*m-u*p*d,this._w=h*c*d+u*p*m;break;case"ZXY":this._x=u*c*d-h*p*m,this._y=h*p*d+u*c*m,this._z=h*c*m+u*p*d,this._w=h*c*d-u*p*m;break;case"ZYX":this._x=u*c*d-h*p*m,this._y=h*p*d+u*c*m,this._z=h*c*m-u*p*d,this._w=h*c*d+u*p*m;break;case"YZX":this._x=u*c*d+h*p*m,this._y=h*p*d+u*c*m,this._z=h*c*m-u*p*d,this._w=h*c*d-u*p*m;break;case"XZY":this._x=u*c*d-h*p*m,this._y=h*p*d-u*c*m,this._z=h*c*m+u*p*d,this._w=h*c*d+u*p*m;break;default:st("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],n=t[8],a=t[1],o=t[5],l=t[9],h=t[2],c=t[6],d=t[10],u=i+o+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(c-l)*p,this._y=(n-h)*p,this._z=(a-r)*p}else if(i>o&&i>d){const p=2*Math.sqrt(1+i-o-d);this._w=(c-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(n+h)/p}else if(o>d){const p=2*Math.sqrt(1+o-i-d);this._w=(n-h)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+c)/p}else{const p=2*Math.sqrt(1+d-i-o);this._w=(a-r)/p,this._x=(n+h)/p,this._y=(l+c)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ft(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,n=e._z,a=e._w,o=t._x,l=t._y,h=t._z,c=t._w;return this._x=i*c+a*o+r*h-n*l,this._y=r*c+a*l+n*o-i*h,this._z=n*c+a*h+i*l-r*o,this._w=a*c-i*o-r*l-n*h,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,n=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,n=-n,a=-a,o=-o);let l=1-t;if(o<.9995){const h=Math.acos(o),c=Math.sin(h);l=Math.sin(l*h)/c,t=Math.sin(t*h)/c,this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+n*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+n*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),n*Math.sin(t),n*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class H{constructor(e=0,t=0,i=0){H.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Zv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Zv.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=e.elements,a=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*r-o*i),c=2*(o*t-n*r),d=2*(n*i-a*t);return this.x=t+l*h+a*d-o*c,this.y=i+l*c+o*h-n*d,this.z=r+l*d+n*c-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ft(this.x,e.x,t.x),this.y=ft(this.y,e.y,t.y),this.z=ft(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ft(this.x,e,t),this.y=ft(this.y,e,t),this.z=ft(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ft(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,n=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-n*o,this.y=n*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return yf.copy(this).projectOnVector(e),this.sub(yf)}reflect(e){return this.sub(yf.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ft(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const yf=new H,Zv=new no;class kt{constructor(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g){kt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g)}set(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=n,f[5]=a,f[9]=o,f[13]=l,f[2]=h,f[6]=c,f[10]=d,f[14]=u,f[3]=p,f[7]=m,f[11]=y,f[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 kt().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/ao.setFromMatrixColumn(e,0).length(),n=1/ao.setFromMatrixColumn(e,1).length(),a=1/ao.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),h=Math.sin(r),c=Math.cos(n),d=Math.sin(n);if(e.order==="XYZ"){const u=a*c,p=a*d,m=o*c,y=o*d;t[0]=l*c,t[4]=-l*d,t[8]=h,t[1]=p+m*h,t[5]=u-y*h,t[9]=-o*l,t[2]=y-u*h,t[6]=m+p*h,t[10]=a*l}else if(e.order==="YXZ"){const u=l*c,p=l*d,m=h*c,y=h*d;t[0]=u+y*o,t[4]=m*o-p,t[8]=a*h,t[1]=a*d,t[5]=a*c,t[9]=-o,t[2]=p*o-m,t[6]=y+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*c,p=l*d,m=h*c,y=h*d;t[0]=u-y*o,t[4]=-a*d,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*c,t[9]=y-u*o,t[2]=-a*h,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*c,p=a*d,m=o*c,y=o*d;t[0]=l*c,t[4]=m*h-p,t[8]=u*h+y,t[1]=l*d,t[5]=y*h+u,t[9]=p*h-m,t[2]=-h,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*h,m=o*l,y=o*h;t[0]=l*c,t[4]=y-u*d,t[8]=m*d+p,t[1]=d,t[5]=a*c,t[9]=-o*c,t[2]=-h*c,t[6]=p*d+m,t[10]=u-y*d}else if(e.order==="XZY"){const u=a*l,p=a*h,m=o*l,y=o*h;t[0]=l*c,t[4]=-d,t[8]=h*c,t[1]=u*d+y,t[5]=a*c,t[9]=p*d-m,t[2]=m*d-p,t[6]=o*c,t[10]=y*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(JC,e,KC)}lookAt(e,t,i){const r=this.elements;return es.subVectors(e,t),es.lengthSq()===0&&(es.z=1),es.normalize(),rn.crossVectors(i,es),rn.lengthSq()===0&&(Math.abs(i.z)===1?es.x+=1e-4:es.z+=1e-4,es.normalize(),rn.crossVectors(i,es)),rn.normalize(),Uu.crossVectors(es,rn),r[0]=rn.x,r[4]=Uu.x,r[8]=es.x,r[1]=rn.y,r[5]=Uu.y,r[9]=es.y,r[2]=rn.z,r[6]=Uu.z,r[10]=es.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[4],l=i[8],h=i[12],c=i[1],d=i[5],u=i[9],p=i[13],m=i[2],y=i[6],g=i[10],f=i[14],x=i[3],v=i[7],M=i[11],w=i[15],T=r[0],A=r[4],_=r[8],S=r[12],P=r[1],C=r[5],L=r[9],U=r[13],V=r[2],B=r[6],k=r[10],W=r[14],se=r[3],ie=r[7],oe=r[11],be=r[15];return n[0]=a*T+o*P+l*V+h*se,n[4]=a*A+o*C+l*B+h*ie,n[8]=a*_+o*L+l*k+h*oe,n[12]=a*S+o*U+l*W+h*be,n[1]=c*T+d*P+u*V+p*se,n[5]=c*A+d*C+u*B+p*ie,n[9]=c*_+d*L+u*k+p*oe,n[13]=c*S+d*U+u*W+p*be,n[2]=m*T+y*P+g*V+f*se,n[6]=m*A+y*C+g*B+f*ie,n[10]=m*_+y*L+g*k+f*oe,n[14]=m*S+y*U+g*W+f*be,n[3]=x*T+v*P+M*V+w*se,n[7]=x*A+v*C+M*B+w*ie,n[11]=x*_+v*L+M*k+w*oe,n[15]=x*S+v*U+M*W+w*be,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],c=e[2],d=e[6],u=e[10],p=e[14],m=e[3],y=e[7],g=e[11],f=e[15],x=l*p-h*u,v=o*p-h*d,M=o*u-l*d,w=a*p-h*c,T=a*u-l*c,A=a*d-o*c;return t*(y*x-g*v+f*M)-i*(m*x-g*w+f*T)+r*(m*v-y*w+f*A)-n*(m*M-y*T+g*A)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],d=e[9],u=e[10],p=e[11],m=e[12],y=e[13],g=e[14],f=e[15],x=t*o-i*a,v=t*l-r*a,M=t*h-n*a,w=i*l-r*o,T=i*h-n*o,A=r*h-n*l,_=c*y-d*m,S=c*g-u*m,P=c*f-p*m,C=d*g-u*y,L=d*f-p*y,U=u*f-p*g,V=x*U-v*L+M*C+w*P-T*S+A*_;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const B=1/V;return e[0]=(o*U-l*L+h*C)*B,e[1]=(r*L-i*U-n*C)*B,e[2]=(y*A-g*T+f*w)*B,e[3]=(u*T-d*A-p*w)*B,e[4]=(l*P-a*U-h*S)*B,e[5]=(t*U-r*P+n*S)*B,e[6]=(g*M-m*A-f*v)*B,e[7]=(c*A-u*M+p*v)*B,e[8]=(a*L-o*P+h*_)*B,e[9]=(i*P-t*L-n*_)*B,e[10]=(m*T-y*M+f*x)*B,e[11]=(d*M-c*T-p*x)*B,e[12]=(o*S-a*C-l*_)*B,e[13]=(t*C-i*S+r*_)*B,e[14]=(y*v-m*w-g*x)*B,e[15]=(c*w-d*v+u*x)*B,this}scale(e){const t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),n=1-i,a=e.x,o=e.y,l=e.z,h=n*a,c=n*o;return this.set(h*a+i,h*o-r*l,h*l+r*o,0,h*o+r*l,c*o+i,c*l-r*a,0,h*l-r*o,c*l+r*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,n,a){return this.set(1,i,n,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,n=t._x,a=t._y,o=t._z,l=t._w,h=n+n,c=a+a,d=o+o,u=n*h,p=n*c,m=n*d,y=a*c,g=a*d,f=o*d,x=l*h,v=l*c,M=l*d,w=i.x,T=i.y,A=i.z;return r[0]=(1-(y+f))*w,r[1]=(p+M)*w,r[2]=(m-v)*w,r[3]=0,r[4]=(p-M)*T,r[5]=(1-(u+f))*T,r[6]=(g+x)*T,r[7]=0,r[8]=(m+v)*A,r[9]=(g-x)*A,r[10]=(1-(u+y))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const n=this.determinant();if(n===0)return i.set(1,1,1),t.identity(),this;let a=ao.set(r[0],r[1],r[2]).length();const o=ao.set(r[4],r[5],r[6]).length(),l=ao.set(r[8],r[9],r[10]).length();n<0&&(a=-a),Os.copy(this);const h=1/a,c=1/o,d=1/l;return Os.elements[0]*=h,Os.elements[1]*=h,Os.elements[2]*=h,Os.elements[4]*=c,Os.elements[5]*=c,Os.elements[6]*=c,Os.elements[8]*=d,Os.elements[9]*=d,Os.elements[10]*=d,t.setFromRotationMatrix(Os),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,r,n,a,o=Zs,l=!1){const h=this.elements,c=2*n/(t-e),d=2*n/(i-r),u=(t+e)/(t-e),p=(i+r)/(i-r);let m,y;if(l)m=n/(a-n),y=a*n/(a-n);else if(o===Zs)m=-(a+n)/(a-n),y=-2*a*n/(a-n);else if(o===tn)m=-a/(a-n),y=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return h[0]=c,h[4]=0,h[8]=u,h[12]=0,h[1]=0,h[5]=d,h[9]=p,h[13]=0,h[2]=0,h[6]=0,h[10]=m,h[14]=y,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,r,n,a,o=Zs,l=!1){const h=this.elements,c=2/(t-e),d=2/(i-r),u=-(t+e)/(t-e),p=-(i+r)/(i-r);let m,y;if(l)m=1/(a-n),y=a/(a-n);else if(o===Zs)m=-2/(a-n),y=-(a+n)/(a-n);else if(o===tn)m=-1/(a-n),y=-n/(a-n);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return h[0]=c,h[4]=0,h[8]=0,h[12]=u,h[1]=0,h[5]=d,h[9]=0,h[13]=p,h[2]=0,h[6]=0,h[10]=m,h[14]=y,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const ao=new H,Os=new kt,JC=new H(0,0,0),KC=new H(1,1,1),rn=new H,Uu=new H,es=new H;class Vt{constructor(e=0,t=0){Vt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ft(this.x,e.x,t.x),this.y=ft(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ft(this.x,e,t),this.y=ft(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ft(i,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ft(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*r+e.x,this.y=n*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ai{constructor(e=0,t=0,i=0,r=1){Ai.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*n,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*n,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*n,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,n;const a=e.elements,o=a[0],l=a[4],h=a[8],c=a[1],d=a[5],u=a[9],p=a[2],m=a[6],y=a[10];if(Math.abs(l-c)<.01&&Math.abs(h-p)<.01&&Math.abs(u-m)<.01){if(Math.abs(l+c)<.1&&Math.abs(h+p)<.1&&Math.abs(u+m)<.1&&Math.abs(o+d+y-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const f=(o+1)/2,x=(d+1)/2,v=(y+1)/2,M=(l+c)/4,w=(h+p)/4,T=(u+m)/4;return f>x&&f>v?f<.01?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(f),r=M/i,n=w/i):x>v?x<.01?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(x),i=M/r,n=T/r):v<.01?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(v),i=w/n,r=T/n),this.set(i,r,n,t),this}let g=Math.sqrt((m-u)*(m-u)+(h-p)*(h-p)+(c-l)*(c-l));return Math.abs(g)<.001&&(g=1),this.x=(m-u)/g,this.y=(h-p)/g,this.z=(c-l)/g,this.w=Math.acos((o+d+y-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ft(this.x,e.x,t.x),this.y=ft(this.y,e.y,t.y),this.z=ft(this.z,e.z,t.z),this.w=ft(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ft(this.x,e,t),this.y=ft(this.y,e,t),this.z=ft(this.z,e,t),this.w=ft(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ft(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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 $C=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function QC(s){const e=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return s.split(`
|
|
4057
|
+
}`;class iC{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new $p(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new $i({vertexShader:eC,fragmentShader:tC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Xt(new na(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class sC extends Es{constructor(e,t){super();const i=this;let r=null,n=1,a=null,o="local-floor",l=1,h=null,c=null,d=null,u=null,p=null,m=null;const y=typeof XRWebGLBinding<"u",g=new iC,f={},x=t.getContextAttributes();let v=null,M=null;const w=[],T=[],A=new te;let _=null;const S=new li;S.viewport=new It;const P=new li;P.viewport=new It;const C=[S,P],L=new Um;let U=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(K){let ae=w[K];return ae===void 0&&(ae=new vc,w[K]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(K){let ae=w[K];return ae===void 0&&(ae=new vc,w[K]=ae),ae.getGripSpace()},this.getHand=function(K){let ae=w[K];return ae===void 0&&(ae=new vc,w[K]=ae),ae.getHandSpace()};function B(K){const ae=T.indexOf(K.inputSource);if(ae===-1)return;const le=w[ae];le!==void 0&&(le.update(K.inputSource,K.frame,h||a),le.dispatchEvent({type:K.type,data:K.inputSource}))}function k(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",k),r.removeEventListener("inputsourceschange",W);for(let K=0;K<w.length;K++){const ae=T[K];ae!==null&&(T[K]=null,w[K]&&w[K].disconnect(ae))}U=null,V=null,g.reset();for(const K in f)delete f[K];e.setRenderTarget(v),p=null,u=null,d=null,r=null,M=null,Et.stop(),i.isPresenting=!1,e.setPixelRatio(_),e.setSize(A.width,A.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){n=K,i.isPresenting===!0&&ge("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,i.isPresenting===!0&&ge("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||a},this.setReferenceSpace=function(K){h=K},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&y&&(d=new XRWebGLBinding(r,t)),d},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(K){if(r=K,r!==null){if(v=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",k),r.addEventListener("inputsourceschange",W),x.xrCompatible!==!0&&await t.makeXRCompatible(),_=e.getPixelRatio(),e.getSize(A),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let ae=null,le=null,Qe=null;x.depth&&(Qe=x.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ae=x.stencil?ur:ws,le=x.stencil?_n:qi);const Ye={colorFormat:t.RGBA8,depthFormat:Qe,scaleFactor:n};d=this.getBinding(),u=d.createProjectionLayer(Ye),r.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),M=new Bi(u.textureWidth,u.textureHeight,{format:vi,type:Ri,depthTexture:new On(u.textureWidth,u.textureHeight,le,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:x.stencil,colorSpace:e.outputColorSpace,samples:x.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ae={antialias:x.antialias,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:n};p=new XRWebGLLayer(r,t,ae),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),M=new Bi(p.framebufferWidth,p.framebufferHeight,{format:vi,type:Ri,colorSpace:e.outputColorSpace,stencilBuffer:x.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),h=null,a=await r.requestReferenceSpace(o),Et.setContext(r),Et.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function W(K){for(let ae=0;ae<K.removed.length;ae++){const le=K.removed[ae],Qe=T.indexOf(le);Qe>=0&&(T[Qe]=null,w[Qe]&&w[Qe].disconnect(le))}for(let ae=0;ae<K.added.length;ae++){const le=K.added[ae];let Qe=T.indexOf(le);if(Qe===-1){for(let Te=0;Te<w.length;Te++)if(Te>=T.length){T.push(le),Qe=Te;break}else if(T[Te]===null){T[Te]=le,Qe=Te;break}if(Qe===-1)break}const Ye=w[Qe];Ye&&Ye.connect(le)}}const se=new R,ie=new R;function oe(K,ae,le){se.setFromMatrixPosition(ae.matrixWorld),ie.setFromMatrixPosition(le.matrixWorld);const Qe=se.distanceTo(ie),Ye=ae.projectionMatrix.elements,Te=le.projectionMatrix.elements,ct=Ye[14]/(Ye[10]-1),Q=Ye[14]/(Ye[10]+1),ee=(Ye[9]+1)/Ye[5],he=(Ye[9]-1)/Ye[5],_e=(Ye[8]-1)/Ye[0],Se=(Te[8]+1)/Te[0],I=ct*_e,Ge=ct*Se,We=Qe/(-_e+Se),Je=We*-_e;if(ae.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Je),K.translateZ(We),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Ye[10]===-1)K.projectionMatrix.copy(ae.projectionMatrix),K.projectionMatrixInverse.copy(ae.projectionMatrixInverse);else{const fe=ct+We,N=Q+We,b=I-Je,D=Ge+(Qe-Je),Z=ee*Q/N*fe,$=he*Q/N*fe;K.projectionMatrix.makePerspective(b,D,Z,$,fe,N),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function be(K,ae){ae===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(ae.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(r===null)return;let ae=K.near,le=K.far;g.texture!==null&&(g.depthNear>0&&(ae=g.depthNear),g.depthFar>0&&(le=g.depthFar)),L.near=P.near=S.near=ae,L.far=P.far=S.far=le,(U!==L.near||V!==L.far)&&(r.updateRenderState({depthNear:L.near,depthFar:L.far}),U=L.near,V=L.far),L.layers.mask=K.layers.mask|6,S.layers.mask=L.layers.mask&-5,P.layers.mask=L.layers.mask&-3;const Qe=K.parent,Ye=L.cameras;be(L,Qe);for(let Te=0;Te<Ye.length;Te++)be(Ye[Te],Qe);Ye.length===2?oe(L,S,P):L.projectionMatrix.copy(S.projectionMatrix),Ce(K,L,Qe)};function Ce(K,ae,le){le===null?K.matrix.copy(ae.matrixWorld):(K.matrix.copy(le.matrixWorld),K.matrix.invert(),K.matrix.multiply(ae.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(ae.projectionMatrix),K.projectionMatrixInverse.copy(ae.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Sa*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function(K){l=K,u!==null&&(u.fixedFoveation=K),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=K)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(L)},this.getCameraTexture=function(K){return f[K]};let tt=null;function wt(K,ae){if(c=ae.getViewerPose(h||a),m=ae,c!==null){const le=c.views;p!==null&&(e.setRenderTargetFramebuffer(M,p.framebuffer),e.setRenderTarget(M));let Qe=!1;le.length!==L.cameras.length&&(L.cameras.length=0,Qe=!0);for(let Te=0;Te<le.length;Te++){const ct=le[Te];let Q=null;if(p!==null)Q=p.getViewport(ct);else{const he=d.getViewSubImage(u,ct);Q=he.viewport,Te===0&&(e.setRenderTargetTextures(M,he.colorTexture,he.depthStencilTexture),e.setRenderTarget(M))}let ee=C[Te];ee===void 0&&(ee=new li,ee.layers.enable(Te),ee.viewport=new It,C[Te]=ee),ee.matrix.fromArray(ct.transform.matrix),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.projectionMatrix.fromArray(ct.projectionMatrix),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert(),ee.viewport.set(Q.x,Q.y,Q.width,Q.height),Te===0&&(L.matrix.copy(ee.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),Qe===!0&&L.cameras.push(ee)}const Ye=r.enabledFeatures;if(Ye&&Ye.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){d=i.getBinding();const Te=d.getDepthInformation(le[0]);Te&&Te.isValid&&Te.texture&&g.init(Te,r.renderState)}if(Ye&&Ye.includes("camera-access")&&y){e.state.unbindTexture(),d=i.getBinding();for(let Te=0;Te<le.length;Te++){const ct=le[Te].camera;if(ct){let Q=f[ct];Q||(Q=new $p,f[ct]=Q);const ee=d.getCameraImage(ct);Q.sourceTexture=ee}}}}if(i.controllerAutoUpdate)for(let le=0;le<w.length;le++){const Qe=T[le],Ye=w[le];Qe!==null&&Ye!==void 0&&Ye.update(Qe,ae,h||a)}tt&&tt(K,ae),ae.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ae}),m=null}const Et=new Yx;Et.setAnimationLoop(wt),this.setAnimationLoop=function(K){tt=K},this.dispose=function(){}}}const qn=new ns,rC=new et;function nC(s,e){function t(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function i(g,f){f.color.getRGB(g.fogColor.value,Yy(s)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function r(g,f,x,v,M){f.isMeshBasicMaterial?n(g,f):f.isMeshLambertMaterial?(n(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(n(g,f),d(g,f)):f.isMeshPhongMaterial?(n(g,f),c(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(n(g,f),u(g,f),f.isMeshPhysicalMaterial&&p(g,f,M)):f.isMeshMatcapMaterial?(n(g,f),m(g,f)):f.isMeshDepthMaterial?n(g,f):f.isMeshDistanceMaterial?(n(g,f),y(g,f)):f.isMeshNormalMaterial?n(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?l(g,f,x,v):f.isSpriteMaterial?h(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function n(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,t(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===yi&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,t(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===yi&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,t(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,t(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);const x=e.get(f),v=x.envMap,M=x.envMapRotation;v&&(g.envMap.value=v,qn.copy(M),qn.x*=-1,qn.y*=-1,qn.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(qn.y*=-1,qn.z*=-1),g.envMapRotation.value.setFromMatrix4(rC.makeRotationFromEuler(qn)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,g.aoMapTransform))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform))}function o(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function l(g,f,x,v){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*x,g.scale.value=v*.5,f.map&&(g.map.value=f.map,t(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function h(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function c(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function d(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function u(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function p(g,f,x){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===yi&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,f){f.matcap&&(g.matcap.value=f.matcap)}function y(g,f){const x=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function aC(s,e,t,i){let r={},n={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,v){const M=v.program;i.uniformBlockBinding(x,M)}function h(x,v){let M=r[x.id];M===void 0&&(m(x),M=c(x),r[x.id]=M,x.addEventListener("dispose",g));const w=v.program;i.updateUBOMapping(x,w);const T=e.render.frame;n[x.id]!==T&&(u(x),n[x.id]=T)}function c(x){const v=d();x.__bindingPointIndex=v;const M=s.createBuffer(),w=x.__size,T=x.usage;return s.bindBuffer(s.UNIFORM_BUFFER,M),s.bufferData(s.UNIFORM_BUFFER,w,T),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,v,M),M}function d(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return Ve("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(x){const v=r[x.id],M=x.uniforms,w=x.__cache;s.bindBuffer(s.UNIFORM_BUFFER,v);for(let T=0,A=M.length;T<A;T++){const _=Array.isArray(M[T])?M[T]:[M[T]];for(let S=0,P=_.length;S<P;S++){const C=_[S];if(p(C,T,S,w)===!0){const L=C.__offset,U=Array.isArray(C.value)?C.value:[C.value];let V=0;for(let B=0;B<U.length;B++){const k=U[B],W=y(k);typeof k=="number"||typeof k=="boolean"?(C.__data[0]=k,s.bufferSubData(s.UNIFORM_BUFFER,L+V,C.__data)):k.isMatrix3?(C.__data[0]=k.elements[0],C.__data[1]=k.elements[1],C.__data[2]=k.elements[2],C.__data[3]=0,C.__data[4]=k.elements[3],C.__data[5]=k.elements[4],C.__data[6]=k.elements[5],C.__data[7]=0,C.__data[8]=k.elements[6],C.__data[9]=k.elements[7],C.__data[10]=k.elements[8],C.__data[11]=0):(k.toArray(C.__data,V),V+=W.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,L,C.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(x,v,M,w){const T=x.value,A=v+"_"+M;if(w[A]===void 0)return typeof T=="number"||typeof T=="boolean"?w[A]=T:w[A]=T.clone(),!0;{const _=w[A];if(typeof T=="number"||typeof T=="boolean"){if(_!==T)return w[A]=T,!0}else if(_.equals(T)===!1)return _.copy(T),!0}return!1}function m(x){const v=x.uniforms;let M=0;const w=16;for(let A=0,_=v.length;A<_;A++){const S=Array.isArray(v[A])?v[A]:[v[A]];for(let P=0,C=S.length;P<C;P++){const L=S[P],U=Array.isArray(L.value)?L.value:[L.value];for(let V=0,B=U.length;V<B;V++){const k=U[V],W=y(k),se=M%w,ie=se%W.boundary,oe=se+ie;M+=ie,oe!==0&&w-oe<W.storage&&(M+=w-oe),L.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=M,M+=W.storage}}}const T=M%w;return T>0&&(M+=w-T),x.__size=M,x.__cache={},this}function y(x){const v={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?ge("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ge("WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){const v=x.target;v.removeEventListener("dispose",g);const M=a.indexOf(v.__bindingPointIndex);a.splice(M,1),s.deleteBuffer(r[v.id]),delete r[v.id],delete n[v.id]}function f(){for(const x in r)s.deleteBuffer(r[x]);a=[],r={},n={}}return{bind:l,update:h,dispose:f}}const oC=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 Ys=null;function lC(){return Ys===null&&(Ys=new os(oC,16,16,Br,Ts),Ys.name="DFG_LUT",Ys.minFilter=Rt,Ys.magFilter=Rt,Ys.wrapS=Ci,Ys.wrapT=Ci,Ys.generateMipmaps=!1,Ys.needsUpdate=!0),Ys}class Sv{constructor(e={}){const{canvas:t=H0(),context:i=null,depth:r=!0,stencil:n=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=Ri}=e;this.isWebGLRenderer=!0;let m;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=i.getContextAttributes().alpha}else m=a;const y=p,g=new Set([Xo,jo,ya]),f=new Set([Ri,qi,ga,_n,jh,Xh]),x=new Uint32Array(4),v=new Int32Array(4);let M=null,w=null;const T=[],A=[];let _=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=rs,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const S=this;let P=!1;this._outputColorSpace=Ii;let C=0,L=0,U=null,V=-1,B=null;const k=new It,W=new It;let se=null;const ie=new we(0);let oe=0,be=t.width,Ce=t.height,tt=1,wt=null,Et=null;const K=new It(0,0,be,Ce),ae=new It(0,0,be,Ce);let le=!1;const Qe=new Pn;let Ye=!1,Te=!1;const ct=new et,Q=new R,ee=new It,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let _e=!1;function Se(){return U===null?tt:1}let I=i;function Ge(E,F){return t.getContext(E,F)}try{const E={alpha:!0,depth:r,stencil:n,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${yn}`),t.addEventListener("webglcontextlost",De,!1),t.addEventListener("webglcontextrestored",Ze,!1),t.addEventListener("webglcontextcreationerror",Qt,!1),I===null){const F="webgl2";if(I=Ge(F,E),I===null)throw Ge(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw Ve("WebGLRenderer: "+E.message),E}let We,Je,fe,N,b,D,Z,$,J,Oe,pe,He,Be,re,ue,je,Ue,Ae,ut,O,me,ce,Le;function ne(){We=new cA(I),We.init(),me=new bv(I,We),Je=new sA(I,We,e,me),fe=new $N(I,We),Je.reversedDepthBuffer&&u&&fe.buffers.depth.setReversed(!0),N=new pA(I),b=new zN,D=new QN(I,We,fe,b,Je,me,N),Z=new hA(S),$=new vT(I),ce=new tA(I,$),J=new uA(I,$,N,ce),Oe=new fA(I,J,$,ce,N),Ae=new mA(I,Je,D),ue=new rA(b),pe=new FN(S,Z,We,Je,ce,ue),He=new nC(S,b),Be=new VN,re=new XN(We),Ue=new eA(S,Z,fe,Oe,m,l),je=new KN(S,Oe,Je),Le=new aC(I,N,Je,fe),ut=new iA(I,We,N),O=new dA(I,We,N),N.programs=pe.programs,S.capabilities=Je,S.extensions=We,S.properties=b,S.renderLists=Be,S.shadowMap=je,S.state=fe,S.info=N}ne(),y!==Ri&&(_=new yA(y,t.width,t.height,r,n));const Y=new sC(S,I);this.xr=Y,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const E=We.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=We.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return tt},this.setPixelRatio=function(E){E!==void 0&&(tt=E,this.setSize(be,Ce,!1))},this.getSize=function(E){return E.set(be,Ce)},this.setSize=function(E,F,X=!0){if(Y.isPresenting){ge("WebGLRenderer: Can't change size while VR device is presenting.");return}be=E,Ce=F,t.width=Math.floor(E*tt),t.height=Math.floor(F*tt),X===!0&&(t.style.width=E+"px",t.style.height=F+"px"),_!==null&&_.setSize(t.width,t.height),this.setViewport(0,0,E,F)},this.getDrawingBufferSize=function(E){return E.set(be*tt,Ce*tt).floor()},this.setDrawingBufferSize=function(E,F,X){be=E,Ce=F,tt=X,t.width=Math.floor(E*X),t.height=Math.floor(F*X),this.setViewport(0,0,E,F)},this.setEffects=function(E){if(y===Ri){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let F=0;F<E.length;F++)if(E[F].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(k)},this.getViewport=function(E){return E.copy(K)},this.setViewport=function(E,F,X,j){E.isVector4?K.set(E.x,E.y,E.z,E.w):K.set(E,F,X,j),fe.viewport(k.copy(K).multiplyScalar(tt).round())},this.getScissor=function(E){return E.copy(ae)},this.setScissor=function(E,F,X,j){E.isVector4?ae.set(E.x,E.y,E.z,E.w):ae.set(E,F,X,j),fe.scissor(W.copy(ae).multiplyScalar(tt).round())},this.getScissorTest=function(){return le},this.setScissorTest=function(E){fe.setScissorTest(le=E)},this.setOpaqueSort=function(E){wt=E},this.setTransparentSort=function(E){Et=E},this.getClearColor=function(E){return E.copy(Ue.getClearColor())},this.setClearColor=function(){Ue.setClearColor(...arguments)},this.getClearAlpha=function(){return Ue.getClearAlpha()},this.setClearAlpha=function(){Ue.setClearAlpha(...arguments)},this.clear=function(E=!0,F=!0,X=!0){let j=0;if(E){let G=!1;if(U!==null){const de=U.texture.format;G=g.has(de)}if(G){const de=U.texture.type,Me=f.has(de),Ie=Ue.getClearColor(),Pe=Ue.getClearAlpha(),$e=Ie.r,lt=Ie.g,pt=Ie.b;Me?(x[0]=$e,x[1]=lt,x[2]=pt,x[3]=Pe,I.clearBufferuiv(I.COLOR,0,x)):(v[0]=$e,v[1]=lt,v[2]=pt,v[3]=Pe,I.clearBufferiv(I.COLOR,0,v))}else j|=I.COLOR_BUFFER_BIT}F&&(j|=I.DEPTH_BUFFER_BIT),X&&(j|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),j!==0&&I.clear(j)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",De,!1),t.removeEventListener("webglcontextrestored",Ze,!1),t.removeEventListener("webglcontextcreationerror",Qt,!1),Ue.dispose(),Be.dispose(),re.dispose(),b.dispose(),Z.dispose(),Oe.dispose(),ce.dispose(),Le.dispose(),pe.dispose(),Y.dispose(),Y.removeEventListener("sessionstart",Og),Y.removeEventListener("sessionend",Ug),mn.stop()};function De(E){E.preventDefault(),yl("WebGLRenderer: Context Lost."),P=!0}function Ze(){yl("WebGLRenderer: Context Restored."),P=!1;const E=N.autoReset,F=je.enabled,X=je.autoUpdate,j=je.needsUpdate,G=je.type;ne(),N.autoReset=E,je.enabled=F,je.autoUpdate=X,je.needsUpdate=j,je.type=G}function Qt(E){Ve("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Mt(E){const F=E.target;F.removeEventListener("dispose",Mt),hr(F)}function hr(E){cr(E),b.remove(E)}function cr(E){const F=b.get(E).programs;F!==void 0&&(F.forEach(function(X){pe.releaseProgram(X)}),E.isShaderMaterial&&pe.releaseShaderCache(E))}this.renderBufferDirect=function(E,F,X,j,G,de){F===null&&(F=he);const Me=G.isMesh&&G.matrixWorld.determinant()<0,Ie=oM(E,F,X,j,G);fe.setMaterial(j,Me);let Pe=X.index,$e=1;if(j.wireframe===!0){if(Pe=J.getWireframeAttribute(X),Pe===void 0)return;$e=2}const lt=X.drawRange,pt=X.attributes.position;let qe=lt.start*$e,Ct=(lt.start+lt.count)*$e;de!==null&&(qe=Math.max(qe,de.start*$e),Ct=Math.min(Ct,(de.start+de.count)*$e)),Pe!==null?(qe=Math.max(qe,0),Ct=Math.min(Ct,Pe.count)):pt!=null&&(qe=Math.max(qe,0),Ct=Math.min(Ct,pt.count));const jt=Ct-qe;if(jt<0||jt===1/0)return;ce.setup(G,j,Ie,X,Pe);let Ut,At=ut;if(Pe!==null&&(Ut=$.get(Pe),At=O,At.setIndex(Ut)),G.isMesh)j.wireframe===!0?(fe.setLineWidth(j.wireframeLinewidth*Se()),At.setMode(I.LINES)):At.setMode(I.TRIANGLES);else if(G.isLine){let Gt=j.linewidth;Gt===void 0&&(Gt=1),fe.setLineWidth(Gt*Se()),G.isLineSegments?At.setMode(I.LINES):G.isLineLoop?At.setMode(I.LINE_LOOP):At.setMode(I.LINE_STRIP)}else G.isPoints?At.setMode(I.POINTS):G.isSprite&&At.setMode(I.TRIANGLES);if(G.isBatchedMesh)if(G._multiDrawInstances!==null)xl("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),At.renderMultiDrawInstances(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount,G._multiDrawInstances);else if(We.get("WEBGL_multi_draw"))At.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const Gt=G._multiDrawStarts,Xe=G._multiDrawCounts,Xi=G._multiDrawCount,fn=Pe?$.get(Pe).bytesPerElement:1,_s=b.get(j).currentProgram.getUniforms();for(let Bs=0;Bs<Xi;Bs++)_s.setValue(I,"_gl_DrawID",Bs),At.render(Gt[Bs]/fn,Xe[Bs])}else if(G.isInstancedMesh)At.renderInstances(qe,jt,G.count);else if(X.isInstancedBufferGeometry){const Gt=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Xe=Math.min(X.instanceCount,Gt);At.renderInstances(qe,jt,Xe)}else At.render(qe,jt)};function Dg(E,F,X){E.transparent===!0&&E.side===Ms&&E.forceSinglePass===!1?(E.side=yi,E.needsUpdate=!0,Lh(E,F,X),E.side=Vs,E.needsUpdate=!0,Lh(E,F,X),E.side=Ms):Lh(E,F,X)}this.compile=function(E,F,X=null){X===null&&(X=E),w=re.get(X),w.init(F),A.push(w),X.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),E!==X&&E.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),w.setupLights();const j=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;const de=G.material;if(de)if(Array.isArray(de))for(let Me=0;Me<de.length;Me++){const Ie=de[Me];Dg(Ie,X,G),j.add(Ie)}else Dg(de,X,G),j.add(de)}),w=A.pop(),j},this.compileAsync=function(E,F,X=null){const j=this.compile(E,F,X);return new Promise(G=>{function de(){if(j.forEach(function(Me){b.get(Me).currentProgram.isReady()&&j.delete(Me)}),j.size===0){G(E);return}setTimeout(de,10)}We.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let Xd=null;function aM(E){Xd&&Xd(E)}function Og(){mn.stop()}function Ug(){mn.start()}const mn=new Yx;mn.setAnimationLoop(aM),typeof self<"u"&&mn.setContext(self),this.setAnimationLoop=function(E){Xd=E,Y.setAnimationLoop(E),E===null?mn.stop():mn.start()},Y.addEventListener("sessionstart",Og),Y.addEventListener("sessionend",Ug),this.render=function(E,F){if(F!==void 0&&F.isCamera!==!0){Ve("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;const X=Y.enabled===!0&&Y.isPresenting===!0,j=_!==null&&(U===null||X)&&_.begin(S,U);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),Y.enabled===!0&&Y.isPresenting===!0&&(_===null||_.isCompositing()===!1)&&(Y.cameraAutoUpdate===!0&&Y.updateCamera(F),F=Y.getCamera()),E.isScene===!0&&E.onBeforeRender(S,E,F,U),w=re.get(E,A.length),w.init(F),A.push(w),ct.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Qe.setFromProjectionMatrix(ct,Yi,F.reversedDepth),Te=this.localClippingEnabled,Ye=ue.init(this.clippingPlanes,Te),M=Be.get(E,T.length),M.init(),T.push(M),Y.enabled===!0&&Y.isPresenting===!0){const de=S.xr.getDepthSensingMesh();de!==null&&qd(de,F,-1/0,S.sortObjects)}qd(E,F,0,S.sortObjects),M.finish(),S.sortObjects===!0&&M.sort(wt,Et),_e=Y.enabled===!1||Y.isPresenting===!1||Y.hasDepthSensing()===!1,_e&&Ue.addToRenderList(M,E),this.info.render.frame++,Ye===!0&&ue.beginShadows();const G=w.state.shadowsArray;if(je.render(G,E,F),Ye===!0&&ue.endShadows(),this.info.autoReset===!0&&this.info.reset(),(j&&_.hasRenderPass())===!1){const de=M.opaque,Me=M.transmissive;if(w.setupLights(),F.isArrayCamera){const Ie=F.cameras;if(Me.length>0)for(let Pe=0,$e=Ie.length;Pe<$e;Pe++){const lt=Ie[Pe];zg(de,Me,E,lt)}_e&&Ue.render(E);for(let Pe=0,$e=Ie.length;Pe<$e;Pe++){const lt=Ie[Pe];Fg(M,E,lt,lt.viewport)}}else Me.length>0&&zg(de,Me,E,F),_e&&Ue.render(E),Fg(M,E,F)}U!==null&&L===0&&(D.updateMultisampleRenderTarget(U),D.updateRenderTargetMipmap(U)),j&&_.end(S),E.isScene===!0&&E.onAfterRender(S,E,F),ce.resetDefaultState(),V=-1,B=null,A.pop(),A.length>0?(w=A[A.length-1],Ye===!0&&ue.setGlobalState(S.clippingPlanes,w.state.camera)):w=null,T.pop(),T.length>0?M=T[T.length-1]:M=null};function qd(E,F,X,j){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)X=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);else if(E.isLight)w.pushLight(E),E.castShadow&&w.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Qe.intersectsSprite(E)){j&&ee.setFromMatrixPosition(E.matrixWorld).applyMatrix4(ct);const de=Oe.update(E),Me=E.material;Me.visible&&M.push(E,de,Me,X,ee.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Qe.intersectsObject(E))){const de=Oe.update(E),Me=E.material;if(j&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),ee.copy(E.boundingSphere.center)):(de.boundingSphere===null&&de.computeBoundingSphere(),ee.copy(de.boundingSphere.center)),ee.applyMatrix4(E.matrixWorld).applyMatrix4(ct)),Array.isArray(Me)){const Ie=de.groups;for(let Pe=0,$e=Ie.length;Pe<$e;Pe++){const lt=Ie[Pe],pt=Me[lt.materialIndex];pt&&pt.visible&&M.push(E,de,pt,X,ee.z,lt)}}else Me.visible&&M.push(E,de,Me,X,ee.z,null)}}const G=E.children;for(let de=0,Me=G.length;de<Me;de++)qd(G[de],F,X,j)}function Fg(E,F,X,j){const{opaque:G,transmissive:de,transparent:Me}=E;w.setupLightsView(X),Ye===!0&&ue.setGlobalState(S.clippingPlanes,X),j&&fe.viewport(k.copy(j)),G.length>0&&Ph(G,F,X),de.length>0&&Ph(de,F,X),Me.length>0&&Ph(Me,F,X),fe.buffers.depth.setTest(!0),fe.buffers.depth.setMask(!0),fe.buffers.color.setMask(!0),fe.setPolygonOffset(!1)}function zg(E,F,X,j){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[j.id]===void 0){const pt=We.has("EXT_color_buffer_half_float")||We.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[j.id]=new Bi(1,1,{generateMipmaps:!0,type:pt?Ts:Ri,minFilter:Ss,samples:Math.max(4,Je.samples),stencilBuffer:n,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:mt.workingColorSpace})}const G=w.state.transmissionRenderTarget[j.id],de=j.viewport||k;G.setSize(de.z*S.transmissionResolutionScale,de.w*S.transmissionResolutionScale);const Me=S.getRenderTarget(),Ie=S.getActiveCubeFace(),Pe=S.getActiveMipmapLevel();S.setRenderTarget(G),S.getClearColor(ie),oe=S.getClearAlpha(),oe<1&&S.setClearColor(16777215,.5),S.clear(),_e&&Ue.render(X);const $e=S.toneMapping;S.toneMapping=rs;const lt=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),w.setupLightsView(j),Ye===!0&&ue.setGlobalState(S.clippingPlanes,j),Ph(E,X,j),D.updateMultisampleRenderTarget(G),D.updateRenderTargetMipmap(G),We.has("WEBGL_multisampled_render_to_texture")===!1){let pt=!1;for(let qe=0,Ct=F.length;qe<Ct;qe++){const jt=F[qe],{object:Ut,geometry:At,material:Gt,group:Xe}=jt;if(Gt.side===Ms&&Ut.layers.test(j.layers)){const Xi=Gt.side;Gt.side=yi,Gt.needsUpdate=!0,Bg(Ut,X,j,At,Gt,Xe),Gt.side=Xi,Gt.needsUpdate=!0,pt=!0}}pt===!0&&(D.updateMultisampleRenderTarget(G),D.updateRenderTargetMipmap(G))}S.setRenderTarget(Me,Ie,Pe),S.setClearColor(ie,oe),lt!==void 0&&(j.viewport=lt),S.toneMapping=$e}function Ph(E,F,X){const j=F.isScene===!0?F.overrideMaterial:null;for(let G=0,de=E.length;G<de;G++){const Me=E[G],{object:Ie,geometry:Pe,group:$e}=Me;let lt=Me.material;lt.allowOverride===!0&&j!==null&&(lt=j),Ie.layers.test(X.layers)&&Bg(Ie,F,X,Pe,lt,$e)}}function Bg(E,F,X,j,G,de){E.onBeforeRender(S,F,X,j,G,de),E.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(S,F,X,j,E,de),G.transparent===!0&&G.side===Ms&&G.forceSinglePass===!1?(G.side=yi,G.needsUpdate=!0,S.renderBufferDirect(X,F,j,G,E,de),G.side=Vs,G.needsUpdate=!0,S.renderBufferDirect(X,F,j,G,E,de),G.side=Ms):S.renderBufferDirect(X,F,j,G,E,de),E.onAfterRender(S,F,X,j,G,de)}function Lh(E,F,X){F.isScene!==!0&&(F=he);const j=b.get(E),G=w.state.lights,de=w.state.shadowsArray,Me=G.state.version,Ie=pe.getParameters(E,G.state,de,F,X),Pe=pe.getProgramCacheKey(Ie);let $e=j.programs;j.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?F.environment:null,j.fog=F.fog;const lt=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;j.envMap=Z.get(E.envMap||j.environment,lt),j.envMapRotation=j.environment!==null&&E.envMap===null?F.environmentRotation:E.envMapRotation,$e===void 0&&(E.addEventListener("dispose",Mt),$e=new Map,j.programs=$e);let pt=$e.get(Pe);if(pt!==void 0){if(j.currentProgram===pt&&j.lightsStateVersion===Me)return kg(E,Ie),pt}else Ie.uniforms=pe.getUniforms(E),E.onBuild(X,Ie,S),E.onBeforeCompile(Ie,S),pt=pe.acquireProgram(Ie,Pe),$e.set(Pe,pt),j.uniforms=Ie.uniforms;const qe=j.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(qe.clippingPlanes=ue.uniform),kg(E,Ie),j.needsLights=hM(E),j.lightsStateVersion=Me,j.needsLights&&(qe.ambientLightColor.value=G.state.ambient,qe.lightProbe.value=G.state.probe,qe.directionalLights.value=G.state.directional,qe.directionalLightShadows.value=G.state.directionalShadow,qe.spotLights.value=G.state.spot,qe.spotLightShadows.value=G.state.spotShadow,qe.rectAreaLights.value=G.state.rectArea,qe.ltc_1.value=G.state.rectAreaLTC1,qe.ltc_2.value=G.state.rectAreaLTC2,qe.pointLights.value=G.state.point,qe.pointLightShadows.value=G.state.pointShadow,qe.hemisphereLights.value=G.state.hemi,qe.directionalShadowMatrix.value=G.state.directionalShadowMatrix,qe.spotLightMatrix.value=G.state.spotLightMatrix,qe.spotLightMap.value=G.state.spotLightMap,qe.pointShadowMatrix.value=G.state.pointShadowMatrix),j.currentProgram=pt,j.uniformsList=null,pt}function Vg(E){if(E.uniformsList===null){const F=E.currentProgram.getUniforms();E.uniformsList=Cu.seqWithValue(F.seq,E.uniforms)}return E.uniformsList}function kg(E,F){const X=b.get(E);X.outputColorSpace=F.outputColorSpace,X.batching=F.batching,X.batchingColor=F.batchingColor,X.instancing=F.instancing,X.instancingColor=F.instancingColor,X.instancingMorph=F.instancingMorph,X.skinning=F.skinning,X.morphTargets=F.morphTargets,X.morphNormals=F.morphNormals,X.morphColors=F.morphColors,X.morphTargetsCount=F.morphTargetsCount,X.numClippingPlanes=F.numClippingPlanes,X.numIntersection=F.numClipIntersection,X.vertexAlphas=F.vertexAlphas,X.vertexTangents=F.vertexTangents,X.toneMapping=F.toneMapping}function oM(E,F,X,j,G){F.isScene!==!0&&(F=he),D.resetTextureUnits();const de=F.fog,Me=j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial?F.environment:null,Ie=U===null?S.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:kr,Pe=j.isMeshStandardMaterial||j.isMeshLambertMaterial&&!j.envMap||j.isMeshPhongMaterial&&!j.envMap,$e=Z.get(j.envMap||Me,Pe),lt=j.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,pt=!!X.attributes.tangent&&(!!j.normalMap||j.anisotropy>0),qe=!!X.morphAttributes.position,Ct=!!X.morphAttributes.normal,jt=!!X.morphAttributes.color;let Ut=rs;j.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(Ut=S.toneMapping);const At=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Gt=At!==void 0?At.length:0,Xe=b.get(j),Xi=w.state.lights;if(Ye===!0&&(Te===!0||E!==B)){const Yt=E===B&&j.id===V;ue.setState(j,E,Yt)}let fn=!1;j.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Xi.state.version||Xe.outputColorSpace!==Ie||G.isBatchedMesh&&Xe.batching===!1||!G.isBatchedMesh&&Xe.batching===!0||G.isBatchedMesh&&Xe.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&Xe.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&Xe.instancing===!1||!G.isInstancedMesh&&Xe.instancing===!0||G.isSkinnedMesh&&Xe.skinning===!1||!G.isSkinnedMesh&&Xe.skinning===!0||G.isInstancedMesh&&Xe.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Xe.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Xe.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Xe.instancingMorph===!1&&G.morphTexture!==null||Xe.envMap!==$e||j.fog===!0&&Xe.fog!==de||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==ue.numPlanes||Xe.numIntersection!==ue.numIntersection)||Xe.vertexAlphas!==lt||Xe.vertexTangents!==pt||Xe.morphTargets!==qe||Xe.morphNormals!==Ct||Xe.morphColors!==jt||Xe.toneMapping!==Ut||Xe.morphTargetsCount!==Gt)&&(fn=!0):(fn=!0,Xe.__version=j.version);let _s=Xe.currentProgram;fn===!0&&(_s=Lh(j,F,G));let Bs=!1,gn=!1,oa=!1;const Nt=_s.getUniforms(),ui=Xe.uniforms;if(fe.useProgram(_s.program)&&(Bs=!0,gn=!0,oa=!0),(j.id!==V||j._forceRefresh)&&(V=j.id,gn=!0,j._forceRefresh=!1),Bs||B!==E){fe.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Nt.setValue(I,"projectionMatrix",E.projectionMatrix),Nt.setValue(I,"viewMatrix",E.matrixWorldInverse);const Yt=Nt.map.cameraPosition;Yt!==void 0&&Yt.setValue(I,Q.setFromMatrixPosition(E.matrixWorld)),Je.logarithmicDepthBuffer&&Nt.setValue(I,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&Nt.setValue(I,"isOrthographic",E.isOrthographicCamera===!0),B!==E&&(B=E,gn=!0,oa=!0)}if(Xe.needsLights&&(Xi.state.directionalShadowMap.length>0&&Nt.setValue(I,"directionalShadowMap",Xi.state.directionalShadowMap,D),Xi.state.spotShadowMap.length>0&&Nt.setValue(I,"spotShadowMap",Xi.state.spotShadowMap,D),Xi.state.pointShadowMap.length>0&&Nt.setValue(I,"pointShadowMap",Xi.state.pointShadowMap,D)),G.isSkinnedMesh){Nt.setOptional(I,G,"bindMatrix"),Nt.setOptional(I,G,"bindMatrixInverse");const Yt=G.skeleton;Yt&&(Yt.boneTexture===null&&Yt.computeBoneTexture(),Nt.setValue(I,"boneTexture",Yt.boneTexture,D))}G.isBatchedMesh&&(Nt.setOptional(I,G,"batchingTexture"),Nt.setValue(I,"batchingTexture",G._matricesTexture,D),Nt.setOptional(I,G,"batchingIdTexture"),Nt.setValue(I,"batchingIdTexture",G._indirectTexture,D),Nt.setOptional(I,G,"batchingColorTexture"),G._colorsTexture!==null&&Nt.setValue(I,"batchingColorTexture",G._colorsTexture,D));const Dr=X.morphAttributes;if((Dr.position!==void 0||Dr.normal!==void 0||Dr.color!==void 0)&&Ae.update(G,X,_s),(gn||Xe.receiveShadow!==G.receiveShadow)&&(Xe.receiveShadow=G.receiveShadow,Nt.setValue(I,"receiveShadow",G.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&F.environment!==null&&(ui.envMapIntensity.value=F.environmentIntensity),ui.dfgLUT!==void 0&&(ui.dfgLUT.value=lC()),gn&&(Nt.setValue(I,"toneMappingExposure",S.toneMappingExposure),Xe.needsLights&&lM(ui,oa),de&&j.fog===!0&&He.refreshFogUniforms(ui,de),He.refreshMaterialUniforms(ui,j,tt,Ce,w.state.transmissionRenderTarget[E.id]),Cu.upload(I,Vg(Xe),ui,D)),j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Cu.upload(I,Vg(Xe),ui,D),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&Nt.setValue(I,"center",G.center),Nt.setValue(I,"modelViewMatrix",G.modelViewMatrix),Nt.setValue(I,"normalMatrix",G.normalMatrix),Nt.setValue(I,"modelMatrix",G.matrixWorld),j.isShaderMaterial||j.isRawShaderMaterial){const Yt=j.uniformsGroups;for(let Oo=0,la=Yt.length;Oo<la;Oo++){const Gg=Yt[Oo];Le.update(Gg,_s),Le.bind(Gg,_s)}}return _s}function lM(E,F){E.ambientLightColor.needsUpdate=F,E.lightProbe.needsUpdate=F,E.directionalLights.needsUpdate=F,E.directionalLightShadows.needsUpdate=F,E.pointLights.needsUpdate=F,E.pointLightShadows.needsUpdate=F,E.spotLights.needsUpdate=F,E.spotLightShadows.needsUpdate=F,E.rectAreaLights.needsUpdate=F,E.hemisphereLights.needsUpdate=F}function hM(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(E,F,X){const j=b.get(E);j.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,j.__autoAllocateDepthBuffer===!1&&(j.__useRenderToTexture=!1),b.get(E.texture).__webglTexture=F,b.get(E.depthTexture).__webglTexture=j.__autoAllocateDepthBuffer?void 0:X,j.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,F){const X=b.get(E);X.__webglFramebuffer=F,X.__useDefaultFramebuffer=F===void 0};const cM=I.createFramebuffer();this.setRenderTarget=function(E,F=0,X=0){U=E,C=F,L=X;let j=null,G=!1,de=!1;if(E){const Me=b.get(E);if(Me.__useDefaultFramebuffer!==void 0){fe.bindFramebuffer(I.FRAMEBUFFER,Me.__webglFramebuffer),k.copy(E.viewport),W.copy(E.scissor),se=E.scissorTest,fe.viewport(k),fe.scissor(W),fe.setScissorTest(se),V=-1;return}else if(Me.__webglFramebuffer===void 0)D.setupRenderTarget(E);else if(Me.__hasExternalTextures)D.rebindTextures(E,b.get(E.texture).__webglTexture,b.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const $e=E.depthTexture;if(Me.__boundDepthTexture!==$e){if($e!==null&&b.has($e)&&(E.width!==$e.image.width||E.height!==$e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");D.setupDepthRenderbuffer(E)}}const Ie=E.texture;(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(de=!0);const Pe=b.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Pe[F])?j=Pe[F][X]:j=Pe[F],G=!0):E.samples>0&&D.useMultisampledRTT(E)===!1?j=b.get(E).__webglMultisampledFramebuffer:Array.isArray(Pe)?j=Pe[X]:j=Pe,k.copy(E.viewport),W.copy(E.scissor),se=E.scissorTest}else k.copy(K).multiplyScalar(tt).floor(),W.copy(ae).multiplyScalar(tt).floor(),se=le;if(X!==0&&(j=cM),fe.bindFramebuffer(I.FRAMEBUFFER,j)&&fe.drawBuffers(E,j),fe.viewport(k),fe.scissor(W),fe.setScissorTest(se),G){const Me=b.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+F,Me.__webglTexture,X)}else if(de){const Me=F;for(let Ie=0;Ie<E.textures.length;Ie++){const Pe=b.get(E.textures[Ie]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+Ie,Pe.__webglTexture,X,Me)}}else if(E!==null&&X!==0){const Me=b.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Me.__webglTexture,X)}V=-1},this.readRenderTargetPixels=function(E,F,X,j,G,de,Me,Ie=0){if(!(E&&E.isWebGLRenderTarget)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=b.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Me!==void 0&&(Pe=Pe[Me]),Pe){fe.bindFramebuffer(I.FRAMEBUFFER,Pe);try{const $e=E.textures[Ie],lt=$e.format,pt=$e.type;if(E.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Ie),!Je.textureFormatReadable(lt)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Je.textureTypeReadable(pt)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=E.width-j&&X>=0&&X<=E.height-G&&I.readPixels(F,X,j,G,me.convert(lt),me.convert(pt),de)}finally{const $e=U!==null?b.get(U).__webglFramebuffer:null;fe.bindFramebuffer(I.FRAMEBUFFER,$e)}}},this.readRenderTargetPixelsAsync=async function(E,F,X,j,G,de,Me,Ie=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pe=b.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Me!==void 0&&(Pe=Pe[Me]),Pe)if(F>=0&&F<=E.width-j&&X>=0&&X<=E.height-G){fe.bindFramebuffer(I.FRAMEBUFFER,Pe);const $e=E.textures[Ie],lt=$e.format,pt=$e.type;if(E.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Ie),!Je.textureFormatReadable(lt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Je.textureTypeReadable(pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qe=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,qe),I.bufferData(I.PIXEL_PACK_BUFFER,de.byteLength,I.STREAM_READ),I.readPixels(F,X,j,G,me.convert(lt),me.convert(pt),0);const Ct=U!==null?b.get(U).__webglFramebuffer:null;fe.bindFramebuffer(I.FRAMEBUFFER,Ct);const jt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await VM(I,jt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,qe),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,de),I.deleteBuffer(qe),I.deleteSync(jt),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,F=null,X=0){const j=Math.pow(2,-X),G=Math.floor(E.image.width*j),de=Math.floor(E.image.height*j),Me=F!==null?F.x:0,Ie=F!==null?F.y:0;D.setTexture2D(E,0),I.copyTexSubImage2D(I.TEXTURE_2D,X,0,0,Me,Ie,G,de),fe.unbindTexture()};const uM=I.createFramebuffer(),dM=I.createFramebuffer();this.copyTextureToTexture=function(E,F,X=null,j=null,G=0,de=0){let Me,Ie,Pe,$e,lt,pt,qe,Ct,jt;const Ut=E.isCompressedTexture?E.mipmaps[de]:E.image;if(X!==null)Me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Pe=X.isBox3?X.max.z-X.min.z:1,$e=X.min.x,lt=X.min.y,pt=X.isBox3?X.min.z:0;else{const ui=Math.pow(2,-G);Me=Math.floor(Ut.width*ui),Ie=Math.floor(Ut.height*ui),E.isDataArrayTexture?Pe=Ut.depth:E.isData3DTexture?Pe=Math.floor(Ut.depth*ui):Pe=1,$e=0,lt=0,pt=0}j!==null?(qe=j.x,Ct=j.y,jt=j.z):(qe=0,Ct=0,jt=0);const At=me.convert(F.format),Gt=me.convert(F.type);let Xe;F.isData3DTexture?(D.setTexture3D(F,0),Xe=I.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(D.setTexture2DArray(F,0),Xe=I.TEXTURE_2D_ARRAY):(D.setTexture2D(F,0),Xe=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,F.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,F.unpackAlignment);const Xi=I.getParameter(I.UNPACK_ROW_LENGTH),fn=I.getParameter(I.UNPACK_IMAGE_HEIGHT),_s=I.getParameter(I.UNPACK_SKIP_PIXELS),Bs=I.getParameter(I.UNPACK_SKIP_ROWS),gn=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,Ut.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Ut.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,$e),I.pixelStorei(I.UNPACK_SKIP_ROWS,lt),I.pixelStorei(I.UNPACK_SKIP_IMAGES,pt);const oa=E.isDataArrayTexture||E.isData3DTexture,Nt=F.isDataArrayTexture||F.isData3DTexture;if(E.isDepthTexture){const ui=b.get(E),Dr=b.get(F),Yt=b.get(ui.__renderTarget),Oo=b.get(Dr.__renderTarget);fe.bindFramebuffer(I.READ_FRAMEBUFFER,Yt.__webglFramebuffer),fe.bindFramebuffer(I.DRAW_FRAMEBUFFER,Oo.__webglFramebuffer);for(let la=0;la<Pe;la++)oa&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,b.get(E).__webglTexture,G,pt+la),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,b.get(F).__webglTexture,de,jt+la)),I.blitFramebuffer($e,lt,Me,Ie,qe,Ct,Me,Ie,I.DEPTH_BUFFER_BIT,I.NEAREST);fe.bindFramebuffer(I.READ_FRAMEBUFFER,null),fe.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(G!==0||E.isRenderTargetTexture||b.has(E)){const ui=b.get(E),Dr=b.get(F);fe.bindFramebuffer(I.READ_FRAMEBUFFER,uM),fe.bindFramebuffer(I.DRAW_FRAMEBUFFER,dM);for(let Yt=0;Yt<Pe;Yt++)oa?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,ui.__webglTexture,G,pt+Yt):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,ui.__webglTexture,G),Nt?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Dr.__webglTexture,de,jt+Yt):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Dr.__webglTexture,de),G!==0?I.blitFramebuffer($e,lt,Me,Ie,qe,Ct,Me,Ie,I.COLOR_BUFFER_BIT,I.NEAREST):Nt?I.copyTexSubImage3D(Xe,de,qe,Ct,jt+Yt,$e,lt,Me,Ie):I.copyTexSubImage2D(Xe,de,qe,Ct,$e,lt,Me,Ie);fe.bindFramebuffer(I.READ_FRAMEBUFFER,null),fe.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else Nt?E.isDataTexture||E.isData3DTexture?I.texSubImage3D(Xe,de,qe,Ct,jt,Me,Ie,Pe,At,Gt,Ut.data):F.isCompressedArrayTexture?I.compressedTexSubImage3D(Xe,de,qe,Ct,jt,Me,Ie,Pe,At,Ut.data):I.texSubImage3D(Xe,de,qe,Ct,jt,Me,Ie,Pe,At,Gt,Ut):E.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,de,qe,Ct,Me,Ie,At,Gt,Ut.data):E.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,de,qe,Ct,Ut.width,Ut.height,At,Ut.data):I.texSubImage2D(I.TEXTURE_2D,de,qe,Ct,Me,Ie,At,Gt,Ut);I.pixelStorei(I.UNPACK_ROW_LENGTH,Xi),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,fn),I.pixelStorei(I.UNPACK_SKIP_PIXELS,_s),I.pixelStorei(I.UNPACK_SKIP_ROWS,Bs),I.pixelStorei(I.UNPACK_SKIP_IMAGES,gn),de===0&&F.generateMipmaps&&I.generateMipmap(Xe),fe.unbindTexture()},this.initRenderTarget=function(E){b.get(E).__webglFramebuffer===void 0&&D.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?D.setTextureCube(E,0):E.isData3DTexture?D.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?D.setTexture2DArray(E,0):D.setTexture2D(E,0),fe.unbindTexture()},this.resetState=function(){C=0,L=0,U=null,fe.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Yi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=mt._getDrawingBufferColorSpace(e),t.unpackColorSpace=mt._getUnpackColorSpace()}}const hC=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Bh,AddEquation:Ur,AddOperation:u0,AdditiveAnimationBlendMode:lp,AdditiveBlending:Dh,AgXToneMapping:Vh,AlphaFormat:rp,AlwaysCompare:V0,AlwaysDepth:Fo,AlwaysStencilFunc:dc,AmbientLight:Im,AnimationAction:Sx,AnimationClip:qa,AnimationLoader:ES,AnimationMixer:Tx,AnimationObjectGroup:YS,AnimationUtils:bS,ArcCurve:Dy,ArrayCamera:Um,ArrowHelper:pT,AttachedBindMode:tp,Audio:Bm,AudioAnalyser:zS,AudioContext:yu,AudioListener:vx,AudioLoader:gx,AxesHelper:jx,BackSide:yi,BasicDepthPacking:hp,BasicShadowMap:mM,BatchedMesh:Xp,BezierInterpolant:tx,Bone:kc,BooleanKeyframeTrack:Jr,Box2:sT,Box3:di,Box3Helper:Hx,BoxGeometry:dn,BoxHelper:Gx,BufferAttribute:bt,BufferGeometry:rt,BufferGeometryLoader:dx,ByteType:ip,Cache:Is,Camera:Hl,CameraHelper:kx,CanvasTexture:Py,CapsuleGeometry:Ld,CatmullRomCurve3:nm,CineonToneMapping:Qd,CircleGeometry:Dd,ClampToEdgeWrapping:Ci,Clock:eT,Color:we,ColorKeyframeTrack:uu,ColorManagement:mt,Compatibility:OM,CompressedArrayTexture:Ry,CompressedCubeTexture:Iy,CompressedTexture:Ol,CompressedTextureLoader:AS,ConeGeometry:Nh,ConstantAlphaFactor:l0,ConstantColorFactor:a0,Controls:qx,CubeCamera:Om,CubeDepthTexture:Ly,CubeReflectionMapping:ks,CubeRefractionMapping:zr,CubeTexture:ka,CubeTextureLoader:NS,CubeUVReflectionMapping:xn,CubicBezierCurve:am,CubicBezierCurve3:Uy,CubicInterpolant:Qy,CullFaceBack:Yd,CullFaceFront:Xg,CullFaceFrontBack:pM,CullFaceNone:jg,Curve:ls,CurvePath:zy,CustomBlending:Kd,CustomToneMapping:ep,CylinderGeometry:Io,Cylindrical:tT,Data3DTexture:_l,DataArrayTexture:gc,DataTexture:os,DataTextureLoader:rx,DataUtils:ay,DecrementStencilOp:T0,DecrementWrapStencilOp:E0,DefaultLoadingManager:Tm,DepthFormat:ws,DepthStencilFormat:ur,DepthTexture:On,DetachedBindMode:d0,DirectionalLight:Rm,DirectionalLightHelper:Vx,DiscreteInterpolant:ex,DodecahedronGeometry:Od,DoubleSide:Ms,DstAlphaFactor:t0,DstColorFactor:s0,DynamicCopyUsage:CM,DynamicDrawUsage:k0,DynamicReadUsage:EM,EdgesGeometry:em,EllipseCurve:iu,EqualCompare:F0,EqualDepth:Bo,EqualStencilFunc:R0,EquirectangularReflectionMapping:ua,EquirectangularRefractionMapping:da,Euler:ns,EventDispatcher:Es,ExternalTexture:$p,ExtrudeGeometry:Ch,FileLoader:js,Float16BufferAttribute:Sb,Float32BufferAttribute:Ne,FloatType:xi,Fog:vp,FogExp2:Id,FramebufferTexture:Gb,FrontSide:Vs,Frustum:Pn,FrustumArray:Pd,GLBufferAttribute:QS,GLSL1:IM,GLSL3:fc,GreaterCompare:z0,GreaterDepth:ko,GreaterEqualCompare:mc,GreaterEqualDepth:Vo,GreaterEqualStencilFunc:D0,GreaterStencilFunc:P0,GridHelper:Fx,Group:wn,HalfFloatType:Ts,HemisphereLight:wm,HemisphereLightHelper:cT,IcosahedronGeometry:Ud,ImageBitmapLoader:fx,ImageLoader:Gl,ImageUtils:pp,IncrementStencilOp:S0,IncrementWrapStencilOp:w0,InstancedBufferAttribute:Rn,InstancedBufferGeometry:Lm,InstancedInterleavedBuffer:wx,InstancedMesh:Gp,Int16BufferAttribute:Mb,Int32BufferAttribute:bb,Int8BufferAttribute:xb,IntType:Wh,InterleavedBuffer:Al,InterleavedBufferAttribute:Oa,Interpolant:zn,InterpolateBezier:op,InterpolateDiscrete:Ma,InterpolateLinear:dl,InterpolateSmooth:cc,InterpolationSamplingMode:DM,InterpolationSamplingType:LM,InvertStencilOp:A0,KeepStencilOp:Gr,KeyframeTrack:Qi,LOD:Dp,LatheGeometry:Fd,Layers:Ml,LessCompare:U0,LessDepth:zo,LessEqualCompare:pc,LessEqualDepth:Fr,LessEqualStencilFunc:I0,LessStencilFunc:C0,Light:Kr,LightProbe:ux,Line:Sr,Line3:Px,LineBasicMaterial:Ti,LineCurve:om,LineCurve3:Fy,LineDashedMaterial:Ky,LineLoop:Yp,LineSegments:Rs,LinearFilter:Rt,LinearInterpolant:Sm,LinearMipMapLinearFilter:m0,LinearMipMapNearestFilter:yM,LinearMipmapLinearFilter:Ss,LinearMipmapNearestFilter:fa,LinearSRGBColorSpace:kr,LinearToneMapping:Fh,LinearTransfer:ml,Loader:Oi,LoaderUtils:fu,LoadingManager:du,LoopOnce:np,LoopPingPong:f0,LoopRepeat:ap,MOUSE:Hg,Material:pi,MaterialBlending:fM,MaterialLoader:Gd,MathUtils:q0,Matrix2:iT,Matrix3:at,Matrix4:et,MaxEquation:$d,Mesh:Xt,MeshBasicMaterial:Mr,MeshDepthMaterial:cu,MeshDistanceMaterial:_m,MeshLambertMaterial:vm,MeshMatcapMaterial:Jy,MeshNormalMaterial:xm,MeshPhongMaterial:ym,MeshPhysicalMaterial:gm,MeshStandardMaterial:hu,MeshToonMaterial:Zy,MinEquation:Jg,MirroredRepeatWrapping:ma,MixOperation:c0,MultiplyBlending:Jd,MultiplyOperation:Ho,NearestFilter:Ht,NearestMipMapLinearFilter:gM,NearestMipMapNearestFilter:p0,NearestMipmapLinearFilter:vn,NearestMipmapNearestFilter:Hh,NeutralToneMapping:kh,NeverCompare:O0,NeverDepth:Uo,NeverStencilFunc:N0,NoBlending:bs,NoColorSpace:Gs,NoNormalPacking:MM,NoToneMapping:rs,NormalAnimationBlendMode:uc,NormalBlending:Or,NormalGAPacking:SM,NormalRGPacking:bM,NotEqualCompare:B0,NotEqualDepth:Go,NotEqualStencilFunc:L0,NumberKeyframeTrack:Wa,Object3D:_t,ObjectLoader:PS,ObjectSpaceNormalMap:_0,OctahedronGeometry:Po,OneFactor:$g,OneMinusConstantAlphaFactor:h0,OneMinusConstantColorFactor:o0,OneMinusDstAlphaFactor:i0,OneMinusDstColorFactor:r0,OneMinusSrcAlphaFactor:Uh,OneMinusSrcColorFactor:e0,OrthographicCamera:Za,PCFShadowMap:ha,PCFSoftShadowMap:qg,PMREMGenerator:wu,Path:nu,PerspectiveCamera:li,Plane:br,PlaneGeometry:na,PlaneHelper:dT,PointLight:Cm,PointLightHelper:lT,Points:Jp,PointsMaterial:Jc,PolarGridHelper:uT,PolyhedronGeometry:pn,PositionalAudio:Mx,PropertyBinding:gt,PropertyMixer:bx,QuadraticBezierCurve:lm,QuadraticBezierCurve3:hm,Quaternion:Mi,QuaternionKeyframeTrack:ja,QuaternionLinearInterpolant:ix,R11_EAC_Format:el,RED_GREEN_RGTC2_Format:cl,RED_RGTC1_Format:ll,REVISION:yn,RG11_EAC_Format:il,RGBADepthPacking:v0,RGBAFormat:vi,RGBAIntegerFormat:Xo,RGBA_ASTC_10x10_Format:ac,RGBA_ASTC_10x5_Format:sc,RGBA_ASTC_10x6_Format:rc,RGBA_ASTC_10x8_Format:nc,RGBA_ASTC_12x10_Format:oc,RGBA_ASTC_12x12_Format:lc,RGBA_ASTC_4x4_Format:rl,RGBA_ASTC_5x4_Format:Kh,RGBA_ASTC_5x5_Format:$h,RGBA_ASTC_6x5_Format:Qh,RGBA_ASTC_6x6_Format:nl,RGBA_ASTC_8x5_Format:ec,RGBA_ASTC_8x6_Format:tc,RGBA_ASTC_8x8_Format:ic,RGBA_BPTC_Format:al,RGBA_ETC2_EAC_Format:Qo,RGBA_PVRTC_2BPPV1_Format:Jo,RGBA_PVRTC_4BPPV1_Format:Zo,RGBA_S3TC_DXT1_Format:va,RGBA_S3TC_DXT3_Format:qo,RGBA_S3TC_DXT5_Format:_a,RGBDepthPacking:vM,RGBFormat:Zh,RGBIntegerFormat:xM,RGB_BPTC_SIGNED_Format:hc,RGB_BPTC_UNSIGNED_Format:ol,RGB_ETC1_Format:Ko,RGB_ETC2_Format:$o,RGB_PVRTC_2BPPV1_Format:Jh,RGB_PVRTC_4BPPV1_Format:Yo,RGB_S3TC_DXT1_Format:xa,RGDepthPacking:_M,RGFormat:Br,RGIntegerFormat:jo,RawShaderMaterial:lu,Ray:Nn,Raycaster:Ax,RectAreaLight:cx,RedFormat:Wo,RedIntegerFormat:ya,ReinhardToneMapping:zh,RenderTarget:gp,RenderTarget3D:JS,RepeatWrapping:pa,ReplaceStencilOp:b0,ReverseSubtractEquation:Zg,RingGeometry:Rh,SIGNED_R11_EAC_Format:tl,SIGNED_RED_GREEN_RGTC2_Format:ul,SIGNED_RED_RGTC1_Format:hl,SIGNED_RG11_EAC_Format:sl,SRGBColorSpace:Ii,SRGBTransfer:vt,Scene:_p,ShaderChunk:ot,ShaderLib:hs,ShaderMaterial:$i,ShadowMaterial:mm,Shape:Zr,ShapeGeometry:zd,ShapePath:Xx,ShapeUtils:ys,ShortType:sp,Skeleton:Ah,SkeletonHelper:oT,SkinnedMesh:kp,Source:pr,Sphere:ai,SphereGeometry:Lo,Spherical:Cx,SphericalHarmonics3:Pm,SplineCurve:cm,SpotLight:Nm,SpotLightHelper:aT,Sprite:Lp,SpriteMaterial:Ec,SrcAlphaFactor:Oh,SrcAlphaSaturateFactor:n0,SrcColorFactor:Qg,StaticCopyUsage:NM,StaticDrawUsage:fl,StaticReadUsage:wM,StereoCamera:DS,StreamCopyUsage:RM,StreamDrawUsage:TM,StreamReadUsage:AM,StringKeyframeTrack:Bn,SubtractEquation:Yg,SubtractiveBlending:Zd,TOUCH:Wg,TangentSpaceNormalMap:Vr,TetrahedronGeometry:Bd,Texture:ei,TextureLoader:nx,TextureUtils:xT,Timer:Fm,TimestampQuery:PM,TorusGeometry:Ih,TorusKnotGeometry:Vd,Triangle:yr,TriangleFanDrawMode:x0,TriangleStripDrawMode:y0,TrianglesDrawMode:g0,TubeGeometry:kd,UVMapping:Gh,Uint16BufferAttribute:wc,Uint32BufferAttribute:Cp,Uint8BufferAttribute:vb,Uint8ClampedBufferAttribute:_b,Uniform:Hd,UniformsGroup:$S,UniformsLib:ye,UniformsUtils:fm,UnsignedByteType:Ri,UnsignedInt101111Type:Yh,UnsignedInt248Type:_n,UnsignedInt5999Type:qh,UnsignedIntType:qi,UnsignedShort4444Type:jh,UnsignedShort5551Type:Xh,UnsignedShortType:ga,VSMShadowMap:ca,Vector2:te,Vector3:R,Vector4:It,VectorKeyframeTrack:Xa,VideoFrameTexture:kb,VideoTexture:Kp,WebGL3DRenderTarget:lb,WebGLArrayRenderTarget:ob,WebGLCoordinateSystem:Yi,WebGLCubeRenderTarget:Au,WebGLRenderTarget:Bi,WebGLRenderer:Sv,WebGLUtils:bv,WebGPUCoordinateSystem:Sn,WebXRController:vc,WireframeGeometry:pm,WrapAroundEnding:pl,ZeroCurvatureEnding:Mn,ZeroFactor:Kg,ZeroSlopeEnding:bn,ZeroStencilOp:M0,createCanvasElement:H0,error:Ve,getConsoleFunction:BM,log:yl,setConsoleFunction:zM,warn:ge,warnOnce:xl},Symbol.toStringTag,{value:"Module"})),Iu={VERTEX:"vertex"},ht={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Tv={READ_ONLY:"readOnly",READ_WRITE:"readWrite"},ql=["x","y","z","w"],cC=0,uC=1,dC=2,Pu=3,tf=0,sf=1,pC=2,mC=0,wv=1,Ev=100,Av=204,Nv=205,Cv=3,fC=0,rf=0,gC=1,yC=2,xC=3,vC=4,_C=6,MC=7,Rv=300,nf=301,bC=302,Iv=1e3,Yl=1001,Pv=1002,cs=1003,Zl=1006,Lv=1008,Dv=1009,SC=1013,af=1014,Ov=1015,Jl=1016,TC=1023,of=1026,wC=1027,Kl=1030,EC=37490,AC=36285,lf=0,NC=1,Lu="",Ps="srgb",Uv="srgb-linear",Fv="linear",$l="srgb",hf="",zv="rg",CC="ga",io=7680,Bv=519,RC=513,cf=515,Vv=516,Du=518,so=35044,uf=35048,Zs=2e3,tn=2001,kv={TEXTURE_COMPARE:"depthTextureCompare"};function IC(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function Gv(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}const Hv={};function df(...s){const e="THREE."+s.shift();console.log(e,...s)}function Wv(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function st(...s){s=Wv(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function Tt(...s){s=Wv(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function ro(...s){const e=s.join(" ");e in Hv||(Hv[e]=!0,st(...s))}const wi=["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 jv=1234567;const Ql=Math.PI/180,eh=180/Math.PI;function wr(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(wi[s&255]+wi[s>>8&255]+wi[s>>16&255]+wi[s>>24&255]+"-"+wi[e&255]+wi[e>>8&255]+"-"+wi[e>>16&15|64]+wi[e>>24&255]+"-"+wi[t&63|128]+wi[t>>8&255]+"-"+wi[t>>16&255]+wi[t>>24&255]+wi[i&255]+wi[i>>8&255]+wi[i>>16&255]+wi[i>>24&255]).toLowerCase()}function ft(s,e,t){return Math.max(e,Math.min(t,s))}function pf(s,e){return(s%e+e)%e}function PC(s,e,t,i,r){return i+(s-e)*(r-i)/(t-e)}function LC(s,e,t){return s!==e?(t-s)/(e-s):0}function th(s,e,t){return(1-t)*s+t*e}function DC(s,e,t,i){return th(s,e,1-Math.exp(-t*i))}function OC(s,e=1){return e-Math.abs(pf(s,e*2)-e)}function UC(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function FC(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function zC(s,e){return s+Math.floor(Math.random()*(e-s+1))}function BC(s,e){return s+Math.random()*(e-s)}function VC(s){return s*(.5-Math.random())}function kC(s){s!==void 0&&(jv=s);let e=jv+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function GC(s){return s*Ql}function HC(s){return s*eh}function WC(s){return(s&s-1)===0&&s!==0}function jC(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function XC(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function qC(s,e,t,i,r){const n=Math.cos,a=Math.sin,o=n(t/2),l=a(t/2),h=n((e+i)/2),c=a((e+i)/2),d=n((e-i)/2),u=a((e-i)/2),p=n((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":s.set(o*c,l*d,l*u,o*h);break;case"YZY":s.set(l*u,o*c,l*d,o*h);break;case"ZXZ":s.set(l*d,l*u,o*c,o*h);break;case"XZX":s.set(o*c,l*m,l*p,o*h);break;case"YXY":s.set(l*p,o*c,l*m,o*h);break;case"ZYZ":s.set(l*m,l*p,o*c,o*h);break;default:st("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ls(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function St(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const YC={DEG2RAD:Ql,RAD2DEG:eh,generateUUID:wr,clamp:ft,euclideanModulo:pf,mapLinear:PC,inverseLerp:LC,lerp:th,damp:DC,pingpong:OC,smoothstep:UC,smootherstep:FC,randInt:zC,randFloat:BC,randFloatSpread:VC,seededRandom:kC,degToRad:GC,radToDeg:HC,isPowerOfTwo:WC,ceilPowerOfTwo:jC,floorPowerOfTwo:XC,setQuaternionFromProperEuler:qC,normalize:St,denormalize:Ls};class xs{constructor(e,t,i,r,n,a,o,l,h){xs.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,h)}set(e,t,i,r,n,a,o,l,h){const c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=t,c[4]=n,c[5]=l,c[6]=i,c[7]=a,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[3],l=i[6],h=i[1],c=i[4],d=i[7],u=i[2],p=i[5],m=i[8],y=r[0],g=r[3],f=r[6],x=r[1],v=r[4],M=r[7],w=r[2],T=r[5],A=r[8];return n[0]=a*y+o*x+l*w,n[3]=a*g+o*v+l*T,n[6]=a*f+o*M+l*A,n[1]=h*y+c*x+d*w,n[4]=h*g+c*v+d*T,n[7]=h*f+c*M+d*A,n[2]=u*y+p*x+m*w,n[5]=u*g+p*v+m*T,n[8]=u*f+p*M+m*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8];return t*a*c-t*o*h-i*n*c+i*o*l+r*n*h-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],d=c*a-o*h,u=o*l-c*n,p=h*n-a*l,m=t*d+i*u+r*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return e[0]=d*y,e[1]=(r*h-c*i)*y,e[2]=(o*i-r*a)*y,e[3]=u*y,e[4]=(c*t-r*l)*y,e[5]=(r*n-o*t)*y,e[6]=p*y,e[7]=(i*l-h*t)*y,e[8]=(a*t-i*n)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,n,a,o){const l=Math.cos(n),h=Math.sin(n);return this.set(i*l,i*h,-i*(l*a+h*o)+a+e,-r*h,r*l,-r*(-h*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(mf.makeScale(e,t)),this}rotate(e){return this.premultiply(mf.makeRotation(-e)),this}translate(e,t){return this.premultiply(mf.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const mf=new xs,Xv=new xs().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),qv=new xs().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ZC(){const s={enabled:!0,workingColorSpace:Uv,spaces:{},convert:function(r,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===$l&&(r.r=Er(r.r),r.g=Er(r.g),r.b=Er(r.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[n].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===$l&&(r.r=no(r.r),r.g=no(r.g),r.b=no(r.b))),r},workingToColorSpace:function(r,n){return this.convert(r,this.workingColorSpace,n)},colorSpaceToWorking:function(r,n){return this.convert(r,n,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Lu?Fv:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,n=this.workingColorSpace){return r.fromArray(this.spaces[n].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,n,a){return r.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,n){return ro("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(r,n)},toWorkingColorSpace:function(r,n){return ro("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(r,n)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[Uv]:{primaries:e,whitePoint:i,transfer:Fv,toXYZ:Xv,fromXYZ:qv,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ps},outputColorSpaceConfig:{drawingBufferColorSpace:Ps}},[Ps]:{primaries:e,whitePoint:i,transfer:$l,toXYZ:Xv,fromXYZ:qv,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ps}}}),s}const si=ZC();function Er(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function no(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.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},sn={h:0,s:0,l:0},Ou={h:0,s:0,l:0};function ff(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Ds{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ps){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,si.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=si.workingColorSpace){return this.r=e,this.g=t,this.b=i,si.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=si.workingColorSpace){if(e=pf(e,1),t=ft(t,0,1),i=ft(i,0,1),t===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,a=2*i-n;this.r=ff(a,n,e+1/3),this.g=ff(a,n,e),this.b=ff(a,n,e-1/3)}return si.colorSpaceToWorking(this,r),this}setStyle(e,t=Ps){function i(n){n!==void 0&&parseFloat(n)<1&&st("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let n;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,t);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,t);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,t);break;default:st("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=r[1],a=n.length;if(a===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(n,16),t);st("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ps){const i=Yv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):st("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Er(e.r),this.g=Er(e.g),this.b=Er(e.b),this}copyLinearToSRGB(e){return this.r=no(e.r),this.g=no(e.g),this.b=no(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ps){return si.workingToColorSpace(Ei.copy(this),e),Math.round(ft(Ei.r*255,0,255))*65536+Math.round(ft(Ei.g*255,0,255))*256+Math.round(ft(Ei.b*255,0,255))}getHexString(e=Ps){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=si.workingColorSpace){si.workingToColorSpace(Ei.copy(this),t);const i=Ei.r,r=Ei.g,n=Ei.b,a=Math.max(i,r,n),o=Math.min(i,r,n);let l,h;const c=(o+a)/2;if(o===a)l=0,h=0;else{const d=a-o;switch(h=c<=.5?d/(a+o):d/(2-a-o),a){case i:l=(r-n)/d+(r<n?6:0);break;case r:l=(n-i)/d+2;break;case n:l=(i-r)/d+4;break}l/=6}return e.h=l,e.s=h,e.l=c,e}getRGB(e,t=si.workingColorSpace){return si.workingToColorSpace(Ei.copy(this),t),e.r=Ei.r,e.g=Ei.g,e.b=Ei.b,e}getStyle(e=Ps){si.workingToColorSpace(Ei.copy(this),e);const t=Ei.r,i=Ei.g,r=Ei.b;return e!==Ps?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(sn),this.setHSL(sn.h+e,sn.s+t,sn.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(sn),e.getHSL(Ou);const i=th(sn.h,Ou.h,t),r=th(sn.s,Ou.s,t),n=th(sn.l,Ou.l,t);return this.setHSL(i,r,n),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,n=e.elements;return this.r=n[0]*t+n[3]*i+n[6]*r,this.g=n[1]*t+n[4]*i+n[7]*r,this.b=n[2]*t+n[5]*i+n[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ei=new Ds;Ds.NAMES=Yv;class Pg{constructor(e,t,i,r){Pg.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const n=this.elements;return n[0]=e,n[2]=t,n[1]=i,n[3]=r,this}}class ao{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,n,a,o){let l=i[r+0],h=i[r+1],c=i[r+2],d=i[r+3],u=n[a+0],p=n[a+1],m=n[a+2],y=n[a+3];if(d!==y||l!==u||h!==p||c!==m){let g=l*u+h*p+c*m+d*y;g<0&&(u=-u,p=-p,m=-m,y=-y,g=-g);let f=1-o;if(g<.9995){const x=Math.acos(g),v=Math.sin(x);f=Math.sin(f*x)/v,o=Math.sin(o*x)/v,l=l*f+u*o,h=h*f+p*o,c=c*f+m*o,d=d*f+y*o}else{l=l*f+u*o,h=h*f+p*o,c=c*f+m*o,d=d*f+y*o;const x=1/Math.sqrt(l*l+h*h+c*c+d*d);l*=x,h*=x,c*=x,d*=x}}e[t]=l,e[t+1]=h,e[t+2]=c,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,n,a){const o=i[r],l=i[r+1],h=i[r+2],c=i[r+3],d=n[a],u=n[a+1],p=n[a+2],m=n[a+3];return e[t]=o*m+c*d+l*p-h*u,e[t+1]=l*m+c*u+h*d-o*p,e[t+2]=h*m+c*p+o*u-l*d,e[t+3]=c*m-o*d-l*u-h*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,n=e._z,a=e._order,o=Math.cos,l=Math.sin,h=o(i/2),c=o(r/2),d=o(n/2),u=l(i/2),p=l(r/2),m=l(n/2);switch(a){case"XYZ":this._x=u*c*d+h*p*m,this._y=h*p*d-u*c*m,this._z=h*c*m+u*p*d,this._w=h*c*d-u*p*m;break;case"YXZ":this._x=u*c*d+h*p*m,this._y=h*p*d-u*c*m,this._z=h*c*m-u*p*d,this._w=h*c*d+u*p*m;break;case"ZXY":this._x=u*c*d-h*p*m,this._y=h*p*d+u*c*m,this._z=h*c*m+u*p*d,this._w=h*c*d-u*p*m;break;case"ZYX":this._x=u*c*d-h*p*m,this._y=h*p*d+u*c*m,this._z=h*c*m-u*p*d,this._w=h*c*d+u*p*m;break;case"YZX":this._x=u*c*d+h*p*m,this._y=h*p*d+u*c*m,this._z=h*c*m-u*p*d,this._w=h*c*d-u*p*m;break;case"XZY":this._x=u*c*d-h*p*m,this._y=h*p*d-u*c*m,this._z=h*c*m+u*p*d,this._w=h*c*d+u*p*m;break;default:st("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],n=t[8],a=t[1],o=t[5],l=t[9],h=t[2],c=t[6],d=t[10],u=i+o+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(c-l)*p,this._y=(n-h)*p,this._z=(a-r)*p}else if(i>o&&i>d){const p=2*Math.sqrt(1+i-o-d);this._w=(c-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(n+h)/p}else if(o>d){const p=2*Math.sqrt(1+o-i-d);this._w=(n-h)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+c)/p}else{const p=2*Math.sqrt(1+d-i-o);this._w=(a-r)/p,this._x=(n+h)/p,this._y=(l+c)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ft(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,n=e._z,a=e._w,o=t._x,l=t._y,h=t._z,c=t._w;return this._x=i*c+a*o+r*h-n*l,this._y=r*c+a*l+n*o-i*h,this._z=n*c+a*h+i*l-r*o,this._w=a*c-i*o-r*l-n*h,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,n=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,n=-n,a=-a,o=-o);let l=1-t;if(o<.9995){const h=Math.acos(o),c=Math.sin(h);l=Math.sin(l*h)/c,t=Math.sin(t*h)/c,this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+n*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+n*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),n*Math.sin(t),n*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class H{constructor(e=0,t=0,i=0){H.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Zv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Zv.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=e.elements,a=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*r-o*i),c=2*(o*t-n*r),d=2*(n*i-a*t);return this.x=t+l*h+a*d-o*c,this.y=i+l*c+o*h-n*d,this.z=r+l*d+n*c-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ft(this.x,e.x,t.x),this.y=ft(this.y,e.y,t.y),this.z=ft(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ft(this.x,e,t),this.y=ft(this.y,e,t),this.z=ft(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ft(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,n=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-n*o,this.y=n*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return gf.copy(this).projectOnVector(e),this.sub(gf)}reflect(e){return this.sub(gf.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ft(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const gf=new H,Zv=new ao;class kt{constructor(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g){kt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g)}set(e,t,i,r,n,a,o,l,h,c,d,u,p,m,y,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=n,f[5]=a,f[9]=o,f[13]=l,f[2]=h,f[6]=c,f[10]=d,f[14]=u,f[3]=p,f[7]=m,f[11]=y,f[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 kt().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/oo.setFromMatrixColumn(e,0).length(),n=1/oo.setFromMatrixColumn(e,1).length(),a=1/oo.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),h=Math.sin(r),c=Math.cos(n),d=Math.sin(n);if(e.order==="XYZ"){const u=a*c,p=a*d,m=o*c,y=o*d;t[0]=l*c,t[4]=-l*d,t[8]=h,t[1]=p+m*h,t[5]=u-y*h,t[9]=-o*l,t[2]=y-u*h,t[6]=m+p*h,t[10]=a*l}else if(e.order==="YXZ"){const u=l*c,p=l*d,m=h*c,y=h*d;t[0]=u+y*o,t[4]=m*o-p,t[8]=a*h,t[1]=a*d,t[5]=a*c,t[9]=-o,t[2]=p*o-m,t[6]=y+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*c,p=l*d,m=h*c,y=h*d;t[0]=u-y*o,t[4]=-a*d,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*c,t[9]=y-u*o,t[2]=-a*h,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*c,p=a*d,m=o*c,y=o*d;t[0]=l*c,t[4]=m*h-p,t[8]=u*h+y,t[1]=l*d,t[5]=y*h+u,t[9]=p*h-m,t[2]=-h,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*h,m=o*l,y=o*h;t[0]=l*c,t[4]=y-u*d,t[8]=m*d+p,t[1]=d,t[5]=a*c,t[9]=-o*c,t[2]=-h*c,t[6]=p*d+m,t[10]=u-y*d}else if(e.order==="XZY"){const u=a*l,p=a*h,m=o*l,y=o*h;t[0]=l*c,t[4]=-d,t[8]=h*c,t[1]=u*d+y,t[5]=a*c,t[9]=p*d-m,t[2]=m*d-p,t[6]=o*c,t[10]=y*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(JC,e,KC)}lookAt(e,t,i){const r=this.elements;return es.subVectors(e,t),es.lengthSq()===0&&(es.z=1),es.normalize(),rn.crossVectors(i,es),rn.lengthSq()===0&&(Math.abs(i.z)===1?es.x+=1e-4:es.z+=1e-4,es.normalize(),rn.crossVectors(i,es)),rn.normalize(),Uu.crossVectors(es,rn),r[0]=rn.x,r[4]=Uu.x,r[8]=es.x,r[1]=rn.y,r[5]=Uu.y,r[9]=es.y,r[2]=rn.z,r[6]=Uu.z,r[10]=es.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[4],l=i[8],h=i[12],c=i[1],d=i[5],u=i[9],p=i[13],m=i[2],y=i[6],g=i[10],f=i[14],x=i[3],v=i[7],M=i[11],w=i[15],T=r[0],A=r[4],_=r[8],S=r[12],P=r[1],C=r[5],L=r[9],U=r[13],V=r[2],B=r[6],k=r[10],W=r[14],se=r[3],ie=r[7],oe=r[11],be=r[15];return n[0]=a*T+o*P+l*V+h*se,n[4]=a*A+o*C+l*B+h*ie,n[8]=a*_+o*L+l*k+h*oe,n[12]=a*S+o*U+l*W+h*be,n[1]=c*T+d*P+u*V+p*se,n[5]=c*A+d*C+u*B+p*ie,n[9]=c*_+d*L+u*k+p*oe,n[13]=c*S+d*U+u*W+p*be,n[2]=m*T+y*P+g*V+f*se,n[6]=m*A+y*C+g*B+f*ie,n[10]=m*_+y*L+g*k+f*oe,n[14]=m*S+y*U+g*W+f*be,n[3]=x*T+v*P+M*V+w*se,n[7]=x*A+v*C+M*B+w*ie,n[11]=x*_+v*L+M*k+w*oe,n[15]=x*S+v*U+M*W+w*be,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],c=e[2],d=e[6],u=e[10],p=e[14],m=e[3],y=e[7],g=e[11],f=e[15],x=l*p-h*u,v=o*p-h*d,M=o*u-l*d,w=a*p-h*c,T=a*u-l*c,A=a*d-o*c;return t*(y*x-g*v+f*M)-i*(m*x-g*w+f*T)+r*(m*v-y*w+f*A)-n*(m*M-y*T+g*A)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],d=e[9],u=e[10],p=e[11],m=e[12],y=e[13],g=e[14],f=e[15],x=t*o-i*a,v=t*l-r*a,M=t*h-n*a,w=i*l-r*o,T=i*h-n*o,A=r*h-n*l,_=c*y-d*m,S=c*g-u*m,P=c*f-p*m,C=d*g-u*y,L=d*f-p*y,U=u*f-p*g,V=x*U-v*L+M*C+w*P-T*S+A*_;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const B=1/V;return e[0]=(o*U-l*L+h*C)*B,e[1]=(r*L-i*U-n*C)*B,e[2]=(y*A-g*T+f*w)*B,e[3]=(u*T-d*A-p*w)*B,e[4]=(l*P-a*U-h*S)*B,e[5]=(t*U-r*P+n*S)*B,e[6]=(g*M-m*A-f*v)*B,e[7]=(c*A-u*M+p*v)*B,e[8]=(a*L-o*P+h*_)*B,e[9]=(i*P-t*L-n*_)*B,e[10]=(m*T-y*M+f*x)*B,e[11]=(d*M-c*T-p*x)*B,e[12]=(o*S-a*C-l*_)*B,e[13]=(t*C-i*S+r*_)*B,e[14]=(y*v-m*w-g*x)*B,e[15]=(c*w-d*v+u*x)*B,this}scale(e){const t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),n=1-i,a=e.x,o=e.y,l=e.z,h=n*a,c=n*o;return this.set(h*a+i,h*o-r*l,h*l+r*o,0,h*o+r*l,c*o+i,c*l-r*a,0,h*l-r*o,c*l+r*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,n,a){return this.set(1,i,n,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,n=t._x,a=t._y,o=t._z,l=t._w,h=n+n,c=a+a,d=o+o,u=n*h,p=n*c,m=n*d,y=a*c,g=a*d,f=o*d,x=l*h,v=l*c,M=l*d,w=i.x,T=i.y,A=i.z;return r[0]=(1-(y+f))*w,r[1]=(p+M)*w,r[2]=(m-v)*w,r[3]=0,r[4]=(p-M)*T,r[5]=(1-(u+f))*T,r[6]=(g+x)*T,r[7]=0,r[8]=(m+v)*A,r[9]=(g-x)*A,r[10]=(1-(u+y))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const n=this.determinant();if(n===0)return i.set(1,1,1),t.identity(),this;let a=oo.set(r[0],r[1],r[2]).length();const o=oo.set(r[4],r[5],r[6]).length(),l=oo.set(r[8],r[9],r[10]).length();n<0&&(a=-a),Os.copy(this);const h=1/a,c=1/o,d=1/l;return Os.elements[0]*=h,Os.elements[1]*=h,Os.elements[2]*=h,Os.elements[4]*=c,Os.elements[5]*=c,Os.elements[6]*=c,Os.elements[8]*=d,Os.elements[9]*=d,Os.elements[10]*=d,t.setFromRotationMatrix(Os),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,r,n,a,o=Zs,l=!1){const h=this.elements,c=2*n/(t-e),d=2*n/(i-r),u=(t+e)/(t-e),p=(i+r)/(i-r);let m,y;if(l)m=n/(a-n),y=a*n/(a-n);else if(o===Zs)m=-(a+n)/(a-n),y=-2*a*n/(a-n);else if(o===tn)m=-a/(a-n),y=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return h[0]=c,h[4]=0,h[8]=u,h[12]=0,h[1]=0,h[5]=d,h[9]=p,h[13]=0,h[2]=0,h[6]=0,h[10]=m,h[14]=y,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,r,n,a,o=Zs,l=!1){const h=this.elements,c=2/(t-e),d=2/(i-r),u=-(t+e)/(t-e),p=-(i+r)/(i-r);let m,y;if(l)m=1/(a-n),y=a/(a-n);else if(o===Zs)m=-2/(a-n),y=-(a+n)/(a-n);else if(o===tn)m=-1/(a-n),y=-n/(a-n);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return h[0]=c,h[4]=0,h[8]=0,h[12]=u,h[1]=0,h[5]=d,h[9]=0,h[13]=p,h[2]=0,h[6]=0,h[10]=m,h[14]=y,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const oo=new H,Os=new kt,JC=new H(0,0,0),KC=new H(1,1,1),rn=new H,Uu=new H,es=new H;class Vt{constructor(e=0,t=0){Vt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ft(this.x,e.x,t.x),this.y=ft(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ft(this.x,e,t),this.y=ft(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ft(i,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ft(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*r+e.x,this.y=n*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ai{constructor(e=0,t=0,i=0,r=1){Ai.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*n,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*n,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*n,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,n;const a=e.elements,o=a[0],l=a[4],h=a[8],c=a[1],d=a[5],u=a[9],p=a[2],m=a[6],y=a[10];if(Math.abs(l-c)<.01&&Math.abs(h-p)<.01&&Math.abs(u-m)<.01){if(Math.abs(l+c)<.1&&Math.abs(h+p)<.1&&Math.abs(u+m)<.1&&Math.abs(o+d+y-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const f=(o+1)/2,x=(d+1)/2,v=(y+1)/2,M=(l+c)/4,w=(h+p)/4,T=(u+m)/4;return f>x&&f>v?f<.01?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(f),r=M/i,n=w/i):x>v?x<.01?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(x),i=M/r,n=T/r):v<.01?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(v),i=w/n,r=T/n),this.set(i,r,n,t),this}let g=Math.sqrt((m-u)*(m-u)+(h-p)*(h-p)+(c-l)*(c-l));return Math.abs(g)<.001&&(g=1),this.x=(m-u)/g,this.y=(h-p)/g,this.z=(c-l)/g,this.w=Math.acos((o+d+y-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ft(this.x,e.x,t.x),this.y=ft(this.y,e.y,t.y),this.z=ft(this.z,e.z,t.z),this.w=ft(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ft(this.x,e,t),this.y=ft(this.y,e,t),this.z=ft(this.z,e,t),this.w=ft(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ft(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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 $C=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function QC(s){const e=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return s.split(`
|
|
4058
4058
|
`).map(t=>{const i=t.match(e);if(!i)return null;const r=i[1]||i[2]||"",n=i[3].split("?")[0],a=parseInt(i[4],10),o=parseInt(i[5],10),l=n.split("/").pop();return{fn:r,file:l,line:a,column:o}}).filter(t=>t&&!$C.some(i=>i.test(t.file)))}class us{constructor(e=null){this.isStackTrace=!0,this.stack=QC(e||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(this.stack.length===0)return e;const t=this.stack.map(i=>{const r=`${i.file}:${i.line}:${i.column}`;return i.fn?` at ${i.fn} (${r})`:` at ${r}`}).join(`
|
|
4059
4059
|
`);return`${e}
|
|
4060
|
-
${t}`}}function xf(s,e=0){let t=3735928559^e,i=1103547991^e;if(s instanceof Array)for(let r=0,n;r<s.length;r++)n=s[r],t=Math.imul(t^n,2654435761),i=Math.imul(i^n,1597334677);else for(let r=0,n;r<s.length;r++)n=s.charCodeAt(r),t=Math.imul(t^n,2654435761),i=Math.imul(i^n,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&i)+(t>>>0)}const vf=s=>xf(s),Jv=s=>xf(s),Kv=(...s)=>xf(s),eR=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),$v=new WeakMap;function tR(s){return eR.get(s)}function Fu(s){if(s==null)return null;const e=typeof s;return s.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":s.isVector2===!0?"vec2":s.isVector3===!0?"vec3":s.isVector4===!0?"vec4":s.isMatrix2===!0?"mat2":s.isMatrix3===!0?"mat3":s.isMatrix4===!0?"mat4":s.isColor===!0?"color":s instanceof ArrayBuffer?"ArrayBuffer":null}function _f(s,...e){const t=s?s.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),s==="color"?new Ds(...e):t==="vec2"?new Vt(...e):t==="vec3"?new H(...e):t==="vec4"?new Ai(...e):t==="mat2"?new Lg(...e):t==="mat3"?new xs(...e):t==="mat4"?new kt(...e):s==="bool"?e[0]||!1:s==="float"||s==="int"||s==="uint"?e[0]||0:s==="string"?e[0]||"":s==="ArrayBuffer"?rR(e[0]):null}function iR(s){let e=$v.get(s);return e===void 0&&(e={},$v.set(s,e)),e}function sR(s){let e="";const t=new Uint8Array(s);for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}function rR(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0)).buffer}class oo{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const n=r.indexOf(t);n!==-1&&r.splice(n,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let n=0,a=r.length;n<a;n++)r[n].call(this,e);e.target=null}}}const nR={analyze:"setup",generate:"analyze"};let aR=0;class ze extends oo{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=ht.NONE,this.updateBeforeType=ht.NONE,this.updateAfterType=ht.NONE,this.uuid=YC.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,ze.captureStackTrace===!0&&(this.stackTrace=new us)}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,ht.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ht.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ht.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const i of Object.getOwnPropertyNames(this)){const r=this[i];if(!(i.startsWith("_")===!0||e.has(r))){if(Array.isArray(r)===!0)for(let n=0;n<r.length;n++){const a=r[n];a&&a.isNode===!0&&t.push({property:i,index:n,childNode:a})}else if(r&&r.isNode===!0)t.push({property:i,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(const n in r){if(n.startsWith("_")===!0)continue;const a=r[n];a&&a.isNode===!0&&t.push({property:i,index:n,childNode:a})}}}return t}getCacheKey(e=!1,t=null){if(e=e||this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);const i=[];for(const{property:r,childNode:n}of this._getChildren(t))i.push(vf(r.slice(0,-4)),n.getCacheKey(e,t));this._cacheKey=Kv(Jv(i),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(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){const t=e.getNodeProperties(this);let i=0;for(const r of this.getChildren())t["node"+i++]=r;return t.outputNode||null}analyze(e,t=null){const i=e.increaseUsage(this);if(this.parents===!0){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(i===1){const r=e.getNodeProperties(this);for(const n of Object.values(r))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){const{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,t)}updateBefore(){st("Abstract function.")}updateAfter(){st("Abstract function.")}update(){st("Abstract function.")}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){const i=this.getShared(e);if(this!==i)return i.build(e,t);if(this._beforeNodes!==null){const l=this._beforeNodes;this._beforeNodes=null;for(const h of l)h.build(e,t);this._beforeNodes=l}const r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;const n=nR[e.buildStage];if(n&&r.buildStages[n]!==!0){const l=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(l)}e.addChain(this);let a=null;const o=e.getBuildStage();if(o==="setup"){e.addNode(this),this.updateReference(e);const l=e.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(e)||l.outputNode||null;for(const h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){const c=e.getNodeProperties(h);c.parents=c.parents||[],c.parents.push(this)}h.build(e)}e.addSequentialNode(this)}a=l.outputNode}else if(o==="analyze")this.analyze(e,t);else if(o==="generate"){if(this.generate.length<2){const l=this.getNodeType(e),h=e.getDataFromNode(this);a=h.snippet,a===void 0?h.generated===void 0?(h.generated=!0,a=this.generate(e)||"",h.snippet=a):(st("Node: Recursion detected.",this),a="/* Recursion detected. */"):h.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,l,t)}else a=this.generate(e,t)||"";a===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(Tt(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){const t=this.getSerializeChildren(),i={};for(const{property:r,index:n,childNode:a}of t)n!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(n)?[]:{}),i[r][n]=a.toJSON(e.meta).uuid):i[r]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){const r=[];for(const n of e.inputNodes[i])r.push(t[n]);this[i]=r}else if(typeof e.inputNodes[i]=="object"){const r={};for(const n in e.inputNodes[i]){const a=e.inputNodes[i][n];r[n]=t[a]}this[i]=r}else{const r=e.inputNodes[i];this[i]=t[r]}}}toJSON(e){const{uuid:t,type:i}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[t];n===void 0&&(n={uuid:t,type:i,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function a(o){const l=[];for(const h in o){const c=o[h];delete c.metadata,l.push(c)}return l}if(r){const o=a(e.textures),l=a(e.images),h=a(e.nodes);o.length>0&&(n.textures=o),l.length>0&&(n.images=l),h.length>0&&(n.nodes=h)}return n}}ze.captureStackTrace=!1;class lo extends ze{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),i=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${i}[ ${r} ]`}}class Qv extends ze{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let i=null;for(const r of this.convertTo.split("|"))(i===null||e.getTypeLength(t)===e.getTypeLength(r))&&(i=r);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const i=this.node,r=this.getNodeType(e),n=i.build(e,r);return e.format(n,r,t)}}class mi extends ze{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const n=super.build(e,i),a=e.getVarFromNode(this,null,i),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${n}`,this),r.snippet=n,r.propertyName=o,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class oR extends mi{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,i)=>t+e.getTypeLength(i.getNodeType(e)),0))}generate(e,t){const i=this.getNodeType(e),r=e.getTypeLength(i),n=this.nodes,a=e.getComponentType(i),o=[];let l=0;for(const c of n){if(l>=r){Tt(`TSL: Length of parameters exceeds maximum length of function '${i}()' type.`,this.stackTrace);break}let d=c.getNodeType(e),u=e.getTypeLength(d),p;if(l+u>r&&(Tt(`TSL: Length of '${i}()' data exceeds maximum length of output type.`,this.stackTrace),u=r-l,d=e.getTypeFromLength(u)),l+=u,p=c.build(e,d),e.getComponentType(d)!==a){const m=e.getTypeFromLength(u,a);p=e.format(p,d,m)}o.push(p)}const h=`${e.getType(i)}( ${o.join(", ")} )`;return e.format(h,i,t)}}const lR=ql.join("");class hR extends ze{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(ql.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const i=this.node,r=e.getTypeLength(i.getNodeType(e));let n=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const o=i.build(e,a);this.components.length===r&&this.components===lR.slice(0,this.components.length)?n=e.format(o,a,t):n=e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else n=i.build(e,t);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class cR extends mi{static get type(){return"SetNode"}constructor(e,t,i){super(),this.sourceNode=e,this.components=t,this.targetNode=i}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:i,targetNode:r}=this,n=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(i.length,a),l=r.build(e,o),h=t.build(e,n),c=e.getTypeLength(n),d=[];for(let u=0;u<c;u++){const p=ql[u];p===i[0]?(d.push(l),u+=i.length-1):d.push(h+"."+p)}return`${e.getType(n)}( ${d.join(", ")} )`}}class uR extends mi{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:i}=this,r=this.getNodeType(e),n=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+n,this);const l=e.getTypeLength(r),h=[];let c=0;for(let d=0;d<l;d++){const u=ql[d];u===t[c]?(h.push("1.0 - "+(o+"."+u)),c++):h.push(o+"."+u)}return`${e.getType(r)}( ${h.join(", ")} )`}}class Mf extends ze{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Fu(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Fu(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=sR(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?_f(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){st("Abstract function.")}}const e_=/float|u?int/;class Js extends Mf{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const i=this.getNodeType(e);return e_.test(i)&&e_.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),i,t)}}class dR extends ze{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!=="void"}getNodeType(e){return this.hasMember(e)===!1?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return"float";const i=this.getNodeType(e);return e.getStructTypeNode(i).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){st(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);const t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+"."+this.property}}let pR=null;const bf=new Map;function q(s,e){if(bf.has(s)){st(`TSL: Redefinition of method chaining '${s}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${s} is not a function`);bf.set(s,e),s!=="assign"&&(ze.prototype[s]=function(...t){return this.isStackNode?this.addToStack(e(...t)):e(this,...t)},ze.prototype[s+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}const mR=s=>s.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),t_=s=>mR(s).split("").sort().join("");ze.prototype.assign=function(...s){if(this.isStackNode!==!0)return Tt("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new us),this;{const e=bf.get("assign");return this.addToStack(e(...s))}},ze.prototype.toVarIntent=function(){return this},ze.prototype.get=function(s){return new dR(this,s)};const ih={};function zu(s,e,t){ih[s]=ih[e]=ih[t]={get(){this._cache=this._cache||{};let a=this._cache[s];return a===void 0&&(a=new hR(this,s),this._cache[s]=a),a},set(a){this[s].assign(Fe(a))}};const i=s.toUpperCase(),r=e.toUpperCase(),n=t.toUpperCase();ze.prototype["set"+i]=ze.prototype["set"+r]=ze.prototype["set"+n]=function(a){const o=t_(s);return new cR(this,o,Fe(a))},ze.prototype["flip"+i]=ze.prototype["flip"+r]=ze.prototype["flip"+n]=function(){const a=t_(s);return new uR(this,a)}}const Ks=["x","y","z","w"],$s=["r","g","b","a"],Qs=["s","t","p","q"];for(let s=0;s<4;s++){let e=Ks[s],t=$s[s],i=Qs[s];zu(e,t,i);for(let r=0;r<4;r++){e=Ks[s]+Ks[r],t=$s[s]+$s[r],i=Qs[s]+Qs[r],zu(e,t,i);for(let n=0;n<4;n++){e=Ks[s]+Ks[r]+Ks[n],t=$s[s]+$s[r]+$s[n],i=Qs[s]+Qs[r]+Qs[n],zu(e,t,i);for(let a=0;a<4;a++)e=Ks[s]+Ks[r]+Ks[n]+Ks[a],t=$s[s]+$s[r]+$s[n]+$s[a],i=Qs[s]+Qs[r]+Qs[n]+Qs[a],zu(e,t,i)}}}for(let s=0;s<32;s++)ih[s]={get(){this._cache=this._cache||{};let e=this._cache[s];return e===void 0&&(e=new lo(this,new Js(s,"uint")),this._cache[s]=e),e},set(e){this[s].assign(Fe(e))}};Object.defineProperties(ze.prototype,ih);const i_=new WeakMap,fR=function(s,e=null){const t=Fu(s);return t==="node"?s:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?Fe(Ef(s,e)):t==="shader"?s.isFn?s:xe(s):s},gR=function(s,e=null){for(const t in s)s[t]=Fe(s[t],e);return s},yR=function(s,e=null){const t=s.length;for(let i=0;i<t;i++)s[i]=Fe(s[i],e);return s},s_=function(s,e=null,t=null,i=null){function r(c){return i!==null?(c=Fe(Object.assign(c,i)),i.intent===!0&&(c=c.toVarIntent())):c=Fe(c),c}let n,a=e,o,l;function h(c){let d;return a?d=/[a-z]/i.test(a)?a+"()":a:d=s.type,o!==void 0&&c.length<o?(Tt(`TSL: "${d}" parameter length is less than minimum required.`,new us),c.concat(new Array(o-c.length).fill(0))):l!==void 0&&c.length>l?(Tt(`TSL: "${d}" parameter length exceeds limit.`,new us),c.slice(0,l)):c}return e===null?n=(...c)=>r(new s(...ho(h(c)))):t!==null?(t=Fe(t),n=(...c)=>r(new s(e,...ho(h(c)),t))):n=(...c)=>r(new s(e,...ho(h(c)))),n.setParameterLength=(...c)=>(c.length===1?o=l=c[0]:c.length===2&&([o,l]=c),n),n.setName=c=>(a=c,n),n},xR=function(s,...e){return new s(...ho(e))};class vR extends ze{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:i}=this,r=e.getNodeProperties(t),n=e.getClosestSubBuild(t.subBuilds)||"",a=n||"default";if(r[a])return r[a];const o=e.subBuildFn,l=e.fnCall;e.subBuildFn=n,e.fnCall=this;let h=null;if(t.layout){let c=i_.get(e.constructor);c===void 0&&(c=new WeakMap,i_.set(e.constructor,c));let d=c.get(t);d===void 0&&(d=Fe(e.buildFunctionNode(t)),c.set(t,d)),e.addInclude(d);const u=i?_R(i):null;h=Fe(d.call(u))}else{const c=new Proxy(e,{get:(y,g,f)=>{let x;return Symbol.iterator===g?x=function*(){yield void 0}:x=Reflect.get(y,g,f),x}}),d=i?MR(i):null,u=Array.isArray(i)?i.length>0:i!==null,p=t.jsFunc,m=u||p.length>1?p(d,c):p(c);h=Fe(m)}return e.subBuildFn=o,e.fnCall=l,t.once&&(r[a]=h),h}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),i=e.getSubBuildOutput(this);return t[i]=t[i]||this.setupOutput(e),t[i].subBuild=e.getClosestSubBuild(this),t[i]}build(e,t=null){let i=null;const r=e.getBuildStage(),n=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),l=e.fnCall;if(e.fnCall=this,r==="setup"){const h=e.getSubBuildProperty("initialized",this);if(n[h]!==!0&&(n[h]=!0,n[a]=this.getOutputNode(e),n[a].build(e),this.shaderNode.subBuilds))for(const c of e.chaining){const d=e.getDataFromNode(c,"any");d.subBuilds=d.subBuilds||new Set;for(const u of this.shaderNode.subBuilds)d.subBuilds.add(u)}i=n[a]}else r==="analyze"?o.build(e,t):r==="generate"&&(i=o.build(e,t)||"");return e.fnCall=l,i}}function _R(s){let e;return Af(s),s[0]&&(s[0].isNode||Object.getPrototypeOf(s[0])!==Object.prototype)?e=[...s]:e=s[0],e}function MR(s){let e=0;return Af(s),new Proxy(s,{get:(t,i,r)=>{let n;if(i==="length")return n=s.length,n;if(Symbol.iterator===i)n=function*(){for(const a of s)yield Fe(a)};else{if(s.length>0)if(Object.getPrototypeOf(s[0])===Object.prototype){const a=s[0];a[i]===void 0?n=a[e++]:n=Reflect.get(a,i,r)}else s[0]instanceof ze&&(s[i]===void 0?n=s[e++]:n=Reflect.get(s,i,r));else n=Reflect.get(t,i,r);n=Fe(n)}return n}})}class bR extends ze{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new vR(this,e)}setup(){return this.call()}}const SR=[!1,!0],TR=[0,1,2,3],wR=[-1,-2],r_=[.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],Sf=new Map;for(const s of SR)Sf.set(s,new Js(s));const Tf=new Map;for(const s of TR)Tf.set(s,new Js(s,"uint"));const wf=new Map([...Tf].map(s=>new Js(s.value,"int")));for(const s of wR)wf.set(s,new Js(s,"int"));const Bu=new Map([...wf].map(s=>new Js(s.value)));for(const s of r_)Bu.set(s,new Js(s));for(const s of r_)Bu.set(-s,new Js(-s));const Vu={bool:Sf,uint:Tf,ints:wf,float:Bu},n_=new Map([...Sf,...Bu]),Ef=(s,e)=>n_.has(s)?n_.get(s):s.isNode===!0?s:new Js(s,e),Jt=function(s,e=null){return(...t)=>{for(const r of t)if(r===void 0)return Tt(`TSL: Invalid parameter for the type "${s}".`,new us),new Js(0,s);if((t.length===0||!["bool","float","int","uint"].includes(s)&&t.every(r=>{const n=typeof r;return n!=="object"&&n!=="function"}))&&(t=[_f(s,...t)]),t.length===1&&e!==null&&e.has(t[0]))return ku(e.get(t[0]));if(t.length===1){const r=Ef(t[0],s);return r.nodeType===s?ku(r):ku(new Qv(r,s))}const i=t.map(r=>Ef(r));return ku(new oR(i,s))}},ER=s=>s!=null?s.nodeType||s.convertTo||(typeof s=="string"?s:null):null;function AR(s,e){return new bR(s,e)}const Fe=(s,e=null)=>fR(s,e),ku=(s,e=null)=>Fe(s,e).toVarIntent(),Af=(s,e=null)=>new gR(s,e),ho=(s,e=null)=>new yR(s,e),Pt=(s,e=null,t=null,i=null)=>new s_(s,e,t,i),Kt=(s,...e)=>new xR(s,...e),Ee=(s,e=null,t=null,i={})=>new s_(s,e,t,{...i,intent:!0});let NR=0;class CR extends ze{constructor(e,t=null){super();let i=null;t!==null&&(typeof t=="object"?i=t.return:(typeof t=="string"?i=t:Tt("TSL: Invalid layout type.",new us),t=null)),this.shaderNode=new AR(e,i),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const i={name:"fn"+NR++,type:t,inputs:[]};for(const r in e)r!=="return"&&i.inputs.push({name:r,type:e[r]});e=i}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return Tt('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function xe(s,e=null){const t=new CR(s,e);return new Proxy(()=>{},{apply(i,r,n){return t.call(...n)},get(i,r,n){return Reflect.get(t,r,n)},set(i,r,n,a){return Reflect.set(t,r,n,a)}})}const ds=(...s)=>pR.If(...s);function RR(s){return s}q("toStack",RR);const IR=new Jt("color"),ke=new Jt("float",Vu.float),zt=new Jt("int",Vu.ints),fi=new Jt("uint",Vu.uint),Nf=new Jt("bool",Vu.bool),xt=new Jt("vec2"),er=new Jt("ivec2"),a_=new Jt("uvec2"),PR=new Jt("bvec2"),Re=new Jt("vec3"),o_=new Jt("ivec3"),l_=new Jt("uvec3"),LR=new Jt("bvec3"),Ui=new Jt("vec4"),h_=new Jt("ivec4"),c_=new Jt("uvec4"),DR=new Jt("bvec4"),u_=new Jt("mat2"),ps=new Jt("mat3"),Gu=new Jt("mat4");q("toColor",IR),q("toFloat",ke),q("toInt",zt),q("toUint",fi),q("toBool",Nf),q("toVec2",xt),q("toIVec2",er),q("toUVec2",a_),q("toBVec2",PR),q("toVec3",Re),q("toIVec3",o_),q("toUVec3",l_),q("toBVec3",LR),q("toVec4",Ui),q("toIVec4",h_),q("toUVec4",c_),q("toBVec4",DR),q("toMat2",u_),q("toMat3",ps),q("toMat4",Gu);const OR=Pt(lo).setParameterLength(2),UR=(s,e)=>new Qv(Fe(s),e);q("element",OR),q("convert",UR),q("append",s=>(st("TSL: .append() has been renamed to .toStack().",new us),s));class d_ extends mi{static get type(){return"ArrayNode"}constructor(e,t,i=null){super(e),this.count=t,this.values=i,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const FR=(...s)=>{let e;if(s.length===1){const t=s[0];e=new d_(null,t.length,t)}else{const t=s[0],i=s[1];e=new d_(t,i)}return Fe(e)};q("toArray",(s,e)=>FR(Array(e).fill(s)));class p_ extends ze{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1){super("string"),this.name=e,this.shared=t,this.order=i,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const zR=s=>new p_(s),m_=(s,e=0)=>new p_(s,!0,e),it=m_("render"),BR=zR("object");class sh extends Mf{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=BR}setName(e){return this.name=e,this}label(e){return st('TSL: "label()" has been deprecated. Use "setName()" instead.',new us),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(i=>{const r=e(i,this);r!==void 0&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const i=this.getNodeType(e),r=this.getUniformHash(e);let n=e.getNodeFromHash(r);n===void 0&&(e.setHashNode(this,r),n=this);const a=n.getInputType(e),o=e.getUniformFromNode(n,a,e.shaderStage,this.name||e.context.nodeName),l=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let h=l;if(i==="bool"){const c=e.getDataFromNode(this);let d=c.propertyName;if(d===void 0){const u=e.getVarFromNode(this,null,"bool");d=e.getPropertyName(u),c.propertyName=d,h=e.format(l,a,i),e.addLineFlowCode(`${d} = ${h}`,this)}h=d}return e.format(h,i,t)}}const dt=(s,e)=>{const t=ER(e||s);if(t===s&&(s=_f(t)),s&&s.isNode===!0){let i=s.value;s.traverse(r=>{r.isConstNode===!0&&(i=r.value)}),s=i}return new sh(s,t)};class rh extends ze{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return vf(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const f_=(s,e)=>new rh(s,e),Hu=(s,e)=>new rh(s,e,!0),Gi=Kt(rh,"vec4","DiffuseColor"),g_=Kt(rh,"vec3","EmissiveColor"),Cf=Kt(rh,"vec4","Output");class VR extends mi{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const i=e.getTypeLength(t.node.getNodeType(e));return ql.join("").slice(0,i)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:i}=this,r=t.getScope(),n=e.getDataFromNode(r);n.assign=!0;const a=e.getNodeProperties(this);a.sourceNode=i,a.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:i,sourceNode:r}=e.getNodeProperties(this),n=this.needsSplitAssign(e),a=i.build(e),o=i.getNodeType(e),l=r.build(e,o),h=r.getNodeType(e),c=e.getDataFromNode(this);let d;if(c.initialized===!0)t!=="void"&&(d=a);else if(n){const u=e.getVarFromNode(this,null,o),p=e.getPropertyName(u);e.addLineFlowCode(`${p} = ${l}`,this);const m=i.node,y=m.node.context({assign:!0}).build(e);for(let g=0;g<m.components.length;g++){const f=m.components[g];e.addLineFlowCode(`${y}.${f} = ${p}[ ${g} ]`,this)}t!=="void"&&(d=a)}else d=`${a} = ${l}`,(t==="void"||h==="void")&&(e.addLineFlowCode(d,this),t!=="void"&&(d=a));return c.initialized=!0,e.format(d,o,t)}}const kR=Pt(VR).setParameterLength(2);q("assign",kR);class GR extends mi{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){const t=[],i=this.functionNode,r=i.getInputs(e),n=this.parameters,a=(o,l)=>{const h=l.type,c=h==="pointer";let d;return c?d="&"+o.build(e):d=o.build(e,h),d};if(Array.isArray(n)){if(n.length>r.length)Tt("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=r.length;else if(n.length<r.length)for(Tt("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<r.length;)n.push(ke(0));for(let o=0;o<n.length;o++)t.push(a(n[o],r[o]))}else for(const o of r){const l=n[o.name];l!==void 0?t.push(a(l,o)):(Tt(`TSL: Input '${o.name}' not found in 'Fn()'.`),t.push(a(ke(0),o)))}return`${i.build(e,"property")}( ${t.join(", ")} )`}}const HR=(s,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?ho(e):Af(e[0]),new GR(Fe(s),e));q("call",HR);const WR={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ot extends mi{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let n=new Ot(e,t,i);for(let a=0;a<r.length-1;a++)n=new Ot(e,n,r[a]);t=n,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(WR[this.op],t)}getNodeType(e,t=null){const i=this.op,r=this.aNode,n=this.bNode,a=r.getNodeType(e),o=n?n.getNodeType(e):null;if(a==="void"||o==="void")return t||"void";if(i==="%")return a;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return e.getIntegerType(a);if(i==="!"||i==="&&"||i==="||"||i==="^^")return"bool";if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">="){const l=Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else{if(e.isMatrix(a)){if(o==="float")return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a==="float")return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}}generate(e,t){const i=this.op,{aNode:r,bNode:n}=this,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=r.getNodeType(e),l=n?n.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="||i==="!="?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):i==="%"?(o=a,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=a):e.isMatrix(l)?o==="float"?o="float":e.isVector(o)?o=e.getVectorFromMatrix(l):o=l=a:o=l=a):o=l=a;const h=r.build(e,o),c=n?n.build(e,l):null,d=e.getFunctionOperator(i);if(t!=="void"){const u=e.renderer.coordinateSystem===Zs;if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">=")return u?e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${h}, ${c} )`,a,t):e.format(`( ${h} ${i} ${c} )`,a,t):e.format(`( ${h} ${i} ${c} )`,a,t);if(i==="%")return e.isInteger(l)?e.format(`( ${h} % ${c} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${h}, ${c} )`,a,t);if(i==="!"||i==="~")return e.format(`(${i}${h})`,o,t);if(d)return e.format(`${d}( ${h}, ${c} )`,a,t);if(e.isMatrix(o)&&l==="float")return e.format(`( ${c} ${i} ${h} )`,a,t);if(o==="float"&&e.isMatrix(l))return e.format(`${h} ${i} ${c}`,a,t);{let p=`( ${h} ${i} ${c} )`;return!u&&a==="bool"&&e.isVector(o)&&e.isVector(l)&&(p=`all${p}`),e.format(p,a,t)}}else if(o!=="void")return d?e.format(`${d}( ${h}, ${c} )`,a,t):e.isMatrix(o)&&l==="float"?e.format(`${c} ${i} ${h}`,a,t):e.format(`${h} ${i} ${c}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const tr=Ee(Ot,"+").setParameterLength(2,1/0).setName("add"),Hi=Ee(Ot,"-").setParameterLength(2,1/0).setName("sub"),Bt=Ee(Ot,"*").setParameterLength(2,1/0).setName("mul"),Wu=Ee(Ot,"/").setParameterLength(2,1/0).setName("div"),Rf=Ee(Ot,"%").setParameterLength(2).setName("mod"),jR=Ee(Ot,"==").setParameterLength(2).setName("equal"),XR=Ee(Ot,"!=").setParameterLength(2).setName("notEqual"),qR=Ee(Ot,"<").setParameterLength(2).setName("lessThan"),YR=Ee(Ot,">").setParameterLength(2).setName("greaterThan"),ZR=Ee(Ot,"<=").setParameterLength(2).setName("lessThanEqual"),JR=Ee(Ot,">=").setParameterLength(2).setName("greaterThanEqual"),KR=Ee(Ot,"&&").setParameterLength(2,1/0).setName("and"),$R=Ee(Ot,"||").setParameterLength(2,1/0).setName("or"),QR=Ee(Ot,"!").setParameterLength(1).setName("not"),eI=Ee(Ot,"^^").setParameterLength(2).setName("xor"),tI=Ee(Ot,"&").setParameterLength(2).setName("bitAnd"),iI=Ee(Ot,"~").setParameterLength(1).setName("bitNot"),sI=Ee(Ot,"|").setParameterLength(2).setName("bitOr"),rI=Ee(Ot,"^").setParameterLength(2).setName("bitXor"),nI=Ee(Ot,"<<").setParameterLength(2).setName("shiftLeft"),aI=Ee(Ot,">>").setParameterLength(2).setName("shiftRight"),oI=xe(([s])=>(s.addAssign(1),s)),lI=xe(([s])=>(s.subAssign(1),s)),hI=xe(([s])=>{const e=zt(s).toConst();return s.addAssign(1),e}),cI=xe(([s])=>{const e=zt(s).toConst();return s.subAssign(1),e});q("add",tr),q("sub",Hi),q("mul",Bt),q("div",Wu),q("mod",Rf),q("equal",jR),q("notEqual",XR),q("lessThan",qR),q("greaterThan",YR),q("lessThanEqual",ZR),q("greaterThanEqual",JR),q("and",KR),q("or",$R),q("not",QR),q("xor",eI),q("bitAnd",tI),q("bitNot",iI),q("bitOr",sI),q("bitXor",rI),q("shiftLeft",nI),q("shiftRight",aI),q("incrementBefore",oI),q("decrementBefore",lI),q("increment",hI),q("decrement",cI);const uI=(s,e)=>(st('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.',new us),Rf(zt(s),zt(e)));q("modInt",uI);class z extends mi{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){if(super(),(e===z.MAX||e===z.MIN)&&arguments.length>3){let n=new z(e,t,i);for(let a=2;a<arguments.length-1;a++)n=new z(e,n,arguments[a]);t=n,i=arguments[arguments.length-1],r=null}this.method=e,this.aNode=t,this.bNode=i,this.cNode=r,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(r)?0:e.getTypeLength(r);return n>a&&n>o?t:a>o?i:o>n?r:t}getNodeType(e){const t=this.method;return t===z.LENGTH||t===z.DISTANCE||t===z.DOT?"float":t===z.CROSS?"vec3":t===z.ALL||t===z.ANY?"bool":t===z.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:i,method:r}=this;let n=null;if(r===z.ONE_MINUS)n=Hi(1,t);else if(r===z.RECIPROCAL)n=Wu(1,t);else if(r===z.DIFFERENCE)n=oh(Hi(t,i));else if(r===z.TRANSFORM_DIRECTION){let a=t,o=i;e.isMatrix(a.getNodeType(e))?o=Ui(Re(o),0):a=Ui(Re(a),0);const l=Bt(a,o).xyz;n=Pf(l)}return n!==null?n:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let i=this.method;const r=this.getNodeType(e),n=this.getInputType(e),a=this.aNode,o=this.bNode,l=this.cNode,h=e.renderer.coordinateSystem;if(i===z.NEGATE)return e.format("( - "+a.build(e,n)+" )",r,t);{const c=[];return i===z.CROSS?c.push(a.build(e,r),o.build(e,r)):h===Zs&&i===z.STEP?c.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":n),o.build(e,n)):h===Zs&&(i===z.MIN||i===z.MAX)?c.push(a.build(e,n),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":n)):i===z.REFRACT?c.push(a.build(e,n),o.build(e,n),l.build(e,"float")):i===z.MIX?c.push(a.build(e,n),o.build(e,n),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":n)):(h===tn&&i===z.ATAN&&o!==null&&(i="atan2"),e.shaderStage!=="fragment"&&(i===z.DFDX||i===z.DFDY)&&(st(`TSL: '${i}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),c.push(a.build(e,n)),o!==null&&c.push(o.build(e,n)),l!==null&&c.push(l.build(e,n))),e.format(`${e.getMethod(i,r)}( ${c.join(", ")} )`,r,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.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 dI=ke(Math.PI),pI=Ee(z,z.ALL).setParameterLength(1),mI=Ee(z,z.ANY).setParameterLength(1),fI=Ee(z,z.RADIANS).setParameterLength(1),gI=Ee(z,z.DEGREES).setParameterLength(1),yI=Ee(z,z.EXP).setParameterLength(1),If=Ee(z,z.EXP2).setParameterLength(1),xI=Ee(z,z.LOG).setParameterLength(1),Yn=Ee(z,z.LOG2).setParameterLength(1),nh=Ee(z,z.SQRT).setParameterLength(1),vI=Ee(z,z.INVERSE_SQRT).setParameterLength(1),ju=Ee(z,z.FLOOR).setParameterLength(1),y_=Ee(z,z.CEIL).setParameterLength(1),Pf=Ee(z,z.NORMALIZE).setParameterLength(1),Zn=Ee(z,z.FRACT).setParameterLength(1),ah=Ee(z,z.SIN).setParameterLength(1),x_=Ee(z,z.COS).setParameterLength(1),_I=Ee(z,z.TAN).setParameterLength(1),MI=Ee(z,z.ASIN).setParameterLength(1),v_=Ee(z,z.ACOS).setParameterLength(1),bI=Ee(z,z.ATAN).setParameterLength(1,2),oh=Ee(z,z.ABS).setParameterLength(1),__=Ee(z,z.SIGN).setParameterLength(1),Xu=Ee(z,z.LENGTH).setParameterLength(1),M_=Ee(z,z.NEGATE).setParameterLength(1),SI=Ee(z,z.ONE_MINUS).setParameterLength(1),b_=Ee(z,z.DFDX).setParameterLength(1),S_=Ee(z,z.DFDY).setParameterLength(1),TI=Ee(z,z.ROUND).setParameterLength(1),wI=Ee(z,z.RECIPROCAL).setParameterLength(1),EI=Ee(z,z.TRUNC).setParameterLength(1),T_=Ee(z,z.FWIDTH).setParameterLength(1),AI=Ee(z,z.TRANSPOSE).setParameterLength(1),NI=Ee(z,z.DETERMINANT).setParameterLength(1),CI=Ee(z,z.INVERSE).setParameterLength(1),lh=Ee(z,z.MIN).setParameterLength(2,1/0),ir=Ee(z,z.MAX).setParameterLength(2,1/0),hh=Ee(z,z.STEP).setParameterLength(2),RI=Ee(z,z.REFLECT).setParameterLength(2),II=Ee(z,z.DISTANCE).setParameterLength(2),PI=Ee(z,z.DIFFERENCE).setParameterLength(2),ch=Ee(z,z.DOT).setParameterLength(2),Lf=Ee(z,z.CROSS).setParameterLength(2),Df=Ee(z,z.POW).setParameterLength(2),LI=s=>Bt(s,s),DI=s=>Bt(s,s,s),OI=s=>Bt(s,s,s,s),UI=Ee(z,z.TRANSFORM_DIRECTION).setParameterLength(2),FI=s=>Bt(__(s),Df(oh(s),1/3)),zI=s=>ch(s,s),Fi=Ee(z,z.MIX).setParameterLength(3),co=(s,e=0,t=1)=>new z(z.CLAMP,Fe(s),Fe(e),Fe(t)),Of=s=>co(s),BI=Ee(z,z.REFRACT).setParameterLength(3),uh=Ee(z,z.SMOOTHSTEP).setParameterLength(3),VI=Ee(z,z.FACEFORWARD).setParameterLength(3),kI=xe(([s])=>{const e=43758.5453,t=ch(s.xy,xt(12.9898,78.233)),i=Rf(t,dI);return Zn(ah(i).mul(e))}),GI=(s,e,t)=>Fi(e,t,s),HI=(s,e,t)=>uh(e,t,s),WI=(s,e)=>hh(e,s);q("all",pI),q("any",mI),q("radians",fI),q("degrees",gI),q("exp",yI),q("exp2",If),q("log",xI),q("log2",Yn),q("sqrt",nh),q("inverseSqrt",vI),q("floor",ju),q("ceil",y_),q("normalize",Pf),q("fract",Zn),q("sin",ah),q("cos",x_),q("tan",_I),q("asin",MI),q("acos",v_),q("atan",bI),q("abs",oh),q("sign",__),q("length",Xu),q("lengthSq",zI),q("negate",M_),q("oneMinus",SI),q("dFdx",b_),q("dFdy",S_),q("round",TI),q("reciprocal",wI),q("trunc",EI),q("fwidth",T_),q("min",lh),q("max",ir),q("step",WI),q("reflect",RI),q("distance",II),q("dot",ch),q("cross",Lf),q("pow",Df),q("pow2",LI),q("pow3",DI),q("pow4",OI),q("transformDirection",UI),q("mix",GI),q("clamp",co),q("refract",BI),q("smoothstep",HI),q("faceForward",VI),q("difference",PI),q("saturate",Of),q("cbrt",FI),q("transpose",AI),q("determinant",NI),q("inverse",CI),q("rand",kI);class jI extends ze{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}getNodeType(e){const{ifNode:t,elseNode:i}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const r=t.getNodeType(e);if(i!==null){const n=i.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(r))return n}return r}setup(e){const t=this.condNode,i=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,n=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=n,r!==null&&(e.getDataFromNode(r).parentNodeBlock=n);const a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?i:i.context({nodeBlock:i}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){const i=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:n,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=e.currentFunctionNode,h=t!=="void",c=h?f_(i).build(e):"";r.nodeProperty=c;const d=n.build(e,"bool");if(e.context.uniformFlow&&o!==null){const p=a.build(e,i),m=o.build(e,i),y=e.getTernary(d,p,m);return e.format(y,i,t)}e.addFlowCode(`
|
|
4060
|
+
${t}`}}function yf(s,e=0){let t=3735928559^e,i=1103547991^e;if(s instanceof Array)for(let r=0,n;r<s.length;r++)n=s[r],t=Math.imul(t^n,2654435761),i=Math.imul(i^n,1597334677);else for(let r=0,n;r<s.length;r++)n=s.charCodeAt(r),t=Math.imul(t^n,2654435761),i=Math.imul(i^n,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&i)+(t>>>0)}const xf=s=>yf(s),Jv=s=>yf(s),Kv=(...s)=>yf(s),eR=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),$v=new WeakMap;function tR(s){return eR.get(s)}function Fu(s){if(s==null)return null;const e=typeof s;return s.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":s.isVector2===!0?"vec2":s.isVector3===!0?"vec3":s.isVector4===!0?"vec4":s.isMatrix2===!0?"mat2":s.isMatrix3===!0?"mat3":s.isMatrix4===!0?"mat4":s.isColor===!0?"color":s instanceof ArrayBuffer?"ArrayBuffer":null}function vf(s,...e){const t=s?s.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),s==="color"?new Ds(...e):t==="vec2"?new Vt(...e):t==="vec3"?new H(...e):t==="vec4"?new Ai(...e):t==="mat2"?new Pg(...e):t==="mat3"?new xs(...e):t==="mat4"?new kt(...e):s==="bool"?e[0]||!1:s==="float"||s==="int"||s==="uint"?e[0]||0:s==="string"?e[0]||"":s==="ArrayBuffer"?rR(e[0]):null}function iR(s){let e=$v.get(s);return e===void 0&&(e={},$v.set(s,e)),e}function sR(s){let e="";const t=new Uint8Array(s);for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}function rR(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0)).buffer}class lo{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const n=r.indexOf(t);n!==-1&&r.splice(n,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let n=0,a=r.length;n<a;n++)r[n].call(this,e);e.target=null}}}const nR={analyze:"setup",generate:"analyze"};let aR=0;class ze extends lo{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=ht.NONE,this.updateBeforeType=ht.NONE,this.updateAfterType=ht.NONE,this.uuid=YC.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,ze.captureStackTrace===!0&&(this.stackTrace=new us)}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,ht.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ht.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ht.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const i of Object.getOwnPropertyNames(this)){const r=this[i];if(!(i.startsWith("_")===!0||e.has(r))){if(Array.isArray(r)===!0)for(let n=0;n<r.length;n++){const a=r[n];a&&a.isNode===!0&&t.push({property:i,index:n,childNode:a})}else if(r&&r.isNode===!0)t.push({property:i,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(const n in r){if(n.startsWith("_")===!0)continue;const a=r[n];a&&a.isNode===!0&&t.push({property:i,index:n,childNode:a})}}}return t}getCacheKey(e=!1,t=null){if(e=e||this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);const i=[];for(const{property:r,childNode:n}of this._getChildren(t))i.push(xf(r.slice(0,-4)),n.getCacheKey(e,t));this._cacheKey=Kv(Jv(i),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(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){const t=e.getNodeProperties(this);let i=0;for(const r of this.getChildren())t["node"+i++]=r;return t.outputNode||null}analyze(e,t=null){const i=e.increaseUsage(this);if(this.parents===!0){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(i===1){const r=e.getNodeProperties(this);for(const n of Object.values(r))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){const{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,t)}updateBefore(){st("Abstract function.")}updateAfter(){st("Abstract function.")}update(){st("Abstract function.")}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){const i=this.getShared(e);if(this!==i)return i.build(e,t);if(this._beforeNodes!==null){const l=this._beforeNodes;this._beforeNodes=null;for(const h of l)h.build(e,t);this._beforeNodes=l}const r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;const n=nR[e.buildStage];if(n&&r.buildStages[n]!==!0){const l=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(l)}e.addChain(this);let a=null;const o=e.getBuildStage();if(o==="setup"){e.addNode(this),this.updateReference(e);const l=e.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(e)||l.outputNode||null;for(const h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){const c=e.getNodeProperties(h);c.parents=c.parents||[],c.parents.push(this)}h.build(e)}e.addSequentialNode(this)}a=l.outputNode}else if(o==="analyze")this.analyze(e,t);else if(o==="generate"){if(this.generate.length<2){const l=this.getNodeType(e),h=e.getDataFromNode(this);a=h.snippet,a===void 0?h.generated===void 0?(h.generated=!0,a=this.generate(e)||"",h.snippet=a):(st("Node: Recursion detected.",this),a="/* Recursion detected. */"):h.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,l,t)}else a=this.generate(e,t)||"";a===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(Tt(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){const t=this.getSerializeChildren(),i={};for(const{property:r,index:n,childNode:a}of t)n!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(n)?[]:{}),i[r][n]=a.toJSON(e.meta).uuid):i[r]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){const r=[];for(const n of e.inputNodes[i])r.push(t[n]);this[i]=r}else if(typeof e.inputNodes[i]=="object"){const r={};for(const n in e.inputNodes[i]){const a=e.inputNodes[i][n];r[n]=t[a]}this[i]=r}else{const r=e.inputNodes[i];this[i]=t[r]}}}toJSON(e){const{uuid:t,type:i}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[t];n===void 0&&(n={uuid:t,type:i,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function a(o){const l=[];for(const h in o){const c=o[h];delete c.metadata,l.push(c)}return l}if(r){const o=a(e.textures),l=a(e.images),h=a(e.nodes);o.length>0&&(n.textures=o),l.length>0&&(n.images=l),h.length>0&&(n.nodes=h)}return n}}ze.captureStackTrace=!1;class ho extends ze{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),i=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${i}[ ${r} ]`}}class Qv extends ze{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let i=null;for(const r of this.convertTo.split("|"))(i===null||e.getTypeLength(t)===e.getTypeLength(r))&&(i=r);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const i=this.node,r=this.getNodeType(e),n=i.build(e,r);return e.format(n,r,t)}}class mi extends ze{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const n=super.build(e,i),a=e.getVarFromNode(this,null,i),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${n}`,this),r.snippet=n,r.propertyName=o,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class oR extends mi{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,i)=>t+e.getTypeLength(i.getNodeType(e)),0))}generate(e,t){const i=this.getNodeType(e),r=e.getTypeLength(i),n=this.nodes,a=e.getComponentType(i),o=[];let l=0;for(const c of n){if(l>=r){Tt(`TSL: Length of parameters exceeds maximum length of function '${i}()' type.`,this.stackTrace);break}let d=c.getNodeType(e),u=e.getTypeLength(d),p;if(l+u>r&&(Tt(`TSL: Length of '${i}()' data exceeds maximum length of output type.`,this.stackTrace),u=r-l,d=e.getTypeFromLength(u)),l+=u,p=c.build(e,d),e.getComponentType(d)!==a){const m=e.getTypeFromLength(u,a);p=e.format(p,d,m)}o.push(p)}const h=`${e.getType(i)}( ${o.join(", ")} )`;return e.format(h,i,t)}}const lR=ql.join("");class hR extends ze{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(ql.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const i=this.node,r=e.getTypeLength(i.getNodeType(e));let n=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const o=i.build(e,a);this.components.length===r&&this.components===lR.slice(0,this.components.length)?n=e.format(o,a,t):n=e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else n=i.build(e,t);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class cR extends mi{static get type(){return"SetNode"}constructor(e,t,i){super(),this.sourceNode=e,this.components=t,this.targetNode=i}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:i,targetNode:r}=this,n=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(i.length,a),l=r.build(e,o),h=t.build(e,n),c=e.getTypeLength(n),d=[];for(let u=0;u<c;u++){const p=ql[u];p===i[0]?(d.push(l),u+=i.length-1):d.push(h+"."+p)}return`${e.getType(n)}( ${d.join(", ")} )`}}class uR extends mi{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:i}=this,r=this.getNodeType(e),n=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+n,this);const l=e.getTypeLength(r),h=[];let c=0;for(let d=0;d<l;d++){const u=ql[d];u===t[c]?(h.push("1.0 - "+(o+"."+u)),c++):h.push(o+"."+u)}return`${e.getType(r)}( ${h.join(", ")} )`}}class _f extends ze{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Fu(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Fu(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=sR(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?vf(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){st("Abstract function.")}}const e_=/float|u?int/;class Js extends _f{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const i=this.getNodeType(e);return e_.test(i)&&e_.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),i,t)}}class dR extends ze{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!=="void"}getNodeType(e){return this.hasMember(e)===!1?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return"float";const i=this.getNodeType(e);return e.getStructTypeNode(i).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){st(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);const t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+"."+this.property}}let pR=null;const Mf=new Map;function q(s,e){if(Mf.has(s)){st(`TSL: Redefinition of method chaining '${s}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${s} is not a function`);Mf.set(s,e),s!=="assign"&&(ze.prototype[s]=function(...t){return this.isStackNode?this.addToStack(e(...t)):e(this,...t)},ze.prototype[s+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}const mR=s=>s.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),t_=s=>mR(s).split("").sort().join("");ze.prototype.assign=function(...s){if(this.isStackNode!==!0)return Tt("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new us),this;{const e=Mf.get("assign");return this.addToStack(e(...s))}},ze.prototype.toVarIntent=function(){return this},ze.prototype.get=function(s){return new dR(this,s)};const ih={};function zu(s,e,t){ih[s]=ih[e]=ih[t]={get(){this._cache=this._cache||{};let a=this._cache[s];return a===void 0&&(a=new hR(this,s),this._cache[s]=a),a},set(a){this[s].assign(Fe(a))}};const i=s.toUpperCase(),r=e.toUpperCase(),n=t.toUpperCase();ze.prototype["set"+i]=ze.prototype["set"+r]=ze.prototype["set"+n]=function(a){const o=t_(s);return new cR(this,o,Fe(a))},ze.prototype["flip"+i]=ze.prototype["flip"+r]=ze.prototype["flip"+n]=function(){const a=t_(s);return new uR(this,a)}}const Ks=["x","y","z","w"],$s=["r","g","b","a"],Qs=["s","t","p","q"];for(let s=0;s<4;s++){let e=Ks[s],t=$s[s],i=Qs[s];zu(e,t,i);for(let r=0;r<4;r++){e=Ks[s]+Ks[r],t=$s[s]+$s[r],i=Qs[s]+Qs[r],zu(e,t,i);for(let n=0;n<4;n++){e=Ks[s]+Ks[r]+Ks[n],t=$s[s]+$s[r]+$s[n],i=Qs[s]+Qs[r]+Qs[n],zu(e,t,i);for(let a=0;a<4;a++)e=Ks[s]+Ks[r]+Ks[n]+Ks[a],t=$s[s]+$s[r]+$s[n]+$s[a],i=Qs[s]+Qs[r]+Qs[n]+Qs[a],zu(e,t,i)}}}for(let s=0;s<32;s++)ih[s]={get(){this._cache=this._cache||{};let e=this._cache[s];return e===void 0&&(e=new ho(this,new Js(s,"uint")),this._cache[s]=e),e},set(e){this[s].assign(Fe(e))}};Object.defineProperties(ze.prototype,ih);const i_=new WeakMap,fR=function(s,e=null){const t=Fu(s);return t==="node"?s:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?Fe(wf(s,e)):t==="shader"?s.isFn?s:xe(s):s},gR=function(s,e=null){for(const t in s)s[t]=Fe(s[t],e);return s},yR=function(s,e=null){const t=s.length;for(let i=0;i<t;i++)s[i]=Fe(s[i],e);return s},s_=function(s,e=null,t=null,i=null){function r(c){return i!==null?(c=Fe(Object.assign(c,i)),i.intent===!0&&(c=c.toVarIntent())):c=Fe(c),c}let n,a=e,o,l;function h(c){let d;return a?d=/[a-z]/i.test(a)?a+"()":a:d=s.type,o!==void 0&&c.length<o?(Tt(`TSL: "${d}" parameter length is less than minimum required.`,new us),c.concat(new Array(o-c.length).fill(0))):l!==void 0&&c.length>l?(Tt(`TSL: "${d}" parameter length exceeds limit.`,new us),c.slice(0,l)):c}return e===null?n=(...c)=>r(new s(...co(h(c)))):t!==null?(t=Fe(t),n=(...c)=>r(new s(e,...co(h(c)),t))):n=(...c)=>r(new s(e,...co(h(c)))),n.setParameterLength=(...c)=>(c.length===1?o=l=c[0]:c.length===2&&([o,l]=c),n),n.setName=c=>(a=c,n),n},xR=function(s,...e){return new s(...co(e))};class vR extends ze{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:i}=this,r=e.getNodeProperties(t),n=e.getClosestSubBuild(t.subBuilds)||"",a=n||"default";if(r[a])return r[a];const o=e.subBuildFn,l=e.fnCall;e.subBuildFn=n,e.fnCall=this;let h=null;if(t.layout){let c=i_.get(e.constructor);c===void 0&&(c=new WeakMap,i_.set(e.constructor,c));let d=c.get(t);d===void 0&&(d=Fe(e.buildFunctionNode(t)),c.set(t,d)),e.addInclude(d);const u=i?_R(i):null;h=Fe(d.call(u))}else{const c=new Proxy(e,{get:(y,g,f)=>{let x;return Symbol.iterator===g?x=function*(){yield void 0}:x=Reflect.get(y,g,f),x}}),d=i?MR(i):null,u=Array.isArray(i)?i.length>0:i!==null,p=t.jsFunc,m=u||p.length>1?p(d,c):p(c);h=Fe(m)}return e.subBuildFn=o,e.fnCall=l,t.once&&(r[a]=h),h}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),i=e.getSubBuildOutput(this);return t[i]=t[i]||this.setupOutput(e),t[i].subBuild=e.getClosestSubBuild(this),t[i]}build(e,t=null){let i=null;const r=e.getBuildStage(),n=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),l=e.fnCall;if(e.fnCall=this,r==="setup"){const h=e.getSubBuildProperty("initialized",this);if(n[h]!==!0&&(n[h]=!0,n[a]=this.getOutputNode(e),n[a].build(e),this.shaderNode.subBuilds))for(const c of e.chaining){const d=e.getDataFromNode(c,"any");d.subBuilds=d.subBuilds||new Set;for(const u of this.shaderNode.subBuilds)d.subBuilds.add(u)}i=n[a]}else r==="analyze"?o.build(e,t):r==="generate"&&(i=o.build(e,t)||"");return e.fnCall=l,i}}function _R(s){let e;return Ef(s),s[0]&&(s[0].isNode||Object.getPrototypeOf(s[0])!==Object.prototype)?e=[...s]:e=s[0],e}function MR(s){let e=0;return Ef(s),new Proxy(s,{get:(t,i,r)=>{let n;if(i==="length")return n=s.length,n;if(Symbol.iterator===i)n=function*(){for(const a of s)yield Fe(a)};else{if(s.length>0)if(Object.getPrototypeOf(s[0])===Object.prototype){const a=s[0];a[i]===void 0?n=a[e++]:n=Reflect.get(a,i,r)}else s[0]instanceof ze&&(s[i]===void 0?n=s[e++]:n=Reflect.get(s,i,r));else n=Reflect.get(t,i,r);n=Fe(n)}return n}})}class bR extends ze{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new vR(this,e)}setup(){return this.call()}}const SR=[!1,!0],TR=[0,1,2,3],wR=[-1,-2],r_=[.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],bf=new Map;for(const s of SR)bf.set(s,new Js(s));const Sf=new Map;for(const s of TR)Sf.set(s,new Js(s,"uint"));const Tf=new Map([...Sf].map(s=>new Js(s.value,"int")));for(const s of wR)Tf.set(s,new Js(s,"int"));const Bu=new Map([...Tf].map(s=>new Js(s.value)));for(const s of r_)Bu.set(s,new Js(s));for(const s of r_)Bu.set(-s,new Js(-s));const Vu={bool:bf,uint:Sf,ints:Tf,float:Bu},n_=new Map([...bf,...Bu]),wf=(s,e)=>n_.has(s)?n_.get(s):s.isNode===!0?s:new Js(s,e),Jt=function(s,e=null){return(...t)=>{for(const r of t)if(r===void 0)return Tt(`TSL: Invalid parameter for the type "${s}".`,new us),new Js(0,s);if((t.length===0||!["bool","float","int","uint"].includes(s)&&t.every(r=>{const n=typeof r;return n!=="object"&&n!=="function"}))&&(t=[vf(s,...t)]),t.length===1&&e!==null&&e.has(t[0]))return ku(e.get(t[0]));if(t.length===1){const r=wf(t[0],s);return r.nodeType===s?ku(r):ku(new Qv(r,s))}const i=t.map(r=>wf(r));return ku(new oR(i,s))}},ER=s=>s!=null?s.nodeType||s.convertTo||(typeof s=="string"?s:null):null;function AR(s,e){return new bR(s,e)}const Fe=(s,e=null)=>fR(s,e),ku=(s,e=null)=>Fe(s,e).toVarIntent(),Ef=(s,e=null)=>new gR(s,e),co=(s,e=null)=>new yR(s,e),Pt=(s,e=null,t=null,i=null)=>new s_(s,e,t,i),Kt=(s,...e)=>new xR(s,...e),Ee=(s,e=null,t=null,i={})=>new s_(s,e,t,{...i,intent:!0});let NR=0;class CR extends ze{constructor(e,t=null){super();let i=null;t!==null&&(typeof t=="object"?i=t.return:(typeof t=="string"?i=t:Tt("TSL: Invalid layout type.",new us),t=null)),this.shaderNode=new AR(e,i),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const i={name:"fn"+NR++,type:t,inputs:[]};for(const r in e)r!=="return"&&i.inputs.push({name:r,type:e[r]});e=i}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return Tt('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function xe(s,e=null){const t=new CR(s,e);return new Proxy(()=>{},{apply(i,r,n){return t.call(...n)},get(i,r,n){return Reflect.get(t,r,n)},set(i,r,n,a){return Reflect.set(t,r,n,a)}})}const ds=(...s)=>pR.If(...s);function RR(s){return s}q("toStack",RR);const IR=new Jt("color"),ke=new Jt("float",Vu.float),zt=new Jt("int",Vu.ints),fi=new Jt("uint",Vu.uint),Af=new Jt("bool",Vu.bool),xt=new Jt("vec2"),er=new Jt("ivec2"),a_=new Jt("uvec2"),PR=new Jt("bvec2"),Re=new Jt("vec3"),o_=new Jt("ivec3"),l_=new Jt("uvec3"),LR=new Jt("bvec3"),Ui=new Jt("vec4"),h_=new Jt("ivec4"),c_=new Jt("uvec4"),DR=new Jt("bvec4"),u_=new Jt("mat2"),ps=new Jt("mat3"),Gu=new Jt("mat4");q("toColor",IR),q("toFloat",ke),q("toInt",zt),q("toUint",fi),q("toBool",Af),q("toVec2",xt),q("toIVec2",er),q("toUVec2",a_),q("toBVec2",PR),q("toVec3",Re),q("toIVec3",o_),q("toUVec3",l_),q("toBVec3",LR),q("toVec4",Ui),q("toIVec4",h_),q("toUVec4",c_),q("toBVec4",DR),q("toMat2",u_),q("toMat3",ps),q("toMat4",Gu);const OR=Pt(ho).setParameterLength(2),UR=(s,e)=>new Qv(Fe(s),e);q("element",OR),q("convert",UR),q("append",s=>(st("TSL: .append() has been renamed to .toStack().",new us),s));class d_ extends mi{static get type(){return"ArrayNode"}constructor(e,t,i=null){super(e),this.count=t,this.values=i,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const FR=(...s)=>{let e;if(s.length===1){const t=s[0];e=new d_(null,t.length,t)}else{const t=s[0],i=s[1];e=new d_(t,i)}return Fe(e)};q("toArray",(s,e)=>FR(Array(e).fill(s)));class p_ extends ze{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1){super("string"),this.name=e,this.shared=t,this.order=i,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const zR=s=>new p_(s),m_=(s,e=0)=>new p_(s,!0,e),it=m_("render"),BR=zR("object");class sh extends _f{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=BR}setName(e){return this.name=e,this}label(e){return st('TSL: "label()" has been deprecated. Use "setName()" instead.',new us),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(i=>{const r=e(i,this);r!==void 0&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const i=this.getNodeType(e),r=this.getUniformHash(e);let n=e.getNodeFromHash(r);n===void 0&&(e.setHashNode(this,r),n=this);const a=n.getInputType(e),o=e.getUniformFromNode(n,a,e.shaderStage,this.name||e.context.nodeName),l=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let h=l;if(i==="bool"){const c=e.getDataFromNode(this);let d=c.propertyName;if(d===void 0){const u=e.getVarFromNode(this,null,"bool");d=e.getPropertyName(u),c.propertyName=d,h=e.format(l,a,i),e.addLineFlowCode(`${d} = ${h}`,this)}h=d}return e.format(h,i,t)}}const dt=(s,e)=>{const t=ER(e||s);if(t===s&&(s=vf(t)),s&&s.isNode===!0){let i=s.value;s.traverse(r=>{r.isConstNode===!0&&(i=r.value)}),s=i}return new sh(s,t)};class rh extends ze{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return xf(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const f_=(s,e)=>new rh(s,e),Hu=(s,e)=>new rh(s,e,!0),Gi=Kt(rh,"vec4","DiffuseColor"),g_=Kt(rh,"vec3","EmissiveColor"),Nf=Kt(rh,"vec4","Output");class VR extends mi{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const i=e.getTypeLength(t.node.getNodeType(e));return ql.join("").slice(0,i)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:i}=this,r=t.getScope(),n=e.getDataFromNode(r);n.assign=!0;const a=e.getNodeProperties(this);a.sourceNode=i,a.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:i,sourceNode:r}=e.getNodeProperties(this),n=this.needsSplitAssign(e),a=i.build(e),o=i.getNodeType(e),l=r.build(e,o),h=r.getNodeType(e),c=e.getDataFromNode(this);let d;if(c.initialized===!0)t!=="void"&&(d=a);else if(n){const u=e.getVarFromNode(this,null,o),p=e.getPropertyName(u);e.addLineFlowCode(`${p} = ${l}`,this);const m=i.node,y=m.node.context({assign:!0}).build(e);for(let g=0;g<m.components.length;g++){const f=m.components[g];e.addLineFlowCode(`${y}.${f} = ${p}[ ${g} ]`,this)}t!=="void"&&(d=a)}else d=`${a} = ${l}`,(t==="void"||h==="void")&&(e.addLineFlowCode(d,this),t!=="void"&&(d=a));return c.initialized=!0,e.format(d,o,t)}}const kR=Pt(VR).setParameterLength(2);q("assign",kR);class GR extends mi{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){const t=[],i=this.functionNode,r=i.getInputs(e),n=this.parameters,a=(o,l)=>{const h=l.type,c=h==="pointer";let d;return c?d="&"+o.build(e):d=o.build(e,h),d};if(Array.isArray(n)){if(n.length>r.length)Tt("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=r.length;else if(n.length<r.length)for(Tt("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<r.length;)n.push(ke(0));for(let o=0;o<n.length;o++)t.push(a(n[o],r[o]))}else for(const o of r){const l=n[o.name];l!==void 0?t.push(a(l,o)):(Tt(`TSL: Input '${o.name}' not found in 'Fn()'.`),t.push(a(ke(0),o)))}return`${i.build(e,"property")}( ${t.join(", ")} )`}}const HR=(s,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?co(e):Ef(e[0]),new GR(Fe(s),e));q("call",HR);const WR={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ot extends mi{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let n=new Ot(e,t,i);for(let a=0;a<r.length-1;a++)n=new Ot(e,n,r[a]);t=n,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(WR[this.op],t)}getNodeType(e,t=null){const i=this.op,r=this.aNode,n=this.bNode,a=r.getNodeType(e),o=n?n.getNodeType(e):null;if(a==="void"||o==="void")return t||"void";if(i==="%")return a;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return e.getIntegerType(a);if(i==="!"||i==="&&"||i==="||"||i==="^^")return"bool";if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">="){const l=Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else{if(e.isMatrix(a)){if(o==="float")return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a==="float")return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}}generate(e,t){const i=this.op,{aNode:r,bNode:n}=this,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=r.getNodeType(e),l=n?n.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="||i==="!="?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):i==="%"?(o=a,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=a):e.isMatrix(l)?o==="float"?o="float":e.isVector(o)?o=e.getVectorFromMatrix(l):o=l=a:o=l=a):o=l=a;const h=r.build(e,o),c=n?n.build(e,l):null,d=e.getFunctionOperator(i);if(t!=="void"){const u=e.renderer.coordinateSystem===Zs;if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">=")return u?e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${h}, ${c} )`,a,t):e.format(`( ${h} ${i} ${c} )`,a,t):e.format(`( ${h} ${i} ${c} )`,a,t);if(i==="%")return e.isInteger(l)?e.format(`( ${h} % ${c} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${h}, ${c} )`,a,t);if(i==="!"||i==="~")return e.format(`(${i}${h})`,o,t);if(d)return e.format(`${d}( ${h}, ${c} )`,a,t);if(e.isMatrix(o)&&l==="float")return e.format(`( ${c} ${i} ${h} )`,a,t);if(o==="float"&&e.isMatrix(l))return e.format(`${h} ${i} ${c}`,a,t);{let p=`( ${h} ${i} ${c} )`;return!u&&a==="bool"&&e.isVector(o)&&e.isVector(l)&&(p=`all${p}`),e.format(p,a,t)}}else if(o!=="void")return d?e.format(`${d}( ${h}, ${c} )`,a,t):e.isMatrix(o)&&l==="float"?e.format(`${c} ${i} ${h}`,a,t):e.format(`${h} ${i} ${c}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const tr=Ee(Ot,"+").setParameterLength(2,1/0).setName("add"),Hi=Ee(Ot,"-").setParameterLength(2,1/0).setName("sub"),Bt=Ee(Ot,"*").setParameterLength(2,1/0).setName("mul"),Wu=Ee(Ot,"/").setParameterLength(2,1/0).setName("div"),Cf=Ee(Ot,"%").setParameterLength(2).setName("mod"),jR=Ee(Ot,"==").setParameterLength(2).setName("equal"),XR=Ee(Ot,"!=").setParameterLength(2).setName("notEqual"),qR=Ee(Ot,"<").setParameterLength(2).setName("lessThan"),YR=Ee(Ot,">").setParameterLength(2).setName("greaterThan"),ZR=Ee(Ot,"<=").setParameterLength(2).setName("lessThanEqual"),JR=Ee(Ot,">=").setParameterLength(2).setName("greaterThanEqual"),KR=Ee(Ot,"&&").setParameterLength(2,1/0).setName("and"),$R=Ee(Ot,"||").setParameterLength(2,1/0).setName("or"),QR=Ee(Ot,"!").setParameterLength(1).setName("not"),eI=Ee(Ot,"^^").setParameterLength(2).setName("xor"),tI=Ee(Ot,"&").setParameterLength(2).setName("bitAnd"),iI=Ee(Ot,"~").setParameterLength(1).setName("bitNot"),sI=Ee(Ot,"|").setParameterLength(2).setName("bitOr"),rI=Ee(Ot,"^").setParameterLength(2).setName("bitXor"),nI=Ee(Ot,"<<").setParameterLength(2).setName("shiftLeft"),aI=Ee(Ot,">>").setParameterLength(2).setName("shiftRight"),oI=xe(([s])=>(s.addAssign(1),s)),lI=xe(([s])=>(s.subAssign(1),s)),hI=xe(([s])=>{const e=zt(s).toConst();return s.addAssign(1),e}),cI=xe(([s])=>{const e=zt(s).toConst();return s.subAssign(1),e});q("add",tr),q("sub",Hi),q("mul",Bt),q("div",Wu),q("mod",Cf),q("equal",jR),q("notEqual",XR),q("lessThan",qR),q("greaterThan",YR),q("lessThanEqual",ZR),q("greaterThanEqual",JR),q("and",KR),q("or",$R),q("not",QR),q("xor",eI),q("bitAnd",tI),q("bitNot",iI),q("bitOr",sI),q("bitXor",rI),q("shiftLeft",nI),q("shiftRight",aI),q("incrementBefore",oI),q("decrementBefore",lI),q("increment",hI),q("decrement",cI);const uI=(s,e)=>(st('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.',new us),Cf(zt(s),zt(e)));q("modInt",uI);class z extends mi{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){if(super(),(e===z.MAX||e===z.MIN)&&arguments.length>3){let n=new z(e,t,i);for(let a=2;a<arguments.length-1;a++)n=new z(e,n,arguments[a]);t=n,i=arguments[arguments.length-1],r=null}this.method=e,this.aNode=t,this.bNode=i,this.cNode=r,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(r)?0:e.getTypeLength(r);return n>a&&n>o?t:a>o?i:o>n?r:t}getNodeType(e){const t=this.method;return t===z.LENGTH||t===z.DISTANCE||t===z.DOT?"float":t===z.CROSS?"vec3":t===z.ALL||t===z.ANY?"bool":t===z.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:i,method:r}=this;let n=null;if(r===z.ONE_MINUS)n=Hi(1,t);else if(r===z.RECIPROCAL)n=Wu(1,t);else if(r===z.DIFFERENCE)n=oh(Hi(t,i));else if(r===z.TRANSFORM_DIRECTION){let a=t,o=i;e.isMatrix(a.getNodeType(e))?o=Ui(Re(o),0):a=Ui(Re(a),0);const l=Bt(a,o).xyz;n=If(l)}return n!==null?n:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let i=this.method;const r=this.getNodeType(e),n=this.getInputType(e),a=this.aNode,o=this.bNode,l=this.cNode,h=e.renderer.coordinateSystem;if(i===z.NEGATE)return e.format("( - "+a.build(e,n)+" )",r,t);{const c=[];return i===z.CROSS?c.push(a.build(e,r),o.build(e,r)):h===Zs&&i===z.STEP?c.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":n),o.build(e,n)):h===Zs&&(i===z.MIN||i===z.MAX)?c.push(a.build(e,n),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":n)):i===z.REFRACT?c.push(a.build(e,n),o.build(e,n),l.build(e,"float")):i===z.MIX?c.push(a.build(e,n),o.build(e,n),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":n)):(h===tn&&i===z.ATAN&&o!==null&&(i="atan2"),e.shaderStage!=="fragment"&&(i===z.DFDX||i===z.DFDY)&&(st(`TSL: '${i}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),c.push(a.build(e,n)),o!==null&&c.push(o.build(e,n)),l!==null&&c.push(l.build(e,n))),e.format(`${e.getMethod(i,r)}( ${c.join(", ")} )`,r,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.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 dI=ke(Math.PI),pI=Ee(z,z.ALL).setParameterLength(1),mI=Ee(z,z.ANY).setParameterLength(1),fI=Ee(z,z.RADIANS).setParameterLength(1),gI=Ee(z,z.DEGREES).setParameterLength(1),yI=Ee(z,z.EXP).setParameterLength(1),Rf=Ee(z,z.EXP2).setParameterLength(1),xI=Ee(z,z.LOG).setParameterLength(1),Yn=Ee(z,z.LOG2).setParameterLength(1),nh=Ee(z,z.SQRT).setParameterLength(1),vI=Ee(z,z.INVERSE_SQRT).setParameterLength(1),ju=Ee(z,z.FLOOR).setParameterLength(1),y_=Ee(z,z.CEIL).setParameterLength(1),If=Ee(z,z.NORMALIZE).setParameterLength(1),Zn=Ee(z,z.FRACT).setParameterLength(1),ah=Ee(z,z.SIN).setParameterLength(1),x_=Ee(z,z.COS).setParameterLength(1),_I=Ee(z,z.TAN).setParameterLength(1),MI=Ee(z,z.ASIN).setParameterLength(1),v_=Ee(z,z.ACOS).setParameterLength(1),bI=Ee(z,z.ATAN).setParameterLength(1,2),oh=Ee(z,z.ABS).setParameterLength(1),__=Ee(z,z.SIGN).setParameterLength(1),Xu=Ee(z,z.LENGTH).setParameterLength(1),M_=Ee(z,z.NEGATE).setParameterLength(1),SI=Ee(z,z.ONE_MINUS).setParameterLength(1),b_=Ee(z,z.DFDX).setParameterLength(1),S_=Ee(z,z.DFDY).setParameterLength(1),TI=Ee(z,z.ROUND).setParameterLength(1),wI=Ee(z,z.RECIPROCAL).setParameterLength(1),EI=Ee(z,z.TRUNC).setParameterLength(1),T_=Ee(z,z.FWIDTH).setParameterLength(1),AI=Ee(z,z.TRANSPOSE).setParameterLength(1),NI=Ee(z,z.DETERMINANT).setParameterLength(1),CI=Ee(z,z.INVERSE).setParameterLength(1),lh=Ee(z,z.MIN).setParameterLength(2,1/0),ir=Ee(z,z.MAX).setParameterLength(2,1/0),hh=Ee(z,z.STEP).setParameterLength(2),RI=Ee(z,z.REFLECT).setParameterLength(2),II=Ee(z,z.DISTANCE).setParameterLength(2),PI=Ee(z,z.DIFFERENCE).setParameterLength(2),ch=Ee(z,z.DOT).setParameterLength(2),Pf=Ee(z,z.CROSS).setParameterLength(2),Lf=Ee(z,z.POW).setParameterLength(2),LI=s=>Bt(s,s),DI=s=>Bt(s,s,s),OI=s=>Bt(s,s,s,s),UI=Ee(z,z.TRANSFORM_DIRECTION).setParameterLength(2),FI=s=>Bt(__(s),Lf(oh(s),1/3)),zI=s=>ch(s,s),Fi=Ee(z,z.MIX).setParameterLength(3),uo=(s,e=0,t=1)=>new z(z.CLAMP,Fe(s),Fe(e),Fe(t)),Df=s=>uo(s),BI=Ee(z,z.REFRACT).setParameterLength(3),uh=Ee(z,z.SMOOTHSTEP).setParameterLength(3),VI=Ee(z,z.FACEFORWARD).setParameterLength(3),kI=xe(([s])=>{const e=43758.5453,t=ch(s.xy,xt(12.9898,78.233)),i=Cf(t,dI);return Zn(ah(i).mul(e))}),GI=(s,e,t)=>Fi(e,t,s),HI=(s,e,t)=>uh(e,t,s),WI=(s,e)=>hh(e,s);q("all",pI),q("any",mI),q("radians",fI),q("degrees",gI),q("exp",yI),q("exp2",Rf),q("log",xI),q("log2",Yn),q("sqrt",nh),q("inverseSqrt",vI),q("floor",ju),q("ceil",y_),q("normalize",If),q("fract",Zn),q("sin",ah),q("cos",x_),q("tan",_I),q("asin",MI),q("acos",v_),q("atan",bI),q("abs",oh),q("sign",__),q("length",Xu),q("lengthSq",zI),q("negate",M_),q("oneMinus",SI),q("dFdx",b_),q("dFdy",S_),q("round",TI),q("reciprocal",wI),q("trunc",EI),q("fwidth",T_),q("min",lh),q("max",ir),q("step",WI),q("reflect",RI),q("distance",II),q("dot",ch),q("cross",Pf),q("pow",Lf),q("pow2",LI),q("pow3",DI),q("pow4",OI),q("transformDirection",UI),q("mix",GI),q("clamp",uo),q("refract",BI),q("smoothstep",HI),q("faceForward",VI),q("difference",PI),q("saturate",Df),q("cbrt",FI),q("transpose",AI),q("determinant",NI),q("inverse",CI),q("rand",kI);class jI extends ze{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}getNodeType(e){const{ifNode:t,elseNode:i}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const r=t.getNodeType(e);if(i!==null){const n=i.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(r))return n}return r}setup(e){const t=this.condNode,i=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,n=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=n,r!==null&&(e.getDataFromNode(r).parentNodeBlock=n);const a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?i:i.context({nodeBlock:i}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){const i=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:n,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=e.currentFunctionNode,h=t!=="void",c=h?f_(i).build(e):"";r.nodeProperty=c;const d=n.build(e,"bool");if(e.context.uniformFlow&&o!==null){const p=a.build(e,i),m=o.build(e,i),y=e.getTernary(d,p,m);return e.format(y,i,t)}e.addFlowCode(`
|
|
4061
4061
|
${e.tab}if ( ${d} ) {
|
|
4062
4062
|
|
|
4063
4063
|
`).addFlowTab();let u=a.build(e,i);if(u&&(h?u=c+" = "+u+";":(u="return "+u+";",l===null&&(st("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),u="// "+u))),e.removeFlowTab().addFlowCode(e.tab+" "+u+`
|
|
@@ -4070,15 +4070,15 @@ ${e.tab}if ( ${d} ) {
|
|
|
4070
4070
|
|
|
4071
4071
|
`)}else e.addFlowCode(`
|
|
4072
4072
|
|
|
4073
|
-
`);return e.format(c,i,t)}}const Uf=Pt(jI).setParameterLength(2,3);q("select",Uf);class w_ extends ze{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const i=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(i),r}}const uo=(s=null,e={})=>{let t=s;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new w_(t,e)},XI=s=>uo(s,{uniformFlow:!0}),E_=(s,e)=>uo(s,{nodeName:e});function qI(s,e,t=null){return uo(t,{getShadow:({light:i,shadowColorNode:r})=>e===i?r.mul(s):r})}function YI(s,e=null){return uo(e,{getAO:(t,{material:i})=>i.transparent===!0?t:t!==null?t.mul(s):s})}function ZI(s,e){return st('TSL: "label()" has been deprecated. Use "setName()" instead.'),E_(s,e)}q("context",uo),q("label",ZI),q("uniformFlow",XI),q("setName",E_),q("builtinShadowContext",(s,e,t)=>qI(e,t,s)),q("builtinAOContext",(s,e)=>YI(e,s));class JI extends ze{static get type(){return"VarNode"}constructor(e,t=null,i=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=i,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let i=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){const n=t.getDataFromNode(this);n.forceDeclaration=!0,i=!0}const r=t.getBaseStack();i?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:i,readOnly:r}=this,{renderer:n}=e,a=n.backend.isWebGPUBackend===!0;let o=!1,l=!1;r&&(o=e.isDeterministic(t),l=a?r:o);const h=this.getNodeType(e);if(h=="void")return this.isIntent(e)!==!0&&Tt('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);const c=e.getVectorType(h),d=t.build(e,c),u=e.getVarFromNode(this,i,c,void 0,l),p=e.getPropertyName(u);let m=p;if(l)if(a)m=o?`const ${p}`:`let ${p}`;else{const y=t.getArrayCount(e);m=`const ${e.getVar(u.type,p,y)}`}return e.addLineFlowCode(`${m} = ${d}`,this),p}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const Ff=Pt(JI),KI=(s,e=null)=>Ff(s,e).toStack(),$I=(s,e=null)=>Ff(s,e,!0).toStack(),QI=s=>Ff(s).setIntent(!0).toStack();q("toVar",KI),q("toConst",$I),q("toVarIntent",QI);class e2 extends ze{static get type(){return"SubBuild"}constructor(e,t,i=null){super(i),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const i=this.node.build(e,...t);return e.removeSubBuild(),i}}const dh=(s,e,t=null)=>new e2(Fe(s),e,t);class t2 extends ze{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=dh(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let i=t.varying;if(i===void 0){const r=this.name,n=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=i=e.getVaryingFromNode(this,r,n,a,o),t.node=dh(this.node,"VERTEX")}return i.needsInterpolation||(i.needsInterpolation=e.shaderStage==="fragment"),i}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Iu.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Iu.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),i=e.getNodeProperties(this),r=this.setupVarying(e);if(i[t]===void 0){const n=this.getNodeType(e),a=e.getPropertyName(r,Iu.VERTEX);e.flowNodeFromShaderStage(Iu.VERTEX,i.node,n,a),i[t]=a}return e.getPropertyName(r)}}const po=Pt(t2).setParameterLength(1,2),i2=s=>po(s);q("toVarying",po),q("toVertexStage",i2);const s2=xe(([s])=>{const e=s.mul(.9478672986).add(.0521327014).pow(2.4),t=s.mul(.0773993808),i=s.lessThanEqual(.04045);return Fi(e,t,i)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),r2=xe(([s])=>{const e=s.pow(.41666).mul(1.055).sub(.055),t=s.mul(12.92),i=s.lessThanEqual(.0031308);return Fi(e,t,i)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),zf="WorkingColorSpace",n2="OutputColorSpace";class A_ extends mi{static get type(){return"ColorSpaceNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.source=t,this.target=i}resolveColorSpace(e,t){return t===zf?si.workingColorSpace:t===n2?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,i=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let n=t;return si.enabled===!1||i===r||!i||!r||(si.getTransfer(i)===$l&&(n=Ui(s2(n.rgb),n.a)),si.getPrimaries(i)!==si.getPrimaries(r)&&(n=Ui(ps(si._getMatrix(new xs,i,r)).mul(n.rgb),n.a)),si.getTransfer(r)===$l&&(n=Ui(r2(n.rgb),n.a))),n}}const a2=(s,e)=>new A_(Fe(s),zf,e),N_=(s,e)=>new A_(Fe(s),e,zf);q("workingToColorSpace",a2),q("colorSpaceToWorking",N_);let o2=class extends lo{static get type(){return"ReferenceElementNode"}constructor(s,e){super(s,e),this.referenceNode=s,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(s){const e=super.generate(s),t=this.referenceNode.getNodeType(),i=this.getNodeType();return s.format(e,t,i)}};class l2 extends ze{static get type(){return"ReferenceBaseNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=ht.OBJECT}setGroup(e){return this.group=e,this}element(e){return new o2(this,Fe(e))}setNodeType(e){const t=dt(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}class h2 extends l2{static get type(){return"RendererReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.renderer=i,this.setGroup(it)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const c2=(s,e,t=null)=>new h2(s,e,t);class u2 extends mi{static get type(){return"ToneMappingNode"}constructor(e,t=p2,i=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=i}customCacheKey(){return Kv(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,i=this._toneMapping;if(i===nf)return t;let r=null;const n=e.renderer.library.getToneMappingFunction(i);return n!==null?r=Ui(n(t.rgb,this.exposureNode),t.a):(Tt("ToneMappingNode: Unsupported Tone Mapping configuration.",i),r=t),r}}const d2=(s,e,t)=>new u2(s,Fe(e),Fe(t)),p2=c2("toneMappingExposure","float");q("toneMapping",(s,e,t)=>d2(e,t,s));const $t=new H,qu=new Vt;let m2=0;class nn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:m2++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=io,this.updateRanges=[],this.gpuType=Ov,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,n=this.itemSize;r<n;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)qu.fromBufferAttribute(this,t),qu.applyMatrix3(e),this.setXY(t,qu.x,qu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)$t.fromBufferAttribute(this,t),$t.applyMatrix3(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)$t.fromBufferAttribute(this,t),$t.applyMatrix4(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$t.fromBufferAttribute(this,t),$t.applyNormalMatrix(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$t.fromBufferAttribute(this,t),$t.transformDirection(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Ls(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=St(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ls(t,this.array)),t}setX(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ls(t,this.array)),t}setY(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ls(t,this.array)),t}setZ(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ls(t,this.array)),t}setW(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),i=St(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),i=St(i,this.array),r=St(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),i=St(i,this.array),r=St(r,this.array),n=St(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==io&&(e.usage=this.usage),e}}class f2 extends nn{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class g2 extends nn{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Bf extends nn{constructor(e,t,i){super(new Float32Array(e),t,i)}}const zi=new H;class Dg{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)zi.fromBufferAttribute(this,t),zi.applyMatrix4(e),this.setXYZ(t,zi.x,zi.y,zi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)zi.fromBufferAttribute(this,t),zi.applyNormalMatrix(e),this.setXYZ(t,zi.x,zi.y,zi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)zi.fromBufferAttribute(this,t),zi.transformDirection(e),this.setXYZ(t,zi.x,zi.y,zi.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Ls(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=St(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ls(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ls(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ls(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ls(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),i=St(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),i=St(i,this.array),r=St(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),i=St(i,this.array),r=St(r,this.array),n=St(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}clone(e){if(e===void 0){pf("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return new nn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Dg(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){pf("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class C_{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=io,this.updateRanges=[],this.version=0,this.uuid=wr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,n=this.stride;r<n;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=wr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=wr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const R_=new WeakMap;function I_(s,e){let t=R_.get(s);return t===void 0&&(t=new C_(s,e),R_.set(s,t)),t}class an extends Mf{static get type(){return"BufferAttributeNode"}constructor(e,t=null,i=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=i,this.bufferOffset=r,this.usage=io,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),i=e.getTypeLength(t),r=this.value,n=this.bufferStride||i,a=this.bufferOffset;let o;r.isInterleavedBuffer===!0?o=r:r.isBufferAttribute===!0?o=I_(r.array,n):o=I_(r,n);const l=new Dg(o,i,a);o.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),i=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(i);let n=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,n=r):n=po(this).build(e,t),n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function Vf(s,e=null,t=0,i=0,r=io,n=!1){return e==="mat3"||e===null&&s.itemSize===9?ps(new an(s,"vec3",9,0).setUsage(r).setInstanced(n),new an(s,"vec3",9,3).setUsage(r).setInstanced(n),new an(s,"vec3",9,6).setUsage(r).setInstanced(n)):e==="mat4"||e===null&&s.itemSize===16?Gu(new an(s,"vec4",16,0).setUsage(r).setInstanced(n),new an(s,"vec4",16,4).setUsage(r).setInstanced(n),new an(s,"vec4",16,8).setUsage(r).setInstanced(n),new an(s,"vec4",16,12).setUsage(r).setInstanced(n)):new an(s,e,t,i).setUsage(r)}const P_=(s,e=null,t=0,i=0)=>Vf(s,e,t,i),L_=(s,e=null,t=0,i=0)=>Vf(s,e,t,i,io,!0),D_=(s,e=null,t=0,i=0)=>Vf(s,e,t,i,df,!0);q("toAttribute",s=>P_(s.value));class y2 extends ze{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=ht.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return st('TSL: "label()" has been deprecated. Use "setName()" instead.',new us),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){const i=e.getNodeProperties(this);i.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:i}=e;if(i==="compute"){const r=this.computeNode.build(e,"void");r!==""&&e.addLineFlowCode(r,this)}else{const r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}const O_=(s,e=[64])=>{(e.length===0||e.length>3)&&Tt("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new us);for(let t=0;t<e.length;t++){const i=e[t];(typeof i!="number"||i<=0||!Number.isInteger(i))&&Tt(`TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`,new us)}for(;e.length<3;)e.push(1);return new y2(Fe(s),e)},x2=(s,e,t)=>O_(s,t).setCount(e);q("compute",x2),q("computeKernel",O_);class v2 extends ze{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){const t=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const i=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const n=this.node.build(e,...t);return e.setCache(i),n}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const U_=s=>new v2(Fe(s));function _2(s,e=!0){return st('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),U_(s).setParent(e)}q("cache",_2),q("isolate",U_);class M2 extends ze{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const b2=Pt(M2).setParameterLength(2);q("bypass",b2);class F_ extends ze{static get type(){return"RemapNode"}constructor(e,t,i,r=ke(0),n=ke(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=i,this.outLowNode=r,this.outHighNode=n,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:i,outLowNode:r,outHighNode:n,doClamp:a}=this;let o=e.sub(t).div(i.sub(t));return a===!0&&(o=o.clamp()),o.mul(n.sub(r)).add(r)}}const S2=Pt(F_,null,null,{doClamp:!1}).setParameterLength(3,5),T2=Pt(F_).setParameterLength(3,5);q("remap",S2),q("remapClamp",T2);class w2 extends ze{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const i=this.getNodeType(e),r=this.snippet;if(i==="void")e.addLineFlowCode(r,this);else return e.format(r,i,t)}}const Ar=Pt(w2).setParameterLength(1,2),E2=s=>(s?Uf(s,Ar("discard")):Ar("discard")).toStack();q("discard",E2);class A2 extends mi{static get type(){return"RenderOutputNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=i,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;const i=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||nf,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Lu;return i!==nf&&(t=t.toneMapping(i)),r!==Lu&&r!==si.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const N2=(s,e=null,t=null)=>new A2(Fe(s),e,t);q("renderOutput",N2);class C2 extends mi{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,i=this.node.build(e);if(t!==null)t(e,i);else{const r="--- TSL debug - "+e.shaderStage+" shader ---",n="-".repeat(r.length);let a="";a+="// #"+r+`#
|
|
4073
|
+
`);return e.format(c,i,t)}}const Of=Pt(jI).setParameterLength(2,3);q("select",Of);class w_ extends ze{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const i=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(i),r}}const po=(s=null,e={})=>{let t=s;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new w_(t,e)},XI=s=>po(s,{uniformFlow:!0}),E_=(s,e)=>po(s,{nodeName:e});function qI(s,e,t=null){return po(t,{getShadow:({light:i,shadowColorNode:r})=>e===i?r.mul(s):r})}function YI(s,e=null){return po(e,{getAO:(t,{material:i})=>i.transparent===!0?t:t!==null?t.mul(s):s})}function ZI(s,e){return st('TSL: "label()" has been deprecated. Use "setName()" instead.'),E_(s,e)}q("context",po),q("label",ZI),q("uniformFlow",XI),q("setName",E_),q("builtinShadowContext",(s,e,t)=>qI(e,t,s)),q("builtinAOContext",(s,e)=>YI(e,s));class JI extends ze{static get type(){return"VarNode"}constructor(e,t=null,i=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=i,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let i=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){const n=t.getDataFromNode(this);n.forceDeclaration=!0,i=!0}const r=t.getBaseStack();i?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:i,readOnly:r}=this,{renderer:n}=e,a=n.backend.isWebGPUBackend===!0;let o=!1,l=!1;r&&(o=e.isDeterministic(t),l=a?r:o);const h=this.getNodeType(e);if(h=="void")return this.isIntent(e)!==!0&&Tt('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);const c=e.getVectorType(h),d=t.build(e,c),u=e.getVarFromNode(this,i,c,void 0,l),p=e.getPropertyName(u);let m=p;if(l)if(a)m=o?`const ${p}`:`let ${p}`;else{const y=t.getArrayCount(e);m=`const ${e.getVar(u.type,p,y)}`}return e.addLineFlowCode(`${m} = ${d}`,this),p}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const Uf=Pt(JI),KI=(s,e=null)=>Uf(s,e).toStack(),$I=(s,e=null)=>Uf(s,e,!0).toStack(),QI=s=>Uf(s).setIntent(!0).toStack();q("toVar",KI),q("toConst",$I),q("toVarIntent",QI);class e2 extends ze{static get type(){return"SubBuild"}constructor(e,t,i=null){super(i),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const i=this.node.build(e,...t);return e.removeSubBuild(),i}}const dh=(s,e,t=null)=>new e2(Fe(s),e,t);class t2 extends ze{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=dh(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let i=t.varying;if(i===void 0){const r=this.name,n=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=i=e.getVaryingFromNode(this,r,n,a,o),t.node=dh(this.node,"VERTEX")}return i.needsInterpolation||(i.needsInterpolation=e.shaderStage==="fragment"),i}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Iu.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Iu.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),i=e.getNodeProperties(this),r=this.setupVarying(e);if(i[t]===void 0){const n=this.getNodeType(e),a=e.getPropertyName(r,Iu.VERTEX);e.flowNodeFromShaderStage(Iu.VERTEX,i.node,n,a),i[t]=a}return e.getPropertyName(r)}}const mo=Pt(t2).setParameterLength(1,2),i2=s=>mo(s);q("toVarying",mo),q("toVertexStage",i2);const s2=xe(([s])=>{const e=s.mul(.9478672986).add(.0521327014).pow(2.4),t=s.mul(.0773993808),i=s.lessThanEqual(.04045);return Fi(e,t,i)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),r2=xe(([s])=>{const e=s.pow(.41666).mul(1.055).sub(.055),t=s.mul(12.92),i=s.lessThanEqual(.0031308);return Fi(e,t,i)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Ff="WorkingColorSpace",n2="OutputColorSpace";class A_ extends mi{static get type(){return"ColorSpaceNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.source=t,this.target=i}resolveColorSpace(e,t){return t===Ff?si.workingColorSpace:t===n2?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,i=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let n=t;return si.enabled===!1||i===r||!i||!r||(si.getTransfer(i)===$l&&(n=Ui(s2(n.rgb),n.a)),si.getPrimaries(i)!==si.getPrimaries(r)&&(n=Ui(ps(si._getMatrix(new xs,i,r)).mul(n.rgb),n.a)),si.getTransfer(r)===$l&&(n=Ui(r2(n.rgb),n.a))),n}}const a2=(s,e)=>new A_(Fe(s),Ff,e),N_=(s,e)=>new A_(Fe(s),e,Ff);q("workingToColorSpace",a2),q("colorSpaceToWorking",N_);let o2=class extends ho{static get type(){return"ReferenceElementNode"}constructor(s,e){super(s,e),this.referenceNode=s,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(s){const e=super.generate(s),t=this.referenceNode.getNodeType(),i=this.getNodeType();return s.format(e,t,i)}};class l2 extends ze{static get type(){return"ReferenceBaseNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=ht.OBJECT}setGroup(e){return this.group=e,this}element(e){return new o2(this,Fe(e))}setNodeType(e){const t=dt(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}class h2 extends l2{static get type(){return"RendererReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.renderer=i,this.setGroup(it)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const c2=(s,e,t=null)=>new h2(s,e,t);class u2 extends mi{static get type(){return"ToneMappingNode"}constructor(e,t=p2,i=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=i}customCacheKey(){return Kv(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,i=this._toneMapping;if(i===rf)return t;let r=null;const n=e.renderer.library.getToneMappingFunction(i);return n!==null?r=Ui(n(t.rgb,this.exposureNode),t.a):(Tt("ToneMappingNode: Unsupported Tone Mapping configuration.",i),r=t),r}}const d2=(s,e,t)=>new u2(s,Fe(e),Fe(t)),p2=c2("toneMappingExposure","float");q("toneMapping",(s,e,t)=>d2(e,t,s));const $t=new H,qu=new Vt;let m2=0;class nn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:m2++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=so,this.updateRanges=[],this.gpuType=Ov,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,n=this.itemSize;r<n;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)qu.fromBufferAttribute(this,t),qu.applyMatrix3(e),this.setXY(t,qu.x,qu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)$t.fromBufferAttribute(this,t),$t.applyMatrix3(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)$t.fromBufferAttribute(this,t),$t.applyMatrix4(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$t.fromBufferAttribute(this,t),$t.applyNormalMatrix(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$t.fromBufferAttribute(this,t),$t.transformDirection(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Ls(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=St(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ls(t,this.array)),t}setX(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ls(t,this.array)),t}setY(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ls(t,this.array)),t}setZ(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ls(t,this.array)),t}setW(e,t){return this.normalized&&(t=St(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),i=St(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),i=St(i,this.array),r=St(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e*=this.itemSize,this.normalized&&(t=St(t,this.array),i=St(i,this.array),r=St(r,this.array),n=St(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==so&&(e.usage=this.usage),e}}class f2 extends nn{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class g2 extends nn{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class zf extends nn{constructor(e,t,i){super(new Float32Array(e),t,i)}}const zi=new H;class Lg{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)zi.fromBufferAttribute(this,t),zi.applyMatrix4(e),this.setXYZ(t,zi.x,zi.y,zi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)zi.fromBufferAttribute(this,t),zi.applyNormalMatrix(e),this.setXYZ(t,zi.x,zi.y,zi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)zi.fromBufferAttribute(this,t),zi.transformDirection(e),this.setXYZ(t,zi.x,zi.y,zi.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Ls(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=St(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=St(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ls(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ls(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ls(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ls(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),i=St(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),i=St(i,this.array),r=St(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=St(t,this.array),i=St(i,this.array),r=St(r,this.array),n=St(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}clone(e){if(e===void 0){df("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return new nn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Lg(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){df("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class C_{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=so,this.updateRanges=[],this.version=0,this.uuid=wr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,n=this.stride;r<n;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=wr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=wr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const R_=new WeakMap;function I_(s,e){let t=R_.get(s);return t===void 0&&(t=new C_(s,e),R_.set(s,t)),t}class an extends _f{static get type(){return"BufferAttributeNode"}constructor(e,t=null,i=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=i,this.bufferOffset=r,this.usage=so,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),i=e.getTypeLength(t),r=this.value,n=this.bufferStride||i,a=this.bufferOffset;let o;r.isInterleavedBuffer===!0?o=r:r.isBufferAttribute===!0?o=I_(r.array,n):o=I_(r,n);const l=new Lg(o,i,a);o.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),i=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(i);let n=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,n=r):n=mo(this).build(e,t),n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function Bf(s,e=null,t=0,i=0,r=so,n=!1){return e==="mat3"||e===null&&s.itemSize===9?ps(new an(s,"vec3",9,0).setUsage(r).setInstanced(n),new an(s,"vec3",9,3).setUsage(r).setInstanced(n),new an(s,"vec3",9,6).setUsage(r).setInstanced(n)):e==="mat4"||e===null&&s.itemSize===16?Gu(new an(s,"vec4",16,0).setUsage(r).setInstanced(n),new an(s,"vec4",16,4).setUsage(r).setInstanced(n),new an(s,"vec4",16,8).setUsage(r).setInstanced(n),new an(s,"vec4",16,12).setUsage(r).setInstanced(n)):new an(s,e,t,i).setUsage(r)}const P_=(s,e=null,t=0,i=0)=>Bf(s,e,t,i),L_=(s,e=null,t=0,i=0)=>Bf(s,e,t,i,so,!0),D_=(s,e=null,t=0,i=0)=>Bf(s,e,t,i,uf,!0);q("toAttribute",s=>P_(s.value));class y2 extends ze{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=ht.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return st('TSL: "label()" has been deprecated. Use "setName()" instead.',new us),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){const i=e.getNodeProperties(this);i.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:i}=e;if(i==="compute"){const r=this.computeNode.build(e,"void");r!==""&&e.addLineFlowCode(r,this)}else{const r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}const O_=(s,e=[64])=>{(e.length===0||e.length>3)&&Tt("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new us);for(let t=0;t<e.length;t++){const i=e[t];(typeof i!="number"||i<=0||!Number.isInteger(i))&&Tt(`TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`,new us)}for(;e.length<3;)e.push(1);return new y2(Fe(s),e)},x2=(s,e,t)=>O_(s,t).setCount(e);q("compute",x2),q("computeKernel",O_);class v2 extends ze{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){const t=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const i=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const n=this.node.build(e,...t);return e.setCache(i),n}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const U_=s=>new v2(Fe(s));function _2(s,e=!0){return st('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),U_(s).setParent(e)}q("cache",_2),q("isolate",U_);class M2 extends ze{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const b2=Pt(M2).setParameterLength(2);q("bypass",b2);class F_ extends ze{static get type(){return"RemapNode"}constructor(e,t,i,r=ke(0),n=ke(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=i,this.outLowNode=r,this.outHighNode=n,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:i,outLowNode:r,outHighNode:n,doClamp:a}=this;let o=e.sub(t).div(i.sub(t));return a===!0&&(o=o.clamp()),o.mul(n.sub(r)).add(r)}}const S2=Pt(F_,null,null,{doClamp:!1}).setParameterLength(3,5),T2=Pt(F_).setParameterLength(3,5);q("remap",S2),q("remapClamp",T2);class w2 extends ze{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const i=this.getNodeType(e),r=this.snippet;if(i==="void")e.addLineFlowCode(r,this);else return e.format(r,i,t)}}const Ar=Pt(w2).setParameterLength(1,2),E2=s=>(s?Of(s,Ar("discard")):Ar("discard")).toStack();q("discard",E2);class A2 extends mi{static get type(){return"RenderOutputNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=i,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;const i=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||rf,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Lu;return i!==rf&&(t=t.toneMapping(i)),r!==Lu&&r!==si.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const N2=(s,e=null,t=null)=>new A2(Fe(s),e,t);q("renderOutput",N2);class C2 extends mi{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,i=this.node.build(e);if(t!==null)t(e,i);else{const r="--- TSL debug - "+e.shaderStage+" shader ---",n="-".repeat(r.length);let a="";a+="// #"+r+`#
|
|
4074
4074
|
`,a+=e.flow.code.replace(/^\t/mg,"")+`
|
|
4075
4075
|
`,a+="/* ... */ "+i+` /* ... */
|
|
4076
4076
|
`,a+="// #"+n+`#
|
|
4077
|
-
`,pf(a)}return i}}const R2=(s,e=null)=>new C2(Fe(s),e).toStack();q("debug",R2);class I2{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class P2 extends ze{static get type(){return"InspectorNode"}constructor(e,t="",i=null){super(),this.node=e,this.name=t,this.callback=i,this.updateType=ht.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==I2&&so('TSL: ".toInspector()" is only available with WebGPU.'),t}}function L2(s,e="",t=null){return s=Fe(s),s.before(new P2(s,e,t))}q("toInspector",L2);class z_ extends ze{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const i=this.getAttributeName(e);if(e.hasGeometryAttribute(i)){const r=e.geometry.getAttribute(i);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),i=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const r=e.geometry.getAttribute(t),n=e.getTypeFromAttribute(r),a=e.getAttribute(t,n);return e.shaderStage==="vertex"?e.format(a.name,n,i):po(this).build(e,i)}else return st(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(i)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const mo=(s,e=null)=>new z_(s,e);class kf extends sh{static get type(){return"BufferNode"}constructor(e,t,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=i,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const B_=(s,e,t)=>new kf(s,e,t);class D2 extends lo{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),i=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,i)}}class O2 extends kf{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Fu(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ht.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,i=this.elementType;if(i==="float"||i==="int"||i==="uint")for(let r=0;r<e.length;r++){const n=r*4;t[n]=e[r]}else if(i==="color")for(let r=0;r<e.length;r++){const n=r*4,a=e[r];t[n]=a.r,t[n+1]=a.g,t[n+2]=a.b||0}else if(i==="mat2")for(let r=0;r<e.length;r++){const n=r*4,a=e[r];t[n]=a.elements[0],t[n+1]=a.elements[1],t[n+2]=a.elements[2],t[n+3]=a.elements[3]}else if(i==="mat3")for(let r=0;r<e.length;r++){const n=r*16,a=e[r];t[n]=a.elements[0],t[n+1]=a.elements[1],t[n+2]=a.elements[2],t[n+4]=a.elements[3],t[n+5]=a.elements[4],t[n+6]=a.elements[5],t[n+8]=a.elements[6],t[n+9]=a.elements[7],t[n+10]=a.elements[8],t[n+15]=1}else if(i==="mat4")for(let r=0;r<e.length;r++){const n=r*16,a=e[r];for(let o=0;o<a.elements.length;o++)t[n+o]=a.elements[o]}else for(let r=0;r<e.length;r++){const n=r*4,a=e[r];t[n]=a.x,t[n+1]=a.y,t[n+2]=a.z||0,t[n+3]=a.w||0}}setup(e){const t=this.array.length,i=this.elementType;let r=Float32Array;const n=this.paddedType,a=e.getTypeLength(n);return i.charAt(0)==="i"&&(r=Int32Array),i.charAt(0)==="u"&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=n,this.update(),super.setup(e)}element(e){return new D2(this,Fe(e))}}const sr=(s,e)=>new O2(s,e);class U2 extends ze{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Yu=Pt(U2).setParameterLength(1);let ph,mh;class Dt extends ze{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Dt.DPR?"float":this.scope===Dt.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=ht.NONE;return(this.scope===Dt.SIZE||this.scope===Dt.VIEWPORT||this.scope===Dt.DPR)&&(e=ht.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Dt.VIEWPORT?t!==null?mh.copy(t.viewport):(e.getViewport(mh),mh.multiplyScalar(e.getPixelRatio())):this.scope===Dt.DPR?this._output.value=e.getPixelRatio():t!==null?(ph.width=t.width,ph.height=t.height):e.getDrawingBufferSize(ph)}setup(){const e=this.scope;let t=null;return e===Dt.SIZE?t=dt(ph||(ph=new Vt)):e===Dt.VIEWPORT?t=dt(mh||(mh=new Ai)):e===Dt.DPR?t=dt(1):t=xt(fh.div(V_)),this._output=t,t}generate(e){if(this.scope===Dt.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(V_).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${i}.y - ${t}.y )`}return t}return super.generate(e)}}Dt.COORDINATE="coordinate",Dt.VIEWPORT="viewport",Dt.SIZE="size",Dt.UV="uv",Dt.DPR="dpr";const Gf=Kt(Dt,Dt.UV),V_=Kt(Dt,Dt.SIZE),fh=Kt(Dt,Dt.COORDINATE),k_=Kt(Dt,Dt.VIEWPORT);k_.zw,k_.xy;let Hf=null,Zu=null,Wf=null,Ju=null,jf=null,Ku=null;const Xf=dt(0,"uint").setName("u_cameraIndex").setGroup(m_("cameraIndex")).toVarying("v_cameraIndex"),Jn=dt("float").setName("cameraNear").setGroup(it).onRenderUpdate(({camera:s})=>s.near),Kn=dt("float").setName("cameraFar").setGroup(it).onRenderUpdate(({camera:s})=>s.far),F2=xe(({camera:s})=>{let e;if(s.isArrayCamera&&s.cameras.length>0){const t=[];for(const i of s.cameras)t.push(i.projectionMatrix);Zu===null?Zu=sr(t).setGroup(it).setName("cameraProjectionMatrices"):Zu.array=t,e=Zu.element(s.isMultiViewCamera?Yu("gl_ViewID_OVR"):Xf).toConst("cameraProjectionMatrix")}else Hf===null&&(Hf=dt(s.projectionMatrix).setName("cameraProjectionMatrix").setGroup(it).onRenderUpdate(({camera:t})=>t.projectionMatrix)),e=Hf;return e}).once()(),z2=xe(({camera:s})=>{let e;if(s.isArrayCamera&&s.cameras.length>0){const t=[];for(const i of s.cameras)t.push(i.projectionMatrixInverse);Ju===null?Ju=sr(t).setGroup(it).setName("cameraProjectionMatricesInverse"):Ju.array=t,e=Ju.element(s.isMultiViewCamera?Yu("gl_ViewID_OVR"):Xf).toConst("cameraProjectionMatrixInverse")}else Wf===null&&(Wf=dt(s.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(it).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse)),e=Wf;return e}).once()(),fo=xe(({camera:s})=>{let e;if(s.isArrayCamera&&s.cameras.length>0){const t=[];for(const i of s.cameras)t.push(i.matrixWorldInverse);Ku===null?Ku=sr(t).setGroup(it).setName("cameraViewMatrices"):Ku.array=t,e=Ku.element(s.isMultiViewCamera?Yu("gl_ViewID_OVR"):Xf).toConst("cameraViewMatrix")}else jf===null&&(jf=dt(s.matrixWorldInverse).setName("cameraViewMatrix").setGroup(it).onRenderUpdate(({camera:t})=>t.matrixWorldInverse)),e=jf;return e}).once()();class gh{constructor(e=new H(1/0,1/0,1/0),t=new H(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Us.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Us.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Us.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const n=i.getAttribute("position");if(t===!0&&n!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=n.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Us):Us.fromBufferAttribute(n,a),Us.applyMatrix4(e.matrixWorld),this.expandByPoint(Us);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),$u.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),$u.copy(i.boundingBox)),$u.applyMatrix4(e.matrixWorld),this.union($u)}const r=e.children;for(let n=0,a=r.length;n<a;n++)this.expandByObject(r[n],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Us),Us.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yh),Qu.subVectors(this.max,yh),go.subVectors(e.a,yh),yo.subVectors(e.b,yh),xo.subVectors(e.c,yh),on.subVectors(yo,go),ln.subVectors(xo,yo),$n.subVectors(go,xo);let t=[0,-on.z,on.y,0,-ln.z,ln.y,0,-$n.z,$n.y,on.z,0,-on.x,ln.z,0,-ln.x,$n.z,0,-$n.x,-on.y,on.x,0,-ln.y,ln.x,0,-$n.y,$n.x,0];return!qf(t,go,yo,xo,Qu)||(t=[1,0,0,0,1,0,0,0,1],!qf(t,go,yo,xo,Qu))?!1:(ed.crossVectors(on,ln),t=[ed.x,ed.y,ed.z],qf(t,go,yo,xo,Qu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Us).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Us).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Nr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Nr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Nr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Nr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Nr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Nr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Nr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Nr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Nr),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Nr=[new H,new H,new H,new H,new H,new H,new H,new H],Us=new H,$u=new gh,go=new H,yo=new H,xo=new H,on=new H,ln=new H,$n=new H,yh=new H,Qu=new H,ed=new H,Qn=new H;function qf(s,e,t,i,r){for(let n=0,a=s.length-3;n<=a;n+=3){Qn.fromArray(s,n);const o=r.x*Math.abs(Qn.x)+r.y*Math.abs(Qn.y)+r.z*Math.abs(Qn.z),l=e.dot(Qn),h=t.dot(Qn),c=i.dot(Qn);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}const B2=new gh,xh=new H,Yf=new H;class td{constructor(e=new H,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):B2.setFromPoints(e).getCenter(i);let r=0;for(let n=0,a=e.length;n<a;n++)r=Math.max(r,i.distanceToSquared(e[n]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;xh.subVectors(e,this.center);const t=xh.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(xh,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Yf.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xh.copy(e.center).add(Yf)),this.expandByPoint(xh.copy(e.center).sub(Yf))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const G_=new td;class Lt extends ze{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ht.OBJECT,this.uniformNode=new sh(null)}getNodeType(){const e=this.scope;if(e===Lt.WORLD_MATRIX)return"mat4";if(e===Lt.POSITION||e===Lt.VIEW_POSITION||e===Lt.DIRECTION||e===Lt.SCALE)return"vec3";if(e===Lt.RADIUS)return"float"}update(e){const t=this.object3d,i=this.uniformNode,r=this.scope;if(r===Lt.WORLD_MATRIX)i.value=t.matrixWorld;else if(r===Lt.POSITION)i.value=i.value||new H,i.value.setFromMatrixPosition(t.matrixWorld);else if(r===Lt.SCALE)i.value=i.value||new H,i.value.setFromMatrixScale(t.matrixWorld);else if(r===Lt.DIRECTION)i.value=i.value||new H,t.getWorldDirection(i.value);else if(r===Lt.VIEW_POSITION){const n=e.camera;i.value=i.value||new H,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(n.matrixWorldInverse)}else if(r===Lt.RADIUS){const n=e.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),G_.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),i.value=G_.radius}}generate(e){const t=this.scope;return t===Lt.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Lt.POSITION||t===Lt.VIEW_POSITION||t===Lt.DIRECTION||t===Lt.SCALE?this.uniformNode.nodeType="vec3":t===Lt.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Lt.WORLD_MATRIX="worldMatrix",Lt.POSITION="position",Lt.SCALE="scale",Lt.VIEW_POSITION="viewPosition",Lt.DIRECTION="direction",Lt.RADIUS="radius";class H_ extends Lt{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Zf=Kt(H_,H_.WORLD_MATRIX),V2=dt(new xs).onObjectUpdate(({object:s},e)=>e.value.getNormalMatrix(s.matrixWorld)),W_=xe(s=>s.context.modelViewMatrix||k2).once()().toVar("modelViewMatrix_2"),k2=fo.mul(Zf),G2=xe(s=>s.shaderStage!=="fragment"?(so("TSL: `clipSpace` is only available in fragment stage."),Ui()):s.context.clipSpace.toVarying("v_clipSpace")).once()(),j_=mo("position","vec3"),Wi=j_.toVarying("positionLocal"),id=j_.toVarying("positionPrevious"),Jf=xe(s=>Zf.mul(Wi).xyz.toVarying(s.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),hi=xe(s=>{if(s.shaderStage==="fragment"&&s.material.vertexNode){const e=z2.mul(G2);return e.xyz.div(e.w).toVar("positionView")}return s.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),X_=xe(s=>{let e;return s.camera.isOrthographicCamera?e=Re(0,0,1):e=hi.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class H2 extends ze{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===rf?"false":e.getFrontFacing()}}const W2=Kt(H2),q_=ke(W2).mul(2).sub(1),sd=xe(([s],{material:e})=>{const t=e.side;return t===rf?s=s.mul(-1):t===pC&&(s=s.mul(q_)),s}),j2=mo("normal","vec3"),rr=xe(s=>s.geometry.hasAttribute("normal")===!1?(st('TSL: Vertex attribute "normal" not found on geometry.'),Re(0,1,0)):j2,"vec3").once()().toVar("normalLocal"),X2=hi.dFdx().cross(hi.dFdy()).normalize().toVar("normalFlat"),q2=xe(s=>{let e;return s.isFlatShading()?e=X2:e=Y_(rr).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),ms=xe(s=>{let e;return s.subBuildFn==="NORMAL"||s.subBuildFn==="VERTEX"?(e=q2,s.isFlatShading()!==!0&&(e=sd(e))):e=s.context.setupNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),rd=ms.transformDirection(fo).toVar("normalWorld"),Y2=xe(({subBuildFn:s,context:e})=>{let t;return s==="NORMAL"||s==="VERTEX"?t=ms:t=e.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),Z2=xe(([s,e=Zf])=>{const t=ps(e),i=s.div(Re(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(i).xyz}),Y_=xe(([s],e)=>{const t=e.context.modelNormalViewMatrix;if(t)return t.transformDirection(s);const i=V2.mul(s);return fo.transformDirection(i)});xe(()=>(st('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),ms)).once(["NORMAL","VERTEX"])(),xe(()=>(st('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),rd)).once(["NORMAL","VERTEX"])(),xe(()=>(st('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Y2)).once(["NORMAL","VERTEX"])();class J2{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(e,t){let i=e.get(t);return i===void 0&&(i={renderId:0,frameId:0},e.set(t,i)),i}updateBeforeNode(e){const t=e.getUpdateBeforeType(),i=e.updateReference(this);if(t===ht.FRAME){const r=this._getMaps(this.updateBeforeMap,i);if(r.frameId!==this.frameId){const n=r.frameId;r.frameId=this.frameId,e.updateBefore(this)===!1&&(r.frameId=n)}}else if(t===ht.RENDER){const r=this._getMaps(this.updateBeforeMap,i);if(r.renderId!==this.renderId){const n=r.renderId;r.renderId=this.renderId,e.updateBefore(this)===!1&&(r.renderId=n)}}else t===ht.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),i=e.updateReference(this);if(t===ht.FRAME){const r=this._getMaps(this.updateAfterMap,i);r.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(r.frameId=this.frameId)}else if(t===ht.RENDER){const r=this._getMaps(this.updateAfterMap,i);r.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(r.renderId=this.renderId)}else t===ht.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),i=e.updateReference(this);if(t===ht.FRAME){const r=this._getMaps(this.updateMap,i);r.frameId!==this.frameId&&e.update(this)!==!1&&(r.frameId=this.frameId)}else if(t===ht.RENDER){const r=this._getMaps(this.updateMap,i);r.renderId!==this.renderId&&e.update(this)!==!1&&(r.renderId=this.renderId)}else t===ht.OBJECT&&e.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 K2=0;class Kf extends oo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:K2++}),this.uuid=wr(),this.name="",this.type="Material",this.blending=wv,this.side=sf,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Av,this.blendDst=Nv,this.blendEquation=Ev,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ds(0,0,0),this.blendAlpha=0,this.depthFunc=Cv,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Bv,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=to,this.stencilZFail=to,this.stencilZPass=to,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){st(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){st(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==wv&&(i.blending=this.blending),this.side!==sf&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Av&&(i.blendSrc=this.blendSrc),this.blendDst!==Nv&&(i.blendDst=this.blendDst),this.blendEquation!==Ev&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Cv&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Bv&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==to&&(i.stencilFail=this.stencilFail),this.stencilZFail!==to&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==to&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(n){const a=[];for(const o in n){const l=n[o];delete l.metadata,a.push(l)}return a}if(t){const n=r(e.textures),a=r(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const nd=(s=0)=>mo("uv"+(s>0?s:""),"vec2");class $2 extends ze{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const i=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${i}, ${r} )`,this.getNodeType(e),t)}}const vo=Pt($2).setParameterLength(1,2);class Q2 extends sh{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=ht.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,i=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(i&&i.width!==void 0){const{width:r,height:n}=i;this.value=Math.log2(Math.max(r,n))}}}const eP=Pt(Q2).setParameterLength(1);let _o;class tP{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{_o===void 0&&(_o=Gv("canvas")),_o.width=e.width,_o.height=e.height;const r=_o.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=_o}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Gv("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),n=r.data;for(let a=0;a<n.length;a++)n[a]=Er(n[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Er(t[i]/255)*255):t[i]=Er(t[i]);return{data:t,width:e.width,height:e.height}}else return st("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let iP=0;class $f{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:iP++}),this.uuid=wr(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let n;if(Array.isArray(r)){n=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?n.push(Qf(r[a].image)):n.push(Qf(r[a]))}else n=Qf(r);i.url=n}return t||(e.images[this.uuid]=i),i}}function Qf(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?tP.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(st("Texture: Unable to serialize Texture."),{})}let sP=0;const eg=new H;class ss extends oo{constructor(e=ss.DEFAULT_IMAGE,t=ss.DEFAULT_MAPPING,i=Yl,r=Yl,n=Zl,a=Lv,o=TC,l=Dv,h=ss.DEFAULT_ANISOTROPY,c=Lu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:sP++}),this.uuid=wr(),this.name="",this.source=new $f(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Vt(0,0),this.repeat=new Vt(1,1),this.center=new Vt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xs,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(eg).x}get height(){return this.source.getSize(eg).y}get depth(){return this.source.getSize(eg).z}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){st(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){st(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Rv)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Iv:e.x=e.x-Math.floor(e.x);break;case Yl:e.x=e.x<0?0:1;break;case Pv:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Iv:e.y=e.y-Math.floor(e.y);break;case Yl:e.y=e.y<0?0:1;break;case Pv:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ss.DEFAULT_IMAGE=null,ss.DEFAULT_MAPPING=Rv,ss.DEFAULT_ANISOTROPY=4;class rP extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const Z_=new ss;class ad extends sh{static get type(){return"TextureNode"}constructor(e=Z_,t=null,i=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=i,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ht.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}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===of?"uvec4":this.value.type===SC?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return nd(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=dt(this.value.matrix)),this._matrixUniform.mul(Re(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=dt(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(zt(vo(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const i=this.value;if(!i||i.isTexture!==!0)throw new rP("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const r=xe(()=>{let l=this.uvNode;return(l===null||e.context.forceUVContext===!0)&&e.context.getUV&&(l=e.context.getUV(this,e)),l||(l=this.getDefaultUV()),this.updateMatrix===!0&&(l=this.getTransformedUV(l)),l=this.setupUV(e,l),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?ht.OBJECT:ht.NONE,l})();let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(kv.TEXTURE_COMPARE))a=this.compareNode;else{const l=i.compareFunction;l===null||l===RC||l===uf||l===Vv||l===Du?o=this.compareNode:(a=this.compareNode,so('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=r,t.levelNode=n,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,i,r,n,a,o,l,h){const c=this.value;let d;return n?d=e.generateTextureBias(c,t,i,n,a,h):l?d=e.generateTextureGrad(c,t,i,l,a,h):o?d=e.generateTextureCompare(c,t,i,o,a,h):this.sampler===!1?d=e.generateTextureLoad(c,t,i,r,a,h):r?d=e.generateTextureLevel(c,t,i,r,a,h):d=e.generateTexture(c,t,i,a,h),d}generate(e,t){const i=this.value,r=e.getNodeProperties(this),n=super.generate(e,"property");if(/^sampler/.test(t))return n+"_sampler";if(e.isReference(t))return n;{const a=e.getDataFromNode(this),o=this.getNodeType(e);let l=a.propertyName;if(l===void 0){const{uvNode:c,levelNode:d,biasNode:u,compareNode:p,compareStepNode:m,depthNode:y,gradNode:g,offsetNode:f}=r,x=this.generateUV(e,c),v=d?d.build(e,"float"):null,M=u?u.build(e,"float"):null,w=y?y.build(e,"int"):null,T=p?p.build(e,"float"):null,A=m?m.build(e,"float"):null,_=g?[g[0].build(e,"vec2"),g[1].build(e,"vec2")]:null,S=f?this.generateOffset(e,f):null,P=e.getVarFromNode(this);l=e.getPropertyName(P);let C=this.generateSnippet(e,n,x,v,M,w,T,_,S);if(A!==null){const L=i.compareFunction;L===Vv||L===Du?C=hh(Ar(C,o),Ar(A,"float")).build(e,o):C=hh(Ar(A,"float"),Ar(C,o)).build(e,o)}e.addLineFlowCode(`${l} = ${C}`,this),a.snippet=C,a.propertyName=l}let h=l;return e.needsToWorkingColorSpace(i)&&(h=N_(Ar(h,o),i.colorSpace).setup(e).build(e,o)),e.format(h,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=Fe(e).mul(eP(t)),t.referenceNode=this.getBase();const i=t.value;return t.generateMipmaps===!1&&(i&&i.generateMipmaps===!1||i.minFilter===cs||i.magFilter===cs)&&(st("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Fe(t)}level(e){const t=this.clone();return t.levelNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}size(e){return vo(this,e)}bias(e){const t=this.clone();return t.biasNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}grad(e,t){const i=this.clone();return i.gradNode=[Fe(e),Fe(t)],i.referenceNode=this.getBase(),Fe(i)}depth(e){const t=this.clone();return t.depthNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}offset(e){const t=this.clone();return t.offsetNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();const i=this._flipYUniform;i!==null&&(i.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}const nP=Pt(ad).setParameterLength(1,4).setName("texture"),gi=(s=Z_,e=null,t=null,i=null)=>{let r;return s&&s.isTextureNode===!0?(r=Fe(s.clone()),r.referenceNode=s.getBase(),e!==null&&(r.uvNode=Fe(e)),t!==null&&(r.levelNode=Fe(t)),i!==null&&(r.biasNode=Fe(i))):r=nP(s,e,t,i),r},fs=(...s)=>gi(...s).setSampler(!1),J_=new kt,K_=new no;class Lo{constructor(e=0,t=0,i=0,r=Lo.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,n=r[0],a=r[4],o=r[8],l=r[1],h=r[5],c=r[9],d=r[2],u=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(ft(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ft(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-d,n),this._z=0);break;case"ZXY":this._x=Math.asin(ft(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-ft(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(ft(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-d,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-ft(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-c,p),this._y=0);break;default:st("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return J_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(J_,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return K_.setFromEuler(this),this.setFromQuaternion(K_,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Lo.DEFAULT_ORDER="XYZ";const $_=new Lo,tg=new kt,aP=dt(0).onReference(({material:s})=>s).onObjectUpdate(({material:s})=>s.refractionRatio),oP=dt(new kt).onReference(function(s){return s.material}).onObjectUpdate(function({material:s,scene:e}){const t=e.environment!==null&&s.envMap===null?e.environmentRotation:s.envMapRotation;return t?($_.copy(t),tg.makeRotationFromEuler($_)):tg.identity(),tg}),lP=X_.negate().reflect(ms),hP=X_.negate().refract(ms,aP),cP=lP.transformDirection(fo).toVar("reflectVector"),uP=hP.transformDirection(fo).toVar("reflectVector");class dP extends ss{constructor(e=[],t=af,i,r,n,a,o,l,h,c){super(e,t,i,r,n,a,o,l,h,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}const pP=new dP;class mP extends ad{static get type(){return"CubeTextureNode"}constructor(e,t=null,i=null,r=null){super(e,t,i,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===af?cP:e.mapping===bC?uP:(Tt('CubeTextureNode: Mapping "%s" not supported.',e.mapping),Re(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const i=this.value;return i.isDepthTexture===!0?e.renderer.coordinateSystem===tn?Re(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===tn||!i.isRenderTargetTexture)&&(t=Re(t.x.negate(),t.yz)),oP.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const fP=Pt(mP).setParameterLength(1,4).setName("cubeTexture"),nr=(s=pP,e=null,t=null,i=null)=>{let r;return s&&s.isCubeTextureNode===!0?(r=Fe(s.clone()),r.referenceNode=s,e!==null&&(r.uvNode=Fe(e)),t!==null&&(r.levelNode=Fe(t)),i!==null&&(r.biasNode=Fe(i))):r=fP(s,e,t,i),r};class gP extends lo{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),i=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,i,r)}}class ig extends ze{static get type(){return"ReferenceNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=ht.OBJECT}element(e){return new gP(this,Fe(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return st('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=B_(null,e,this.count):Array.isArray(this.getValueFromReference())?t=sr(null,e):e==="texture"?t=gi(null):e==="cubeTexture"?t=nr(null):t=dt(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const ri=(s,e,t)=>new ig(s,e,t),Q_=(s,e,t,i)=>new ig(s,e,i,t);class yP extends ig{static get type(){return"MaterialReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const Mo=(s,e,t=null)=>new yP(s,e,t),e1=nd(),xP=hi.dFdx(),vP=hi.dFdy(),t1=e1.dFdx(),i1=e1.dFdy(),s1=ms,r1=vP.cross(s1),n1=s1.cross(xP),sg=r1.mul(t1.x).add(n1.mul(i1.x)),rg=r1.mul(t1.y).add(n1.mul(i1.y)),a1=sg.dot(sg).max(rg.dot(rg)),o1=a1.equal(0).select(0,a1.inverseSqrt()),_P=sg.mul(o1).toVar("tangentViewFrame"),MP=rg.mul(o1).toVar("bitangentViewFrame"),l1=mo("tangent","vec4"),od=l1.xyz.toVar("tangentLocal"),h1=xe(s=>{let e;return s.subBuildFn==="VERTEX"||s.geometry.hasAttribute("tangent")?e=W_.mul(Ui(od,0)).xyz.toVarying("v_tangentView").normalize():e=_P,s.isFlatShading()!==!0&&(e=sd(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),bP=xe(([s,e],t)=>{let i=s.mul(l1.w).xyz;return t.subBuildFn==="NORMAL"&&t.isFlatShading()!==!0&&(i=i.toVarying(e)),i}).once(["NORMAL"]),SP=xe(s=>{let e;return s.subBuildFn==="VERTEX"||s.geometry.hasAttribute("tangent")?e=bP(ms.cross(h1),"v_bitangentView").normalize():e=MP,s.isFlatShading()!==!0&&(e=sd(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),TP=ps(h1,SP,ms).toVar("TBNViewMatrix"),c1=s=>Re(s,nh(Of(ke(1).sub(ch(s,s)))));class wP extends mi{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=hf,this.unpackNormalMode=cf}setup(e){const{normalMapType:t,scaleNode:i,unpackNormalMode:r}=this;let n=this.node.mul(2).sub(1);if(t===hf?r===zv?n=c1(n.xy):r===CC?n=c1(n.yw):r!==cf&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==cf&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),i!==null){let o=i;e.isFlatShading()===!0&&(o=sd(o)),n=Re(n.xy.mul(o),n.z)}let a=null;return t===NC?a=Y_(n):t===hf?a=TP.mul(n).normalize():(Tt(`NodeMaterial: Unsupported normal map type: ${t}`),a=ms),a}}const u1=Pt(wP).setParameterLength(1,2),EP=xe(({textureNode:s,bumpScale:e})=>{const t=r=>s.isolate().context({getUV:n=>r(n.uvNode||nd()),forceUVContext:!0}),i=ke(t(r=>r));return xt(ke(t(r=>r.add(r.dFdx()))).sub(i),ke(t(r=>r.add(r.dFdy()))).sub(i)).mul(e)}),AP=xe(s=>{const{surf_pos:e,surf_norm:t,dHdxy:i}=s,r=e.dFdx().normalize(),n=e.dFdy().normalize(),a=t,o=n.cross(a),l=a.cross(r),h=r.dot(o).mul(q_),c=h.sign().mul(i.x.mul(o).add(i.y.mul(l)));return h.abs().mul(t).sub(c).normalize()});class NP extends mi{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=EP({textureNode:this.textureNode,bumpScale:e});return AP({surf_pos:hi,surf_norm:ms,dHdxy:t})}}const CP=Pt(NP).setParameterLength(1,2),d1=new Map;class ve extends ze{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=d1.get(e);return i===void 0&&(i=Mo(e,t),d1.set(e,i)),i}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,i=this.scope;let r=null;if(i===ve.COLOR){const n=t.color!==void 0?this.getColor(i):Re();t.map&&t.map.isTexture===!0?r=n.mul(this.getTexture("map")):r=n}else if(i===ve.OPACITY){const n=this.getFloat(i);t.alphaMap&&t.alphaMap.isTexture===!0?r=n.mul(this.getTexture("alpha")):r=n}else if(i===ve.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=ke(1);else if(i===ve.SPECULAR_INTENSITY){const n=this.getFloat(i);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=n.mul(this.getTexture(i).a):r=n}else if(i===ve.SPECULAR_COLOR){const n=this.getColor(i);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=n.mul(this.getTexture(i).rgb):r=n}else if(i===ve.ROUGHNESS){const n=this.getFloat(i);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=n.mul(this.getTexture(i).g):r=n}else if(i===ve.METALNESS){const n=this.getFloat(i);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=n.mul(this.getTexture(i).b):r=n}else if(i===ve.EMISSIVE){const n=this.getFloat("emissiveIntensity"),a=this.getColor(i).mul(n);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(i)):r=a}else if(i===ve.NORMAL)t.normalMap?(r=u1(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType,(t.normalMap.format==Kl||t.normalMap.format==AC||t.normalMap.format==EC)&&(r.unpackNormalMode=zv)):t.bumpMap?r=CP(this.getTexture("bump").r,this.getFloat("bumpScale")):r=ms;else if(i===ve.CLEARCOAT){const n=this.getFloat(i);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=n.mul(this.getTexture(i).r):r=n}else if(i===ve.CLEARCOAT_ROUGHNESS){const n=this.getFloat(i);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=n.mul(this.getTexture(i).r):r=n}else if(i===ve.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=u1(this.getTexture(i),this.getCache(i+"Scale","vec2")):r=ms;else if(i===ve.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=n.mul(this.getTexture("sheenColor").rgb):r=n}else if(i===ve.SHEEN_ROUGHNESS){const n=this.getFloat(i);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=n.mul(this.getTexture(i).a):r=n,r=r.clamp(1e-4,1)}else if(i===ve.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const n=this.getTexture(i);r=u_(vh.x,vh.y,vh.y.negate(),vh.x).mul(n.rg.mul(2).sub(xt(1)).normalize().mul(n.b))}else r=vh;else if(i===ve.IRIDESCENCE_THICKNESS){const n=ri("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=ri("0","float",t.iridescenceThicknessRange);r=n.sub(a).mul(this.getTexture(i).g).add(a)}else r=n}else if(i===ve.TRANSMISSION){const n=this.getFloat(i);t.transmissionMap?r=n.mul(this.getTexture(i).r):r=n}else if(i===ve.THICKNESS){const n=this.getFloat(i);t.thicknessMap?r=n.mul(this.getTexture(i).g):r=n}else if(i===ve.IOR)r=this.getFloat(i);else if(i===ve.LIGHT_MAP)r=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===ve.AO)r=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(i===ve.LINE_DASH_OFFSET)r=t.dashOffset?this.getFloat(i):ke(0);else{const n=this.getNodeType(e);r=this.getCache(i,n)}return r}}ve.ALPHA_TEST="alphaTest",ve.COLOR="color",ve.OPACITY="opacity",ve.SHININESS="shininess",ve.SPECULAR="specular",ve.SPECULAR_STRENGTH="specularStrength",ve.SPECULAR_INTENSITY="specularIntensity",ve.SPECULAR_COLOR="specularColor",ve.REFLECTIVITY="reflectivity",ve.ROUGHNESS="roughness",ve.METALNESS="metalness",ve.NORMAL="normal",ve.CLEARCOAT="clearcoat",ve.CLEARCOAT_ROUGHNESS="clearcoatRoughness",ve.CLEARCOAT_NORMAL="clearcoatNormal",ve.EMISSIVE="emissive",ve.ROTATION="rotation",ve.SHEEN="sheen",ve.SHEEN_ROUGHNESS="sheenRoughness",ve.ANISOTROPY="anisotropy",ve.IRIDESCENCE="iridescence",ve.IRIDESCENCE_IOR="iridescenceIOR",ve.IRIDESCENCE_THICKNESS="iridescenceThickness",ve.IOR="ior",ve.TRANSMISSION="transmission",ve.THICKNESS="thickness",ve.ATTENUATION_DISTANCE="attenuationDistance",ve.ATTENUATION_COLOR="attenuationColor",ve.LINE_SCALE="scale",ve.LINE_DASH_SIZE="dashSize",ve.LINE_GAP_SIZE="gapSize",ve.LINE_WIDTH="linewidth",ve.LINE_DASH_OFFSET="dashOffset",ve.POINT_SIZE="size",ve.DISPERSION="dispersion",ve.LIGHT_MAP="light",ve.AO="ao";const RP=Kt(ve,ve.ALPHA_TEST),IP=Kt(ve,ve.COLOR),PP=Kt(ve,ve.EMISSIVE),LP=Kt(ve,ve.OPACITY),DP=Kt(ve,ve.NORMAL),OP=Kt(ve,ve.LIGHT_MAP),UP=Kt(ve,ve.AO),vh=dt(new Vt).onReference(function(s){return s.material}).onRenderUpdate(function({material:s}){this.value.set(s.anisotropy*Math.cos(s.anisotropyRotation),s.anisotropy*Math.sin(s.anisotropyRotation))}),FP=xe(s=>s.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class zP extends lo{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const i=this.storageBufferNode.structTypeNode;return i?i.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let i;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?i=e.generatePBO(this):i=this.node.build(e):i=super.generate(e),r!==!0){const n=this.getNodeType(e);i=e.format(i,n,t)}return i}}const BP=Pt(zP).setParameterLength(2);class VP extends kf{static get type(){return"StorageBufferNode"}constructor(e,t=null,i=0){let r,n=null;t&&t.isStruct?(r="struct",n=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(i=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=tR(e.itemSize),i=e.count):r=t,super(e,r,i),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=Tv.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return BP(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Tv.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=P_(this.value),this._varying=po(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:i}=this.getAttributeData(),r=i.build(e);return e.registerTransform(r,t),r}}const p1=(s,e=null,t=0)=>new VP(s,e,t);class ni extends ze{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),i=this.scope;let r;if(i===ni.VERTEX)r=e.getVertexIndex();else if(i===ni.INSTANCE)r=e.getInstanceIndex();else if(i===ni.DRAW)r=e.getDrawIndex();else if(i===ni.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(i===ni.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(i===ni.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+i);let n;return e.shaderStage==="vertex"||e.shaderStage==="compute"?n=r:n=po(this).build(e,t),n}}ni.VERTEX="vertex",ni.INSTANCE="instance",ni.SUBGROUP="subgroup",ni.INVOCATION_LOCAL="invocationLocal",ni.INVOCATION_SUBGROUP="invocationSubgroup",ni.DRAW="draw";const kP=Kt(ni,ni.VERTEX),_h=Kt(ni,ni.INSTANCE),GP=Kt(ni,ni.DRAW);class HP extends C_{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class WP extends nn{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}class jP extends ze{static get type(){return"InstanceNode"}constructor(e,t,i=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=i,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ht.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){const{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){let{instanceMatrixNode:t,instanceColorNode:i}=this;t===null&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);const{instanceColor:r,isStorageColor:n}=this;if(r&&i===null){if(n)i=p1(r,"vec3",Math.max(r.count,1)).element(_h);else{const o=new WP(r.array,3),l=r.usage===df?D_:L_;this.bufferColor=o,i=Re(l(o,"vec3",3,0))}this.instanceColorNode=i}const a=t.mul(Wi).xyz;if(Wi.assign(a),e.needsPreviousData()&&id.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){const o=Z2(rr,t);rr.assign(o)}this.instanceColorNode!==null&&Hu("vec3","vInstanceColor").assign(this.instanceColorNode)}update(e){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&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){const t=e.object;return this.previousInstanceMatrixNode===null&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(id).xyz}_createInstanceMatrixNode(e,t){let i;const{instanceMatrix:r}=this,{count:n}=r;if(this.isStorageMatrix)i=p1(r,"mat4",Math.max(n,1)).element(_h);else if(n*16*4<=t.getUniformBufferLimit())i=B_(r.array,"mat4",Math.max(n,1)).element(_h);else{const a=new HP(r.array,16,1);e===!0&&(this.buffer=a);const o=r.usage===df?D_:L_,l=[o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)];i=Gu(...l)}return i}}class XP extends jP{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:i,instanceColor:r}=e;super(t,i,r),this.instancedMesh=e}}const qP=Pt(XP).setParameterLength(1);class YP extends ze{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=_h:this.batchingIdNode=GP);const t=xe(([p])=>{const m=zt(vo(fs(this.batchMesh._indirectTexture),0).x).toConst(),y=zt(p).mod(m).toConst(),g=zt(p).div(m).toConst();return fs(this.batchMesh._indirectTexture,er(y,g)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(zt(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=zt(vo(fs(i),0).x).toConst(),n=ke(t).mul(4).toInt().toConst(),a=n.mod(r).toConst(),o=n.div(r).toConst(),l=Gu(fs(i,er(a,o)),fs(i,er(a.add(1),o)),fs(i,er(a.add(2),o)),fs(i,er(a.add(3),o))),h=this.batchMesh._colorsTexture;if(h!==null){const p=xe(([m])=>{const y=zt(vo(fs(h),0).x).toConst(),g=m,f=g.mod(y).toConst(),x=g.div(y).toConst();return fs(h,er(f,x)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);Hu("vec3","vBatchColor").assign(p)}const c=ps(l);Wi.assign(l.mul(Wi));const d=rr.div(Re(c[0].dot(c[0]),c[1].dot(c[1]),c[2].dot(c[2]))),u=c.mul(d).xyz;rr.assign(u),e.hasGeometryAttribute("tangent")&&od.mulAssign(c)}}const ZP=Pt(YP).setParameterLength(1),m1=new WeakMap;class JP extends ze{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=ht.OBJECT,this.skinIndexNode=mo("skinIndex","uvec4"),this.skinWeightNode=mo("skinWeight","vec4"),this.bindMatrixNode=ri("bindMatrix","mat4"),this.bindMatrixInverseNode=ri("bindMatrixInverse","mat4"),this.boneMatricesNode=Q_("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Wi,this.toPositionNode=Wi,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),h=e.element(i.z),c=e.element(i.w),d=n.mul(t),u=tr(o.mul(r.x).mul(d),l.mul(r.y).mul(d),h.mul(r.z).mul(d),c.mul(r.w).mul(d));return a.mul(u).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=rr,i=od){const{skinIndexNode:r,skinWeightNode:n,bindMatrixNode:a,bindMatrixInverseNode:o}=this,l=e.element(r.x),h=e.element(r.y),c=e.element(r.z),d=e.element(r.w);let u=tr(n.x.mul(l),n.y.mul(h),n.z.mul(c),n.w.mul(d));u=o.mul(u).mul(a);const p=u.transformDirection(t).xyz,m=u.transformDirection(i).xyz;return{skinNormal:p,skinTangent:m}}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Q_("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,id)}setup(e){e.needsPreviousData()&&id.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const{skinNormal:i,skinTangent:r}=this.getSkinnedNormalAndTangent();rr.assign(i),e.hasGeometryAttribute("tangent")&&od.assign(r)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;m1.get(t)!==e.frameId&&(m1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const KP=s=>new JP(s);class $P extends ze{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const i={};for(let o=0,l=this.params.length-1;o<l;o++){const h=this.params[o],c=h.isNode!==!0&&h.name||this.getVarName(o),d=h.isNode!==!0&&h.type||"int";i[c]=Ar(c,d)}const r=e.addStack(),n=this.params[this.params.length-1](i);t.returnsNode=n.context({nodeLoop:n}),t.stackNode=r;const a=this.params[0];if(a.isNode!==!0&&typeof a.update=="function"){const o=xe(this.params[0].update)(i);t.updateNode=o.context({nodeLoop:o})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){const t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){const t=this.getProperties(e),i=this.params,r=t.stackNode;for(let a=0,o=i.length-1;a<o;a++){const l=i[a];let h=!1,c=null,d=null,u=null,p=null,m=null,y=null;l.isNode?l.getNodeType(e)==="bool"?(h=!0,p="bool",d=l.build(e,p)):(p="int",u=this.getVarName(a),c="0",d=l.build(e,p),m="<"):(p=l.type||"int",u=l.name||this.getVarName(a),c=l.start,d=l.end,m=l.condition,y=l.update,typeof c=="number"?c=e.generateConst(p,c):c&&c.isNode&&(c=c.build(e,p)),typeof d=="number"?d=e.generateConst(p,d):d&&d.isNode&&(d=d.build(e,p)),c!==void 0&&d===void 0?(c=c+" - 1",d="0",m=">="):d!==void 0&&c===void 0&&(c="0",m="<"),m===void 0&&(Number(c)>Number(d)?m=">=":m="<"));let g;if(h)g=`while ( ${d} )`;else{const f={start:c,end:d},x=f.start,v=f.end;let M;const w=()=>m.includes("<")?"+=":"-=";if(y!=null)switch(typeof y){case"function":M=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":M=u+" "+w()+" "+e.generateConst(p,y);break;case"string":M=u+" "+y;break;default:y.isNode?M=u+" "+w()+" "+y.build(e):(Tt("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),M="break /* invalid update */")}else p==="int"||p==="uint"?y=m.includes("<")?"++":"--":y=w()+" 1.",M=u+" "+y;const T=e.getVar(p,u)+" = "+x,A=u+" "+m+" "+v;g=`for ( ${T}; ${A}; ${M} )`}e.addFlowCode((a===0?`
|
|
4077
|
+
`,df(a)}return i}}const R2=(s,e=null)=>new C2(Fe(s),e).toStack();q("debug",R2);class I2{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class P2 extends ze{static get type(){return"InspectorNode"}constructor(e,t="",i=null){super(),this.node=e,this.name=t,this.callback=i,this.updateType=ht.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==I2&&ro('TSL: ".toInspector()" is only available with WebGPU.'),t}}function L2(s,e="",t=null){return s=Fe(s),s.before(new P2(s,e,t))}q("toInspector",L2);class z_ extends ze{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const i=this.getAttributeName(e);if(e.hasGeometryAttribute(i)){const r=e.geometry.getAttribute(i);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),i=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const r=e.geometry.getAttribute(t),n=e.getTypeFromAttribute(r),a=e.getAttribute(t,n);return e.shaderStage==="vertex"?e.format(a.name,n,i):mo(this).build(e,i)}else return st(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(i)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const fo=(s,e=null)=>new z_(s,e);class Vf extends sh{static get type(){return"BufferNode"}constructor(e,t,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=i,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const B_=(s,e,t)=>new Vf(s,e,t);class D2 extends ho{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),i=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,i)}}class O2 extends Vf{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Fu(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ht.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,i=this.elementType;if(i==="float"||i==="int"||i==="uint")for(let r=0;r<e.length;r++){const n=r*4;t[n]=e[r]}else if(i==="color")for(let r=0;r<e.length;r++){const n=r*4,a=e[r];t[n]=a.r,t[n+1]=a.g,t[n+2]=a.b||0}else if(i==="mat2")for(let r=0;r<e.length;r++){const n=r*4,a=e[r];t[n]=a.elements[0],t[n+1]=a.elements[1],t[n+2]=a.elements[2],t[n+3]=a.elements[3]}else if(i==="mat3")for(let r=0;r<e.length;r++){const n=r*16,a=e[r];t[n]=a.elements[0],t[n+1]=a.elements[1],t[n+2]=a.elements[2],t[n+4]=a.elements[3],t[n+5]=a.elements[4],t[n+6]=a.elements[5],t[n+8]=a.elements[6],t[n+9]=a.elements[7],t[n+10]=a.elements[8],t[n+15]=1}else if(i==="mat4")for(let r=0;r<e.length;r++){const n=r*16,a=e[r];for(let o=0;o<a.elements.length;o++)t[n+o]=a.elements[o]}else for(let r=0;r<e.length;r++){const n=r*4,a=e[r];t[n]=a.x,t[n+1]=a.y,t[n+2]=a.z||0,t[n+3]=a.w||0}}setup(e){const t=this.array.length,i=this.elementType;let r=Float32Array;const n=this.paddedType,a=e.getTypeLength(n);return i.charAt(0)==="i"&&(r=Int32Array),i.charAt(0)==="u"&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=n,this.update(),super.setup(e)}element(e){return new D2(this,Fe(e))}}const sr=(s,e)=>new O2(s,e);class U2 extends ze{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Yu=Pt(U2).setParameterLength(1);let ph,mh;class Dt extends ze{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Dt.DPR?"float":this.scope===Dt.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=ht.NONE;return(this.scope===Dt.SIZE||this.scope===Dt.VIEWPORT||this.scope===Dt.DPR)&&(e=ht.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Dt.VIEWPORT?t!==null?mh.copy(t.viewport):(e.getViewport(mh),mh.multiplyScalar(e.getPixelRatio())):this.scope===Dt.DPR?this._output.value=e.getPixelRatio():t!==null?(ph.width=t.width,ph.height=t.height):e.getDrawingBufferSize(ph)}setup(){const e=this.scope;let t=null;return e===Dt.SIZE?t=dt(ph||(ph=new Vt)):e===Dt.VIEWPORT?t=dt(mh||(mh=new Ai)):e===Dt.DPR?t=dt(1):t=xt(fh.div(V_)),this._output=t,t}generate(e){if(this.scope===Dt.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(V_).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${i}.y - ${t}.y )`}return t}return super.generate(e)}}Dt.COORDINATE="coordinate",Dt.VIEWPORT="viewport",Dt.SIZE="size",Dt.UV="uv",Dt.DPR="dpr";const kf=Kt(Dt,Dt.UV),V_=Kt(Dt,Dt.SIZE),fh=Kt(Dt,Dt.COORDINATE),k_=Kt(Dt,Dt.VIEWPORT);k_.zw,k_.xy;let Gf=null,Zu=null,Hf=null,Ju=null,Wf=null,Ku=null;const jf=dt(0,"uint").setName("u_cameraIndex").setGroup(m_("cameraIndex")).toVarying("v_cameraIndex"),Jn=dt("float").setName("cameraNear").setGroup(it).onRenderUpdate(({camera:s})=>s.near),Kn=dt("float").setName("cameraFar").setGroup(it).onRenderUpdate(({camera:s})=>s.far),F2=xe(({camera:s})=>{let e;if(s.isArrayCamera&&s.cameras.length>0){const t=[];for(const i of s.cameras)t.push(i.projectionMatrix);Zu===null?Zu=sr(t).setGroup(it).setName("cameraProjectionMatrices"):Zu.array=t,e=Zu.element(s.isMultiViewCamera?Yu("gl_ViewID_OVR"):jf).toConst("cameraProjectionMatrix")}else Gf===null&&(Gf=dt(s.projectionMatrix).setName("cameraProjectionMatrix").setGroup(it).onRenderUpdate(({camera:t})=>t.projectionMatrix)),e=Gf;return e}).once()(),z2=xe(({camera:s})=>{let e;if(s.isArrayCamera&&s.cameras.length>0){const t=[];for(const i of s.cameras)t.push(i.projectionMatrixInverse);Ju===null?Ju=sr(t).setGroup(it).setName("cameraProjectionMatricesInverse"):Ju.array=t,e=Ju.element(s.isMultiViewCamera?Yu("gl_ViewID_OVR"):jf).toConst("cameraProjectionMatrixInverse")}else Hf===null&&(Hf=dt(s.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(it).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse)),e=Hf;return e}).once()(),go=xe(({camera:s})=>{let e;if(s.isArrayCamera&&s.cameras.length>0){const t=[];for(const i of s.cameras)t.push(i.matrixWorldInverse);Ku===null?Ku=sr(t).setGroup(it).setName("cameraViewMatrices"):Ku.array=t,e=Ku.element(s.isMultiViewCamera?Yu("gl_ViewID_OVR"):jf).toConst("cameraViewMatrix")}else Wf===null&&(Wf=dt(s.matrixWorldInverse).setName("cameraViewMatrix").setGroup(it).onRenderUpdate(({camera:t})=>t.matrixWorldInverse)),e=Wf;return e}).once()();class gh{constructor(e=new H(1/0,1/0,1/0),t=new H(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Us.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Us.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Us.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const n=i.getAttribute("position");if(t===!0&&n!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=n.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Us):Us.fromBufferAttribute(n,a),Us.applyMatrix4(e.matrixWorld),this.expandByPoint(Us);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),$u.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),$u.copy(i.boundingBox)),$u.applyMatrix4(e.matrixWorld),this.union($u)}const r=e.children;for(let n=0,a=r.length;n<a;n++)this.expandByObject(r[n],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Us),Us.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yh),Qu.subVectors(this.max,yh),yo.subVectors(e.a,yh),xo.subVectors(e.b,yh),vo.subVectors(e.c,yh),on.subVectors(xo,yo),ln.subVectors(vo,xo),$n.subVectors(yo,vo);let t=[0,-on.z,on.y,0,-ln.z,ln.y,0,-$n.z,$n.y,on.z,0,-on.x,ln.z,0,-ln.x,$n.z,0,-$n.x,-on.y,on.x,0,-ln.y,ln.x,0,-$n.y,$n.x,0];return!Xf(t,yo,xo,vo,Qu)||(t=[1,0,0,0,1,0,0,0,1],!Xf(t,yo,xo,vo,Qu))?!1:(ed.crossVectors(on,ln),t=[ed.x,ed.y,ed.z],Xf(t,yo,xo,vo,Qu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Us).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Us).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Nr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Nr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Nr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Nr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Nr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Nr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Nr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Nr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Nr),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Nr=[new H,new H,new H,new H,new H,new H,new H,new H],Us=new H,$u=new gh,yo=new H,xo=new H,vo=new H,on=new H,ln=new H,$n=new H,yh=new H,Qu=new H,ed=new H,Qn=new H;function Xf(s,e,t,i,r){for(let n=0,a=s.length-3;n<=a;n+=3){Qn.fromArray(s,n);const o=r.x*Math.abs(Qn.x)+r.y*Math.abs(Qn.y)+r.z*Math.abs(Qn.z),l=e.dot(Qn),h=t.dot(Qn),c=i.dot(Qn);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}const B2=new gh,xh=new H,qf=new H;class td{constructor(e=new H,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):B2.setFromPoints(e).getCenter(i);let r=0;for(let n=0,a=e.length;n<a;n++)r=Math.max(r,i.distanceToSquared(e[n]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;xh.subVectors(e,this.center);const t=xh.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(xh,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(qf.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xh.copy(e.center).add(qf)),this.expandByPoint(xh.copy(e.center).sub(qf))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const G_=new td;class Lt extends ze{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ht.OBJECT,this.uniformNode=new sh(null)}getNodeType(){const e=this.scope;if(e===Lt.WORLD_MATRIX)return"mat4";if(e===Lt.POSITION||e===Lt.VIEW_POSITION||e===Lt.DIRECTION||e===Lt.SCALE)return"vec3";if(e===Lt.RADIUS)return"float"}update(e){const t=this.object3d,i=this.uniformNode,r=this.scope;if(r===Lt.WORLD_MATRIX)i.value=t.matrixWorld;else if(r===Lt.POSITION)i.value=i.value||new H,i.value.setFromMatrixPosition(t.matrixWorld);else if(r===Lt.SCALE)i.value=i.value||new H,i.value.setFromMatrixScale(t.matrixWorld);else if(r===Lt.DIRECTION)i.value=i.value||new H,t.getWorldDirection(i.value);else if(r===Lt.VIEW_POSITION){const n=e.camera;i.value=i.value||new H,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(n.matrixWorldInverse)}else if(r===Lt.RADIUS){const n=e.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),G_.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),i.value=G_.radius}}generate(e){const t=this.scope;return t===Lt.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Lt.POSITION||t===Lt.VIEW_POSITION||t===Lt.DIRECTION||t===Lt.SCALE?this.uniformNode.nodeType="vec3":t===Lt.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Lt.WORLD_MATRIX="worldMatrix",Lt.POSITION="position",Lt.SCALE="scale",Lt.VIEW_POSITION="viewPosition",Lt.DIRECTION="direction",Lt.RADIUS="radius";class H_ extends Lt{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Yf=Kt(H_,H_.WORLD_MATRIX),V2=dt(new xs).onObjectUpdate(({object:s},e)=>e.value.getNormalMatrix(s.matrixWorld)),W_=xe(s=>s.context.modelViewMatrix||k2).once()().toVar("modelViewMatrix_2"),k2=go.mul(Yf),G2=xe(s=>s.shaderStage!=="fragment"?(ro("TSL: `clipSpace` is only available in fragment stage."),Ui()):s.context.clipSpace.toVarying("v_clipSpace")).once()(),j_=fo("position","vec3"),Wi=j_.toVarying("positionLocal"),id=j_.toVarying("positionPrevious"),Zf=xe(s=>Yf.mul(Wi).xyz.toVarying(s.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),hi=xe(s=>{if(s.shaderStage==="fragment"&&s.material.vertexNode){const e=z2.mul(G2);return e.xyz.div(e.w).toVar("positionView")}return s.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),X_=xe(s=>{let e;return s.camera.isOrthographicCamera?e=Re(0,0,1):e=hi.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class H2 extends ze{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===sf?"false":e.getFrontFacing()}}const W2=Kt(H2),q_=ke(W2).mul(2).sub(1),sd=xe(([s],{material:e})=>{const t=e.side;return t===sf?s=s.mul(-1):t===pC&&(s=s.mul(q_)),s}),j2=fo("normal","vec3"),rr=xe(s=>s.geometry.hasAttribute("normal")===!1?(st('TSL: Vertex attribute "normal" not found on geometry.'),Re(0,1,0)):j2,"vec3").once()().toVar("normalLocal"),X2=hi.dFdx().cross(hi.dFdy()).normalize().toVar("normalFlat"),q2=xe(s=>{let e;return s.isFlatShading()?e=X2:e=Y_(rr).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),ms=xe(s=>{let e;return s.subBuildFn==="NORMAL"||s.subBuildFn==="VERTEX"?(e=q2,s.isFlatShading()!==!0&&(e=sd(e))):e=s.context.setupNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),rd=ms.transformDirection(go).toVar("normalWorld"),Y2=xe(({subBuildFn:s,context:e})=>{let t;return s==="NORMAL"||s==="VERTEX"?t=ms:t=e.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),Z2=xe(([s,e=Yf])=>{const t=ps(e),i=s.div(Re(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(i).xyz}),Y_=xe(([s],e)=>{const t=e.context.modelNormalViewMatrix;if(t)return t.transformDirection(s);const i=V2.mul(s);return go.transformDirection(i)});xe(()=>(st('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),ms)).once(["NORMAL","VERTEX"])(),xe(()=>(st('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),rd)).once(["NORMAL","VERTEX"])(),xe(()=>(st('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Y2)).once(["NORMAL","VERTEX"])();class J2{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(e,t){let i=e.get(t);return i===void 0&&(i={renderId:0,frameId:0},e.set(t,i)),i}updateBeforeNode(e){const t=e.getUpdateBeforeType(),i=e.updateReference(this);if(t===ht.FRAME){const r=this._getMaps(this.updateBeforeMap,i);if(r.frameId!==this.frameId){const n=r.frameId;r.frameId=this.frameId,e.updateBefore(this)===!1&&(r.frameId=n)}}else if(t===ht.RENDER){const r=this._getMaps(this.updateBeforeMap,i);if(r.renderId!==this.renderId){const n=r.renderId;r.renderId=this.renderId,e.updateBefore(this)===!1&&(r.renderId=n)}}else t===ht.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),i=e.updateReference(this);if(t===ht.FRAME){const r=this._getMaps(this.updateAfterMap,i);r.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(r.frameId=this.frameId)}else if(t===ht.RENDER){const r=this._getMaps(this.updateAfterMap,i);r.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(r.renderId=this.renderId)}else t===ht.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),i=e.updateReference(this);if(t===ht.FRAME){const r=this._getMaps(this.updateMap,i);r.frameId!==this.frameId&&e.update(this)!==!1&&(r.frameId=this.frameId)}else if(t===ht.RENDER){const r=this._getMaps(this.updateMap,i);r.renderId!==this.renderId&&e.update(this)!==!1&&(r.renderId=this.renderId)}else t===ht.OBJECT&&e.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 K2=0;class Jf extends lo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:K2++}),this.uuid=wr(),this.name="",this.type="Material",this.blending=wv,this.side=tf,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Av,this.blendDst=Nv,this.blendEquation=Ev,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ds(0,0,0),this.blendAlpha=0,this.depthFunc=Cv,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Bv,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=io,this.stencilZFail=io,this.stencilZPass=io,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){st(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){st(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==wv&&(i.blending=this.blending),this.side!==tf&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Av&&(i.blendSrc=this.blendSrc),this.blendDst!==Nv&&(i.blendDst=this.blendDst),this.blendEquation!==Ev&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Cv&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Bv&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==io&&(i.stencilFail=this.stencilFail),this.stencilZFail!==io&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==io&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(n){const a=[];for(const o in n){const l=n[o];delete l.metadata,a.push(l)}return a}if(t){const n=r(e.textures),a=r(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const nd=(s=0)=>fo("uv"+(s>0?s:""),"vec2");class $2 extends ze{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const i=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${i}, ${r} )`,this.getNodeType(e),t)}}const _o=Pt($2).setParameterLength(1,2);class Q2 extends sh{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=ht.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,i=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(i&&i.width!==void 0){const{width:r,height:n}=i;this.value=Math.log2(Math.max(r,n))}}}const eP=Pt(Q2).setParameterLength(1);let Mo;class tP{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Mo===void 0&&(Mo=Gv("canvas")),Mo.width=e.width,Mo.height=e.height;const r=Mo.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Mo}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Gv("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),n=r.data;for(let a=0;a<n.length;a++)n[a]=Er(n[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Er(t[i]/255)*255):t[i]=Er(t[i]);return{data:t,width:e.width,height:e.height}}else return st("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let iP=0;class Kf{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:iP++}),this.uuid=wr(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let n;if(Array.isArray(r)){n=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?n.push($f(r[a].image)):n.push($f(r[a]))}else n=$f(r);i.url=n}return t||(e.images[this.uuid]=i),i}}function $f(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?tP.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(st("Texture: Unable to serialize Texture."),{})}let sP=0;const Qf=new H;class ss extends lo{constructor(e=ss.DEFAULT_IMAGE,t=ss.DEFAULT_MAPPING,i=Yl,r=Yl,n=Zl,a=Lv,o=TC,l=Dv,h=ss.DEFAULT_ANISOTROPY,c=Lu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:sP++}),this.uuid=wr(),this.name="",this.source=new Kf(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Vt(0,0),this.repeat=new Vt(1,1),this.center=new Vt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xs,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Qf).x}get height(){return this.source.getSize(Qf).y}get depth(){return this.source.getSize(Qf).z}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){st(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){st(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Rv)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Iv:e.x=e.x-Math.floor(e.x);break;case Yl:e.x=e.x<0?0:1;break;case Pv:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Iv:e.y=e.y-Math.floor(e.y);break;case Yl:e.y=e.y<0?0:1;break;case Pv:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ss.DEFAULT_IMAGE=null,ss.DEFAULT_MAPPING=Rv,ss.DEFAULT_ANISOTROPY=4;class rP extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const Z_=new ss;class ad extends sh{static get type(){return"TextureNode"}constructor(e=Z_,t=null,i=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=i,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ht.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}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===af?"uvec4":this.value.type===SC?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return nd(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=dt(this.value.matrix)),this._matrixUniform.mul(Re(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=dt(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(zt(_o(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const i=this.value;if(!i||i.isTexture!==!0)throw new rP("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const r=xe(()=>{let l=this.uvNode;return(l===null||e.context.forceUVContext===!0)&&e.context.getUV&&(l=e.context.getUV(this,e)),l||(l=this.getDefaultUV()),this.updateMatrix===!0&&(l=this.getTransformedUV(l)),l=this.setupUV(e,l),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?ht.OBJECT:ht.NONE,l})();let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(kv.TEXTURE_COMPARE))a=this.compareNode;else{const l=i.compareFunction;l===null||l===RC||l===cf||l===Vv||l===Du?o=this.compareNode:(a=this.compareNode,ro('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=r,t.levelNode=n,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,i,r,n,a,o,l,h){const c=this.value;let d;return n?d=e.generateTextureBias(c,t,i,n,a,h):l?d=e.generateTextureGrad(c,t,i,l,a,h):o?d=e.generateTextureCompare(c,t,i,o,a,h):this.sampler===!1?d=e.generateTextureLoad(c,t,i,r,a,h):r?d=e.generateTextureLevel(c,t,i,r,a,h):d=e.generateTexture(c,t,i,a,h),d}generate(e,t){const i=this.value,r=e.getNodeProperties(this),n=super.generate(e,"property");if(/^sampler/.test(t))return n+"_sampler";if(e.isReference(t))return n;{const a=e.getDataFromNode(this),o=this.getNodeType(e);let l=a.propertyName;if(l===void 0){const{uvNode:c,levelNode:d,biasNode:u,compareNode:p,compareStepNode:m,depthNode:y,gradNode:g,offsetNode:f}=r,x=this.generateUV(e,c),v=d?d.build(e,"float"):null,M=u?u.build(e,"float"):null,w=y?y.build(e,"int"):null,T=p?p.build(e,"float"):null,A=m?m.build(e,"float"):null,_=g?[g[0].build(e,"vec2"),g[1].build(e,"vec2")]:null,S=f?this.generateOffset(e,f):null,P=e.getVarFromNode(this);l=e.getPropertyName(P);let C=this.generateSnippet(e,n,x,v,M,w,T,_,S);if(A!==null){const L=i.compareFunction;L===Vv||L===Du?C=hh(Ar(C,o),Ar(A,"float")).build(e,o):C=hh(Ar(A,"float"),Ar(C,o)).build(e,o)}e.addLineFlowCode(`${l} = ${C}`,this),a.snippet=C,a.propertyName=l}let h=l;return e.needsToWorkingColorSpace(i)&&(h=N_(Ar(h,o),i.colorSpace).setup(e).build(e,o)),e.format(h,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=Fe(e).mul(eP(t)),t.referenceNode=this.getBase();const i=t.value;return t.generateMipmaps===!1&&(i&&i.generateMipmaps===!1||i.minFilter===cs||i.magFilter===cs)&&(st("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Fe(t)}level(e){const t=this.clone();return t.levelNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}size(e){return _o(this,e)}bias(e){const t=this.clone();return t.biasNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}grad(e,t){const i=this.clone();return i.gradNode=[Fe(e),Fe(t)],i.referenceNode=this.getBase(),Fe(i)}depth(e){const t=this.clone();return t.depthNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}offset(e){const t=this.clone();return t.offsetNode=Fe(e),t.referenceNode=this.getBase(),Fe(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();const i=this._flipYUniform;i!==null&&(i.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}const nP=Pt(ad).setParameterLength(1,4).setName("texture"),gi=(s=Z_,e=null,t=null,i=null)=>{let r;return s&&s.isTextureNode===!0?(r=Fe(s.clone()),r.referenceNode=s.getBase(),e!==null&&(r.uvNode=Fe(e)),t!==null&&(r.levelNode=Fe(t)),i!==null&&(r.biasNode=Fe(i))):r=nP(s,e,t,i),r},fs=(...s)=>gi(...s).setSampler(!1),J_=new kt,K_=new ao;class Do{constructor(e=0,t=0,i=0,r=Do.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,n=r[0],a=r[4],o=r[8],l=r[1],h=r[5],c=r[9],d=r[2],u=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(ft(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ft(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-d,n),this._z=0);break;case"ZXY":this._x=Math.asin(ft(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-ft(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(ft(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-d,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-ft(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-c,p),this._y=0);break;default:st("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return J_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(J_,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return K_.setFromEuler(this),this.setFromQuaternion(K_,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Do.DEFAULT_ORDER="XYZ";const $_=new Do,eg=new kt,aP=dt(0).onReference(({material:s})=>s).onObjectUpdate(({material:s})=>s.refractionRatio),oP=dt(new kt).onReference(function(s){return s.material}).onObjectUpdate(function({material:s,scene:e}){const t=e.environment!==null&&s.envMap===null?e.environmentRotation:s.envMapRotation;return t?($_.copy(t),eg.makeRotationFromEuler($_)):eg.identity(),eg}),lP=X_.negate().reflect(ms),hP=X_.negate().refract(ms,aP),cP=lP.transformDirection(go).toVar("reflectVector"),uP=hP.transformDirection(go).toVar("reflectVector");class dP extends ss{constructor(e=[],t=nf,i,r,n,a,o,l,h,c){super(e,t,i,r,n,a,o,l,h,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}const pP=new dP;class mP extends ad{static get type(){return"CubeTextureNode"}constructor(e,t=null,i=null,r=null){super(e,t,i,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===nf?cP:e.mapping===bC?uP:(Tt('CubeTextureNode: Mapping "%s" not supported.',e.mapping),Re(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const i=this.value;return i.isDepthTexture===!0?e.renderer.coordinateSystem===tn?Re(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===tn||!i.isRenderTargetTexture)&&(t=Re(t.x.negate(),t.yz)),oP.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const fP=Pt(mP).setParameterLength(1,4).setName("cubeTexture"),nr=(s=pP,e=null,t=null,i=null)=>{let r;return s&&s.isCubeTextureNode===!0?(r=Fe(s.clone()),r.referenceNode=s,e!==null&&(r.uvNode=Fe(e)),t!==null&&(r.levelNode=Fe(t)),i!==null&&(r.biasNode=Fe(i))):r=fP(s,e,t,i),r};class gP extends ho{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),i=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,i,r)}}class tg extends ze{static get type(){return"ReferenceNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=ht.OBJECT}element(e){return new gP(this,Fe(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return st('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=B_(null,e,this.count):Array.isArray(this.getValueFromReference())?t=sr(null,e):e==="texture"?t=gi(null):e==="cubeTexture"?t=nr(null):t=dt(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const ri=(s,e,t)=>new tg(s,e,t),Q_=(s,e,t,i)=>new tg(s,e,i,t);class yP extends tg{static get type(){return"MaterialReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const bo=(s,e,t=null)=>new yP(s,e,t),e1=nd(),xP=hi.dFdx(),vP=hi.dFdy(),t1=e1.dFdx(),i1=e1.dFdy(),s1=ms,r1=vP.cross(s1),n1=s1.cross(xP),ig=r1.mul(t1.x).add(n1.mul(i1.x)),sg=r1.mul(t1.y).add(n1.mul(i1.y)),a1=ig.dot(ig).max(sg.dot(sg)),o1=a1.equal(0).select(0,a1.inverseSqrt()),_P=ig.mul(o1).toVar("tangentViewFrame"),MP=sg.mul(o1).toVar("bitangentViewFrame"),l1=fo("tangent","vec4"),od=l1.xyz.toVar("tangentLocal"),h1=xe(s=>{let e;return s.subBuildFn==="VERTEX"||s.geometry.hasAttribute("tangent")?e=W_.mul(Ui(od,0)).xyz.toVarying("v_tangentView").normalize():e=_P,s.isFlatShading()!==!0&&(e=sd(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),bP=xe(([s,e],t)=>{let i=s.mul(l1.w).xyz;return t.subBuildFn==="NORMAL"&&t.isFlatShading()!==!0&&(i=i.toVarying(e)),i}).once(["NORMAL"]),SP=xe(s=>{let e;return s.subBuildFn==="VERTEX"||s.geometry.hasAttribute("tangent")?e=bP(ms.cross(h1),"v_bitangentView").normalize():e=MP,s.isFlatShading()!==!0&&(e=sd(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),TP=ps(h1,SP,ms).toVar("TBNViewMatrix"),c1=s=>Re(s,nh(Df(ke(1).sub(ch(s,s)))));class wP extends mi{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=lf,this.unpackNormalMode=hf}setup(e){const{normalMapType:t,scaleNode:i,unpackNormalMode:r}=this;let n=this.node.mul(2).sub(1);if(t===lf?r===zv?n=c1(n.xy):r===CC?n=c1(n.yw):r!==hf&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==hf&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),i!==null){let o=i;e.isFlatShading()===!0&&(o=sd(o)),n=Re(n.xy.mul(o),n.z)}let a=null;return t===NC?a=Y_(n):t===lf?a=TP.mul(n).normalize():(Tt(`NodeMaterial: Unsupported normal map type: ${t}`),a=ms),a}}const u1=Pt(wP).setParameterLength(1,2),EP=xe(({textureNode:s,bumpScale:e})=>{const t=r=>s.isolate().context({getUV:n=>r(n.uvNode||nd()),forceUVContext:!0}),i=ke(t(r=>r));return xt(ke(t(r=>r.add(r.dFdx()))).sub(i),ke(t(r=>r.add(r.dFdy()))).sub(i)).mul(e)}),AP=xe(s=>{const{surf_pos:e,surf_norm:t,dHdxy:i}=s,r=e.dFdx().normalize(),n=e.dFdy().normalize(),a=t,o=n.cross(a),l=a.cross(r),h=r.dot(o).mul(q_),c=h.sign().mul(i.x.mul(o).add(i.y.mul(l)));return h.abs().mul(t).sub(c).normalize()});class NP extends mi{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=EP({textureNode:this.textureNode,bumpScale:e});return AP({surf_pos:hi,surf_norm:ms,dHdxy:t})}}const CP=Pt(NP).setParameterLength(1,2),d1=new Map;class ve extends ze{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=d1.get(e);return i===void 0&&(i=bo(e,t),d1.set(e,i)),i}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,i=this.scope;let r=null;if(i===ve.COLOR){const n=t.color!==void 0?this.getColor(i):Re();t.map&&t.map.isTexture===!0?r=n.mul(this.getTexture("map")):r=n}else if(i===ve.OPACITY){const n=this.getFloat(i);t.alphaMap&&t.alphaMap.isTexture===!0?r=n.mul(this.getTexture("alpha")):r=n}else if(i===ve.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=ke(1);else if(i===ve.SPECULAR_INTENSITY){const n=this.getFloat(i);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=n.mul(this.getTexture(i).a):r=n}else if(i===ve.SPECULAR_COLOR){const n=this.getColor(i);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=n.mul(this.getTexture(i).rgb):r=n}else if(i===ve.ROUGHNESS){const n=this.getFloat(i);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=n.mul(this.getTexture(i).g):r=n}else if(i===ve.METALNESS){const n=this.getFloat(i);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=n.mul(this.getTexture(i).b):r=n}else if(i===ve.EMISSIVE){const n=this.getFloat("emissiveIntensity"),a=this.getColor(i).mul(n);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(i)):r=a}else if(i===ve.NORMAL)t.normalMap?(r=u1(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType,(t.normalMap.format==Kl||t.normalMap.format==AC||t.normalMap.format==EC)&&(r.unpackNormalMode=zv)):t.bumpMap?r=CP(this.getTexture("bump").r,this.getFloat("bumpScale")):r=ms;else if(i===ve.CLEARCOAT){const n=this.getFloat(i);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=n.mul(this.getTexture(i).r):r=n}else if(i===ve.CLEARCOAT_ROUGHNESS){const n=this.getFloat(i);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=n.mul(this.getTexture(i).r):r=n}else if(i===ve.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=u1(this.getTexture(i),this.getCache(i+"Scale","vec2")):r=ms;else if(i===ve.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=n.mul(this.getTexture("sheenColor").rgb):r=n}else if(i===ve.SHEEN_ROUGHNESS){const n=this.getFloat(i);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=n.mul(this.getTexture(i).a):r=n,r=r.clamp(1e-4,1)}else if(i===ve.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const n=this.getTexture(i);r=u_(vh.x,vh.y,vh.y.negate(),vh.x).mul(n.rg.mul(2).sub(xt(1)).normalize().mul(n.b))}else r=vh;else if(i===ve.IRIDESCENCE_THICKNESS){const n=ri("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=ri("0","float",t.iridescenceThicknessRange);r=n.sub(a).mul(this.getTexture(i).g).add(a)}else r=n}else if(i===ve.TRANSMISSION){const n=this.getFloat(i);t.transmissionMap?r=n.mul(this.getTexture(i).r):r=n}else if(i===ve.THICKNESS){const n=this.getFloat(i);t.thicknessMap?r=n.mul(this.getTexture(i).g):r=n}else if(i===ve.IOR)r=this.getFloat(i);else if(i===ve.LIGHT_MAP)r=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===ve.AO)r=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(i===ve.LINE_DASH_OFFSET)r=t.dashOffset?this.getFloat(i):ke(0);else{const n=this.getNodeType(e);r=this.getCache(i,n)}return r}}ve.ALPHA_TEST="alphaTest",ve.COLOR="color",ve.OPACITY="opacity",ve.SHININESS="shininess",ve.SPECULAR="specular",ve.SPECULAR_STRENGTH="specularStrength",ve.SPECULAR_INTENSITY="specularIntensity",ve.SPECULAR_COLOR="specularColor",ve.REFLECTIVITY="reflectivity",ve.ROUGHNESS="roughness",ve.METALNESS="metalness",ve.NORMAL="normal",ve.CLEARCOAT="clearcoat",ve.CLEARCOAT_ROUGHNESS="clearcoatRoughness",ve.CLEARCOAT_NORMAL="clearcoatNormal",ve.EMISSIVE="emissive",ve.ROTATION="rotation",ve.SHEEN="sheen",ve.SHEEN_ROUGHNESS="sheenRoughness",ve.ANISOTROPY="anisotropy",ve.IRIDESCENCE="iridescence",ve.IRIDESCENCE_IOR="iridescenceIOR",ve.IRIDESCENCE_THICKNESS="iridescenceThickness",ve.IOR="ior",ve.TRANSMISSION="transmission",ve.THICKNESS="thickness",ve.ATTENUATION_DISTANCE="attenuationDistance",ve.ATTENUATION_COLOR="attenuationColor",ve.LINE_SCALE="scale",ve.LINE_DASH_SIZE="dashSize",ve.LINE_GAP_SIZE="gapSize",ve.LINE_WIDTH="linewidth",ve.LINE_DASH_OFFSET="dashOffset",ve.POINT_SIZE="size",ve.DISPERSION="dispersion",ve.LIGHT_MAP="light",ve.AO="ao";const RP=Kt(ve,ve.ALPHA_TEST),IP=Kt(ve,ve.COLOR),PP=Kt(ve,ve.EMISSIVE),LP=Kt(ve,ve.OPACITY),DP=Kt(ve,ve.NORMAL),OP=Kt(ve,ve.LIGHT_MAP),UP=Kt(ve,ve.AO),vh=dt(new Vt).onReference(function(s){return s.material}).onRenderUpdate(function({material:s}){this.value.set(s.anisotropy*Math.cos(s.anisotropyRotation),s.anisotropy*Math.sin(s.anisotropyRotation))}),FP=xe(s=>s.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class zP extends ho{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const i=this.storageBufferNode.structTypeNode;return i?i.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let i;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?i=e.generatePBO(this):i=this.node.build(e):i=super.generate(e),r!==!0){const n=this.getNodeType(e);i=e.format(i,n,t)}return i}}const BP=Pt(zP).setParameterLength(2);class VP extends Vf{static get type(){return"StorageBufferNode"}constructor(e,t=null,i=0){let r,n=null;t&&t.isStruct?(r="struct",n=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(i=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=tR(e.itemSize),i=e.count):r=t,super(e,r,i),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=Tv.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return BP(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Tv.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=P_(this.value),this._varying=mo(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:i}=this.getAttributeData(),r=i.build(e);return e.registerTransform(r,t),r}}const p1=(s,e=null,t=0)=>new VP(s,e,t);class ni extends ze{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),i=this.scope;let r;if(i===ni.VERTEX)r=e.getVertexIndex();else if(i===ni.INSTANCE)r=e.getInstanceIndex();else if(i===ni.DRAW)r=e.getDrawIndex();else if(i===ni.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(i===ni.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(i===ni.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+i);let n;return e.shaderStage==="vertex"||e.shaderStage==="compute"?n=r:n=mo(this).build(e,t),n}}ni.VERTEX="vertex",ni.INSTANCE="instance",ni.SUBGROUP="subgroup",ni.INVOCATION_LOCAL="invocationLocal",ni.INVOCATION_SUBGROUP="invocationSubgroup",ni.DRAW="draw";const kP=Kt(ni,ni.VERTEX),_h=Kt(ni,ni.INSTANCE),GP=Kt(ni,ni.DRAW);class HP extends C_{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class WP extends nn{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}class jP extends ze{static get type(){return"InstanceNode"}constructor(e,t,i=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=i,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ht.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){const{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){let{instanceMatrixNode:t,instanceColorNode:i}=this;t===null&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);const{instanceColor:r,isStorageColor:n}=this;if(r&&i===null){if(n)i=p1(r,"vec3",Math.max(r.count,1)).element(_h);else{const o=new WP(r.array,3),l=r.usage===uf?D_:L_;this.bufferColor=o,i=Re(l(o,"vec3",3,0))}this.instanceColorNode=i}const a=t.mul(Wi).xyz;if(Wi.assign(a),e.needsPreviousData()&&id.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){const o=Z2(rr,t);rr.assign(o)}this.instanceColorNode!==null&&Hu("vec3","vInstanceColor").assign(this.instanceColorNode)}update(e){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&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){const t=e.object;return this.previousInstanceMatrixNode===null&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(id).xyz}_createInstanceMatrixNode(e,t){let i;const{instanceMatrix:r}=this,{count:n}=r;if(this.isStorageMatrix)i=p1(r,"mat4",Math.max(n,1)).element(_h);else if(n*16*4<=t.getUniformBufferLimit())i=B_(r.array,"mat4",Math.max(n,1)).element(_h);else{const a=new HP(r.array,16,1);e===!0&&(this.buffer=a);const o=r.usage===uf?D_:L_,l=[o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)];i=Gu(...l)}return i}}class XP extends jP{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:i,instanceColor:r}=e;super(t,i,r),this.instancedMesh=e}}const qP=Pt(XP).setParameterLength(1);class YP extends ze{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=_h:this.batchingIdNode=GP);const t=xe(([p])=>{const m=zt(_o(fs(this.batchMesh._indirectTexture),0).x).toConst(),y=zt(p).mod(m).toConst(),g=zt(p).div(m).toConst();return fs(this.batchMesh._indirectTexture,er(y,g)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(zt(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=zt(_o(fs(i),0).x).toConst(),n=ke(t).mul(4).toInt().toConst(),a=n.mod(r).toConst(),o=n.div(r).toConst(),l=Gu(fs(i,er(a,o)),fs(i,er(a.add(1),o)),fs(i,er(a.add(2),o)),fs(i,er(a.add(3),o))),h=this.batchMesh._colorsTexture;if(h!==null){const p=xe(([m])=>{const y=zt(_o(fs(h),0).x).toConst(),g=m,f=g.mod(y).toConst(),x=g.div(y).toConst();return fs(h,er(f,x)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);Hu("vec3","vBatchColor").assign(p)}const c=ps(l);Wi.assign(l.mul(Wi));const d=rr.div(Re(c[0].dot(c[0]),c[1].dot(c[1]),c[2].dot(c[2]))),u=c.mul(d).xyz;rr.assign(u),e.hasGeometryAttribute("tangent")&&od.mulAssign(c)}}const ZP=Pt(YP).setParameterLength(1),m1=new WeakMap;class JP extends ze{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=ht.OBJECT,this.skinIndexNode=fo("skinIndex","uvec4"),this.skinWeightNode=fo("skinWeight","vec4"),this.bindMatrixNode=ri("bindMatrix","mat4"),this.bindMatrixInverseNode=ri("bindMatrixInverse","mat4"),this.boneMatricesNode=Q_("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Wi,this.toPositionNode=Wi,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),h=e.element(i.z),c=e.element(i.w),d=n.mul(t),u=tr(o.mul(r.x).mul(d),l.mul(r.y).mul(d),h.mul(r.z).mul(d),c.mul(r.w).mul(d));return a.mul(u).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=rr,i=od){const{skinIndexNode:r,skinWeightNode:n,bindMatrixNode:a,bindMatrixInverseNode:o}=this,l=e.element(r.x),h=e.element(r.y),c=e.element(r.z),d=e.element(r.w);let u=tr(n.x.mul(l),n.y.mul(h),n.z.mul(c),n.w.mul(d));u=o.mul(u).mul(a);const p=u.transformDirection(t).xyz,m=u.transformDirection(i).xyz;return{skinNormal:p,skinTangent:m}}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Q_("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,id)}setup(e){e.needsPreviousData()&&id.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const{skinNormal:i,skinTangent:r}=this.getSkinnedNormalAndTangent();rr.assign(i),e.hasGeometryAttribute("tangent")&&od.assign(r)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;m1.get(t)!==e.frameId&&(m1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const KP=s=>new JP(s);class $P extends ze{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const i={};for(let o=0,l=this.params.length-1;o<l;o++){const h=this.params[o],c=h.isNode!==!0&&h.name||this.getVarName(o),d=h.isNode!==!0&&h.type||"int";i[c]=Ar(c,d)}const r=e.addStack(),n=this.params[this.params.length-1](i);t.returnsNode=n.context({nodeLoop:n}),t.stackNode=r;const a=this.params[0];if(a.isNode!==!0&&typeof a.update=="function"){const o=xe(this.params[0].update)(i);t.updateNode=o.context({nodeLoop:o})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){const t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){const t=this.getProperties(e),i=this.params,r=t.stackNode;for(let a=0,o=i.length-1;a<o;a++){const l=i[a];let h=!1,c=null,d=null,u=null,p=null,m=null,y=null;l.isNode?l.getNodeType(e)==="bool"?(h=!0,p="bool",d=l.build(e,p)):(p="int",u=this.getVarName(a),c="0",d=l.build(e,p),m="<"):(p=l.type||"int",u=l.name||this.getVarName(a),c=l.start,d=l.end,m=l.condition,y=l.update,typeof c=="number"?c=e.generateConst(p,c):c&&c.isNode&&(c=c.build(e,p)),typeof d=="number"?d=e.generateConst(p,d):d&&d.isNode&&(d=d.build(e,p)),c!==void 0&&d===void 0?(c=c+" - 1",d="0",m=">="):d!==void 0&&c===void 0&&(c="0",m="<"),m===void 0&&(Number(c)>Number(d)?m=">=":m="<"));let g;if(h)g=`while ( ${d} )`;else{const f={start:c,end:d},x=f.start,v=f.end;let M;const w=()=>m.includes("<")?"+=":"-=";if(y!=null)switch(typeof y){case"function":M=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":M=u+" "+w()+" "+e.generateConst(p,y);break;case"string":M=u+" "+y;break;default:y.isNode?M=u+" "+w()+" "+y.build(e):(Tt("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),M="break /* invalid update */")}else p==="int"||p==="uint"?y=m.includes("<")?"++":"--":y=w()+" 1.",M=u+" "+y;const T=e.getVar(p,u)+" = "+x,A=u+" "+m+" "+v;g=`for ( ${T}; ${A}; ${M} )`}e.addFlowCode((a===0?`
|
|
4078
4078
|
`:"")+e.tab+g+` {
|
|
4079
4079
|
|
|
4080
4080
|
`).addFlowTab()}const n=r.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(`
|
|
4081
4081
|
`+e.tab+n);for(let a=0,o=this.params.length-1;a<o;a++)e.addFlowCode((a===0?"":e.tab)+`}
|
|
4082
4082
|
|
|
4083
|
-
`).removeFlowTab();e.addFlowTab()}}const hn=(...s)=>new $P(ho(s,"int")).toStack();class QP extends ss{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=cs,this.minFilter=cs,this.wrapR=Yl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}const ng=new WeakMap,ts=new Ai,f1=xe(({bufferMap:s,influence:e,stride:t,width:i,depth:r,offset:n})=>{const a=zt(kP).mul(t).add(n),o=a.div(i),l=a.sub(o.mul(i));return fs(s,er(l,o)).depth(r).xyz.mul(e)});function e3(s){const e=s.morphAttributes.position!==void 0,t=s.morphAttributes.normal!==void 0,i=s.morphAttributes.color!==void 0,r=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,n=r!==void 0?r.length:0;let a=ng.get(s);if(a===void 0||a.count!==n){let o=function(){g.dispose(),ng.delete(s),s.removeEventListener("dispose",o)};a!==void 0&&a.texture.dispose();const l=s.morphAttributes.position||[],h=s.morphAttributes.normal||[],c=s.morphAttributes.color||[];let d=0;e===!0&&(d=1),t===!0&&(d=2),i===!0&&(d=3);let u=s.attributes.position.count*d,p=1;const m=4096;u>m&&(p=Math.ceil(u/m),u=m);const y=new Float32Array(u*p*4*n),g=new QP(y,u,p,n);g.type=Ov,g.needsUpdate=!0;const f=d*4;for(let x=0;x<n;x++){const v=l[x],M=h[x],w=c[x],T=u*p*4*x;for(let A=0;A<v.count;A++){const _=A*f;e===!0&&(ts.fromBufferAttribute(v,A),y[T+_+0]=ts.x,y[T+_+1]=ts.y,y[T+_+2]=ts.z,y[T+_+3]=0),t===!0&&(ts.fromBufferAttribute(M,A),y[T+_+4]=ts.x,y[T+_+5]=ts.y,y[T+_+6]=ts.z,y[T+_+7]=0),i===!0&&(ts.fromBufferAttribute(w,A),y[T+_+8]=ts.x,y[T+_+9]=ts.y,y[T+_+10]=ts.z,y[T+_+11]=w.itemSize===4?ts.w:1)}}a={count:n,texture:g,stride:d,size:new Vt(u,p)},ng.set(s,a),s.addEventListener("dispose",o)}return a}class t3 extends ze{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=dt(1),this.updateType=ht.OBJECT}setup(e){const{geometry:t}=e,i=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,n=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=n!==void 0?n.length:0,{texture:o,stride:l,size:h}=e3(t);i===!0&&Wi.mulAssign(this.morphBaseInfluence),r===!0&&rr.mulAssign(this.morphBaseInfluence);const c=zt(h.width);hn(a,({i:d})=>{const u=ke(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?u.assign(fs(this.mesh.morphTexture,er(zt(d).add(1),zt(_h))).r):u.assign(ri("morphTargetInfluences","float").element(d).toVar()),ds(u.notEqual(0),()=>{i===!0&&Wi.addAssign(f1({bufferMap:o,influence:u,stride:l,width:c,depth:d,offset:zt(0)})),r===!0&&rr.addAssign(f1({bufferMap:o,influence:u,stride:l,width:c,depth:d,offset:zt(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,i)=>t+i,0)}}const i3=Pt(t3).setParameterLength(1);class ag extends ze{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class s3 extends ag{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class r3 extends w_{static get type(){return"LightingContextNode"}constructor(e,t=null,i=null,r=null){super(e),this.lightingModel=t,this.backdropNode=i,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,i=Re().toVar("directDiffuse"),r=Re().toVar("directSpecular"),n=Re().toVar("indirectDiffuse"),a=Re().toVar("indirectSpecular"),o={directDiffuse:i,directSpecular:r,indirectDiffuse:n,indirectSpecular:a};return{radiance:Re().toVar("radiance"),irradiance:Re().toVar("irradiance"),iblIrradiance:Re().toVar("iblIrradiance"),ambientOcclusion:ke(1).toVar("ambientOcclusion"),reflectedLight:o,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const n3=Pt(r3);class a3 extends ag{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}class o3 extends ss{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=cs,this.minFilter=cs,this.generateMipmaps=!1,this.needsUpdate=!0}}const bo=new Vt;class l3 extends ad{static get type(){return"ViewportTextureNode"}constructor(e=Gf,t=null,i=null){let r=null;i===null?(r=new o3,r.minFilter=Lv,i=r):r=i,super(i,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=ht.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,i;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,i=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,i=this._cacheTextures),e===null)return t;if(i.has(e)===!1){const r=t.clone();i.set(e,r)}return i.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,i=t.getRenderTarget();i===null?t.getDrawingBufferSize(bo):bo.set(i.width,i.height);const r=this.getTextureForReference(i);(r.image.width!==bo.width||r.image.height!==bo.height)&&(r.image.width=bo.width,r.image.height=bo.height,r.needsUpdate=!0);const n=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=n}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}class Mh extends ss{constructor(e,t,i=of,r,n,a,o=cs,l=cs,h,c=lf,d=1){if(c!==lf&&c!==wC)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,r,n,a,o,l,c,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new $f(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}let ld=null;class h3 extends l3{static get type(){return"ViewportDepthTextureNode"}constructor(e=Gf,t=null){ld===null&&(ld=new Mh),super(e,t,ld)}getTextureForReference(){return ld}}const c3=Pt(h3).setParameterLength(0,2);class ji extends ze{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===ji.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,i=this.valueNode;let r=null;if(t===ji.DEPTH_BASE)i!==null&&(r=v1().assign(i));else if(t===ji.DEPTH)e.isPerspectiveCamera?r=g1(hi.z,Jn,Kn):r=bh(hi.z,Jn,Kn);else if(t===ji.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const n=y1(i,Jn,Kn);r=bh(n,Jn,Kn)}else r=i;else r=bh(hi.z,Jn,Kn);return r}}ji.DEPTH_BASE="depthBase",ji.DEPTH="depth",ji.LINEAR_DEPTH="linearDepth";const bh=(s,e,t)=>s.add(e).div(e.sub(t)),g1=(s,e,t)=>e.add(s).mul(t).div(t.sub(e).mul(s)),u3=(s,e,t)=>e.mul(s.add(t)).div(s.mul(e.sub(t))),y1=xe(([s,e,t],i)=>i.renderer.reversedDepthBuffer===!0?e.mul(t).div(e.sub(t).mul(s).sub(e)):e.mul(t).div(t.sub(e).mul(s).sub(t))),x1=(s,e,t)=>{e=e.max(1e-6).toVar();const i=Yn(s.negate().div(e)),r=Yn(t.div(e));return i.div(r)},v1=Pt(ji,ji.DEPTH_BASE),_1=Kt(ji,ji.DEPTH),oD=Pt(ji,ji.LINEAR_DEPTH).setParameterLength(0,1);c3(),_1.assign=s=>v1(s);class vs extends ze{static get type(){return"ClippingNode"}constructor(e=vs.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:i,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===vs.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(i,r):this.scope===vs.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(i,r)}setupAlphaToCoverage(e,t){return xe(()=>{const i=ke().toVar("distanceToPlane"),r=ke().toVar("distanceToGradient"),n=ke(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const l=sr(t).setGroup(it);hn(a,({i:h})=>{const c=l.element(h);i.assign(hi.dot(c.xyz).negate().add(c.w)),r.assign(i.fwidth().div(2)),n.mulAssign(uh(r.negate(),r,i))})}const o=e.length;if(o>0){const l=sr(e).setGroup(it),h=ke(1).toVar("intersectionClipOpacity");hn(o,({i:c})=>{const d=l.element(c);i.assign(hi.dot(d.xyz).negate().add(d.w)),r.assign(i.fwidth().div(2)),h.mulAssign(uh(r.negate(),r,i).oneMinus())}),n.mulAssign(h.oneMinus())}Gi.a.mulAssign(n),Gi.a.equal(0).discard()})()}setupDefault(e,t){return xe(()=>{const i=t.length;if(this.hardwareClipping===!1&&i>0){const n=sr(t).setGroup(it);hn(i,({i:a})=>{const o=n.element(a);hi.dot(o.xyz).greaterThan(o.w).discard()})}const r=e.length;if(r>0){const n=sr(e).setGroup(it),a=Nf(!0).toVar("clipped");hn(r,({i:o})=>{const l=n.element(o);a.assign(hi.dot(l.xyz).greaterThan(l.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const i=e.length;return t.enableHardwareClipping(i),xe(()=>{const r=sr(e).setGroup(it),n=Yu(t.getClipDistance());hn(i,({i:a})=>{const o=r.element(a),l=hi.dot(o.xyz).sub(o.w).negate();n.element(a).assign(l)})})()}}vs.ALPHA_TO_COVERAGE="alphaToCoverage",vs.DEFAULT="default",vs.HARDWARE="hardware";const d3=()=>new vs,p3=()=>new vs(vs.ALPHA_TO_COVERAGE),m3=()=>new vs(vs.HARDWARE),f3=["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"],og=new WeakMap;class g3{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=f3,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){const t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:i,material:r,object:n}=e;if(t={material:this.getMaterialData(r),geometry:{id:i.id,attributes:this.getAttributesData(i.attributes),indexId:i.index?i.index.id:null,indexVersion:i.index?i.index.version:null,drawRange:{start:i.drawRange.start,count:i.drawRange.count}},worldMatrix:n.matrixWorld.clone()},n.center&&(t.center=n.center.clone()),n.morphTargetInfluences&&(t.morphTargetInfluences=n.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:a,height:o}=e.context;t.bufferWidth=a,t.bufferHeight=o}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const i in e){const r=e[i];t[i]={id:r.id,version:r.version}}return t}containsNode(e){const t=e.material;for(const i in t)if(t[i]&&t[i].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){const t={};for(const i of this.refreshUniforms){const r=e[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[i]={id:r.id,version:r.version}:t[i]=r.clone():t[i]=r)}return t}equals(e,t){const{object:i,material:r,geometry:n}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(i.matrixWorld)!==!0)return a.worldMatrix.copy(i.matrixWorld),!1;const o=a.material;for(const x in o){const v=o[x],M=r[x];if(v.equals!==void 0){if(v.equals(M)===!1)return v.copy(M),!1}else if(M.isTexture===!0){if(v.id!==M.id||v.version!==M.version)return v.id=M.id,v.version=M.version,!1}else if(v!==M)return o[x]=M,!1}if(o.transmission>0){const{width:x,height:v}=e.context;if(a.bufferWidth!==x||a.bufferHeight!==v)return a.bufferWidth=x,a.bufferHeight=v,!1}const l=a.geometry,h=n.attributes,c=l.attributes,d=Object.keys(c),u=Object.keys(h);if(l.id!==n.id)return l.id=n.id,!1;if(d.length!==u.length)return a.geometry.attributes=this.getAttributesData(h),!1;for(const x of d){const v=c[x],M=h[x];if(M===void 0)return delete c[x],!1;if(v.id!==M.id||v.version!==M.version)return v.id=M.id,v.version=M.version,!1}const p=n.index,m=l.indexId,y=l.indexVersion,g=p?p.id:null,f=p?p.version:null;if(m!==g||y!==f)return l.indexId=g,l.indexVersion=f,!1;if(l.drawRange.start!==n.drawRange.start||l.drawRange.count!==n.drawRange.count)return l.drawRange.start=n.drawRange.start,l.drawRange.count=n.drawRange.count,!1;if(a.morphTargetInfluences){let x=!1;for(let v=0;v<a.morphTargetInfluences.length;v++)a.morphTargetInfluences[v]!==i.morphTargetInfluences[v]&&(a.morphTargetInfluences[v]=i.morphTargetInfluences[v],x=!0);if(x)return!1}if(a.lights){for(let x=0;x<t.length;x++)if(a.lights[x].map!==t[x].map)return!1}return a.center&&a.center.equals(i.center)===!1?(a.center.copy(i.center),!0):(e.bundle!==null&&(a.version=e.bundle.version),!0)}getLightsData(e){const t=[];for(const i of e)i.isSpotLight===!0&&i.map!==null&&t.push({map:i.map.version});return t}getLights(e,t){if(og.has(e)){const r=og.get(e);if(r.renderId===t)return r.lightsData}const i=this.getLightsData(e.getLights());return og.set(e,{renderId:t,lightsData:i}),i}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;const r=e.object.static===!0,n=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||n)return!1;const a=this.getLights(e.lightsNode,i);return this.equals(e,a)!==!0}}const y3=.05,M1=xe(([s])=>Zn(Bt(1e4,ah(Bt(17,s.x).add(Bt(.1,s.y)))).mul(tr(.1,oh(ah(Bt(13,s.y).add(s.x))))))),b1=xe(([s])=>M1(xt(M1(s.xy),s.z))),x3=xe(([s])=>{const e=ir(Xu(b_(s.xyz)),Xu(S_(s.xyz))),t=ke(1).div(ke(y3).mul(e)).toVar("pixScale"),i=xt(If(ju(Yn(t))),If(y_(Yn(t)))),r=xt(b1(ju(i.x.mul(s.xyz))),b1(ju(i.y.mul(s.xyz)))),n=Zn(Yn(t)),a=tr(Bt(n.oneMinus(),r.x),Bt(n,r.y)),o=lh(n,n.oneMinus()),l=Re(a.mul(a).div(Bt(2,o).mul(Hi(1,o))),a.sub(Bt(.5,o)).div(Hi(1,o)),Hi(1,Hi(1,a).mul(Hi(1,a)).div(Bt(2,o).mul(Hi(1,o))))),h=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return co(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class v3 extends z_{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),i=e.hasGeometryAttribute(t);let r;return i===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new Ai(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const _3=(s=0)=>new v3(s),M3=xe(([s])=>Ui(s.rgb.mul(s.a),s.a),{color:"vec4",return:"vec4"});class lg extends Kf{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}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 e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const i=this[t];i&&i.isNode===!0&&e.push({property:t,childNode:i})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:i}of this._getNodeChildren())e.push(vf(t.slice(0,-4)),i.getCacheKey());return this.type+Jv(e)}build(e){this.setup(e)}setupObserver(e){return new g3(e)}setup(e){e.context.setupNormal=()=>dh(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,i=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context={...e.context,...t.contextNode.getFlowContextData()}:Tt('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context={...e.context,...this.contextNode.getFlowContextData()}:Tt('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();const r=this.setupVertex(e),n=dh(this.vertexNode||r,"VERTEX");e.context.clipSpace=n,e.stack.outputNode=n,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a;const o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(i!==null?i.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);o!==null&&e.stack.addToStack(o);const h=Ui(l,Gi.a).max(0);a=this.setupOutput(e,h),Cf.assign(a);const c=this.outputNode!==null;if(c&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),i!==null){const d=t.getMRT(),u=this.mrtNode;d!==null?(c&&Cf.assign(a),a=d,u!==null&&(a=d.merge(u))):u!==null&&(a=u)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=Ui(l)),a=this.setupOutput(e,l)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:i}=e.clippingContext;let r=null;if(t.length>0||i.length>0){const n=e.renderer.currentSamples;this.alphaToCoverage&&n>1?r=p3():e.stack.addToStack(d3())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(m3()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:i}=e;let r=this.depthNode;if(r===null){const n="getMRT"in t&&t.getMRT();n&&n.has("depth")?r=n.get("depth"):t.logarithmicDepthBuffer===!0&&(i.isPerspectiveCamera?r=x1(hi.z,Jn,Kn):r=bh(hi.z,Jn,Kn))}r!==null&&_1.assign(r).toStack()}setupPositionView(){return W_.mul(Wi).xyz}setupModelViewProjection(){return F2.mul(hi)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),FP}setupPosition(e){const{object:t,geometry:i}=e;if((i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&i3(t).toStack(),t.isSkinnedMesh===!0&&KP(t).toStack(),this.displacementMap){const r=Mo("displacementMap","texture"),n=Mo("displacementScale","float"),a=Mo("displacementBias","float");Wi.addAssign(rr.normalize().mul(r.x.mul(n).add(a)))}return t.isBatchedMesh&&ZP(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&qP(t).toStack(),this.positionNode!==null&&Wi.assign(dh(this.positionNode,"POSITION","vec3")),Wi}setupDiffuseColor(e){const{object:t,geometry:i}=e;this.maskNode!==null&&Nf(this.maskNode).not().discard();let r=this.colorNode?Ui(this.colorNode):IP;this.vertexColors===!0&&i.hasAttribute("color")&&(r=r.mul(_3())),t.instanceColor&&(r=Hu("vec3","vInstanceColor").mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=Hu("vec3","vBatchColor").mul(r)),Gi.assign(r);const n=this.opacityNode?ke(this.opacityNode):LP;Gi.a.assign(Gi.a.mul(n));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode!==null?ke(this.alphaTestNode):RP,this.alphaToCoverage===!0?(Gi.a=uh(a,a.add(T_(Gi.a)),Gi.a),Gi.a.lessThanEqual(0).discard()):Gi.a.lessThanEqual(a).discard()),this.alphaHash===!0&&Gi.a.lessThan(x3(Wi)).discard(),e.isOpaque()&&Gi.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Re(0):Gi.rgb}setupNormal(){return this.normalNode?Re(this.normalNode):DP}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Mo("envMap","cubeTexture"):Mo("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new a3(OP)),t}setupLights(e){const t=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&t.push(i);const r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let n=this.aoNode;n===null&&e.material.aoMap&&(n=UP),e.context.getAO&&(n=e.context.getAO(n,e)),n&&t.push(new s3(n));let a=this.lightsNode||e.lightsNode;return t.length>0&&(a=e.renderer.lighting.createNode([...a.getLights(),...t])),a}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:i,backdropAlphaNode:r,emissiveNode:n}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let o=this.setupOutgoingLight(e);if(a&&a.getScope().hasLights){const l=this.setupLightingModel(e)||null;o=n3(a,l,i,r)}else i!==null&&(o=Re(r!==null?Fi(o,i,r):i));return(n&&n.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(g_.assign(Re(n||PP)),o=o.add(g_)),o}setupFog(e,t){const i=e.fogNode;return i&&(Cf.assign(t),t=Ui(i.toVar())),t}setupPremultipliedAlpha(e,t){return M3(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const i in e){const r=e[i];this[i]===void 0&&(this[i]=r,r&&r.clone&&(this[i]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const i in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,i)===void 0&&t[i].get!==void 0&&Object.defineProperty(this.constructor.prototype,i,t[i])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const i=Kf.prototype.toJSON.call(this,e);i.inputNodes={};for(const{property:n,childNode:a}of this._getNodeChildren())i.inputNodes[n]=a.toJSON(e).uuid;function r(n){const a=[];for(const o in n){const l=n[o];delete l.metadata,a.push(l)}return a}if(t){const n=r(e.textures),a=r(e.images),o=r(e.nodes);n.length>0&&(i.textures=n),a.length>0&&(i.images=a),o.length>0&&(i.nodes=o)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}}class S1 extends oo{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zl,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Ai(0,0,e,t),this.scissorTest=!1,this.viewport=new Ai(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:i.depth},n=new ss(r),a=i.count;for(let o=0;o<a;o++)this.textures[o]=n.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:Zl,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,n=this.textures.length;r<n;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new $f(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class b3{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let S3=0;const T1=new H,So=new no,Cr=new kt,hd=new H,Sh=new H,T3=new H,w3=new no,w1=new H(1,0,0),E1=new H(0,1,0),A1=new H(0,0,1),N1={type:"added"},E3={type:"removed"},To={type:"childadded",child:null},hg={type:"childremoved",child:null};class Ni extends oo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:S3++}),this.uuid=wr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ni.DEFAULT_UP.clone();const e=new H,t=new Lo,i=new no,r=new H(1,1,1);function n(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(n),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new kt},normalMatrix:{value:new xs}}),this.matrix=new kt,this.matrixWorld=new kt,this.matrixAutoUpdate=Ni.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ni.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new b3,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return So.setFromAxisAngle(e,t),this.quaternion.multiply(So),this}rotateOnWorldAxis(e,t){return So.setFromAxisAngle(e,t),this.quaternion.premultiply(So),this}rotateX(e){return this.rotateOnAxis(w1,e)}rotateY(e){return this.rotateOnAxis(E1,e)}rotateZ(e){return this.rotateOnAxis(A1,e)}translateOnAxis(e,t){return T1.copy(e).applyQuaternion(this.quaternion),this.position.add(T1.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(w1,e)}translateY(e){return this.translateOnAxis(E1,e)}translateZ(e){return this.translateOnAxis(A1,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Cr.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?hd.copy(e):hd.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Sh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Cr.lookAt(Sh,hd,this.up):Cr.lookAt(hd,Sh,this.up),this.quaternion.setFromRotationMatrix(Cr),r&&(Cr.extractRotation(r.matrixWorld),So.setFromRotationMatrix(Cr),this.quaternion.premultiply(So.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Tt("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(N1),To.child=e,this.dispatchEvent(To),To.child=null):Tt("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(E3),hg.child=e,this.dispatchEvent(hg),hg.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Cr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Cr.multiply(e.parent.matrixWorld)),e.applyMatrix4(Cr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(N1),To.child=e,this.dispatchEvent(To),To.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const n=this.children[i].getObjectByProperty(e,t);if(n!==void 0)return n}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sh,e,T3),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sh,w3,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,r=e.z,n=this.matrix.elements;n[12]+=t-n[0]*t-n[4]*i-n[8]*r,n[13]+=i-n[1]*t-n[5]*i-n[9]*r,n[14]+=r-n[2]*t-n[6]*i-n[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.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)),t===!0){const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=n(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let h=0,c=l.length;h<c;h++){const d=l[h];n(e.shapes,d)}else n(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(e.materials,this.material[l]));r.material=o}else r.material=n(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(n(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),h=a(e.textures),c=a(e.images),d=a(e.shapes),u=a(e.skeletons),p=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),h.length>0&&(i.textures=h),c.length>0&&(i.images=c),d.length>0&&(i.shapes=d),u.length>0&&(i.skeletons=u),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const h in o){const c=o[h];delete c.metadata,l.push(c)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}Ni.DEFAULT_UP=new H(0,1,0),Ni.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ni.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const cd=new H,ud=new no,ar=new H;class C1 extends Ni{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new kt,this.projectionMatrix=new kt,this.projectionMatrixInverse=new kt,this.coordinateSystem=Zs,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(cd,ud,ar),ar.x===1&&ar.y===1&&ar.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(cd,ud,ar.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(cd,ud,ar),ar.x===1&&ar.y===1&&ar.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(cd,ud,ar.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const cn=new H,R1=new Vt,I1=new Vt;class P1 extends C1{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=eh*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ql*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return eh*2*Math.atan(Math.tan(Ql*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){cn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(cn.x,cn.y).multiplyScalar(-e/cn.z),cn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(cn.x,cn.y).multiplyScalar(-e/cn.z)}getViewSize(e,t){return this.getViewBounds(e,R1,I1),t.subVectors(I1,R1)}setViewOffset(e,t,i,r,n,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ql*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,n=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,h=a.fullHeight;n+=a.offsetX*r/l,t-=a.offsetY*i/h,r*=a.width/l,i*=a.height/h}const o=this.filmOffset;o!==0&&(n+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}let A3=0;const gs=new kt,cg=new Ni,wo=new H,is=new gh,Th=new gh,ci=new H;class Wd extends oo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:A3++}),this.uuid=wr(),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(e){return Array.isArray(e)?this.index=new(IC(e)?g2:f2)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new xs().getNormalMatrix(e);i.applyNormalMatrix(n),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return gs.makeRotationFromQuaternion(e),this.applyMatrix4(gs),this}rotateX(e){return gs.makeRotationX(e),this.applyMatrix4(gs),this}rotateY(e){return gs.makeRotationY(e),this.applyMatrix4(gs),this}rotateZ(e){return gs.makeRotationZ(e),this.applyMatrix4(gs),this}translate(e,t,i){return gs.makeTranslation(e,t,i),this.applyMatrix4(gs),this}scale(e,t,i){return gs.makeScale(e,t,i),this.applyMatrix4(gs),this}lookAt(e){return cg.lookAt(e),cg.updateMatrix(),this.applyMatrix4(cg.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wo).negate(),this.translate(wo.x,wo.y,wo.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,n=e.length;r<n;r++){const a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Bf(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&st("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gh);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Tt("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(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const n=t[i];is.setFromBufferAttribute(n),this.morphTargetsRelative?(ci.addVectors(this.boundingBox.min,is.min),this.boundingBox.expandByPoint(ci),ci.addVectors(this.boundingBox.max,is.max),this.boundingBox.expandByPoint(ci)):(this.boundingBox.expandByPoint(is.min),this.boundingBox.expandByPoint(is.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Tt('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 td);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Tt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new H,1/0);return}if(e){const i=this.boundingSphere.center;if(is.setFromBufferAttribute(e),t)for(let n=0,a=t.length;n<a;n++){const o=t[n];Th.setFromBufferAttribute(o),this.morphTargetsRelative?(ci.addVectors(is.min,Th.min),is.expandByPoint(ci),ci.addVectors(is.max,Th.max),is.expandByPoint(ci)):(is.expandByPoint(Th.min),is.expandByPoint(Th.max))}is.getCenter(i);let r=0;for(let n=0,a=e.count;n<a;n++)ci.fromBufferAttribute(e,n),r=Math.max(r,i.distanceToSquared(ci));if(t)for(let n=0,a=t.length;n<a;n++){const o=t[n],l=this.morphTargetsRelative;for(let h=0,c=o.count;h<c;h++)ci.fromBufferAttribute(o,h),l&&(wo.fromBufferAttribute(e,h),ci.add(wo)),r=Math.max(r,i.distanceToSquared(ci))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Tt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Tt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,n=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new nn(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let _=0;_<i.count;_++)o[_]=new H,l[_]=new H;const h=new H,c=new H,d=new H,u=new Vt,p=new Vt,m=new Vt,y=new H,g=new H;function f(_,S,P){h.fromBufferAttribute(i,_),c.fromBufferAttribute(i,S),d.fromBufferAttribute(i,P),u.fromBufferAttribute(n,_),p.fromBufferAttribute(n,S),m.fromBufferAttribute(n,P),c.sub(h),d.sub(h),p.sub(u),m.sub(u);const C=1/(p.x*m.y-m.x*p.y);isFinite(C)&&(y.copy(c).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(C),g.copy(d).multiplyScalar(p.x).addScaledVector(c,-m.x).multiplyScalar(C),o[_].add(y),o[S].add(y),o[P].add(y),l[_].add(g),l[S].add(g),l[P].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let _=0,S=x.length;_<S;++_){const P=x[_],C=P.start,L=P.count;for(let U=C,V=C+L;U<V;U+=3)f(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const v=new H,M=new H,w=new H,T=new H;function A(_){w.fromBufferAttribute(r,_),T.copy(w);const S=o[_];v.copy(S),v.sub(w.multiplyScalar(w.dot(S))).normalize(),M.crossVectors(T,S);const P=M.dot(l[_])<0?-1:1;a.setXYZW(_,v.x,v.y,v.z,P)}for(let _=0,S=x.length;_<S;++_){const P=x[_],C=P.start,L=P.count;for(let U=C,V=C+L;U<V;U+=3)A(e.getX(U+0)),A(e.getX(U+1)),A(e.getX(U+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new nn(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,p=i.count;u<p;u++)i.setXYZ(u,0,0,0);const r=new H,n=new H,a=new H,o=new H,l=new H,h=new H,c=new H,d=new H;if(e)for(let u=0,p=e.count;u<p;u+=3){const m=e.getX(u+0),y=e.getX(u+1),g=e.getX(u+2);r.fromBufferAttribute(t,m),n.fromBufferAttribute(t,y),a.fromBufferAttribute(t,g),c.subVectors(a,n),d.subVectors(r,n),c.cross(d),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,y),h.fromBufferAttribute(i,g),o.add(c),l.add(c),h.add(c),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(g,h.x,h.y,h.z)}else for(let u=0,p=t.count;u<p;u+=3)r.fromBufferAttribute(t,u+0),n.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),c.subVectors(a,n),d.subVectors(r,n),c.cross(d),i.setXYZ(u+0,c.x,c.y,c.z),i.setXYZ(u+1,c.x,c.y,c.z),i.setXYZ(u+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ci.fromBufferAttribute(e,t),ci.normalize(),e.setXYZ(t,ci.x,ci.y,ci.z)}toNonIndexed(){function e(o,l){const h=o.array,c=o.itemSize,d=o.normalized,u=new h.constructor(l.length*c);let p=0,m=0;for(let y=0,g=l.length;y<g;y++){o.isInterleavedBufferAttribute?p=l[y]*o.data.stride+o.offset:p=l[y]*c;for(let f=0;f<c;f++)u[m++]=h[p++]}return new nn(u,c,d)}if(this.index===null)return st("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Wd,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],h=e(l,i);t.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const l=[],h=n[o];for(let c=0,d=h.length;c<d;c++){const u=h[c],p=e(u,i);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const h=a[o];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const h in l)l[h]!==void 0&&(e[h]=l[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const h=i[l];e.data.attributes[l]=h.toJSON(e.data)}const r={};let n=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],c=[];for(let d=0,u=h.length;d<u;d++){const p=h[d];c.push(p.toJSON(e.data))}c.length>0&&(r[l]=c,n=!0)}n&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const h in r){const c=r[h];this.setAttribute(h,c.clone(t))}const n=e.morphAttributes;for(const h in n){const c=[],d=n[h];for(let u=0,p=d.length;u<p;u++)c.push(d[u].clone(t));this.morphAttributes[h]=c}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let h=0,c=a.length;h<c;h++){const d=a[h];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Rr=new H,ug=new H,dd=new H,un=new H,dg=new H,pd=new H,pg=new H;class N3{constructor(e=new H,t=new H(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Rr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Rr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Rr.copy(this.origin).addScaledVector(this.direction,t),Rr.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){ug.copy(e).add(t).multiplyScalar(.5),dd.copy(t).sub(e).normalize(),un.copy(this.origin).sub(ug);const n=e.distanceTo(t)*.5,a=-this.direction.dot(dd),o=un.dot(this.direction),l=-un.dot(dd),h=un.lengthSq(),c=Math.abs(1-a*a);let d,u,p,m;if(c>0)if(d=a*l-o,u=a*o-l,m=n*c,d>=0)if(u>=-m)if(u<=m){const y=1/c;d*=y,u*=y,p=d*(d+a*u+2*o)+u*(a*d+u+2*l)+h}else u=n,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+h;else u=-n,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+h;else u<=-m?(d=Math.max(0,-(-a*n+o)),u=d>0?-n:Math.min(Math.max(-n,-l),n),p=-d*d+u*(u+2*l)+h):u<=m?(d=0,u=Math.min(Math.max(-n,-l),n),p=u*(u+2*l)+h):(d=Math.max(0,-(a*n+o)),u=d>0?n:Math.min(Math.max(-n,-l),n),p=-d*d+u*(u+2*l)+h);else u=a>0?-n:n,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(ug).addScaledVector(dd,u),p}intersectSphere(e,t){Rr.subVectors(e.center,this.origin);const i=Rr.dot(this.direction),r=Rr.dot(Rr)-i*i,n=e.radius*e.radius;if(r>n)return null;const a=Math.sqrt(n-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,n,a,o,l;const h=1/this.direction.x,c=1/this.direction.y,d=1/this.direction.z,u=this.origin;return h>=0?(i=(e.min.x-u.x)*h,r=(e.max.x-u.x)*h):(i=(e.max.x-u.x)*h,r=(e.min.x-u.x)*h),c>=0?(n=(e.min.y-u.y)*c,a=(e.max.y-u.y)*c):(n=(e.max.y-u.y)*c,a=(e.min.y-u.y)*c),i>a||n>r||((n>i||isNaN(i))&&(i=n),(a<r||isNaN(r))&&(r=a),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Rr)!==null}intersectTriangle(e,t,i,r,n){dg.subVectors(t,e),pd.subVectors(i,e),pg.crossVectors(dg,pd);let a=this.direction.dot(pg),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;un.subVectors(this.origin,e);const l=o*this.direction.dot(pd.crossVectors(un,pd));if(l<0)return null;const h=o*this.direction.dot(dg.cross(un));if(h<0||l+h>a)return null;const c=-o*un.dot(pg);return c<0?null:this.at(c/a,n)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}const Fs=new H,Ir=new H,mg=new H,Pr=new H,Eo=new H,Ao=new H,L1=new H,fg=new H,gg=new H,yg=new H,xg=new Ai,vg=new Ai,_g=new Ai;class zs{constructor(e=new H,t=new H,i=new H){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Fs.subVectors(e,t),r.cross(Fs);const n=r.lengthSq();return n>0?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)}static getBarycoord(e,t,i,r,n){Fs.subVectors(r,t),Ir.subVectors(i,t),mg.subVectors(e,t);const a=Fs.dot(Fs),o=Fs.dot(Ir),l=Fs.dot(mg),h=Ir.dot(Ir),c=Ir.dot(mg),d=a*h-o*o;if(d===0)return n.set(0,0,0),null;const u=1/d,p=(h*l-o*c)*u,m=(a*c-o*l)*u;return n.set(1-p-m,m,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Pr)===null?!1:Pr.x>=0&&Pr.y>=0&&Pr.x+Pr.y<=1}static getInterpolation(e,t,i,r,n,a,o,l){return this.getBarycoord(e,t,i,r,Pr)===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(n,Pr.x),l.addScaledVector(a,Pr.y),l.addScaledVector(o,Pr.z),l)}static getInterpolatedAttribute(e,t,i,r,n,a){return xg.setScalar(0),vg.setScalar(0),_g.setScalar(0),xg.fromBufferAttribute(e,t),vg.fromBufferAttribute(e,i),_g.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(xg,n.x),a.addScaledVector(vg,n.y),a.addScaledVector(_g,n.z),a}static isFrontFacing(e,t,i,r){return Fs.subVectors(i,t),Ir.subVectors(e,t),Fs.cross(Ir).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fs.subVectors(this.c,this.b),Ir.subVectors(this.a,this.b),Fs.cross(Ir).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zs.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zs.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,n){return zs.getInterpolation(e,this.a,this.b,this.c,t,i,r,n)}containsPoint(e){return zs.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zs.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,n=this.c;let a,o;Eo.subVectors(r,i),Ao.subVectors(n,i),fg.subVectors(e,i);const l=Eo.dot(fg),h=Ao.dot(fg);if(l<=0&&h<=0)return t.copy(i);gg.subVectors(e,r);const c=Eo.dot(gg),d=Ao.dot(gg);if(c>=0&&d<=c)return t.copy(r);const u=l*d-c*h;if(u<=0&&l>=0&&c<=0)return a=l/(l-c),t.copy(i).addScaledVector(Eo,a);yg.subVectors(e,n);const p=Eo.dot(yg),m=Ao.dot(yg);if(m>=0&&p<=m)return t.copy(n);const y=p*h-l*m;if(y<=0&&h>=0&&m<=0)return o=h/(h-m),t.copy(i).addScaledVector(Ao,o);const g=c*m-p*d;if(g<=0&&d-c>=0&&p-m>=0)return L1.subVectors(n,r),o=(d-c)/(d-c+(p-m)),t.copy(r).addScaledVector(L1,o);const f=1/(g+y+u);return a=y*f,o=u*f,t.copy(i).addScaledVector(Eo,a).addScaledVector(Ao,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class C3 extends Kf{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ds(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 Lo,this.combine=fC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const D1=new kt,ea=new N3,md=new td,O1=new H,fd=new H,gd=new H,yd=new H,Mg=new H,xd=new H,U1=new H,vd=new H;class R3 extends Ni{constructor(e=new Wd,t=new C3){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,n=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(n&&o){xd.set(0,0,0);for(let l=0,h=n.length;l<h;l++){const c=o[l],d=n[l];c!==0&&(Mg.fromBufferAttribute(d,e),a?xd.addScaledVector(Mg,c):xd.addScaledVector(Mg.sub(t),c))}t.add(xd)}return t}raycast(e,t){const i=this.geometry,r=this.material,n=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),md.copy(i.boundingSphere),md.applyMatrix4(n),ea.copy(e.ray).recast(e.near),!(md.containsPoint(ea.origin)===!1&&(ea.intersectSphere(md,O1)===null||ea.origin.distanceToSquared(O1)>(e.far-e.near)**2))&&(D1.copy(n).invert(),ea.copy(e.ray).applyMatrix4(D1),!(i.boundingBox!==null&&ea.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,ea)))}_computeIntersections(e,t,i){let r;const n=this.geometry,a=this.material,o=n.index,l=n.attributes.position,h=n.attributes.uv,c=n.attributes.uv1,d=n.attributes.normal,u=n.groups,p=n.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,y=u.length;m<y;m++){const g=u[m],f=a[g.materialIndex],x=Math.max(g.start,p.start),v=Math.min(o.count,Math.min(g.start+g.count,p.start+p.count));for(let M=x,w=v;M<w;M+=3){const T=o.getX(M),A=o.getX(M+1),_=o.getX(M+2);r=_d(this,f,e,i,h,c,d,T,A,_),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),y=Math.min(o.count,p.start+p.count);for(let g=m,f=y;g<f;g+=3){const x=o.getX(g),v=o.getX(g+1),M=o.getX(g+2);r=_d(this,a,e,i,h,c,d,x,v,M),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,y=u.length;m<y;m++){const g=u[m],f=a[g.materialIndex],x=Math.max(g.start,p.start),v=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let M=x,w=v;M<w;M+=3){const T=M,A=M+1,_=M+2;r=_d(this,f,e,i,h,c,d,T,A,_),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let g=m,f=y;g<f;g+=3){const x=g,v=g+1,M=g+2;r=_d(this,a,e,i,h,c,d,x,v,M),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}}function I3(s,e,t,i,r,n,a,o){let l;if(e.side===rf?l=i.intersectTriangle(a,n,r,!0,o):l=i.intersectTriangle(r,n,a,e.side===sf,o),l===null)return null;vd.copy(o),vd.applyMatrix4(s.matrixWorld);const h=t.ray.origin.distanceTo(vd);return h<t.near||h>t.far?null:{distance:h,point:vd.clone(),object:s}}function _d(s,e,t,i,r,n,a,o,l,h){s.getVertexPosition(o,fd),s.getVertexPosition(l,gd),s.getVertexPosition(h,yd);const c=I3(s,e,t,i,fd,gd,yd,U1);if(c){const d=new H;zs.getBarycoord(U1,fd,gd,yd,d),r&&(c.uv=zs.getInterpolatedAttribute(r,o,l,h,d,new Vt)),n&&(c.uv1=zs.getInterpolatedAttribute(n,o,l,h,d,new Vt)),a&&(c.normal=zs.getInterpolatedAttribute(a,o,l,h,d,new H),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const u={a:o,b:l,c:h,normal:new H,materialIndex:0};zs.getNormal(fd,gd,yd,u.normal),c.face=u,c.barycoord=d}return c}class P3{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const i=this.getMaterialNodeClass(e.type);if(i!==null){t=new i;for(const r in e)t[r]=e[r]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,i){if(i.has(t)){st(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);i.set(t,e)}addClass(e,t,i){if(i.has(t)){st(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);i.set(t,e)}}class ta extends Ni{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ds(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}const bg=new H,L3=new H,D3=new xs;class ia{constructor(e=new H(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=bg.subVectors(i,t).cross(L3.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(bg),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const n=-(e.start.dot(this.normal)+this.constant)/r;return n<0||n>1?null:t.copy(e.start).addScaledVector(i,n)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||D3.getNormalMatrix(e),r=this.coplanarPoint(bg).applyMatrix4(e),n=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(n),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const sa=new td,O3=new Vt(.5,.5),Md=new H;class U3{constructor(e=new ia,t=new ia,i=new ia,r=new ia,n=new ia,a=new ia){this.planes=[e,t,i,r,n,a]}set(e,t,i,r,n,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(n),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zs,i=!1){const r=this.planes,n=e.elements,a=n[0],o=n[1],l=n[2],h=n[3],c=n[4],d=n[5],u=n[6],p=n[7],m=n[8],y=n[9],g=n[10],f=n[11],x=n[12],v=n[13],M=n[14],w=n[15];if(r[0].setComponents(h-a,p-c,f-m,w-x).normalize(),r[1].setComponents(h+a,p+c,f+m,w+x).normalize(),r[2].setComponents(h+o,p+d,f+y,w+v).normalize(),r[3].setComponents(h-o,p-d,f-y,w-v).normalize(),i)r[4].setComponents(l,u,g,M).normalize(),r[5].setComponents(h-l,p-u,f-g,w-M).normalize();else if(r[4].setComponents(h-l,p-u,f-g,w-M).normalize(),t===Zs)r[5].setComponents(h+l,p+u,f+g,w+M).normalize();else if(t===tn)r[5].setComponents(l,u,g,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),sa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),sa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sa)}intersectsSprite(e){sa.center.set(0,0,0);const t=O3.distanceTo(e.center);return sa.radius=.7071067811865476+t,sa.applyMatrix4(e.matrixWorld),this.intersectsSphere(sa)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let n=0;n<6;n++)if(t[n].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Md.x=r.normal.x>0?e.max.x:e.min.x,Md.y=r.normal.y>0?e.max.y:e.min.y,Md.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Md)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Sg=new kt,F1=new H,z1=new H;class Tg{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vt(512,512),this.mapType=Dv,this.map=null,this.mapPass=null,this.matrix=new kt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new U3,this._frameExtents=new Vt(1,1),this._viewportCount=1,this._viewports=[new Ai(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;F1.setFromMatrixPosition(e.matrixWorld),t.position.copy(F1),z1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(z1),t.updateMatrixWorld(),Sg.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sg,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===tn||t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Sg)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class F3 extends Tg{constructor(){super(new P1(90,1,.5,500)),this.isPointLightShadow=!0}}class z3 extends ta{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new F3}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class B1 extends C1{constructor(e=-1,t=1,i=1,r=-1,n=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=n,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,n,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let n=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,a=n+h*this.view.width,o-=c*this.view.offsetY,l=o-c*this.view.height}this.projectionMatrix.makeOrthographic(n,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class B3 extends Tg{constructor(){super(new B1(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class V3 extends ta{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ni.DEFAULT_UP),this.updateMatrix(),this.target=new Ni,this.shadow=new B3}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class k3 extends ta{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class G3 extends Tg{constructor(){super(new P1(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=eh*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,n=e.distance||t.far;(i!==t.fov||r!==t.aspect||n!==t.far)&&(t.fov=i,t.aspect=r,t.far=n,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class wg extends ta{constructor(e,t,i=0,r=Math.PI/3,n=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ni.DEFAULT_UP),this.updateMatrix(),this.target=new Ni,this.distance=i,this.angle=r,this.penumbra=n,this.decay=a,this.map=null,this.shadow=new G3}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class H3 extends ta{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class W3 extends ta{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ni.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ds(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}class j3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new H)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,n=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*n),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*n)),t.addScaledVector(a[6],.315392*(3*n*n-1)),t.addScaledVector(a[7],1.092548*(i*n)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,n=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*n),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*n),t.addScaledVector(a[6],.743125*n*n-.247708),t.addScaledVector(a[7],2*.429043*i*n),t.addScaledVector(a[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,n=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*n,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*n,t[6]=.315392*(3*n*n-1),t[7]=1.092548*i*n,t[8]=.546274*(i*i-r*r)}}class X3 extends ta{constructor(e=new j3,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class q3 extends wg{constructor(e,t,i,r,n,a){super(e,t,i,r,n,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class Y3 extends wg{constructor(e,t,i,r,n,a){super(e,t,i,r,n,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}xe(({texture:s,uv:e})=>{const t=Re().toVar();return ds(e.x.lessThan(1e-4),()=>{t.assign(Re(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{t.assign(Re(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{t.assign(Re(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{t.assign(Re(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{t.assign(Re(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{t.assign(Re(0,0,-1))}).Else(()=>{const i=s.sample(e.add(Re(-.01,0,0))).r.sub(s.sample(e.add(Re(.01,0,0))).r),r=s.sample(e.add(Re(0,-.01,0))).r.sub(s.sample(e.add(Re(0,.01,0))).r),n=s.sample(e.add(Re(0,0,-.01))).r.sub(s.sample(e.add(Re(0,0,.01))).r);t.assign(Re(i,r,n))}),t.normalize()});const bd=new Vt;class Z3 extends ad{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){const t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class V1 extends Z3{static get type(){return"PassMultipleTextureNode"}constructor(e,t,i=!1){super(e,null),this.textureName=t,this.previousTexture=i,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}class jd extends mi{static get type(){return"PassNode"}constructor(e,t,i,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=i,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const n=new Mh;n.isRenderTargetTexture=!0,n.name="depth";const a=new S1(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Jl,...r});a.texture.name="output",a.depthTexture=n,this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=dt(0),this._cameraFar=dt(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ht.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return st("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return st("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const i=this._textures[e],r=this.renderTarget.textures.indexOf(i);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=i,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new V1(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new V1(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=y1(this.getTextureNode(e),i,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar,n=this.getViewZNode(e);this._linearDepthNodes[e]=t=bh(n,i,r)}return t}async compileAsync(e){const t=e.getRenderTarget(),i=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(i)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),this.scope===jd.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:i}=this;let r,n;const a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(n=1,r=t.xr.getCamera(),t.xr.updateCamera(r),bd.set(a.width,a.height)):(r=this.camera,n=t.getPixelRatio(),t.getSize(bd)),this._pixelRatio=n,this.setSize(bd.width,bd.height);const o=t.getRenderTarget(),l=t.getMRT(),h=t.autoClear,c=t.transparent,d=t.opaque,u=r.layers.mask,p=t.contextNode,m=i.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(const g in this._previousTextures)this.toggleTexture(g);this.overrideMaterial!==null&&(i.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:uo({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const y=i.name;i.name=this.name?this.name:i.name,t.render(i,r),i.name=y,i.overrideMaterial=m,t.setRenderTarget(o),t.setMRT(l),t.autoClear=h,t.transparent=c,t.opaque=d,t.contextNode=p,r.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const i=Math.floor(this._width*this._pixelRatio*this._resolutionScale),r=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(i,r),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,i,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Ai),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,i,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,i,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Ai),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,i,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}jd.COLOR="color",jd.DEPTH="depth";class or extends ze{static get type(){return"AtomicFunctionNode"}constructor(e,t,i){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=i,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),i=t.parents,r=this.method,n=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,l=this.valueNode,h=[];h.push(`&${o.build(e,a)}`),l!==null&&h.push(l.build(e,a));const c=`${e.getMethod(r,n)}( ${h.join(", ")} )`;if(i&&i.length===1&&i[0].isStackNode===!0)e.addLineFlowCode(c,this);else return t.constNode===void 0&&(t.constNode=Ar(c,n).toConst()),t.constNode.build(e)}}or.ATOMIC_LOAD="atomicLoad",or.ATOMIC_STORE="atomicStore",or.ATOMIC_ADD="atomicAdd",or.ATOMIC_SUB="atomicSub",or.ATOMIC_MAX="atomicMax",or.ATOMIC_MIN="atomicMin",or.ATOMIC_AND="atomicAnd",or.ATOMIC_OR="atomicOr",or.ATOMIC_XOR="atomicXor",Pt(or);class J3 extends ze{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:i}=e;i.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
|
|
4084
|
-
`):e.addLineFlowCode(`${t}Barrier()`,this)}}Pt(J3);class yt extends mi{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,i=null){super(),this.method=e,this.aNode=t,this.bNode=i}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,i=this.bNode?this.bNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),n=e.isMatrix(i)?0:e.getTypeLength(i);return r>n?t:i}getNodeType(e){const t=this.method;return t===yt.SUBGROUP_ELECT?"bool":t===yt.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const i=this.method,r=this.getNodeType(e),n=this.getInputType(e),a=this.aNode,o=this.bNode,l=[];if(i===yt.SUBGROUP_BROADCAST||i===yt.SUBGROUP_SHUFFLE||i===yt.QUAD_BROADCAST){const c=o.getNodeType(e);l.push(a.build(e,r),o.build(e,c==="float"?"int":r))}else i===yt.SUBGROUP_SHUFFLE_XOR||i===yt.SUBGROUP_SHUFFLE_DOWN||i===yt.SUBGROUP_SHUFFLE_UP?l.push(a.build(e,r),o.build(e,"uint")):(a!==null&&l.push(a.build(e,n)),o!==null&&l.push(o.build(e,n)));const h=l.length===0?"()":`( ${l.join(", ")} )`;return e.format(`${e.getMethod(i,r)}${h}`,r,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}yt.SUBGROUP_ELECT="subgroupElect",yt.SUBGROUP_BALLOT="subgroupBallot",yt.SUBGROUP_ADD="subgroupAdd",yt.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",yt.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",yt.SUBGROUP_MUL="subgroupMul",yt.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",yt.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",yt.SUBGROUP_AND="subgroupAnd",yt.SUBGROUP_OR="subgroupOr",yt.SUBGROUP_XOR="subgroupXor",yt.SUBGROUP_MIN="subgroupMin",yt.SUBGROUP_MAX="subgroupMax",yt.SUBGROUP_ALL="subgroupAll",yt.SUBGROUP_ANY="subgroupAny",yt.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",yt.QUAD_SWAP_X="quadSwapX",yt.QUAD_SWAP_Y="quadSwapY",yt.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",yt.SUBGROUP_BROADCAST="subgroupBroadcast",yt.SUBGROUP_SHUFFLE="subgroupShuffle",yt.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",yt.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",yt.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",yt.QUAD_BROADCAST="quadBroadcast";class K3 extends ze{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=ht.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){k1.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Jf)}}const k1=f_("vec3","shadowPositionWorld"),Eg=new B1(-1,1,1,-1,0,1);class $3 extends Wd{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Bf([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Bf(t,2))}}const Q3=new $3;class eL extends R3{constructor(e=null){super(Q3,e),this.camera=Eg,this.isQuadMesh=!0}async renderAsync(e){so('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,Eg)}render(e){e.render(this,Eg)}}let Sd;function Td(s){Sd=Sd||new WeakMap;let e=Sd.get(s);return e===void 0&&Sd.set(s,e={}),e}function Ag(s){const e=Td(s);return e.shadowMatrix||(e.shadowMatrix=dt("mat4").setGroup(it).onRenderUpdate(t=>((s.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(s.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(s.shadow.camera.coordinateSystem=t.camera.coordinateSystem,s.shadow.camera.updateProjectionMatrix()),s.shadow.updateMatrices(s)),s.shadow.matrix)))}function tL(s,e=Jf){const t=Ag(s).mul(e);return t.xyz.div(t.w)}function G1(s){const e=Td(s);return e.position||(e.position=dt(new H).setGroup(it).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(s.matrixWorld)))}function iL(s){const e=Td(s);return e.targetPosition||(e.targetPosition=dt(new H).setGroup(it).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(s.target.matrixWorld)))}function H1(s){const e=Td(s);return e.viewPosition||(e.viewPosition=dt(new H).setGroup(it).onRenderUpdate(({camera:t},i)=>{i.value=i.value||new H,i.value.setFromMatrixPosition(s.matrixWorld),i.value.applyMatrix4(t.matrixWorldInverse)}))}const W1=s=>fo.transformDirection(G1(s).sub(iL(s)));function sL(s,e={}){return e.toneMapping=s.toneMapping,e.toneMappingExposure=s.toneMappingExposure,e.outputColorSpace=s.outputColorSpace,e.renderTarget=s.getRenderTarget(),e.activeCubeFace=s.getActiveCubeFace(),e.activeMipmapLevel=s.getActiveMipmapLevel(),e.renderObjectFunction=s.getRenderObjectFunction(),e.pixelRatio=s.getPixelRatio(),e.mrt=s.getMRT(),e.clearColor=s.getClearColor(e.clearColor||new Ds),e.clearAlpha=s.getClearAlpha(),e.autoClear=s.autoClear,e.scissorTest=s.getScissorTest(),e}function rL(s,e){return e=sL(s,e),s.setMRT(null),s.setRenderObjectFunction(null),s.setClearColor(0,1),s.autoClear=!0,e}function nL(s,e){s.toneMapping=e.toneMapping,s.toneMappingExposure=e.toneMappingExposure,s.outputColorSpace=e.outputColorSpace,s.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),s.setRenderObjectFunction(e.renderObjectFunction),s.setPixelRatio(e.pixelRatio),s.setMRT(e.mrt),s.setClearColor(e.clearColor,e.clearAlpha),s.autoClear=e.autoClear,s.setScissorTest(e.scissorTest)}function aL(s,e={}){return e.background=s.background,e.backgroundNode=s.backgroundNode,e.overrideMaterial=s.overrideMaterial,e}function oL(s,e){return e=aL(s,e),s.background=null,s.backgroundNode=null,s.overrideMaterial=null,e}function lL(s,e){s.background=e.background,s.backgroundNode=e.backgroundNode,s.overrideMaterial=e.overrideMaterial}function hL(s,e,t){return t=rL(s,t),t=oL(e,t),t}function cL(s,e,t){nL(s,t),lL(e,t)}const j1=xe(([s])=>Zn(ke(52.9829189).mul(Zn(ch(s,xt(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),lr=xe(([s,e,t])=>{const i=ke(2.399963229728653),r=nh(ke(s).add(.5).div(ke(e))),n=ke(s).mul(i).add(t);return xt(x_(n),ah(n)).mul(r)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),wd=new WeakMap,uL=xe(({depthTexture:s,shadowCoord:e,depthLayer:t})=>{let i=gi(s,e.xy).setName("t_basic");return s.isArrayTexture&&(i=i.depth(t)),i.compare(e.z)}),dL=xe(({depthTexture:s,shadowCoord:e,shadow:t,depthLayer:i})=>{const r=(c,d)=>{let u=gi(s,c);return s.isArrayTexture&&(u=u.depth(i)),u.compare(d)},n=ri("mapSize","vec2",t).setGroup(it),a=ri("radius","float",t).setGroup(it),o=xt(1).div(n),l=a.mul(o.x),h=j1(fh.xy).mul(6.28318530718);return tr(r(e.xy.add(lr(0,5,h).mul(l)),e.z),r(e.xy.add(lr(1,5,h).mul(l)),e.z),r(e.xy.add(lr(2,5,h).mul(l)),e.z),r(e.xy.add(lr(3,5,h).mul(l)),e.z),r(e.xy.add(lr(4,5,h).mul(l)),e.z)).mul(1/5)}),pL=xe(({depthTexture:s,shadowCoord:e,shadow:t,depthLayer:i})=>{const r=(d,u)=>{let p=gi(s,d);return s.isArrayTexture&&(p=p.depth(i)),p.compare(u)},n=ri("mapSize","vec2",t).setGroup(it),a=xt(1).div(n),o=a.x,l=a.y,h=e.xy,c=Zn(h.mul(n).add(.5));return h.subAssign(c.mul(a)),tr(r(h,e.z),r(h.add(xt(o,0)),e.z),r(h.add(xt(0,l)),e.z),r(h.add(a),e.z),Fi(r(h.add(xt(o.negate(),0)),e.z),r(h.add(xt(o.mul(2),0)),e.z),c.x),Fi(r(h.add(xt(o.negate(),l)),e.z),r(h.add(xt(o.mul(2),l)),e.z),c.x),Fi(r(h.add(xt(0,l.negate())),e.z),r(h.add(xt(0,l.mul(2))),e.z),c.y),Fi(r(h.add(xt(o,l.negate())),e.z),r(h.add(xt(o,l.mul(2))),e.z),c.y),Fi(Fi(r(h.add(xt(o.negate(),l.negate())),e.z),r(h.add(xt(o.mul(2),l.negate())),e.z),c.x),Fi(r(h.add(xt(o.negate(),l.mul(2))),e.z),r(h.add(xt(o.mul(2),l.mul(2))),e.z),c.x),c.y)).mul(1/9)}),mL=xe(({depthTexture:s,shadowCoord:e,depthLayer:t},i)=>{let r=gi(s).sample(e.xy);s.isArrayTexture&&(r=r.depth(t)),r=r.rg;const n=r.x,a=ir(1e-7,r.y.mul(r.y)),o=i.renderer.reversedDepthBuffer?hh(n,e.z):hh(e.z,n),l=ke(1).toVar();return ds(o.notEqual(1),()=>{const h=e.z.sub(n);let c=a.div(a.add(h.mul(h)));c=co(Hi(c,.3).div(.65)),l.assign(ir(o,c))}),l}),fL=s=>{let e=wd.get(s);return e===void 0&&(e=new lg,e.colorNode=Ui(0,0,0,1),e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.blending=mC,e.fog=!1,wd.set(s,e)),e},gL=s=>{const e=wd.get(s);e!==void 0&&(e.dispose(),wd.delete(s))};class yL{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let i=this.weakMaps[t];return i===void 0&&(i=new WeakMap,this.weakMaps[t]=i),i}get(e){let t=this._getWeakMap(e);for(let i=0;i<e.length-1;i++)if(t=t.get(e[i]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let i=this._getWeakMap(e);for(let r=0;r<e.length-1;r++){const n=e[r];i.has(n)===!1&&i.set(n,new WeakMap),i=i.get(n)}return i.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let i=0;i<e.length-1;i++)if(t=t.get(e[i]),t===void 0)return!1;return t.delete(e[e.length-1])}}const X1=new yL,No=[],xL=(s,e,t,i)=>{No[0]=s,No[1]=e;let r=X1.get(No);return(r===void 0||r.shadowType!==t||r.useVelocity!==i)&&(r=(n,a,o,l,h,c,...d)=>{(n.castShadow===!0||n.receiveShadow&&t===Pu)&&(i&&(iR(n).useVelocity=!0),n.onBeforeShadow(s,n,o,e.camera,l,a.overrideMaterial,c),s.renderObject(n,a,o,l,h,c,...d),n.onAfterShadow(s,n,o,e.camera,l,a.overrideMaterial,c))},r.shadowType=t,r.useVelocity=i,X1.set(No,r)),No[0]=null,No[1]=null,r},vL=xe(({samples:s,radius:e,size:t,shadowPass:i,depthLayer:r})=>{const n=ke(0).toVar("meanVertical"),a=ke(0).toVar("squareMeanVertical"),o=s.lessThanEqual(ke(1)).select(ke(0),ke(2).div(s.sub(1))),l=s.lessThanEqual(ke(1)).select(ke(0),ke(-1));hn({start:zt(0),end:zt(s),type:"int",condition:"<"},({i:c})=>{const d=l.add(ke(c).mul(o));let u=i.sample(tr(fh.xy,xt(0,d).mul(e)).div(t));i.value.isArrayTexture&&(u=u.depth(r)),u=u.x,n.addAssign(u),a.addAssign(u.mul(u))}),n.divAssign(s),a.divAssign(s);const h=nh(a.sub(n.mul(n)).max(0));return xt(n,h)}),_L=xe(({samples:s,radius:e,size:t,shadowPass:i,depthLayer:r})=>{const n=ke(0).toVar("meanHorizontal"),a=ke(0).toVar("squareMeanHorizontal"),o=s.lessThanEqual(ke(1)).select(ke(0),ke(2).div(s.sub(1))),l=s.lessThanEqual(ke(1)).select(ke(0),ke(-1));hn({start:zt(0),end:zt(s),type:"int",condition:"<"},({i:c})=>{const d=l.add(ke(c).mul(o));let u=i.sample(tr(fh.xy,xt(d,0).mul(e)).div(t));i.value.isArrayTexture&&(u=u.depth(r)),n.addAssign(u.x),a.addAssign(tr(u.y.mul(u.y),u.x.mul(u.x)))}),n.divAssign(s),a.divAssign(s);const h=nh(a.sub(n.mul(n)).max(0));return xt(n,h)}),ML=[uL,dL,pL,mL];let Ng;const Ed=new eL;class q1 extends K3{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.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(e,{filterFn:t,depthTexture:i,shadowCoord:r,shadow:n,depthLayer:a}){const o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:i,shadowCoord:r,shadow:n,depthLayer:a});return o.select(l,ke(1))}setupShadowCoord(e,t){const{shadow:i}=this,{renderer:r}=e,n=i.biasNode||ri("bias","float",i).setGroup(it);let a=t,o;if(i.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{const l=a.w;a=a.xy.div(l);const h=ri("near","float",i.camera).setGroup(it),c=ri("far","float",i.camera).setGroup(it);o=x1(l.negate(),h,c)}return a=Re(a.x,a.y.oneMinus(),r.reversedDepthBuffer?o.sub(n):o.add(n)),a}getShadowFilterFn(e){return ML[e]}setupRenderTarget(e,t){const i=new Mh(e.mapSize.width,e.mapSize.height);i.name="ShadowDepthTexture",i.compareFunction=t.renderer.reversedDepthBuffer?Du:uf;const r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name="ShadowMap",r.texture.type=e.mapType,r.depthTexture=i,{shadowMap:r,depthTexture:i}}setupShadow(e){const{renderer:t,camera:i}=e,{light:r,shadow:n}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(n,e),l=t.shadowMap.type,h=t.hasCompatibility(kv.TEXTURE_COMPARE);if((l===uC||l===dC)&&h?(a.minFilter=Zl,a.magFilter=Zl):(a.minFilter=cs,a.magFilter=cs),n.camera.coordinateSystem=i.coordinateSystem,n.camera.updateProjectionMatrix(),l===Pu&&n.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Kl,type:Jl,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Kl,type:Jl,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Kl,type:Jl,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Kl,type:Jl,depthBuffer:!1}));let M=gi(a);a.isArrayTexture&&(M=M.depth(this.depthLayer));let w=gi(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(w=w.depth(this.depthLayer));const T=ri("blurSamples","float",n).setGroup(it),A=ri("radius","float",n).setGroup(it),_=ri("mapSize","vec2",n).setGroup(it);let S=this.vsmMaterialVertical||(this.vsmMaterialVertical=new lg);S.fragmentNode=vL({samples:T,radius:A,size:_,shadowPass:M,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMVertical",S=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new lg),S.fragmentNode=_L({samples:T,radius:A,size:_,shadowPass:w,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMHorizontal"}const c=ri("intensity","float",n).setGroup(it),d=ri("normalBias","float",n).setGroup(it),u=Ag(r).mul(k1.add(rd.mul(d))),p=this.setupShadowCoord(e,u),m=n.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(m===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const y=l===Pu&&n.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,g=this.setupShadowFilter(e,{filterFn:m,shadowTexture:o.texture,depthTexture:y,shadowCoord:p,shadow:n,depthLayer:this.depthLayer});let f;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?f=nr(o.texture,p.xyz):(f=gi(o.texture,p),a.isArrayTexture&&(f=f.depth(this.depthLayer))));let x;f?x=Fi(1,g.rgb.mix(f,1),c.mul(f.a)).toVar():x=Fi(1,g,c).toVar(),this.shadowMap=o,this.shadow.map=o;const v=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return f&&x.toInspector(`${v} / Color`,()=>this.shadowMap.texture.isCubeTexture?nr(this.shadowMap.texture):gi(this.shadowMap.texture)),x.toInspector(`${v} / Depth`,()=>this.shadowMap.texture.isCubeTexture?nr(this.shadowMap.texture).r.oneMinus():fs(this.shadowMap.depthTexture,nd().mul(vo(gi(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return xe(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let i=this._node;return this.setupShadowPosition(e),i===null&&(this._node=i=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(i=e.material.receivedShadowNode(i)),i})()}renderShadow(e){const{shadow:t,shadowMap:i,light:r}=this,{renderer:n,scene:a}=e;t.updateMatrices(r),i.setSize(t.mapSize.width,t.mapSize.height,i.depth);const o=a.name;a.name=`Shadow Map [ ${r.name||"ID: "+r.id} ]`,n.render(a,t.camera),a.name=o}updateShadow(e){const{shadowMap:t,light:i,shadow:r}=this,{renderer:n,scene:a,camera:o}=e,l=n.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h;const c=r.camera.layers.mask;(r.camera.layers.mask&4294967294)===0&&(r.camera.layers.mask=o.layers.mask);const d=n.getRenderObjectFunction(),u=n.getMRT(),p=u?u.has("velocity"):!1;Ng=hL(n,a,Ng),a.overrideMaterial=fL(i),n.setRenderObjectFunction(xL(n,r,l,p)),n.setClearColor(0,0),n.setRenderTarget(t),this.renderShadow(e),n.setRenderObjectFunction(d),l===Pu&&r.isPointLightShadow!==!0&&this.vsmPass(n),r.camera.layers.mask=c,cL(n,a,Ng)}vsmPass(e){const{shadow:t}=this,i=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,i),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,i),e.setRenderTarget(this.vsmShadowMapVertical),Ed.material=this.vsmMaterialVertical,Ed.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Ed.material=this.vsmMaterialHorizontal,Ed.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,gL(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(e){const{shadow:t}=this;let i=t.needsUpdate||t.autoUpdate;i&&(this._cameraFrameId[e.camera]===e.frameId&&(i=!1),this._cameraFrameId[e.camera]=e.frameId),i&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const bL=(s,e)=>new q1(s,e);class ra extends ag{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Ds,this.colorNode=e&&e.colorNode||dt(this.color).setGroup(it),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ht.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.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(e){return H1(this.light).sub(e.context.positionView||hi)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return bL(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let i=this.shadowColorNode;if(i===null){const r=this.light.shadow.shadowNode;let n;r!==void 0?n=Fe(r):n=this.setupShadowNode(),this.shadowNode=n,this.shadowColorNode=i=this.colorNode.mul(n),this.baseColorNode=this.colorNode}e.context.getShadow&&(i=e.context.getShadow(this,e)),this.colorNode=i}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),i=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),i&&e.lightsNode.setupDirectRectAreaLight(e,this,i)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}class SL extends ra{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class TL extends ra{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:W1(this.light),lightColor:e}}}class wL extends ra{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=G1(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=dt(new Ds).setGroup(it)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:i,lightDirectionNode:r}=this,n=rd.dot(r).mul(.5).add(.5),a=Fi(i,t,n);e.context.irradiance.addAssign(a)}}const Y1=xe(({lightDistance:s,cutoffDistance:e,decayExponent:t})=>{const i=s.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(i.mul(s.div(e).pow4().oneMinus().clamp().pow2()),i)});class Cg extends ra{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=dt(0).setGroup(it),this.penumbraCosNode=dt(0).setGroup(it),this.cutoffDistanceNode=dt(0).setGroup(it),this.decayExponentNode=dt(0).setGroup(it),this.colorNode=dt(this.color).setGroup(it)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:i,penumbraCosNode:r}=this;return uh(i,r,t)}getLightCoord(e){const t=e.getNodeProperties(this);let i=t.projectionUV;return i===void 0&&(i=tL(this.light,e.context.positionWorld),t.projectionUV=i),i}setupDirect(e){const{colorNode:t,cutoffDistanceNode:i,decayExponentNode:r,light:n}=this,a=this.getLightVector(e),o=a.normalize(),l=o.dot(W1(n)),h=this.getSpotAttenuation(e,l),c=a.length(),d=Y1({lightDistance:c,cutoffDistance:i,decayExponent:r});let u=t.mul(h).mul(d),p,m;return n.colorNode?(m=this.getLightCoord(e),p=n.colorNode(m)):n.map&&(m=this.getLightCoord(e),p=gi(n.map,m.xy).onRenderUpdate(()=>n.map)),p&&(u=m.mul(2).sub(1).abs().lessThan(1).all().select(u.mul(p),u)),{lightColor:u,lightDirection:o}}}class EL extends Cg{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const i=this.light.iesMap;let r=null;if(i&&i.isTexture===!0){const n=t.acos().mul(1/Math.PI);r=gi(i,xt(n,0),0).r}else r=super.getSpotAttenuation(t);return r}}const AL=xe(([s,e])=>{const t=s.x,i=s.y,r=s.z;let n=e.element(0).mul(.886227);return n=n.add(e.element(1).mul(2*.511664).mul(i)),n=n.add(e.element(2).mul(2*.511664).mul(r)),n=n.add(e.element(3).mul(2*.511664).mul(t)),n=n.add(e.element(4).mul(2*.429043).mul(t).mul(i)),n=n.add(e.element(5).mul(2*.429043).mul(i).mul(r)),n=n.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),n=n.add(e.element(7).mul(2*.429043).mul(t).mul(r)),n=n.add(e.element(8).mul(.429043).mul(Bt(t,t).sub(Bt(i,i)))),n});class NL extends ra{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let i=0;i<9;i++)t.push(new H);this.lightProbe=sr(t)}update(e){const{light:t}=this;super.update(e);for(let i=0;i<9;i++)this.lightProbe.array[i].copy(t.sh.coefficients[i]).multiplyScalar(t.intensity)}setup(e){const t=AL(rd,this.lightProbe);e.context.irradiance.addAssign(t)}}class CL extends Mh{constructor(e,t=of,i=af,r,n,a=cs,o=cs,l,h=lf){const c={width:e,height:e,depth:1},d=[c,c,c,c,c,c];super(e,e,t,i,r,n,a,o,l,h),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}const RL=new Ds,Z1=new kt,wh=new H,Rg=new H,IL=[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)],PL=[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)],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)],DL=[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=xe(({depthTexture:s,bd3D:e,dp:t})=>nr(s,e).compare(t)),UL=xe(({depthTexture:s,bd3D:e,dp:t,shadow:i})=>{const r=ri("radius","float",i).setGroup(it),n=ri("mapSize","vec2",i).setGroup(it),a=r.div(n.x),o=oh(e),l=Pf(Lf(e,o.x.greaterThan(o.z).select(Re(0,1,0),Re(1,0,0)))),h=Lf(e,l),c=j1(fh.xy).mul(6.28318530718),d=lr(0,5,c),u=lr(1,5,c),p=lr(2,5,c),m=lr(3,5,c),y=lr(4,5,c);return nr(s,e.add(l.mul(d.x).add(h.mul(d.y)).mul(a))).compare(t).add(nr(s,e.add(l.mul(u.x).add(h.mul(u.y)).mul(a))).compare(t)).add(nr(s,e.add(l.mul(p.x).add(h.mul(p.y)).mul(a))).compare(t)).add(nr(s,e.add(l.mul(m.x).add(h.mul(m.y)).mul(a))).compare(t)).add(nr(s,e.add(l.mul(y.x).add(h.mul(y.y)).mul(a))).compare(t)).mul(1/5)}),FL=xe(({filterFn:s,depthTexture:e,shadowCoord:t,shadow:i},r)=>{const n=t.xyz.toConst(),a=n.abs().toConst(),o=a.x.max(a.y).max(a.z),l=dt("float").setGroup(it).onRenderUpdate(()=>i.camera.near),h=dt("float").setGroup(it).onRenderUpdate(()=>i.camera.far),c=ri("bias","float",i).setGroup(it),d=ke(1).toVar();return ds(o.sub(h).lessThanEqual(0).and(o.sub(l).greaterThanEqual(0)),()=>{let u;r.renderer.reversedDepthBuffer?(u=u3(o.negate(),l,h),u.subAssign(c)):(u=g1(o.negate(),l,h),u.addAssign(c));const p=n.normalize();d.assign(s({depthTexture:e,bd3D:p,dp:u,shadow:i}))}),d});class zL extends q1{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===cC?OL:UL}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:i,shadowCoord:r,shadow:n}){return FL({filterFn:t,depthTexture:i,shadowCoord:r,shadow:n})}setupRenderTarget(e,t){const i=new CL(e.mapSize.width);i.name="PointShadowDepthTexture",i.compareFunction=t.renderer.reversedDepthBuffer?Du:uf;const r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name="PointShadowMap",r.depthTexture=i,{shadowMap:r,depthTexture:i}}renderShadow(e){const{shadow:t,shadowMap:i,light:r}=this,{renderer:n,scene:a}=e,o=t.camera,l=t.matrix,h=n.coordinateSystem===tn,c=h?IL:LL,d=h?PL:DL;i.setSize(t.mapSize.width,t.mapSize.width);const u=n.autoClear,p=n.getClearColor(RL),m=n.getClearAlpha();n.autoClear=!1,n.setClearColor(t.clearColor,t.clearAlpha);for(let y=0;y<6;y++){n.setRenderTarget(i,y),n.clear();const g=r.distance||o.far;g!==o.far&&(o.far=g,o.updateProjectionMatrix()),wh.setFromMatrixPosition(r.matrixWorld),o.position.copy(wh),Rg.copy(o.position),Rg.add(c[y]),o.up.copy(d[y]),o.lookAt(Rg),o.updateMatrixWorld(),l.makeTranslation(-wh.x,-wh.y,-wh.z),Z1.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(Z1,o.coordinateSystem,o.reversedDepth);const f=a.name;a.name=`Point Light Shadow [ ${r.name||"ID: "+r.id} ] - Face ${y+1}`,n.render(a,o),a.name=f}n.autoClear=u,n.setClearColor(p,m)}}const BL=(s,e)=>new zL(s,e),VL=({color:s,lightVector:e,cutoffDistance:t,decayExponent:i})=>{const r=e.normalize(),n=e.length(),a=Y1({lightDistance:n,cutoffDistance:t,decayExponent:i}),o=s.mul(a);return{lightDirection:r,lightColor:o}};class kL extends ra{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=dt(0).setGroup(it),this.decayExponentNode=dt(2).setGroup(it)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return BL(this.light)}setupDirect(e){return VL({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const GL=xe(([s,e])=>{const t=s.abs().sub(e);return Xu(ir(t,0)).add(lh(ir(t.x,t.y),0))});class HL extends Cg{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let i=1;t.map!==null&&(i=t.map.width/t.map.height),t.shadow.aspect=i}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=ke(0),i=this.penumbraCosNode,r=Ag(this.light).mul(e.context.positionWorld||Jf);return ds(r.w.greaterThan(0),()=>{const n=r.xyz.div(r.w),a=GL(n.xy.sub(xt(.5)),xt(.5)),o=Wu(-1,Hi(1,v_(i)).sub(1));t.assign(Of(a.mul(-2).mul(o)))}),t}}const Ig=new kt,Ad=new kt;let Eh=null;class WL extends ra{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=dt(new H).setGroup(it),this.halfWidth=dt(new H).setGroup(it),this.updateType=ht.RENDER}update(e){super.update(e);const{light:t}=this,i=e.camera.matrixWorldInverse;Ad.identity(),Ig.copy(t.matrixWorld),Ig.premultiply(i),Ad.extractRotation(Ig),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Ad),this.halfHeight.value.applyMatrix4(Ad)}setupDirectRectArea(e){let t,i;e.isAvailable("float32Filterable")?(t=gi(Eh.LTC_FLOAT_1),i=gi(Eh.LTC_FLOAT_2)):(t=gi(Eh.LTC_HALF_1),i=gi(Eh.LTC_HALF_2));const{colorNode:r,light:n}=this,a=H1(n);return{lightColor:r,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:i}}static setLTC(e){Eh=e}}class J1 extends mi{static get type(){return"BitcastNode"}constructor(e,t,i=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=i,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){const t=this.valueNode.getNodeType(e),i=e.getTypeLength(t);return e.getTypeFromLength(i,this.conversionType)}return this.conversionType}generate(e){const t=this.getNodeType(e);let i="";if(this.inputType!==null){const r=this.valueNode.getNodeType(e);i=e.getTypeLength(r)===1?this.inputType:e.changeComponentType(r,this.inputType)}else i=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,i)}( ${this.valueNode.build(e,i)} )`}}const jL=Ee(J1).setParameterLength(2),XL=s=>new J1(s,"uint","float"),Nd={};class aa extends z{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,i){i==="int"?t.assign(jL(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return fi;case"int":return zt;case"uvec2":return a_;case"uvec3":return l_;case"uvec4":return c_;case"ivec2":return er;case"ivec3":return o_;case"ivec4":return h_}}_createTrailingZerosBaseLayout(e,t){const i=this._returnDataNode(t);return xe(([r])=>{const n=fi(0);this._resolveElementType(r,n,t);const a=ke(n.bitAnd(M_(n))),o=XL(a).shiftRight(23).sub(127);return i(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const i=this._returnDataNode(t);return xe(([r])=>{ds(r.equal(fi(0)),()=>fi(32));const n=fi(0),a=fi(0);return this._resolveElementType(r,n,t),ds(n.shiftRight(16).equal(0),()=>{a.addAssign(16),n.shiftLeftAssign(16)}),ds(n.shiftRight(24).equal(0),()=>{a.addAssign(8),n.shiftLeftAssign(8)}),ds(n.shiftRight(28).equal(0),()=>{a.addAssign(4),n.shiftLeftAssign(4)}),ds(n.shiftRight(30).equal(0),()=>{a.addAssign(2),n.shiftLeftAssign(2)}),ds(n.shiftRight(31).equal(0),()=>{a.addAssign(1)}),i(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const i=this._returnDataNode(t);return xe(([r])=>{const n=fi(0);this._resolveElementType(r,n,t),n.assign(n.sub(n.shiftRight(fi(1)).bitAnd(fi(1431655765)))),n.assign(n.bitAnd(fi(858993459)).add(n.shiftRight(fi(2)).bitAnd(fi(858993459))));const a=n.add(n.shiftRight(fi(4))).bitAnd(fi(252645135)).mul(fi(16843009)).shiftRight(fi(24));return i(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,i,r){const n=this._returnDataNode(t);return xe(([a])=>{if(i===1)return n(r(a));{const o=n(0),l=["x","y","z","w"];for(let h=0;h<i;h++){const c=l[h];o[c].assign(r(a[c]))}return o}}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}setup(e){const{method:t,aNode:i}=this,{renderer:r}=e;if(r.backend.isWebGPUBackend)return super.setup(e);const n=this.getInputType(e),a=e.getElementType(n),o=e.getTypeLength(n),l=`${t}_base_${a}`,h=`${t}_${n}`;let c=Nd[l];if(c===void 0){switch(t){case aa.COUNT_LEADING_ZEROS:{c=this._createLeadingZerosBaseLayout(l,a);break}case aa.COUNT_TRAILING_ZEROS:{c=this._createTrailingZerosBaseLayout(l,a);break}case aa.COUNT_ONE_BITS:{c=this._createOneBitsBaseLayout(l,a);break}}Nd[l]=c}let d=Nd[h];return d===void 0&&(d=this._createMainLayout(h,n,o,c),Nd[h]=d),xe(()=>d(i))()}}aa.COUNT_TRAILING_ZEROS="countTrailingZeros",aa.COUNT_LEADING_ZEROS="countLeadingZeros",aa.COUNT_ONE_BITS="countOneBits";class Lr extends ze{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===Lr.OBJECT?this.updateType=ht.OBJECT:e===Lr.MATERIAL?this.updateType=ht.RENDER:e===Lr.BEFORE_OBJECT?this.updateBeforeType=ht.OBJECT:e===Lr.BEFORE_MATERIAL&&(this.updateBeforeType=ht.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}Lr.OBJECT="object",Lr.MATERIAL="material",Lr.BEFORE_OBJECT="beforeObject",Lr.BEFORE_MATERIAL="beforeMaterial",new ia,new H,new H,new H,new kt,new H(0,0,-1),new Ai,new H,new H,new Ai,new Vt;const qL=new S1;Gf.flipX(),qL.depthTexture=new Mh(1,1),Re(.04),ke(1);const YL=xe(([s,e])=>s.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ZL=xe(([s,e])=>(s=s.mul(e),s.div(s.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),JL=xe(([s,e])=>{s=s.mul(e),s=s.sub(.004).max(0);const t=s.mul(s.mul(6.2).add(.5)),i=s.mul(s.mul(6.2).add(1.7)).add(.06);return t.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),KL=xe(([s])=>{const e=s.mul(s.add(.0245786)).sub(90537e-9),t=s.mul(s.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),$L=xe(([s,e])=>{const t=ps(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=ps(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return s=s.mul(e).div(.6),s=t.mul(s),s=KL(s),s=i.mul(s),s.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),QL=ps(Re(1.6605,-.1246,-.0182),Re(-.5876,1.1329,-.1006),Re(-.0728,-.0083,1.1187)),eD=ps(Re(.6274,.0691,.0164),Re(.3293,.9195,.088),Re(.0433,.0113,.8956)),tD=xe(([s])=>{const e=Re(s).toVar(),t=Re(e.mul(e)).toVar(),i=Re(t.mul(t)).toVar();return ke(15.5).mul(i.mul(t)).sub(Bt(40.14,i.mul(e))).add(Bt(31.96,i).sub(Bt(6.868,t.mul(e))).add(Bt(.4298,t).add(Bt(.1191,e).sub(.00232))))}),iD=xe(([s,e])=>{const t=Re(s).toVar(),i=ps(Re(.856627153315983,.137318972929847,.11189821299995),Re(.0951212405381588,.761241990602591,.0767994186031903),Re(.0482516061458583,.101439036467562,.811302368396859)),r=ps(Re(1.1271005818144368,-.1413297634984383,-.14132976349843826),Re(-.11060664309660323,1.157823702216272,-.11060664309660294),Re(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ke(-12.47393),a=ke(4.026069);return t.mulAssign(e),t.assign(eD.mul(t)),t.assign(i.mul(t)),t.assign(ir(t,1e-10)),t.assign(Yn(t)),t.assign(t.sub(n).div(a.sub(n))),t.assign(co(t,0,1)),t.assign(tD(t)),t.assign(r.mul(t)),t.assign(Df(ir(Re(0),t),Re(2.2))),t.assign(QL.mul(t)),t.assign(co(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),sD=xe(([s,e])=>{const t=ke(.76),i=ke(.15);s=s.mul(e);const r=lh(s.r,lh(s.g,s.b)),n=Uf(r.lessThan(.08),r.sub(Bt(6.25,r.mul(r))),.04);s.subAssign(n);const a=ir(s.r,ir(s.g,s.b));ds(a.lessThan(t),()=>s);const o=Hi(1,t),l=Hi(1,o.mul(o).div(a.add(o.sub(t))));s.mulAssign(l.div(a));const h=Hi(1,Wu(1,i.mul(a.sub(l)).add(1)));return Fi(s,Re(l),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class rD extends P3{constructor(){super(),this.addLight(kL,z3),this.addLight(TL,V3),this.addLight(WL,k3),this.addLight(Cg,wg),this.addLight(SL,H3),this.addLight(wL,W3),this.addLight(NL,X3),this.addLight(EL,q3),this.addLight(HL,Y3),this.addToneMapping(YL,gC),this.addToneMapping(ZL,yC),this.addToneMapping(JL,xC),this.addToneMapping($L,vC),this.addToneMapping(iD,_C),this.addToneMapping(sD,MC)}}function nD(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const r=s[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(st("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function aD(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}export{Bh as ACESFilmicToneMapping,Dh as AdditiveBlending,Vh as AgXToneMapping,Fo as AlwaysDepth,dc as AlwaysStencilFunc,Pm as AmbientLight,Xa as AnimationClip,Tx as AnimationMixer,Fm as ArrayCamera,Vm as Audio,yu as AudioContext,vx as AudioListener,gx as AudioLoader,jx as AxesHelper,yi as BackSide,cp as BasicDepthPacking,rD as BasicNodeLibrary,qp as BatchedMesh,kc as Bone,Jr as BooleanKeyframeTrack,di as Box3,Hx as Box3Helper,dn as BoxGeometry,Gx as BoxHelper,bt as BufferAttribute,rt as BufferGeometry,Is as Cache,Hl as Camera,kx as CameraHelper,Py as CanvasTexture,am as CatmullRomCurve3,Ci as ClampToEdgeWrapping,we as Color,uu as ColorKeyframeTrack,mt as ColorManagement,Ry as CompressedArrayTexture,Iy as CompressedCubeTexture,Ol as CompressedTexture,qx as Controls,Um as CubeCamera,Va as CubeTexture,xn as CubeUVReflectionMapping,ls as Curve,$d as CustomBlending,Ro as CylinderGeometry,_l as Data3DTexture,os as DataTexture,rx as DataTextureLoader,ay as DataUtils,T0 as DecrementStencilOp,E0 as DecrementWrapStencilOp,wm as DefaultLoadingManager,ws as DepthFormat,ur as DepthStencilFormat,On as DepthTexture,Im as DirectionalLight,Vx as DirectionalLightHelper,Ms as DoubleSide,k0 as DynamicDrawUsage,tm as EdgesGeometry,Bo as EqualDepth,R0 as EqualStencilFunc,ca as EquirectangularReflectionMapping,ua as EquirectangularRefractionMapping,ns as Euler,Es as EventDispatcher,Ch as ExtrudeGeometry,js as FileLoader,Ne as Float32BufferAttribute,xi as FloatType,_p as Fog,Vs as FrontSide,Pn as Frustum,fc as GLSL3,ko as GreaterDepth,Vo as GreaterEqualDepth,D0 as GreaterEqualStencilFunc,P0 as GreaterStencilFunc,Fx as GridHelper,wn as Group,Ts as HalfFloatType,Em as HemisphereLight,fx as ImageBitmapLoader,mp as ImageUtils,S0 as IncrementStencilOp,w0 as IncrementWrapStencilOp,Rn as InstancedBufferAttribute,Dm as InstancedBufferGeometry,wx as InstancedInterleavedBuffer,Hp as InstancedMesh,Al as InterleavedBuffer,Da as InterleavedBufferAttribute,zn as Interpolant,_a as InterpolateDiscrete,dl as InterpolateLinear,A0 as InvertStencilOp,Gr as KeepStencilOp,Qi as KeyframeTrack,Op as LOD,Ml as Layers,zo as LessDepth,Fr as LessEqualDepth,I0 as LessEqualStencilFunc,C0 as LessStencilFunc,Sr as Line,Px as Line3,Ti as LineBasicMaterial,Zp as LineLoop,Rs as LineSegments,Rt as LinearFilter,m0 as LinearMipMapLinearFilter,Ss as LinearMipmapLinearFilter,ma as LinearMipmapNearestFilter,kr as LinearSRGBColorSpace,Fh as LinearToneMapping,Oi as Loader,fu as LoaderUtils,du as LoadingManager,ap as LoopOnce,op as LoopRepeat,Wg as MOUSE,pi as Material,q0 as MathUtils,at as Matrix3,et as Matrix4,Qd as MaxEquation,Xt as Mesh,Mr as MeshBasicMaterial,cu as MeshDepthMaterial,_m as MeshLambertMaterial,vm as MeshNormalMaterial,xm as MeshPhongMaterial,ym as MeshPhysicalMaterial,hu as MeshStandardMaterial,pa as MirroredRepeatWrapping,Ht as NearestFilter,p0 as NearestMipMapNearestFilter,vn as NearestMipmapLinearFilter,Hh as NearestMipmapNearestFilter,kh as NeutralToneMapping,Uo as NeverDepth,N0 as NeverStencilFunc,bs as NoBlending,Gs as NoColorSpace,rs as NoToneMapping,J2 as NodeFrame,Or as NormalBlending,Go as NotEqualDepth,L0 as NotEqualStencilFunc,Ha as NumberKeyframeTrack,_t as Object3D,Io as OctahedronGeometry,Ya as OrthographicCamera,Zd as PCFSoftShadowMap,wu as PMREMGenerator,li as PerspectiveCamera,br as Plane,na as PlaneGeometry,Rm as PointLight,Kp as Points,Jc as PointsMaterial,Mx as PositionalAudio,gt as PropertyBinding,Mi as Quaternion,Wa as QuaternionKeyframeTrack,el as R11_EAC_Format,cl as RED_GREEN_RGTC2_Format,ll as RED_RGTC1_Format,yn as REVISION,il as RG11_EAC_Format,v0 as RGBADepthPacking,vi as RGBAFormat,Xo as RGBAIntegerFormat,rl as RGBA_ASTC_4x4_Format,nl as RGBA_ASTC_6x6_Format,al as RGBA_BPTC_Format,Qo as RGBA_ETC2_EAC_Format,Jo as RGBA_PVRTC_2BPPV1_Format,Zo as RGBA_PVRTC_4BPPV1_Format,xa as RGBA_S3TC_DXT1_Format,va as RGBA_S3TC_DXT5_Format,Zh as RGBFormat,ol as RGB_BPTC_UNSIGNED_Format,Ko as RGB_ETC1_Format,$o as RGB_ETC2_Format,Yo as RGB_PVRTC_4BPPV1_Format,ya as RGB_S3TC_DXT1_Format,Br as RGFormat,jo as RGIntegerFormat,lu as RawShaderMaterial,Nn as Ray,Ax as Raycaster,Wo as RedFormat,ga as RedIntegerFormat,zh as ReinhardToneMapping,da as RepeatWrapping,b0 as ReplaceStencilOp,Rh as RingGeometry,tl as SIGNED_R11_EAC_Format,ul as SIGNED_RED_GREEN_RGTC2_Format,hl as SIGNED_RED_RGTC1_Format,sl as SIGNED_RG11_EAC_Format,Ii as SRGBColorSpace,Mp as Scene,ot as ShaderChunk,hs as ShaderLib,$i as ShaderMaterial,fm as ShadowMaterial,Zr as Shape,Xx as ShapePath,ys as ShapeUtils,Ah as Skeleton,Gp as SkinnedMesh,pr as Source,ai as Sphere,Po as SphereGeometry,Cx as Spherical,Cm as SpotLight,Dp as Sprite,Ec as SpriteMaterial,hC as THREE,jg as TOUCH,ei as Texture,nx as TextureLoader,zm as Timer,Ih as TorusGeometry,yr as Triangle,x0 as TriangleFanDrawMode,y0 as TriangleStripDrawMode,g0 as TrianglesDrawMode,wc as Uint16BufferAttribute,Hd as Uniform,ye as UniformsLib,gm as UniformsUtils,Ri as UnsignedByteType,Yh as UnsignedInt101111Type,_n as UnsignedInt248Type,qh as UnsignedInt5999Type,qi as UnsignedIntType,te as Vector2,R as Vector3,It as Vector4,ja as VectorKeyframeTrack,$p as VideoTexture,Au as WebGLCubeRenderTarget,Bi as WebGLRenderTarget,Sv as WebGLRenderer,mm as WireframeGeometry,M0 as ZeroStencilOp,nD as cloneUniforms,aD as cloneUniformsGroups};
|
|
4083
|
+
`).removeFlowTab();e.addFlowTab()}}const hn=(...s)=>new $P(co(s,"int")).toStack();class QP extends ss{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=cs,this.minFilter=cs,this.wrapR=Yl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}const rg=new WeakMap,ts=new Ai,f1=xe(({bufferMap:s,influence:e,stride:t,width:i,depth:r,offset:n})=>{const a=zt(kP).mul(t).add(n),o=a.div(i),l=a.sub(o.mul(i));return fs(s,er(l,o)).depth(r).xyz.mul(e)});function e3(s){const e=s.morphAttributes.position!==void 0,t=s.morphAttributes.normal!==void 0,i=s.morphAttributes.color!==void 0,r=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,n=r!==void 0?r.length:0;let a=rg.get(s);if(a===void 0||a.count!==n){let o=function(){g.dispose(),rg.delete(s),s.removeEventListener("dispose",o)};a!==void 0&&a.texture.dispose();const l=s.morphAttributes.position||[],h=s.morphAttributes.normal||[],c=s.morphAttributes.color||[];let d=0;e===!0&&(d=1),t===!0&&(d=2),i===!0&&(d=3);let u=s.attributes.position.count*d,p=1;const m=4096;u>m&&(p=Math.ceil(u/m),u=m);const y=new Float32Array(u*p*4*n),g=new QP(y,u,p,n);g.type=Ov,g.needsUpdate=!0;const f=d*4;for(let x=0;x<n;x++){const v=l[x],M=h[x],w=c[x],T=u*p*4*x;for(let A=0;A<v.count;A++){const _=A*f;e===!0&&(ts.fromBufferAttribute(v,A),y[T+_+0]=ts.x,y[T+_+1]=ts.y,y[T+_+2]=ts.z,y[T+_+3]=0),t===!0&&(ts.fromBufferAttribute(M,A),y[T+_+4]=ts.x,y[T+_+5]=ts.y,y[T+_+6]=ts.z,y[T+_+7]=0),i===!0&&(ts.fromBufferAttribute(w,A),y[T+_+8]=ts.x,y[T+_+9]=ts.y,y[T+_+10]=ts.z,y[T+_+11]=w.itemSize===4?ts.w:1)}}a={count:n,texture:g,stride:d,size:new Vt(u,p)},rg.set(s,a),s.addEventListener("dispose",o)}return a}class t3 extends ze{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=dt(1),this.updateType=ht.OBJECT}setup(e){const{geometry:t}=e,i=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,n=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=n!==void 0?n.length:0,{texture:o,stride:l,size:h}=e3(t);i===!0&&Wi.mulAssign(this.morphBaseInfluence),r===!0&&rr.mulAssign(this.morphBaseInfluence);const c=zt(h.width);hn(a,({i:d})=>{const u=ke(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?u.assign(fs(this.mesh.morphTexture,er(zt(d).add(1),zt(_h))).r):u.assign(ri("morphTargetInfluences","float").element(d).toVar()),ds(u.notEqual(0),()=>{i===!0&&Wi.addAssign(f1({bufferMap:o,influence:u,stride:l,width:c,depth:d,offset:zt(0)})),r===!0&&rr.addAssign(f1({bufferMap:o,influence:u,stride:l,width:c,depth:d,offset:zt(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,i)=>t+i,0)}}const i3=Pt(t3).setParameterLength(1);class ng extends ze{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class s3 extends ng{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class r3 extends w_{static get type(){return"LightingContextNode"}constructor(e,t=null,i=null,r=null){super(e),this.lightingModel=t,this.backdropNode=i,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,i=Re().toVar("directDiffuse"),r=Re().toVar("directSpecular"),n=Re().toVar("indirectDiffuse"),a=Re().toVar("indirectSpecular"),o={directDiffuse:i,directSpecular:r,indirectDiffuse:n,indirectSpecular:a};return{radiance:Re().toVar("radiance"),irradiance:Re().toVar("irradiance"),iblIrradiance:Re().toVar("iblIrradiance"),ambientOcclusion:ke(1).toVar("ambientOcclusion"),reflectedLight:o,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const n3=Pt(r3);class a3 extends ng{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}class o3 extends ss{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=cs,this.minFilter=cs,this.generateMipmaps=!1,this.needsUpdate=!0}}const So=new Vt;class l3 extends ad{static get type(){return"ViewportTextureNode"}constructor(e=kf,t=null,i=null){let r=null;i===null?(r=new o3,r.minFilter=Lv,i=r):r=i,super(i,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=ht.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,i;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,i=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,i=this._cacheTextures),e===null)return t;if(i.has(e)===!1){const r=t.clone();i.set(e,r)}return i.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,i=t.getRenderTarget();i===null?t.getDrawingBufferSize(So):So.set(i.width,i.height);const r=this.getTextureForReference(i);(r.image.width!==So.width||r.image.height!==So.height)&&(r.image.width=So.width,r.image.height=So.height,r.needsUpdate=!0);const n=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=n}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}class Mh extends ss{constructor(e,t,i=af,r,n,a,o=cs,l=cs,h,c=of,d=1){if(c!==of&&c!==wC)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,r,n,a,o,l,c,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Kf(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}let ld=null;class h3 extends l3{static get type(){return"ViewportDepthTextureNode"}constructor(e=kf,t=null){ld===null&&(ld=new Mh),super(e,t,ld)}getTextureForReference(){return ld}}const c3=Pt(h3).setParameterLength(0,2);class ji extends ze{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===ji.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,i=this.valueNode;let r=null;if(t===ji.DEPTH_BASE)i!==null&&(r=v1().assign(i));else if(t===ji.DEPTH)e.isPerspectiveCamera?r=g1(hi.z,Jn,Kn):r=bh(hi.z,Jn,Kn);else if(t===ji.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const n=y1(i,Jn,Kn);r=bh(n,Jn,Kn)}else r=i;else r=bh(hi.z,Jn,Kn);return r}}ji.DEPTH_BASE="depthBase",ji.DEPTH="depth",ji.LINEAR_DEPTH="linearDepth";const bh=(s,e,t)=>s.add(e).div(e.sub(t)),g1=(s,e,t)=>e.add(s).mul(t).div(t.sub(e).mul(s)),u3=(s,e,t)=>e.mul(s.add(t)).div(s.mul(e.sub(t))),y1=xe(([s,e,t],i)=>i.renderer.reversedDepthBuffer===!0?e.mul(t).div(e.sub(t).mul(s).sub(e)):e.mul(t).div(t.sub(e).mul(s).sub(t))),x1=(s,e,t)=>{e=e.max(1e-6).toVar();const i=Yn(s.negate().div(e)),r=Yn(t.div(e));return i.div(r)},v1=Pt(ji,ji.DEPTH_BASE),_1=Kt(ji,ji.DEPTH),oD=Pt(ji,ji.LINEAR_DEPTH).setParameterLength(0,1);c3(),_1.assign=s=>v1(s);class vs extends ze{static get type(){return"ClippingNode"}constructor(e=vs.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:i,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===vs.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(i,r):this.scope===vs.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(i,r)}setupAlphaToCoverage(e,t){return xe(()=>{const i=ke().toVar("distanceToPlane"),r=ke().toVar("distanceToGradient"),n=ke(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const l=sr(t).setGroup(it);hn(a,({i:h})=>{const c=l.element(h);i.assign(hi.dot(c.xyz).negate().add(c.w)),r.assign(i.fwidth().div(2)),n.mulAssign(uh(r.negate(),r,i))})}const o=e.length;if(o>0){const l=sr(e).setGroup(it),h=ke(1).toVar("intersectionClipOpacity");hn(o,({i:c})=>{const d=l.element(c);i.assign(hi.dot(d.xyz).negate().add(d.w)),r.assign(i.fwidth().div(2)),h.mulAssign(uh(r.negate(),r,i).oneMinus())}),n.mulAssign(h.oneMinus())}Gi.a.mulAssign(n),Gi.a.equal(0).discard()})()}setupDefault(e,t){return xe(()=>{const i=t.length;if(this.hardwareClipping===!1&&i>0){const n=sr(t).setGroup(it);hn(i,({i:a})=>{const o=n.element(a);hi.dot(o.xyz).greaterThan(o.w).discard()})}const r=e.length;if(r>0){const n=sr(e).setGroup(it),a=Af(!0).toVar("clipped");hn(r,({i:o})=>{const l=n.element(o);a.assign(hi.dot(l.xyz).greaterThan(l.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const i=e.length;return t.enableHardwareClipping(i),xe(()=>{const r=sr(e).setGroup(it),n=Yu(t.getClipDistance());hn(i,({i:a})=>{const o=r.element(a),l=hi.dot(o.xyz).sub(o.w).negate();n.element(a).assign(l)})})()}}vs.ALPHA_TO_COVERAGE="alphaToCoverage",vs.DEFAULT="default",vs.HARDWARE="hardware";const d3=()=>new vs,p3=()=>new vs(vs.ALPHA_TO_COVERAGE),m3=()=>new vs(vs.HARDWARE),f3=["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"],ag=new WeakMap;class g3{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=f3,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){const t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:i,material:r,object:n}=e;if(t={material:this.getMaterialData(r),geometry:{id:i.id,attributes:this.getAttributesData(i.attributes),indexId:i.index?i.index.id:null,indexVersion:i.index?i.index.version:null,drawRange:{start:i.drawRange.start,count:i.drawRange.count}},worldMatrix:n.matrixWorld.clone()},n.center&&(t.center=n.center.clone()),n.morphTargetInfluences&&(t.morphTargetInfluences=n.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:a,height:o}=e.context;t.bufferWidth=a,t.bufferHeight=o}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const i in e){const r=e[i];t[i]={id:r.id,version:r.version}}return t}containsNode(e){const t=e.material;for(const i in t)if(t[i]&&t[i].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){const t={};for(const i of this.refreshUniforms){const r=e[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[i]={id:r.id,version:r.version}:t[i]=r.clone():t[i]=r)}return t}equals(e,t){const{object:i,material:r,geometry:n}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(i.matrixWorld)!==!0)return a.worldMatrix.copy(i.matrixWorld),!1;const o=a.material;for(const x in o){const v=o[x],M=r[x];if(v.equals!==void 0){if(v.equals(M)===!1)return v.copy(M),!1}else if(M.isTexture===!0){if(v.id!==M.id||v.version!==M.version)return v.id=M.id,v.version=M.version,!1}else if(v!==M)return o[x]=M,!1}if(o.transmission>0){const{width:x,height:v}=e.context;if(a.bufferWidth!==x||a.bufferHeight!==v)return a.bufferWidth=x,a.bufferHeight=v,!1}const l=a.geometry,h=n.attributes,c=l.attributes,d=Object.keys(c),u=Object.keys(h);if(l.id!==n.id)return l.id=n.id,!1;if(d.length!==u.length)return a.geometry.attributes=this.getAttributesData(h),!1;for(const x of d){const v=c[x],M=h[x];if(M===void 0)return delete c[x],!1;if(v.id!==M.id||v.version!==M.version)return v.id=M.id,v.version=M.version,!1}const p=n.index,m=l.indexId,y=l.indexVersion,g=p?p.id:null,f=p?p.version:null;if(m!==g||y!==f)return l.indexId=g,l.indexVersion=f,!1;if(l.drawRange.start!==n.drawRange.start||l.drawRange.count!==n.drawRange.count)return l.drawRange.start=n.drawRange.start,l.drawRange.count=n.drawRange.count,!1;if(a.morphTargetInfluences){let x=!1;for(let v=0;v<a.morphTargetInfluences.length;v++)a.morphTargetInfluences[v]!==i.morphTargetInfluences[v]&&(a.morphTargetInfluences[v]=i.morphTargetInfluences[v],x=!0);if(x)return!1}if(a.lights){for(let x=0;x<t.length;x++)if(a.lights[x].map!==t[x].map)return!1}return a.center&&a.center.equals(i.center)===!1?(a.center.copy(i.center),!0):(e.bundle!==null&&(a.version=e.bundle.version),!0)}getLightsData(e){const t=[];for(const i of e)i.isSpotLight===!0&&i.map!==null&&t.push({map:i.map.version});return t}getLights(e,t){if(ag.has(e)){const r=ag.get(e);if(r.renderId===t)return r.lightsData}const i=this.getLightsData(e.getLights());return ag.set(e,{renderId:t,lightsData:i}),i}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;const r=e.object.static===!0,n=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||n)return!1;const a=this.getLights(e.lightsNode,i);return this.equals(e,a)!==!0}}const y3=.05,M1=xe(([s])=>Zn(Bt(1e4,ah(Bt(17,s.x).add(Bt(.1,s.y)))).mul(tr(.1,oh(ah(Bt(13,s.y).add(s.x))))))),b1=xe(([s])=>M1(xt(M1(s.xy),s.z))),x3=xe(([s])=>{const e=ir(Xu(b_(s.xyz)),Xu(S_(s.xyz))),t=ke(1).div(ke(y3).mul(e)).toVar("pixScale"),i=xt(Rf(ju(Yn(t))),Rf(y_(Yn(t)))),r=xt(b1(ju(i.x.mul(s.xyz))),b1(ju(i.y.mul(s.xyz)))),n=Zn(Yn(t)),a=tr(Bt(n.oneMinus(),r.x),Bt(n,r.y)),o=lh(n,n.oneMinus()),l=Re(a.mul(a).div(Bt(2,o).mul(Hi(1,o))),a.sub(Bt(.5,o)).div(Hi(1,o)),Hi(1,Hi(1,a).mul(Hi(1,a)).div(Bt(2,o).mul(Hi(1,o))))),h=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return uo(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class v3 extends z_{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),i=e.hasGeometryAttribute(t);let r;return i===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new Ai(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const _3=(s=0)=>new v3(s),M3=xe(([s])=>Ui(s.rgb.mul(s.a),s.a),{color:"vec4",return:"vec4"});class og extends Jf{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}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 e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const i=this[t];i&&i.isNode===!0&&e.push({property:t,childNode:i})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:i}of this._getNodeChildren())e.push(xf(t.slice(0,-4)),i.getCacheKey());return this.type+Jv(e)}build(e){this.setup(e)}setupObserver(e){return new g3(e)}setup(e){e.context.setupNormal=()=>dh(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,i=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context={...e.context,...t.contextNode.getFlowContextData()}:Tt('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context={...e.context,...this.contextNode.getFlowContextData()}:Tt('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();const r=this.setupVertex(e),n=dh(this.vertexNode||r,"VERTEX");e.context.clipSpace=n,e.stack.outputNode=n,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a;const o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(i!==null?i.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);o!==null&&e.stack.addToStack(o);const h=Ui(l,Gi.a).max(0);a=this.setupOutput(e,h),Nf.assign(a);const c=this.outputNode!==null;if(c&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),i!==null){const d=t.getMRT(),u=this.mrtNode;d!==null?(c&&Nf.assign(a),a=d,u!==null&&(a=d.merge(u))):u!==null&&(a=u)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=Ui(l)),a=this.setupOutput(e,l)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:i}=e.clippingContext;let r=null;if(t.length>0||i.length>0){const n=e.renderer.currentSamples;this.alphaToCoverage&&n>1?r=p3():e.stack.addToStack(d3())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(m3()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:i}=e;let r=this.depthNode;if(r===null){const n="getMRT"in t&&t.getMRT();n&&n.has("depth")?r=n.get("depth"):t.logarithmicDepthBuffer===!0&&(i.isPerspectiveCamera?r=x1(hi.z,Jn,Kn):r=bh(hi.z,Jn,Kn))}r!==null&&_1.assign(r).toStack()}setupPositionView(){return W_.mul(Wi).xyz}setupModelViewProjection(){return F2.mul(hi)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),FP}setupPosition(e){const{object:t,geometry:i}=e;if((i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&i3(t).toStack(),t.isSkinnedMesh===!0&&KP(t).toStack(),this.displacementMap){const r=bo("displacementMap","texture"),n=bo("displacementScale","float"),a=bo("displacementBias","float");Wi.addAssign(rr.normalize().mul(r.x.mul(n).add(a)))}return t.isBatchedMesh&&ZP(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&qP(t).toStack(),this.positionNode!==null&&Wi.assign(dh(this.positionNode,"POSITION","vec3")),Wi}setupDiffuseColor(e){const{object:t,geometry:i}=e;this.maskNode!==null&&Af(this.maskNode).not().discard();let r=this.colorNode?Ui(this.colorNode):IP;this.vertexColors===!0&&i.hasAttribute("color")&&(r=r.mul(_3())),t.instanceColor&&(r=Hu("vec3","vInstanceColor").mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=Hu("vec3","vBatchColor").mul(r)),Gi.assign(r);const n=this.opacityNode?ke(this.opacityNode):LP;Gi.a.assign(Gi.a.mul(n));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode!==null?ke(this.alphaTestNode):RP,this.alphaToCoverage===!0?(Gi.a=uh(a,a.add(T_(Gi.a)),Gi.a),Gi.a.lessThanEqual(0).discard()):Gi.a.lessThanEqual(a).discard()),this.alphaHash===!0&&Gi.a.lessThan(x3(Wi)).discard(),e.isOpaque()&&Gi.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Re(0):Gi.rgb}setupNormal(){return this.normalNode?Re(this.normalNode):DP}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?bo("envMap","cubeTexture"):bo("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new a3(OP)),t}setupLights(e){const t=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&t.push(i);const r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let n=this.aoNode;n===null&&e.material.aoMap&&(n=UP),e.context.getAO&&(n=e.context.getAO(n,e)),n&&t.push(new s3(n));let a=this.lightsNode||e.lightsNode;return t.length>0&&(a=e.renderer.lighting.createNode([...a.getLights(),...t])),a}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:i,backdropAlphaNode:r,emissiveNode:n}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let o=this.setupOutgoingLight(e);if(a&&a.getScope().hasLights){const l=this.setupLightingModel(e)||null;o=n3(a,l,i,r)}else i!==null&&(o=Re(r!==null?Fi(o,i,r):i));return(n&&n.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(g_.assign(Re(n||PP)),o=o.add(g_)),o}setupFog(e,t){const i=e.fogNode;return i&&(Nf.assign(t),t=Ui(i.toVar())),t}setupPremultipliedAlpha(e,t){return M3(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const i in e){const r=e[i];this[i]===void 0&&(this[i]=r,r&&r.clone&&(this[i]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const i in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,i)===void 0&&t[i].get!==void 0&&Object.defineProperty(this.constructor.prototype,i,t[i])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const i=Jf.prototype.toJSON.call(this,e);i.inputNodes={};for(const{property:n,childNode:a}of this._getNodeChildren())i.inputNodes[n]=a.toJSON(e).uuid;function r(n){const a=[];for(const o in n){const l=n[o];delete l.metadata,a.push(l)}return a}if(t){const n=r(e.textures),a=r(e.images),o=r(e.nodes);n.length>0&&(i.textures=n),a.length>0&&(i.images=a),o.length>0&&(i.nodes=o)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}}class S1 extends lo{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zl,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Ai(0,0,e,t),this.scissorTest=!1,this.viewport=new Ai(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:i.depth},n=new ss(r),a=i.count;for(let o=0;o<a;o++)this.textures[o]=n.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:Zl,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,n=this.textures.length;r<n;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new Kf(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class b3{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let S3=0;const T1=new H,To=new ao,Cr=new kt,hd=new H,Sh=new H,T3=new H,w3=new ao,w1=new H(1,0,0),E1=new H(0,1,0),A1=new H(0,0,1),N1={type:"added"},E3={type:"removed"},wo={type:"childadded",child:null},lg={type:"childremoved",child:null};class Ni extends lo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:S3++}),this.uuid=wr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ni.DEFAULT_UP.clone();const e=new H,t=new Do,i=new ao,r=new H(1,1,1);function n(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(n),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new kt},normalMatrix:{value:new xs}}),this.matrix=new kt,this.matrixWorld=new kt,this.matrixAutoUpdate=Ni.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ni.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new b3,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return To.setFromAxisAngle(e,t),this.quaternion.multiply(To),this}rotateOnWorldAxis(e,t){return To.setFromAxisAngle(e,t),this.quaternion.premultiply(To),this}rotateX(e){return this.rotateOnAxis(w1,e)}rotateY(e){return this.rotateOnAxis(E1,e)}rotateZ(e){return this.rotateOnAxis(A1,e)}translateOnAxis(e,t){return T1.copy(e).applyQuaternion(this.quaternion),this.position.add(T1.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(w1,e)}translateY(e){return this.translateOnAxis(E1,e)}translateZ(e){return this.translateOnAxis(A1,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Cr.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?hd.copy(e):hd.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Sh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Cr.lookAt(Sh,hd,this.up):Cr.lookAt(hd,Sh,this.up),this.quaternion.setFromRotationMatrix(Cr),r&&(Cr.extractRotation(r.matrixWorld),To.setFromRotationMatrix(Cr),this.quaternion.premultiply(To.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Tt("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(N1),wo.child=e,this.dispatchEvent(wo),wo.child=null):Tt("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(E3),lg.child=e,this.dispatchEvent(lg),lg.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Cr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Cr.multiply(e.parent.matrixWorld)),e.applyMatrix4(Cr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(N1),wo.child=e,this.dispatchEvent(wo),wo.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const n=this.children[i].getObjectByProperty(e,t);if(n!==void 0)return n}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sh,e,T3),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sh,w3,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,r=e.z,n=this.matrix.elements;n[12]+=t-n[0]*t-n[4]*i-n[8]*r,n[13]+=i-n[1]*t-n[5]*i-n[9]*r,n[14]+=r-n[2]*t-n[6]*i-n[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.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)),t===!0){const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=n(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let h=0,c=l.length;h<c;h++){const d=l[h];n(e.shapes,d)}else n(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(e.materials,this.material[l]));r.material=o}else r.material=n(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(n(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),h=a(e.textures),c=a(e.images),d=a(e.shapes),u=a(e.skeletons),p=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),h.length>0&&(i.textures=h),c.length>0&&(i.images=c),d.length>0&&(i.shapes=d),u.length>0&&(i.skeletons=u),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const h in o){const c=o[h];delete c.metadata,l.push(c)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}Ni.DEFAULT_UP=new H(0,1,0),Ni.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ni.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const cd=new H,ud=new ao,ar=new H;class C1 extends Ni{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new kt,this.projectionMatrix=new kt,this.projectionMatrixInverse=new kt,this.coordinateSystem=Zs,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(cd,ud,ar),ar.x===1&&ar.y===1&&ar.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(cd,ud,ar.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(cd,ud,ar),ar.x===1&&ar.y===1&&ar.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(cd,ud,ar.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const cn=new H,R1=new Vt,I1=new Vt;class P1 extends C1{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=eh*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ql*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return eh*2*Math.atan(Math.tan(Ql*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){cn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(cn.x,cn.y).multiplyScalar(-e/cn.z),cn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(cn.x,cn.y).multiplyScalar(-e/cn.z)}getViewSize(e,t){return this.getViewBounds(e,R1,I1),t.subVectors(I1,R1)}setViewOffset(e,t,i,r,n,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ql*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,n=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,h=a.fullHeight;n+=a.offsetX*r/l,t-=a.offsetY*i/h,r*=a.width/l,i*=a.height/h}const o=this.filmOffset;o!==0&&(n+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}let A3=0;const gs=new kt,hg=new Ni,Eo=new H,is=new gh,Th=new gh,ci=new H;class Wd extends lo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:A3++}),this.uuid=wr(),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(e){return Array.isArray(e)?this.index=new(IC(e)?g2:f2)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new xs().getNormalMatrix(e);i.applyNormalMatrix(n),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return gs.makeRotationFromQuaternion(e),this.applyMatrix4(gs),this}rotateX(e){return gs.makeRotationX(e),this.applyMatrix4(gs),this}rotateY(e){return gs.makeRotationY(e),this.applyMatrix4(gs),this}rotateZ(e){return gs.makeRotationZ(e),this.applyMatrix4(gs),this}translate(e,t,i){return gs.makeTranslation(e,t,i),this.applyMatrix4(gs),this}scale(e,t,i){return gs.makeScale(e,t,i),this.applyMatrix4(gs),this}lookAt(e){return hg.lookAt(e),hg.updateMatrix(),this.applyMatrix4(hg.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Eo).negate(),this.translate(Eo.x,Eo.y,Eo.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,n=e.length;r<n;r++){const a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new zf(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&st("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gh);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Tt("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(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const n=t[i];is.setFromBufferAttribute(n),this.morphTargetsRelative?(ci.addVectors(this.boundingBox.min,is.min),this.boundingBox.expandByPoint(ci),ci.addVectors(this.boundingBox.max,is.max),this.boundingBox.expandByPoint(ci)):(this.boundingBox.expandByPoint(is.min),this.boundingBox.expandByPoint(is.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Tt('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 td);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Tt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new H,1/0);return}if(e){const i=this.boundingSphere.center;if(is.setFromBufferAttribute(e),t)for(let n=0,a=t.length;n<a;n++){const o=t[n];Th.setFromBufferAttribute(o),this.morphTargetsRelative?(ci.addVectors(is.min,Th.min),is.expandByPoint(ci),ci.addVectors(is.max,Th.max),is.expandByPoint(ci)):(is.expandByPoint(Th.min),is.expandByPoint(Th.max))}is.getCenter(i);let r=0;for(let n=0,a=e.count;n<a;n++)ci.fromBufferAttribute(e,n),r=Math.max(r,i.distanceToSquared(ci));if(t)for(let n=0,a=t.length;n<a;n++){const o=t[n],l=this.morphTargetsRelative;for(let h=0,c=o.count;h<c;h++)ci.fromBufferAttribute(o,h),l&&(Eo.fromBufferAttribute(e,h),ci.add(Eo)),r=Math.max(r,i.distanceToSquared(ci))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Tt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Tt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,n=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new nn(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let _=0;_<i.count;_++)o[_]=new H,l[_]=new H;const h=new H,c=new H,d=new H,u=new Vt,p=new Vt,m=new Vt,y=new H,g=new H;function f(_,S,P){h.fromBufferAttribute(i,_),c.fromBufferAttribute(i,S),d.fromBufferAttribute(i,P),u.fromBufferAttribute(n,_),p.fromBufferAttribute(n,S),m.fromBufferAttribute(n,P),c.sub(h),d.sub(h),p.sub(u),m.sub(u);const C=1/(p.x*m.y-m.x*p.y);isFinite(C)&&(y.copy(c).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(C),g.copy(d).multiplyScalar(p.x).addScaledVector(c,-m.x).multiplyScalar(C),o[_].add(y),o[S].add(y),o[P].add(y),l[_].add(g),l[S].add(g),l[P].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let _=0,S=x.length;_<S;++_){const P=x[_],C=P.start,L=P.count;for(let U=C,V=C+L;U<V;U+=3)f(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const v=new H,M=new H,w=new H,T=new H;function A(_){w.fromBufferAttribute(r,_),T.copy(w);const S=o[_];v.copy(S),v.sub(w.multiplyScalar(w.dot(S))).normalize(),M.crossVectors(T,S);const P=M.dot(l[_])<0?-1:1;a.setXYZW(_,v.x,v.y,v.z,P)}for(let _=0,S=x.length;_<S;++_){const P=x[_],C=P.start,L=P.count;for(let U=C,V=C+L;U<V;U+=3)A(e.getX(U+0)),A(e.getX(U+1)),A(e.getX(U+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new nn(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,p=i.count;u<p;u++)i.setXYZ(u,0,0,0);const r=new H,n=new H,a=new H,o=new H,l=new H,h=new H,c=new H,d=new H;if(e)for(let u=0,p=e.count;u<p;u+=3){const m=e.getX(u+0),y=e.getX(u+1),g=e.getX(u+2);r.fromBufferAttribute(t,m),n.fromBufferAttribute(t,y),a.fromBufferAttribute(t,g),c.subVectors(a,n),d.subVectors(r,n),c.cross(d),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,y),h.fromBufferAttribute(i,g),o.add(c),l.add(c),h.add(c),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(g,h.x,h.y,h.z)}else for(let u=0,p=t.count;u<p;u+=3)r.fromBufferAttribute(t,u+0),n.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),c.subVectors(a,n),d.subVectors(r,n),c.cross(d),i.setXYZ(u+0,c.x,c.y,c.z),i.setXYZ(u+1,c.x,c.y,c.z),i.setXYZ(u+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ci.fromBufferAttribute(e,t),ci.normalize(),e.setXYZ(t,ci.x,ci.y,ci.z)}toNonIndexed(){function e(o,l){const h=o.array,c=o.itemSize,d=o.normalized,u=new h.constructor(l.length*c);let p=0,m=0;for(let y=0,g=l.length;y<g;y++){o.isInterleavedBufferAttribute?p=l[y]*o.data.stride+o.offset:p=l[y]*c;for(let f=0;f<c;f++)u[m++]=h[p++]}return new nn(u,c,d)}if(this.index===null)return st("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Wd,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],h=e(l,i);t.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const l=[],h=n[o];for(let c=0,d=h.length;c<d;c++){const u=h[c],p=e(u,i);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const h=a[o];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const h in l)l[h]!==void 0&&(e[h]=l[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const h=i[l];e.data.attributes[l]=h.toJSON(e.data)}const r={};let n=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],c=[];for(let d=0,u=h.length;d<u;d++){const p=h[d];c.push(p.toJSON(e.data))}c.length>0&&(r[l]=c,n=!0)}n&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const h in r){const c=r[h];this.setAttribute(h,c.clone(t))}const n=e.morphAttributes;for(const h in n){const c=[],d=n[h];for(let u=0,p=d.length;u<p;u++)c.push(d[u].clone(t));this.morphAttributes[h]=c}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let h=0,c=a.length;h<c;h++){const d=a[h];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Rr=new H,cg=new H,dd=new H,un=new H,ug=new H,pd=new H,dg=new H;class N3{constructor(e=new H,t=new H(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Rr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Rr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Rr.copy(this.origin).addScaledVector(this.direction,t),Rr.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){cg.copy(e).add(t).multiplyScalar(.5),dd.copy(t).sub(e).normalize(),un.copy(this.origin).sub(cg);const n=e.distanceTo(t)*.5,a=-this.direction.dot(dd),o=un.dot(this.direction),l=-un.dot(dd),h=un.lengthSq(),c=Math.abs(1-a*a);let d,u,p,m;if(c>0)if(d=a*l-o,u=a*o-l,m=n*c,d>=0)if(u>=-m)if(u<=m){const y=1/c;d*=y,u*=y,p=d*(d+a*u+2*o)+u*(a*d+u+2*l)+h}else u=n,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+h;else u=-n,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+h;else u<=-m?(d=Math.max(0,-(-a*n+o)),u=d>0?-n:Math.min(Math.max(-n,-l),n),p=-d*d+u*(u+2*l)+h):u<=m?(d=0,u=Math.min(Math.max(-n,-l),n),p=u*(u+2*l)+h):(d=Math.max(0,-(a*n+o)),u=d>0?n:Math.min(Math.max(-n,-l),n),p=-d*d+u*(u+2*l)+h);else u=a>0?-n:n,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(cg).addScaledVector(dd,u),p}intersectSphere(e,t){Rr.subVectors(e.center,this.origin);const i=Rr.dot(this.direction),r=Rr.dot(Rr)-i*i,n=e.radius*e.radius;if(r>n)return null;const a=Math.sqrt(n-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,n,a,o,l;const h=1/this.direction.x,c=1/this.direction.y,d=1/this.direction.z,u=this.origin;return h>=0?(i=(e.min.x-u.x)*h,r=(e.max.x-u.x)*h):(i=(e.max.x-u.x)*h,r=(e.min.x-u.x)*h),c>=0?(n=(e.min.y-u.y)*c,a=(e.max.y-u.y)*c):(n=(e.max.y-u.y)*c,a=(e.min.y-u.y)*c),i>a||n>r||((n>i||isNaN(i))&&(i=n),(a<r||isNaN(r))&&(r=a),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Rr)!==null}intersectTriangle(e,t,i,r,n){ug.subVectors(t,e),pd.subVectors(i,e),dg.crossVectors(ug,pd);let a=this.direction.dot(dg),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;un.subVectors(this.origin,e);const l=o*this.direction.dot(pd.crossVectors(un,pd));if(l<0)return null;const h=o*this.direction.dot(ug.cross(un));if(h<0||l+h>a)return null;const c=-o*un.dot(dg);return c<0?null:this.at(c/a,n)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}const Fs=new H,Ir=new H,pg=new H,Pr=new H,Ao=new H,No=new H,L1=new H,mg=new H,fg=new H,gg=new H,yg=new Ai,xg=new Ai,vg=new Ai;class zs{constructor(e=new H,t=new H,i=new H){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Fs.subVectors(e,t),r.cross(Fs);const n=r.lengthSq();return n>0?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)}static getBarycoord(e,t,i,r,n){Fs.subVectors(r,t),Ir.subVectors(i,t),pg.subVectors(e,t);const a=Fs.dot(Fs),o=Fs.dot(Ir),l=Fs.dot(pg),h=Ir.dot(Ir),c=Ir.dot(pg),d=a*h-o*o;if(d===0)return n.set(0,0,0),null;const u=1/d,p=(h*l-o*c)*u,m=(a*c-o*l)*u;return n.set(1-p-m,m,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Pr)===null?!1:Pr.x>=0&&Pr.y>=0&&Pr.x+Pr.y<=1}static getInterpolation(e,t,i,r,n,a,o,l){return this.getBarycoord(e,t,i,r,Pr)===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(n,Pr.x),l.addScaledVector(a,Pr.y),l.addScaledVector(o,Pr.z),l)}static getInterpolatedAttribute(e,t,i,r,n,a){return yg.setScalar(0),xg.setScalar(0),vg.setScalar(0),yg.fromBufferAttribute(e,t),xg.fromBufferAttribute(e,i),vg.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(yg,n.x),a.addScaledVector(xg,n.y),a.addScaledVector(vg,n.z),a}static isFrontFacing(e,t,i,r){return Fs.subVectors(i,t),Ir.subVectors(e,t),Fs.cross(Ir).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fs.subVectors(this.c,this.b),Ir.subVectors(this.a,this.b),Fs.cross(Ir).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zs.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zs.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,n){return zs.getInterpolation(e,this.a,this.b,this.c,t,i,r,n)}containsPoint(e){return zs.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zs.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,n=this.c;let a,o;Ao.subVectors(r,i),No.subVectors(n,i),mg.subVectors(e,i);const l=Ao.dot(mg),h=No.dot(mg);if(l<=0&&h<=0)return t.copy(i);fg.subVectors(e,r);const c=Ao.dot(fg),d=No.dot(fg);if(c>=0&&d<=c)return t.copy(r);const u=l*d-c*h;if(u<=0&&l>=0&&c<=0)return a=l/(l-c),t.copy(i).addScaledVector(Ao,a);gg.subVectors(e,n);const p=Ao.dot(gg),m=No.dot(gg);if(m>=0&&p<=m)return t.copy(n);const y=p*h-l*m;if(y<=0&&h>=0&&m<=0)return o=h/(h-m),t.copy(i).addScaledVector(No,o);const g=c*m-p*d;if(g<=0&&d-c>=0&&p-m>=0)return L1.subVectors(n,r),o=(d-c)/(d-c+(p-m)),t.copy(r).addScaledVector(L1,o);const f=1/(g+y+u);return a=y*f,o=u*f,t.copy(i).addScaledVector(Ao,a).addScaledVector(No,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class C3 extends Jf{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ds(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 Do,this.combine=fC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const D1=new kt,ea=new N3,md=new td,O1=new H,fd=new H,gd=new H,yd=new H,_g=new H,xd=new H,U1=new H,vd=new H;class R3 extends Ni{constructor(e=new Wd,t=new C3){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,n=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(n&&o){xd.set(0,0,0);for(let l=0,h=n.length;l<h;l++){const c=o[l],d=n[l];c!==0&&(_g.fromBufferAttribute(d,e),a?xd.addScaledVector(_g,c):xd.addScaledVector(_g.sub(t),c))}t.add(xd)}return t}raycast(e,t){const i=this.geometry,r=this.material,n=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),md.copy(i.boundingSphere),md.applyMatrix4(n),ea.copy(e.ray).recast(e.near),!(md.containsPoint(ea.origin)===!1&&(ea.intersectSphere(md,O1)===null||ea.origin.distanceToSquared(O1)>(e.far-e.near)**2))&&(D1.copy(n).invert(),ea.copy(e.ray).applyMatrix4(D1),!(i.boundingBox!==null&&ea.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,ea)))}_computeIntersections(e,t,i){let r;const n=this.geometry,a=this.material,o=n.index,l=n.attributes.position,h=n.attributes.uv,c=n.attributes.uv1,d=n.attributes.normal,u=n.groups,p=n.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,y=u.length;m<y;m++){const g=u[m],f=a[g.materialIndex],x=Math.max(g.start,p.start),v=Math.min(o.count,Math.min(g.start+g.count,p.start+p.count));for(let M=x,w=v;M<w;M+=3){const T=o.getX(M),A=o.getX(M+1),_=o.getX(M+2);r=_d(this,f,e,i,h,c,d,T,A,_),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),y=Math.min(o.count,p.start+p.count);for(let g=m,f=y;g<f;g+=3){const x=o.getX(g),v=o.getX(g+1),M=o.getX(g+2);r=_d(this,a,e,i,h,c,d,x,v,M),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,y=u.length;m<y;m++){const g=u[m],f=a[g.materialIndex],x=Math.max(g.start,p.start),v=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let M=x,w=v;M<w;M+=3){const T=M,A=M+1,_=M+2;r=_d(this,f,e,i,h,c,d,T,A,_),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let g=m,f=y;g<f;g+=3){const x=g,v=g+1,M=g+2;r=_d(this,a,e,i,h,c,d,x,v,M),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}}function I3(s,e,t,i,r,n,a,o){let l;if(e.side===sf?l=i.intersectTriangle(a,n,r,!0,o):l=i.intersectTriangle(r,n,a,e.side===tf,o),l===null)return null;vd.copy(o),vd.applyMatrix4(s.matrixWorld);const h=t.ray.origin.distanceTo(vd);return h<t.near||h>t.far?null:{distance:h,point:vd.clone(),object:s}}function _d(s,e,t,i,r,n,a,o,l,h){s.getVertexPosition(o,fd),s.getVertexPosition(l,gd),s.getVertexPosition(h,yd);const c=I3(s,e,t,i,fd,gd,yd,U1);if(c){const d=new H;zs.getBarycoord(U1,fd,gd,yd,d),r&&(c.uv=zs.getInterpolatedAttribute(r,o,l,h,d,new Vt)),n&&(c.uv1=zs.getInterpolatedAttribute(n,o,l,h,d,new Vt)),a&&(c.normal=zs.getInterpolatedAttribute(a,o,l,h,d,new H),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const u={a:o,b:l,c:h,normal:new H,materialIndex:0};zs.getNormal(fd,gd,yd,u.normal),c.face=u,c.barycoord=d}return c}class P3{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const i=this.getMaterialNodeClass(e.type);if(i!==null){t=new i;for(const r in e)t[r]=e[r]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,i){if(i.has(t)){st(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);i.set(t,e)}addClass(e,t,i){if(i.has(t)){st(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);i.set(t,e)}}class ta extends Ni{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ds(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}const Mg=new H,L3=new H,D3=new xs;class ia{constructor(e=new H(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=Mg.subVectors(i,t).cross(L3.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(Mg),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const n=-(e.start.dot(this.normal)+this.constant)/r;return n<0||n>1?null:t.copy(e.start).addScaledVector(i,n)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||D3.getNormalMatrix(e),r=this.coplanarPoint(Mg).applyMatrix4(e),n=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(n),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const sa=new td,O3=new Vt(.5,.5),Md=new H;class U3{constructor(e=new ia,t=new ia,i=new ia,r=new ia,n=new ia,a=new ia){this.planes=[e,t,i,r,n,a]}set(e,t,i,r,n,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(n),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zs,i=!1){const r=this.planes,n=e.elements,a=n[0],o=n[1],l=n[2],h=n[3],c=n[4],d=n[5],u=n[6],p=n[7],m=n[8],y=n[9],g=n[10],f=n[11],x=n[12],v=n[13],M=n[14],w=n[15];if(r[0].setComponents(h-a,p-c,f-m,w-x).normalize(),r[1].setComponents(h+a,p+c,f+m,w+x).normalize(),r[2].setComponents(h+o,p+d,f+y,w+v).normalize(),r[3].setComponents(h-o,p-d,f-y,w-v).normalize(),i)r[4].setComponents(l,u,g,M).normalize(),r[5].setComponents(h-l,p-u,f-g,w-M).normalize();else if(r[4].setComponents(h-l,p-u,f-g,w-M).normalize(),t===Zs)r[5].setComponents(h+l,p+u,f+g,w+M).normalize();else if(t===tn)r[5].setComponents(l,u,g,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),sa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),sa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sa)}intersectsSprite(e){sa.center.set(0,0,0);const t=O3.distanceTo(e.center);return sa.radius=.7071067811865476+t,sa.applyMatrix4(e.matrixWorld),this.intersectsSphere(sa)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let n=0;n<6;n++)if(t[n].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Md.x=r.normal.x>0?e.max.x:e.min.x,Md.y=r.normal.y>0?e.max.y:e.min.y,Md.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Md)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const bg=new kt,F1=new H,z1=new H;class Sg{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vt(512,512),this.mapType=Dv,this.map=null,this.mapPass=null,this.matrix=new kt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new U3,this._frameExtents=new Vt(1,1),this._viewportCount=1,this._viewports=[new Ai(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;F1.setFromMatrixPosition(e.matrixWorld),t.position.copy(F1),z1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(z1),t.updateMatrixWorld(),bg.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bg,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===tn||t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(bg)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class F3 extends Sg{constructor(){super(new P1(90,1,.5,500)),this.isPointLightShadow=!0}}class z3 extends ta{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new F3}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class B1 extends C1{constructor(e=-1,t=1,i=1,r=-1,n=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=n,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,n,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let n=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,a=n+h*this.view.width,o-=c*this.view.offsetY,l=o-c*this.view.height}this.projectionMatrix.makeOrthographic(n,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class B3 extends Sg{constructor(){super(new B1(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class V3 extends ta{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ni.DEFAULT_UP),this.updateMatrix(),this.target=new Ni,this.shadow=new B3}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class k3 extends ta{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class G3 extends Sg{constructor(){super(new P1(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=eh*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,n=e.distance||t.far;(i!==t.fov||r!==t.aspect||n!==t.far)&&(t.fov=i,t.aspect=r,t.far=n,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Tg extends ta{constructor(e,t,i=0,r=Math.PI/3,n=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ni.DEFAULT_UP),this.updateMatrix(),this.target=new Ni,this.distance=i,this.angle=r,this.penumbra=n,this.decay=a,this.map=null,this.shadow=new G3}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class H3 extends ta{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class W3 extends ta{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ni.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ds(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}class j3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new H)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,n=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*n),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*n)),t.addScaledVector(a[6],.315392*(3*n*n-1)),t.addScaledVector(a[7],1.092548*(i*n)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,n=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*n),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*n),t.addScaledVector(a[6],.743125*n*n-.247708),t.addScaledVector(a[7],2*.429043*i*n),t.addScaledVector(a[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,n=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*n,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*n,t[6]=.315392*(3*n*n-1),t[7]=1.092548*i*n,t[8]=.546274*(i*i-r*r)}}class X3 extends ta{constructor(e=new j3,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class q3 extends Tg{constructor(e,t,i,r,n,a){super(e,t,i,r,n,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class Y3 extends Tg{constructor(e,t,i,r,n,a){super(e,t,i,r,n,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}xe(({texture:s,uv:e})=>{const t=Re().toVar();return ds(e.x.lessThan(1e-4),()=>{t.assign(Re(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{t.assign(Re(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{t.assign(Re(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{t.assign(Re(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{t.assign(Re(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{t.assign(Re(0,0,-1))}).Else(()=>{const i=s.sample(e.add(Re(-.01,0,0))).r.sub(s.sample(e.add(Re(.01,0,0))).r),r=s.sample(e.add(Re(0,-.01,0))).r.sub(s.sample(e.add(Re(0,.01,0))).r),n=s.sample(e.add(Re(0,0,-.01))).r.sub(s.sample(e.add(Re(0,0,.01))).r);t.assign(Re(i,r,n))}),t.normalize()});const bd=new Vt;class Z3 extends ad{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){const t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class V1 extends Z3{static get type(){return"PassMultipleTextureNode"}constructor(e,t,i=!1){super(e,null),this.textureName=t,this.previousTexture=i,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}class jd extends mi{static get type(){return"PassNode"}constructor(e,t,i,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=i,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const n=new Mh;n.isRenderTargetTexture=!0,n.name="depth";const a=new S1(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Jl,...r});a.texture.name="output",a.depthTexture=n,this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=dt(0),this._cameraFar=dt(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ht.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return st("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return st("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const i=this._textures[e],r=this.renderTarget.textures.indexOf(i);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=i,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new V1(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new V1(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=y1(this.getTextureNode(e),i,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar,n=this.getViewZNode(e);this._linearDepthNodes[e]=t=bh(n,i,r)}return t}async compileAsync(e){const t=e.getRenderTarget(),i=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(i)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),this.scope===jd.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:i}=this;let r,n;const a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(n=1,r=t.xr.getCamera(),t.xr.updateCamera(r),bd.set(a.width,a.height)):(r=this.camera,n=t.getPixelRatio(),t.getSize(bd)),this._pixelRatio=n,this.setSize(bd.width,bd.height);const o=t.getRenderTarget(),l=t.getMRT(),h=t.autoClear,c=t.transparent,d=t.opaque,u=r.layers.mask,p=t.contextNode,m=i.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(const g in this._previousTextures)this.toggleTexture(g);this.overrideMaterial!==null&&(i.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:po({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const y=i.name;i.name=this.name?this.name:i.name,t.render(i,r),i.name=y,i.overrideMaterial=m,t.setRenderTarget(o),t.setMRT(l),t.autoClear=h,t.transparent=c,t.opaque=d,t.contextNode=p,r.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const i=Math.floor(this._width*this._pixelRatio*this._resolutionScale),r=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(i,r),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,i,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Ai),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,i,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,i,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Ai),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,i,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}jd.COLOR="color",jd.DEPTH="depth";class or extends ze{static get type(){return"AtomicFunctionNode"}constructor(e,t,i){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=i,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),i=t.parents,r=this.method,n=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,l=this.valueNode,h=[];h.push(`&${o.build(e,a)}`),l!==null&&h.push(l.build(e,a));const c=`${e.getMethod(r,n)}( ${h.join(", ")} )`;if(i&&i.length===1&&i[0].isStackNode===!0)e.addLineFlowCode(c,this);else return t.constNode===void 0&&(t.constNode=Ar(c,n).toConst()),t.constNode.build(e)}}or.ATOMIC_LOAD="atomicLoad",or.ATOMIC_STORE="atomicStore",or.ATOMIC_ADD="atomicAdd",or.ATOMIC_SUB="atomicSub",or.ATOMIC_MAX="atomicMax",or.ATOMIC_MIN="atomicMin",or.ATOMIC_AND="atomicAnd",or.ATOMIC_OR="atomicOr",or.ATOMIC_XOR="atomicXor",Pt(or);class J3 extends ze{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:i}=e;i.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
|
|
4084
|
+
`):e.addLineFlowCode(`${t}Barrier()`,this)}}Pt(J3);class yt extends mi{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,i=null){super(),this.method=e,this.aNode=t,this.bNode=i}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,i=this.bNode?this.bNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),n=e.isMatrix(i)?0:e.getTypeLength(i);return r>n?t:i}getNodeType(e){const t=this.method;return t===yt.SUBGROUP_ELECT?"bool":t===yt.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const i=this.method,r=this.getNodeType(e),n=this.getInputType(e),a=this.aNode,o=this.bNode,l=[];if(i===yt.SUBGROUP_BROADCAST||i===yt.SUBGROUP_SHUFFLE||i===yt.QUAD_BROADCAST){const c=o.getNodeType(e);l.push(a.build(e,r),o.build(e,c==="float"?"int":r))}else i===yt.SUBGROUP_SHUFFLE_XOR||i===yt.SUBGROUP_SHUFFLE_DOWN||i===yt.SUBGROUP_SHUFFLE_UP?l.push(a.build(e,r),o.build(e,"uint")):(a!==null&&l.push(a.build(e,n)),o!==null&&l.push(o.build(e,n)));const h=l.length===0?"()":`( ${l.join(", ")} )`;return e.format(`${e.getMethod(i,r)}${h}`,r,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}yt.SUBGROUP_ELECT="subgroupElect",yt.SUBGROUP_BALLOT="subgroupBallot",yt.SUBGROUP_ADD="subgroupAdd",yt.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",yt.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",yt.SUBGROUP_MUL="subgroupMul",yt.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",yt.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",yt.SUBGROUP_AND="subgroupAnd",yt.SUBGROUP_OR="subgroupOr",yt.SUBGROUP_XOR="subgroupXor",yt.SUBGROUP_MIN="subgroupMin",yt.SUBGROUP_MAX="subgroupMax",yt.SUBGROUP_ALL="subgroupAll",yt.SUBGROUP_ANY="subgroupAny",yt.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",yt.QUAD_SWAP_X="quadSwapX",yt.QUAD_SWAP_Y="quadSwapY",yt.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",yt.SUBGROUP_BROADCAST="subgroupBroadcast",yt.SUBGROUP_SHUFFLE="subgroupShuffle",yt.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",yt.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",yt.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",yt.QUAD_BROADCAST="quadBroadcast";class K3 extends ze{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=ht.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){k1.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Zf)}}const k1=f_("vec3","shadowPositionWorld"),wg=new B1(-1,1,1,-1,0,1);class $3 extends Wd{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new zf([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new zf(t,2))}}const Q3=new $3;class eL extends R3{constructor(e=null){super(Q3,e),this.camera=wg,this.isQuadMesh=!0}async renderAsync(e){ro('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,wg)}render(e){e.render(this,wg)}}let Sd;function Td(s){Sd=Sd||new WeakMap;let e=Sd.get(s);return e===void 0&&Sd.set(s,e={}),e}function Eg(s){const e=Td(s);return e.shadowMatrix||(e.shadowMatrix=dt("mat4").setGroup(it).onRenderUpdate(t=>((s.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(s.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(s.shadow.camera.coordinateSystem=t.camera.coordinateSystem,s.shadow.camera.updateProjectionMatrix()),s.shadow.updateMatrices(s)),s.shadow.matrix)))}function tL(s,e=Zf){const t=Eg(s).mul(e);return t.xyz.div(t.w)}function G1(s){const e=Td(s);return e.position||(e.position=dt(new H).setGroup(it).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(s.matrixWorld)))}function iL(s){const e=Td(s);return e.targetPosition||(e.targetPosition=dt(new H).setGroup(it).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(s.target.matrixWorld)))}function H1(s){const e=Td(s);return e.viewPosition||(e.viewPosition=dt(new H).setGroup(it).onRenderUpdate(({camera:t},i)=>{i.value=i.value||new H,i.value.setFromMatrixPosition(s.matrixWorld),i.value.applyMatrix4(t.matrixWorldInverse)}))}const W1=s=>go.transformDirection(G1(s).sub(iL(s)));function sL(s,e={}){return e.toneMapping=s.toneMapping,e.toneMappingExposure=s.toneMappingExposure,e.outputColorSpace=s.outputColorSpace,e.renderTarget=s.getRenderTarget(),e.activeCubeFace=s.getActiveCubeFace(),e.activeMipmapLevel=s.getActiveMipmapLevel(),e.renderObjectFunction=s.getRenderObjectFunction(),e.pixelRatio=s.getPixelRatio(),e.mrt=s.getMRT(),e.clearColor=s.getClearColor(e.clearColor||new Ds),e.clearAlpha=s.getClearAlpha(),e.autoClear=s.autoClear,e.scissorTest=s.getScissorTest(),e}function rL(s,e){return e=sL(s,e),s.setMRT(null),s.setRenderObjectFunction(null),s.setClearColor(0,1),s.autoClear=!0,e}function nL(s,e){s.toneMapping=e.toneMapping,s.toneMappingExposure=e.toneMappingExposure,s.outputColorSpace=e.outputColorSpace,s.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),s.setRenderObjectFunction(e.renderObjectFunction),s.setPixelRatio(e.pixelRatio),s.setMRT(e.mrt),s.setClearColor(e.clearColor,e.clearAlpha),s.autoClear=e.autoClear,s.setScissorTest(e.scissorTest)}function aL(s,e={}){return e.background=s.background,e.backgroundNode=s.backgroundNode,e.overrideMaterial=s.overrideMaterial,e}function oL(s,e){return e=aL(s,e),s.background=null,s.backgroundNode=null,s.overrideMaterial=null,e}function lL(s,e){s.background=e.background,s.backgroundNode=e.backgroundNode,s.overrideMaterial=e.overrideMaterial}function hL(s,e,t){return t=rL(s,t),t=oL(e,t),t}function cL(s,e,t){nL(s,t),lL(e,t)}const j1=xe(([s])=>Zn(ke(52.9829189).mul(Zn(ch(s,xt(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),lr=xe(([s,e,t])=>{const i=ke(2.399963229728653),r=nh(ke(s).add(.5).div(ke(e))),n=ke(s).mul(i).add(t);return xt(x_(n),ah(n)).mul(r)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),wd=new WeakMap,uL=xe(({depthTexture:s,shadowCoord:e,depthLayer:t})=>{let i=gi(s,e.xy).setName("t_basic");return s.isArrayTexture&&(i=i.depth(t)),i.compare(e.z)}),dL=xe(({depthTexture:s,shadowCoord:e,shadow:t,depthLayer:i})=>{const r=(c,d)=>{let u=gi(s,c);return s.isArrayTexture&&(u=u.depth(i)),u.compare(d)},n=ri("mapSize","vec2",t).setGroup(it),a=ri("radius","float",t).setGroup(it),o=xt(1).div(n),l=a.mul(o.x),h=j1(fh.xy).mul(6.28318530718);return tr(r(e.xy.add(lr(0,5,h).mul(l)),e.z),r(e.xy.add(lr(1,5,h).mul(l)),e.z),r(e.xy.add(lr(2,5,h).mul(l)),e.z),r(e.xy.add(lr(3,5,h).mul(l)),e.z),r(e.xy.add(lr(4,5,h).mul(l)),e.z)).mul(1/5)}),pL=xe(({depthTexture:s,shadowCoord:e,shadow:t,depthLayer:i})=>{const r=(d,u)=>{let p=gi(s,d);return s.isArrayTexture&&(p=p.depth(i)),p.compare(u)},n=ri("mapSize","vec2",t).setGroup(it),a=xt(1).div(n),o=a.x,l=a.y,h=e.xy,c=Zn(h.mul(n).add(.5));return h.subAssign(c.mul(a)),tr(r(h,e.z),r(h.add(xt(o,0)),e.z),r(h.add(xt(0,l)),e.z),r(h.add(a),e.z),Fi(r(h.add(xt(o.negate(),0)),e.z),r(h.add(xt(o.mul(2),0)),e.z),c.x),Fi(r(h.add(xt(o.negate(),l)),e.z),r(h.add(xt(o.mul(2),l)),e.z),c.x),Fi(r(h.add(xt(0,l.negate())),e.z),r(h.add(xt(0,l.mul(2))),e.z),c.y),Fi(r(h.add(xt(o,l.negate())),e.z),r(h.add(xt(o,l.mul(2))),e.z),c.y),Fi(Fi(r(h.add(xt(o.negate(),l.negate())),e.z),r(h.add(xt(o.mul(2),l.negate())),e.z),c.x),Fi(r(h.add(xt(o.negate(),l.mul(2))),e.z),r(h.add(xt(o.mul(2),l.mul(2))),e.z),c.x),c.y)).mul(1/9)}),mL=xe(({depthTexture:s,shadowCoord:e,depthLayer:t},i)=>{let r=gi(s).sample(e.xy);s.isArrayTexture&&(r=r.depth(t)),r=r.rg;const n=r.x,a=ir(1e-7,r.y.mul(r.y)),o=i.renderer.reversedDepthBuffer?hh(n,e.z):hh(e.z,n),l=ke(1).toVar();return ds(o.notEqual(1),()=>{const h=e.z.sub(n);let c=a.div(a.add(h.mul(h)));c=uo(Hi(c,.3).div(.65)),l.assign(ir(o,c))}),l}),fL=s=>{let e=wd.get(s);return e===void 0&&(e=new og,e.colorNode=Ui(0,0,0,1),e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.blending=mC,e.fog=!1,wd.set(s,e)),e},gL=s=>{const e=wd.get(s);e!==void 0&&(e.dispose(),wd.delete(s))};class yL{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let i=this.weakMaps[t];return i===void 0&&(i=new WeakMap,this.weakMaps[t]=i),i}get(e){let t=this._getWeakMap(e);for(let i=0;i<e.length-1;i++)if(t=t.get(e[i]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let i=this._getWeakMap(e);for(let r=0;r<e.length-1;r++){const n=e[r];i.has(n)===!1&&i.set(n,new WeakMap),i=i.get(n)}return i.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let i=0;i<e.length-1;i++)if(t=t.get(e[i]),t===void 0)return!1;return t.delete(e[e.length-1])}}const X1=new yL,Co=[],xL=(s,e,t,i)=>{Co[0]=s,Co[1]=e;let r=X1.get(Co);return(r===void 0||r.shadowType!==t||r.useVelocity!==i)&&(r=(n,a,o,l,h,c,...d)=>{(n.castShadow===!0||n.receiveShadow&&t===Pu)&&(i&&(iR(n).useVelocity=!0),n.onBeforeShadow(s,n,o,e.camera,l,a.overrideMaterial,c),s.renderObject(n,a,o,l,h,c,...d),n.onAfterShadow(s,n,o,e.camera,l,a.overrideMaterial,c))},r.shadowType=t,r.useVelocity=i,X1.set(Co,r)),Co[0]=null,Co[1]=null,r},vL=xe(({samples:s,radius:e,size:t,shadowPass:i,depthLayer:r})=>{const n=ke(0).toVar("meanVertical"),a=ke(0).toVar("squareMeanVertical"),o=s.lessThanEqual(ke(1)).select(ke(0),ke(2).div(s.sub(1))),l=s.lessThanEqual(ke(1)).select(ke(0),ke(-1));hn({start:zt(0),end:zt(s),type:"int",condition:"<"},({i:c})=>{const d=l.add(ke(c).mul(o));let u=i.sample(tr(fh.xy,xt(0,d).mul(e)).div(t));i.value.isArrayTexture&&(u=u.depth(r)),u=u.x,n.addAssign(u),a.addAssign(u.mul(u))}),n.divAssign(s),a.divAssign(s);const h=nh(a.sub(n.mul(n)).max(0));return xt(n,h)}),_L=xe(({samples:s,radius:e,size:t,shadowPass:i,depthLayer:r})=>{const n=ke(0).toVar("meanHorizontal"),a=ke(0).toVar("squareMeanHorizontal"),o=s.lessThanEqual(ke(1)).select(ke(0),ke(2).div(s.sub(1))),l=s.lessThanEqual(ke(1)).select(ke(0),ke(-1));hn({start:zt(0),end:zt(s),type:"int",condition:"<"},({i:c})=>{const d=l.add(ke(c).mul(o));let u=i.sample(tr(fh.xy,xt(d,0).mul(e)).div(t));i.value.isArrayTexture&&(u=u.depth(r)),n.addAssign(u.x),a.addAssign(tr(u.y.mul(u.y),u.x.mul(u.x)))}),n.divAssign(s),a.divAssign(s);const h=nh(a.sub(n.mul(n)).max(0));return xt(n,h)}),ML=[uL,dL,pL,mL];let Ag;const Ed=new eL;class q1 extends K3{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.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(e,{filterFn:t,depthTexture:i,shadowCoord:r,shadow:n,depthLayer:a}){const o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:i,shadowCoord:r,shadow:n,depthLayer:a});return o.select(l,ke(1))}setupShadowCoord(e,t){const{shadow:i}=this,{renderer:r}=e,n=i.biasNode||ri("bias","float",i).setGroup(it);let a=t,o;if(i.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{const l=a.w;a=a.xy.div(l);const h=ri("near","float",i.camera).setGroup(it),c=ri("far","float",i.camera).setGroup(it);o=x1(l.negate(),h,c)}return a=Re(a.x,a.y.oneMinus(),r.reversedDepthBuffer?o.sub(n):o.add(n)),a}getShadowFilterFn(e){return ML[e]}setupRenderTarget(e,t){const i=new Mh(e.mapSize.width,e.mapSize.height);i.name="ShadowDepthTexture",i.compareFunction=t.renderer.reversedDepthBuffer?Du:cf;const r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name="ShadowMap",r.texture.type=e.mapType,r.depthTexture=i,{shadowMap:r,depthTexture:i}}setupShadow(e){const{renderer:t,camera:i}=e,{light:r,shadow:n}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(n,e),l=t.shadowMap.type,h=t.hasCompatibility(kv.TEXTURE_COMPARE);if((l===uC||l===dC)&&h?(a.minFilter=Zl,a.magFilter=Zl):(a.minFilter=cs,a.magFilter=cs),n.camera.coordinateSystem=i.coordinateSystem,n.camera.updateProjectionMatrix(),l===Pu&&n.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Kl,type:Jl,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Kl,type:Jl,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Kl,type:Jl,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Kl,type:Jl,depthBuffer:!1}));let M=gi(a);a.isArrayTexture&&(M=M.depth(this.depthLayer));let w=gi(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(w=w.depth(this.depthLayer));const T=ri("blurSamples","float",n).setGroup(it),A=ri("radius","float",n).setGroup(it),_=ri("mapSize","vec2",n).setGroup(it);let S=this.vsmMaterialVertical||(this.vsmMaterialVertical=new og);S.fragmentNode=vL({samples:T,radius:A,size:_,shadowPass:M,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMVertical",S=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new og),S.fragmentNode=_L({samples:T,radius:A,size:_,shadowPass:w,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMHorizontal"}const c=ri("intensity","float",n).setGroup(it),d=ri("normalBias","float",n).setGroup(it),u=Eg(r).mul(k1.add(rd.mul(d))),p=this.setupShadowCoord(e,u),m=n.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(m===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const y=l===Pu&&n.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,g=this.setupShadowFilter(e,{filterFn:m,shadowTexture:o.texture,depthTexture:y,shadowCoord:p,shadow:n,depthLayer:this.depthLayer});let f;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?f=nr(o.texture,p.xyz):(f=gi(o.texture,p),a.isArrayTexture&&(f=f.depth(this.depthLayer))));let x;f?x=Fi(1,g.rgb.mix(f,1),c.mul(f.a)).toVar():x=Fi(1,g,c).toVar(),this.shadowMap=o,this.shadow.map=o;const v=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return f&&x.toInspector(`${v} / Color`,()=>this.shadowMap.texture.isCubeTexture?nr(this.shadowMap.texture):gi(this.shadowMap.texture)),x.toInspector(`${v} / Depth`,()=>this.shadowMap.texture.isCubeTexture?nr(this.shadowMap.texture).r.oneMinus():fs(this.shadowMap.depthTexture,nd().mul(_o(gi(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return xe(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let i=this._node;return this.setupShadowPosition(e),i===null&&(this._node=i=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(i=e.material.receivedShadowNode(i)),i})()}renderShadow(e){const{shadow:t,shadowMap:i,light:r}=this,{renderer:n,scene:a}=e;t.updateMatrices(r),i.setSize(t.mapSize.width,t.mapSize.height,i.depth);const o=a.name;a.name=`Shadow Map [ ${r.name||"ID: "+r.id} ]`,n.render(a,t.camera),a.name=o}updateShadow(e){const{shadowMap:t,light:i,shadow:r}=this,{renderer:n,scene:a,camera:o}=e,l=n.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h;const c=r.camera.layers.mask;(r.camera.layers.mask&4294967294)===0&&(r.camera.layers.mask=o.layers.mask);const d=n.getRenderObjectFunction(),u=n.getMRT(),p=u?u.has("velocity"):!1;Ag=hL(n,a,Ag),a.overrideMaterial=fL(i),n.setRenderObjectFunction(xL(n,r,l,p)),n.setClearColor(0,0),n.setRenderTarget(t),this.renderShadow(e),n.setRenderObjectFunction(d),l===Pu&&r.isPointLightShadow!==!0&&this.vsmPass(n),r.camera.layers.mask=c,cL(n,a,Ag)}vsmPass(e){const{shadow:t}=this,i=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,i),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,i),e.setRenderTarget(this.vsmShadowMapVertical),Ed.material=this.vsmMaterialVertical,Ed.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Ed.material=this.vsmMaterialHorizontal,Ed.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,gL(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(e){const{shadow:t}=this;let i=t.needsUpdate||t.autoUpdate;i&&(this._cameraFrameId[e.camera]===e.frameId&&(i=!1),this._cameraFrameId[e.camera]=e.frameId),i&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const bL=(s,e)=>new q1(s,e);class ra extends ng{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Ds,this.colorNode=e&&e.colorNode||dt(this.color).setGroup(it),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ht.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.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(e){return H1(this.light).sub(e.context.positionView||hi)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return bL(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let i=this.shadowColorNode;if(i===null){const r=this.light.shadow.shadowNode;let n;r!==void 0?n=Fe(r):n=this.setupShadowNode(),this.shadowNode=n,this.shadowColorNode=i=this.colorNode.mul(n),this.baseColorNode=this.colorNode}e.context.getShadow&&(i=e.context.getShadow(this,e)),this.colorNode=i}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),i=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),i&&e.lightsNode.setupDirectRectAreaLight(e,this,i)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}class SL extends ra{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class TL extends ra{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:W1(this.light),lightColor:e}}}class wL extends ra{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=G1(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=dt(new Ds).setGroup(it)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:i,lightDirectionNode:r}=this,n=rd.dot(r).mul(.5).add(.5),a=Fi(i,t,n);e.context.irradiance.addAssign(a)}}const Y1=xe(({lightDistance:s,cutoffDistance:e,decayExponent:t})=>{const i=s.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(i.mul(s.div(e).pow4().oneMinus().clamp().pow2()),i)});class Ng extends ra{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=dt(0).setGroup(it),this.penumbraCosNode=dt(0).setGroup(it),this.cutoffDistanceNode=dt(0).setGroup(it),this.decayExponentNode=dt(0).setGroup(it),this.colorNode=dt(this.color).setGroup(it)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:i,penumbraCosNode:r}=this;return uh(i,r,t)}getLightCoord(e){const t=e.getNodeProperties(this);let i=t.projectionUV;return i===void 0&&(i=tL(this.light,e.context.positionWorld),t.projectionUV=i),i}setupDirect(e){const{colorNode:t,cutoffDistanceNode:i,decayExponentNode:r,light:n}=this,a=this.getLightVector(e),o=a.normalize(),l=o.dot(W1(n)),h=this.getSpotAttenuation(e,l),c=a.length(),d=Y1({lightDistance:c,cutoffDistance:i,decayExponent:r});let u=t.mul(h).mul(d),p,m;return n.colorNode?(m=this.getLightCoord(e),p=n.colorNode(m)):n.map&&(m=this.getLightCoord(e),p=gi(n.map,m.xy).onRenderUpdate(()=>n.map)),p&&(u=m.mul(2).sub(1).abs().lessThan(1).all().select(u.mul(p),u)),{lightColor:u,lightDirection:o}}}class EL extends Ng{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const i=this.light.iesMap;let r=null;if(i&&i.isTexture===!0){const n=t.acos().mul(1/Math.PI);r=gi(i,xt(n,0),0).r}else r=super.getSpotAttenuation(t);return r}}const AL=xe(([s,e])=>{const t=s.x,i=s.y,r=s.z;let n=e.element(0).mul(.886227);return n=n.add(e.element(1).mul(2*.511664).mul(i)),n=n.add(e.element(2).mul(2*.511664).mul(r)),n=n.add(e.element(3).mul(2*.511664).mul(t)),n=n.add(e.element(4).mul(2*.429043).mul(t).mul(i)),n=n.add(e.element(5).mul(2*.429043).mul(i).mul(r)),n=n.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),n=n.add(e.element(7).mul(2*.429043).mul(t).mul(r)),n=n.add(e.element(8).mul(.429043).mul(Bt(t,t).sub(Bt(i,i)))),n});class NL extends ra{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let i=0;i<9;i++)t.push(new H);this.lightProbe=sr(t)}update(e){const{light:t}=this;super.update(e);for(let i=0;i<9;i++)this.lightProbe.array[i].copy(t.sh.coefficients[i]).multiplyScalar(t.intensity)}setup(e){const t=AL(rd,this.lightProbe);e.context.irradiance.addAssign(t)}}class CL extends Mh{constructor(e,t=af,i=nf,r,n,a=cs,o=cs,l,h=of){const c={width:e,height:e,depth:1},d=[c,c,c,c,c,c];super(e,e,t,i,r,n,a,o,l,h),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}const RL=new Ds,Z1=new kt,wh=new H,Cg=new H,IL=[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)],PL=[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)],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)],DL=[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=xe(({depthTexture:s,bd3D:e,dp:t})=>nr(s,e).compare(t)),UL=xe(({depthTexture:s,bd3D:e,dp:t,shadow:i})=>{const r=ri("radius","float",i).setGroup(it),n=ri("mapSize","vec2",i).setGroup(it),a=r.div(n.x),o=oh(e),l=If(Pf(e,o.x.greaterThan(o.z).select(Re(0,1,0),Re(1,0,0)))),h=Pf(e,l),c=j1(fh.xy).mul(6.28318530718),d=lr(0,5,c),u=lr(1,5,c),p=lr(2,5,c),m=lr(3,5,c),y=lr(4,5,c);return nr(s,e.add(l.mul(d.x).add(h.mul(d.y)).mul(a))).compare(t).add(nr(s,e.add(l.mul(u.x).add(h.mul(u.y)).mul(a))).compare(t)).add(nr(s,e.add(l.mul(p.x).add(h.mul(p.y)).mul(a))).compare(t)).add(nr(s,e.add(l.mul(m.x).add(h.mul(m.y)).mul(a))).compare(t)).add(nr(s,e.add(l.mul(y.x).add(h.mul(y.y)).mul(a))).compare(t)).mul(1/5)}),FL=xe(({filterFn:s,depthTexture:e,shadowCoord:t,shadow:i},r)=>{const n=t.xyz.toConst(),a=n.abs().toConst(),o=a.x.max(a.y).max(a.z),l=dt("float").setGroup(it).onRenderUpdate(()=>i.camera.near),h=dt("float").setGroup(it).onRenderUpdate(()=>i.camera.far),c=ri("bias","float",i).setGroup(it),d=ke(1).toVar();return ds(o.sub(h).lessThanEqual(0).and(o.sub(l).greaterThanEqual(0)),()=>{let u;r.renderer.reversedDepthBuffer?(u=u3(o.negate(),l,h),u.subAssign(c)):(u=g1(o.negate(),l,h),u.addAssign(c));const p=n.normalize();d.assign(s({depthTexture:e,bd3D:p,dp:u,shadow:i}))}),d});class zL extends q1{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===cC?OL:UL}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:i,shadowCoord:r,shadow:n}){return FL({filterFn:t,depthTexture:i,shadowCoord:r,shadow:n})}setupRenderTarget(e,t){const i=new CL(e.mapSize.width);i.name="PointShadowDepthTexture",i.compareFunction=t.renderer.reversedDepthBuffer?Du:cf;const r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name="PointShadowMap",r.depthTexture=i,{shadowMap:r,depthTexture:i}}renderShadow(e){const{shadow:t,shadowMap:i,light:r}=this,{renderer:n,scene:a}=e,o=t.camera,l=t.matrix,h=n.coordinateSystem===tn,c=h?IL:LL,d=h?PL:DL;i.setSize(t.mapSize.width,t.mapSize.width);const u=n.autoClear,p=n.getClearColor(RL),m=n.getClearAlpha();n.autoClear=!1,n.setClearColor(t.clearColor,t.clearAlpha);for(let y=0;y<6;y++){n.setRenderTarget(i,y),n.clear();const g=r.distance||o.far;g!==o.far&&(o.far=g,o.updateProjectionMatrix()),wh.setFromMatrixPosition(r.matrixWorld),o.position.copy(wh),Cg.copy(o.position),Cg.add(c[y]),o.up.copy(d[y]),o.lookAt(Cg),o.updateMatrixWorld(),l.makeTranslation(-wh.x,-wh.y,-wh.z),Z1.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(Z1,o.coordinateSystem,o.reversedDepth);const f=a.name;a.name=`Point Light Shadow [ ${r.name||"ID: "+r.id} ] - Face ${y+1}`,n.render(a,o),a.name=f}n.autoClear=u,n.setClearColor(p,m)}}const BL=(s,e)=>new zL(s,e),VL=({color:s,lightVector:e,cutoffDistance:t,decayExponent:i})=>{const r=e.normalize(),n=e.length(),a=Y1({lightDistance:n,cutoffDistance:t,decayExponent:i}),o=s.mul(a);return{lightDirection:r,lightColor:o}};class kL extends ra{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=dt(0).setGroup(it),this.decayExponentNode=dt(2).setGroup(it)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return BL(this.light)}setupDirect(e){return VL({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const GL=xe(([s,e])=>{const t=s.abs().sub(e);return Xu(ir(t,0)).add(lh(ir(t.x,t.y),0))});class HL extends Ng{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let i=1;t.map!==null&&(i=t.map.width/t.map.height),t.shadow.aspect=i}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=ke(0),i=this.penumbraCosNode,r=Eg(this.light).mul(e.context.positionWorld||Zf);return ds(r.w.greaterThan(0),()=>{const n=r.xyz.div(r.w),a=GL(n.xy.sub(xt(.5)),xt(.5)),o=Wu(-1,Hi(1,v_(i)).sub(1));t.assign(Df(a.mul(-2).mul(o)))}),t}}const Rg=new kt,Ad=new kt;let Eh=null;class WL extends ra{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=dt(new H).setGroup(it),this.halfWidth=dt(new H).setGroup(it),this.updateType=ht.RENDER}update(e){super.update(e);const{light:t}=this,i=e.camera.matrixWorldInverse;Ad.identity(),Rg.copy(t.matrixWorld),Rg.premultiply(i),Ad.extractRotation(Rg),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Ad),this.halfHeight.value.applyMatrix4(Ad)}setupDirectRectArea(e){let t,i;e.isAvailable("float32Filterable")?(t=gi(Eh.LTC_FLOAT_1),i=gi(Eh.LTC_FLOAT_2)):(t=gi(Eh.LTC_HALF_1),i=gi(Eh.LTC_HALF_2));const{colorNode:r,light:n}=this,a=H1(n);return{lightColor:r,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:i}}static setLTC(e){Eh=e}}class J1 extends mi{static get type(){return"BitcastNode"}constructor(e,t,i=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=i,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){const t=this.valueNode.getNodeType(e),i=e.getTypeLength(t);return e.getTypeFromLength(i,this.conversionType)}return this.conversionType}generate(e){const t=this.getNodeType(e);let i="";if(this.inputType!==null){const r=this.valueNode.getNodeType(e);i=e.getTypeLength(r)===1?this.inputType:e.changeComponentType(r,this.inputType)}else i=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,i)}( ${this.valueNode.build(e,i)} )`}}const jL=Ee(J1).setParameterLength(2),XL=s=>new J1(s,"uint","float"),Nd={};class aa extends z{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,i){i==="int"?t.assign(jL(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return fi;case"int":return zt;case"uvec2":return a_;case"uvec3":return l_;case"uvec4":return c_;case"ivec2":return er;case"ivec3":return o_;case"ivec4":return h_}}_createTrailingZerosBaseLayout(e,t){const i=this._returnDataNode(t);return xe(([r])=>{const n=fi(0);this._resolveElementType(r,n,t);const a=ke(n.bitAnd(M_(n))),o=XL(a).shiftRight(23).sub(127);return i(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const i=this._returnDataNode(t);return xe(([r])=>{ds(r.equal(fi(0)),()=>fi(32));const n=fi(0),a=fi(0);return this._resolveElementType(r,n,t),ds(n.shiftRight(16).equal(0),()=>{a.addAssign(16),n.shiftLeftAssign(16)}),ds(n.shiftRight(24).equal(0),()=>{a.addAssign(8),n.shiftLeftAssign(8)}),ds(n.shiftRight(28).equal(0),()=>{a.addAssign(4),n.shiftLeftAssign(4)}),ds(n.shiftRight(30).equal(0),()=>{a.addAssign(2),n.shiftLeftAssign(2)}),ds(n.shiftRight(31).equal(0),()=>{a.addAssign(1)}),i(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const i=this._returnDataNode(t);return xe(([r])=>{const n=fi(0);this._resolveElementType(r,n,t),n.assign(n.sub(n.shiftRight(fi(1)).bitAnd(fi(1431655765)))),n.assign(n.bitAnd(fi(858993459)).add(n.shiftRight(fi(2)).bitAnd(fi(858993459))));const a=n.add(n.shiftRight(fi(4))).bitAnd(fi(252645135)).mul(fi(16843009)).shiftRight(fi(24));return i(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,i,r){const n=this._returnDataNode(t);return xe(([a])=>{if(i===1)return n(r(a));{const o=n(0),l=["x","y","z","w"];for(let h=0;h<i;h++){const c=l[h];o[c].assign(r(a[c]))}return o}}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}setup(e){const{method:t,aNode:i}=this,{renderer:r}=e;if(r.backend.isWebGPUBackend)return super.setup(e);const n=this.getInputType(e),a=e.getElementType(n),o=e.getTypeLength(n),l=`${t}_base_${a}`,h=`${t}_${n}`;let c=Nd[l];if(c===void 0){switch(t){case aa.COUNT_LEADING_ZEROS:{c=this._createLeadingZerosBaseLayout(l,a);break}case aa.COUNT_TRAILING_ZEROS:{c=this._createTrailingZerosBaseLayout(l,a);break}case aa.COUNT_ONE_BITS:{c=this._createOneBitsBaseLayout(l,a);break}}Nd[l]=c}let d=Nd[h];return d===void 0&&(d=this._createMainLayout(h,n,o,c),Nd[h]=d),xe(()=>d(i))()}}aa.COUNT_TRAILING_ZEROS="countTrailingZeros",aa.COUNT_LEADING_ZEROS="countLeadingZeros",aa.COUNT_ONE_BITS="countOneBits";class Lr extends ze{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===Lr.OBJECT?this.updateType=ht.OBJECT:e===Lr.MATERIAL?this.updateType=ht.RENDER:e===Lr.BEFORE_OBJECT?this.updateBeforeType=ht.OBJECT:e===Lr.BEFORE_MATERIAL&&(this.updateBeforeType=ht.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}Lr.OBJECT="object",Lr.MATERIAL="material",Lr.BEFORE_OBJECT="beforeObject",Lr.BEFORE_MATERIAL="beforeMaterial",new ia,new H,new H,new H,new kt,new H(0,0,-1),new Ai,new H,new H,new Ai,new Vt;const qL=new S1;kf.flipX(),qL.depthTexture=new Mh(1,1),Re(.04),ke(1);const YL=xe(([s,e])=>s.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ZL=xe(([s,e])=>(s=s.mul(e),s.div(s.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),JL=xe(([s,e])=>{s=s.mul(e),s=s.sub(.004).max(0);const t=s.mul(s.mul(6.2).add(.5)),i=s.mul(s.mul(6.2).add(1.7)).add(.06);return t.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),KL=xe(([s])=>{const e=s.mul(s.add(.0245786)).sub(90537e-9),t=s.mul(s.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),$L=xe(([s,e])=>{const t=ps(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=ps(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return s=s.mul(e).div(.6),s=t.mul(s),s=KL(s),s=i.mul(s),s.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),QL=ps(Re(1.6605,-.1246,-.0182),Re(-.5876,1.1329,-.1006),Re(-.0728,-.0083,1.1187)),eD=ps(Re(.6274,.0691,.0164),Re(.3293,.9195,.088),Re(.0433,.0113,.8956)),tD=xe(([s])=>{const e=Re(s).toVar(),t=Re(e.mul(e)).toVar(),i=Re(t.mul(t)).toVar();return ke(15.5).mul(i.mul(t)).sub(Bt(40.14,i.mul(e))).add(Bt(31.96,i).sub(Bt(6.868,t.mul(e))).add(Bt(.4298,t).add(Bt(.1191,e).sub(.00232))))}),iD=xe(([s,e])=>{const t=Re(s).toVar(),i=ps(Re(.856627153315983,.137318972929847,.11189821299995),Re(.0951212405381588,.761241990602591,.0767994186031903),Re(.0482516061458583,.101439036467562,.811302368396859)),r=ps(Re(1.1271005818144368,-.1413297634984383,-.14132976349843826),Re(-.11060664309660323,1.157823702216272,-.11060664309660294),Re(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ke(-12.47393),a=ke(4.026069);return t.mulAssign(e),t.assign(eD.mul(t)),t.assign(i.mul(t)),t.assign(ir(t,1e-10)),t.assign(Yn(t)),t.assign(t.sub(n).div(a.sub(n))),t.assign(uo(t,0,1)),t.assign(tD(t)),t.assign(r.mul(t)),t.assign(Lf(ir(Re(0),t),Re(2.2))),t.assign(QL.mul(t)),t.assign(uo(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),sD=xe(([s,e])=>{const t=ke(.76),i=ke(.15);s=s.mul(e);const r=lh(s.r,lh(s.g,s.b)),n=Of(r.lessThan(.08),r.sub(Bt(6.25,r.mul(r))),.04);s.subAssign(n);const a=ir(s.r,ir(s.g,s.b));ds(a.lessThan(t),()=>s);const o=Hi(1,t),l=Hi(1,o.mul(o).div(a.add(o.sub(t))));s.mulAssign(l.div(a));const h=Hi(1,Wu(1,i.mul(a.sub(l)).add(1)));return Fi(s,Re(l),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class rD extends P3{constructor(){super(),this.addLight(kL,z3),this.addLight(TL,V3),this.addLight(WL,k3),this.addLight(Ng,Tg),this.addLight(SL,H3),this.addLight(wL,W3),this.addLight(NL,X3),this.addLight(EL,q3),this.addLight(HL,Y3),this.addToneMapping(YL,gC),this.addToneMapping(ZL,yC),this.addToneMapping(JL,xC),this.addToneMapping($L,vC),this.addToneMapping(iD,_C),this.addToneMapping(sD,MC)}}function nD(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const r=s[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(st("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function aD(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}export{Bh as ACESFilmicToneMapping,Dh as AdditiveBlending,Vh as AgXToneMapping,Fo as AlwaysDepth,dc as AlwaysStencilFunc,Im as AmbientLight,qa as AnimationClip,Tx as AnimationMixer,Um as ArrayCamera,Bm as Audio,yu as AudioContext,vx as AudioListener,gx as AudioLoader,jx as AxesHelper,yi as BackSide,hp as BasicDepthPacking,rD as BasicNodeLibrary,Xp as BatchedMesh,kc as Bone,Jr as BooleanKeyframeTrack,di as Box3,Hx as Box3Helper,dn as BoxGeometry,Gx as BoxHelper,bt as BufferAttribute,rt as BufferGeometry,Is as Cache,Hl as Camera,kx as CameraHelper,Py as CanvasTexture,nm as CatmullRomCurve3,Ci as ClampToEdgeWrapping,we as Color,uu as ColorKeyframeTrack,mt as ColorManagement,Ry as CompressedArrayTexture,Iy as CompressedCubeTexture,Ol as CompressedTexture,qx as Controls,Om as CubeCamera,ka as CubeTexture,xn as CubeUVReflectionMapping,ls as Curve,Kd as CustomBlending,Io as CylinderGeometry,_l as Data3DTexture,os as DataTexture,rx as DataTextureLoader,ay as DataUtils,T0 as DecrementStencilOp,E0 as DecrementWrapStencilOp,Tm as DefaultLoadingManager,ws as DepthFormat,ur as DepthStencilFormat,On as DepthTexture,Rm as DirectionalLight,Vx as DirectionalLightHelper,Ms as DoubleSide,k0 as DynamicDrawUsage,em as EdgesGeometry,Bo as EqualDepth,R0 as EqualStencilFunc,ua as EquirectangularReflectionMapping,da as EquirectangularRefractionMapping,ns as Euler,Es as EventDispatcher,Ch as ExtrudeGeometry,js as FileLoader,Ne as Float32BufferAttribute,xi as FloatType,vp as Fog,Vs as FrontSide,Pn as Frustum,fc as GLSL3,ko as GreaterDepth,Vo as GreaterEqualDepth,D0 as GreaterEqualStencilFunc,P0 as GreaterStencilFunc,Fx as GridHelper,wn as Group,Ts as HalfFloatType,wm as HemisphereLight,fx as ImageBitmapLoader,pp as ImageUtils,S0 as IncrementStencilOp,w0 as IncrementWrapStencilOp,Rn as InstancedBufferAttribute,Lm as InstancedBufferGeometry,wx as InstancedInterleavedBuffer,Gp as InstancedMesh,Al as InterleavedBuffer,Oa as InterleavedBufferAttribute,zn as Interpolant,Ma as InterpolateDiscrete,dl as InterpolateLinear,A0 as InvertStencilOp,Gr as KeepStencilOp,Qi as KeyframeTrack,Dp as LOD,Ml as Layers,zo as LessDepth,Fr as LessEqualDepth,I0 as LessEqualStencilFunc,C0 as LessStencilFunc,Sr as Line,Px as Line3,Ti as LineBasicMaterial,Yp as LineLoop,Rs as LineSegments,Rt as LinearFilter,m0 as LinearMipMapLinearFilter,Ss as LinearMipmapLinearFilter,fa as LinearMipmapNearestFilter,kr as LinearSRGBColorSpace,Fh as LinearToneMapping,Oi as Loader,fu as LoaderUtils,du as LoadingManager,np as LoopOnce,ap as LoopRepeat,Hg as MOUSE,pi as Material,q0 as MathUtils,at as Matrix3,et as Matrix4,$d as MaxEquation,Xt as Mesh,Mr as MeshBasicMaterial,cu as MeshDepthMaterial,vm as MeshLambertMaterial,xm as MeshNormalMaterial,ym as MeshPhongMaterial,gm as MeshPhysicalMaterial,hu as MeshStandardMaterial,ma as MirroredRepeatWrapping,Ht as NearestFilter,p0 as NearestMipMapNearestFilter,vn as NearestMipmapLinearFilter,Hh as NearestMipmapNearestFilter,kh as NeutralToneMapping,Uo as NeverDepth,N0 as NeverStencilFunc,bs as NoBlending,Gs as NoColorSpace,rs as NoToneMapping,J2 as NodeFrame,Or as NormalBlending,Go as NotEqualDepth,L0 as NotEqualStencilFunc,Wa as NumberKeyframeTrack,_t as Object3D,Po as OctahedronGeometry,Za as OrthographicCamera,ha as PCFShadowMap,wu as PMREMGenerator,li as PerspectiveCamera,br as Plane,na as PlaneGeometry,Cm as PointLight,Jp as Points,Jc as PointsMaterial,Mx as PositionalAudio,gt as PropertyBinding,Mi as Quaternion,ja as QuaternionKeyframeTrack,el as R11_EAC_Format,cl as RED_GREEN_RGTC2_Format,ll as RED_RGTC1_Format,yn as REVISION,il as RG11_EAC_Format,v0 as RGBADepthPacking,vi as RGBAFormat,Xo as RGBAIntegerFormat,rl as RGBA_ASTC_4x4_Format,nl as RGBA_ASTC_6x6_Format,al as RGBA_BPTC_Format,Qo as RGBA_ETC2_EAC_Format,Jo as RGBA_PVRTC_2BPPV1_Format,Zo as RGBA_PVRTC_4BPPV1_Format,va as RGBA_S3TC_DXT1_Format,_a as RGBA_S3TC_DXT5_Format,Zh as RGBFormat,ol as RGB_BPTC_UNSIGNED_Format,Ko as RGB_ETC1_Format,$o as RGB_ETC2_Format,Yo as RGB_PVRTC_4BPPV1_Format,xa as RGB_S3TC_DXT1_Format,Br as RGFormat,jo as RGIntegerFormat,lu as RawShaderMaterial,Nn as Ray,Ax as Raycaster,Wo as RedFormat,ya as RedIntegerFormat,zh as ReinhardToneMapping,pa as RepeatWrapping,b0 as ReplaceStencilOp,Rh as RingGeometry,tl as SIGNED_R11_EAC_Format,ul as SIGNED_RED_GREEN_RGTC2_Format,hl as SIGNED_RED_RGTC1_Format,sl as SIGNED_RG11_EAC_Format,Ii as SRGBColorSpace,_p as Scene,ot as ShaderChunk,hs as ShaderLib,$i as ShaderMaterial,mm as ShadowMaterial,Zr as Shape,Xx as ShapePath,ys as ShapeUtils,Ah as Skeleton,kp as SkinnedMesh,pr as Source,ai as Sphere,Lo as SphereGeometry,Cx as Spherical,Nm as SpotLight,Lp as Sprite,Ec as SpriteMaterial,hC as THREE,Wg as TOUCH,ei as Texture,nx as TextureLoader,Fm as Timer,Ih as TorusGeometry,yr as Triangle,x0 as TriangleFanDrawMode,y0 as TriangleStripDrawMode,g0 as TrianglesDrawMode,wc as Uint16BufferAttribute,Hd as Uniform,ye as UniformsLib,fm as UniformsUtils,Ri as UnsignedByteType,Yh as UnsignedInt101111Type,_n as UnsignedInt248Type,qh as UnsignedInt5999Type,qi as UnsignedIntType,te as Vector2,R as Vector3,It as Vector4,Xa as VectorKeyframeTrack,Kp as VideoTexture,Au as WebGLCubeRenderTarget,Bi as WebGLRenderTarget,Sv as WebGLRenderer,pm as WireframeGeometry,M0 as ZeroStencilOp,nD as cloneUniforms,aD as cloneUniformsGroups};
|