@needle-tools/engine 4.13.1 → 4.14.0-beta
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/CHANGELOG.md +9 -0
- package/components.needle.json +1 -1
- package/dist/generateMeshBVH.worker-DiCnZlf3.js +21 -0
- package/dist/gltf-progressive-Bm_6aEi4.js +1528 -0
- package/dist/gltf-progressive-BttGBXw6.umd.cjs +10 -0
- package/dist/gltf-progressive-T5WKTux5.min.js +10 -0
- package/dist/loader.worker-BqODMeeW.js +23 -0
- package/dist/{materialx-B9ddsHcF.min.js → materialx-CJyQZtjt.min.js} +1 -1
- package/dist/{materialx-fkoFuRh3.js → materialx-DMs1E08Z.js} +2 -2
- package/dist/{materialx-BF23AVE8.umd.cjs → materialx-DaKKOoVk.umd.cjs} +1 -1
- package/dist/needle-engine.bundle-BW2VusZV.min.js +1646 -0
- package/dist/{needle-engine.bundle-tjI5Fq2c.umd.cjs → needle-engine.bundle-Cb5bKEqa.umd.cjs} +152 -159
- package/dist/{needle-engine.bundle-DauZUYl7.js → needle-engine.bundle-D9VPvp5o.js} +7798 -7497
- package/dist/needle-engine.d.ts +779 -42
- package/dist/needle-engine.js +416 -415
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-BVNrgYZK.min.js → postprocessing-CctM1XIO.min.js} +1 -1
- package/dist/{postprocessing-DdM-tz1j.js → postprocessing-DGm6qJ-I.js} +2 -2
- package/dist/{postprocessing-CI2TjWpu.umd.cjs → postprocessing-Dbl2PJpd.umd.cjs} +1 -1
- package/dist/{three-BW2s1Yl-.umd.cjs → three-BjYim-vL.umd.cjs} +4 -4
- package/dist/{three-VvRoMeIN.js → three-Bvk2VKbF.js} +4210 -4210
- package/dist/{three-I__hSXzr.min.js → three-IG2qPafA.min.js} +33 -33
- package/dist/{three-examples-Bpfu6ke_.umd.cjs → three-examples-BMmNgNCN.umd.cjs} +1 -1
- package/dist/{three-examples-BhfOE7NG.js → three-examples-CMYCd5nH.js} +1 -1
- package/dist/{three-examples-D8zAE_7t.min.js → three-examples-CQl1fFZp.min.js} +1 -1
- package/dist/{three-mesh-ui-C3QbemOV.min.js → three-mesh-ui-5HVE2RV-.min.js} +1 -1
- package/dist/{three-mesh-ui-CcMp-FQm.js → three-mesh-ui-BlakAItG.js} +1 -1
- package/dist/{three-mesh-ui-BU55xDxJ.umd.cjs → three-mesh-ui-D828VbQp.umd.cjs} +1 -1
- package/dist/{vendor-DW7zqjuT.min.js → vendor-BxK0WKmT.min.js} +1 -1
- package/dist/{vendor-COVQl0b8.umd.cjs → vendor-CIDkyBaO.umd.cjs} +1 -1
- package/dist/{vendor-BiyIZ61v.js → vendor-ixwD-vv2.js} +1 -1
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_context.js +12 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_lightdata.js +8 -6
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_materialpropertyblock.d.ts +259 -0
- package/lib/engine/engine_materialpropertyblock.js +682 -0
- package/lib/engine/engine_materialpropertyblock.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +1 -0
- package/lib/engine/engine_utils.js +1 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.d.ts +171 -14
- package/lib/engine/engine_utils_screenshot.js +65 -0
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.xr.d.ts +1 -1
- package/lib/engine/engine_utils_screenshot.xr.js +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +5 -0
- package/lib/engine/xr/NeedleXRSession.js +5 -0
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +32 -4
- package/lib/engine-components/ReflectionProbe.js +58 -88
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +2 -0
- package/lib/engine-components/Renderer.js +30 -6
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RendererLightmap.d.ts +13 -9
- package/lib/engine-components/RendererLightmap.js +67 -81
- package/lib/engine-components/RendererLightmap.js.map +1 -1
- package/lib/engine-components/SeeThrough.d.ts +0 -2
- package/lib/engine-components/SeeThrough.js +114 -88
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/VideoPlayer.js +6 -0
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/utils/OpenURL.d.ts +1 -0
- package/lib/engine-components/utils/OpenURL.js +1 -0
- package/lib/engine-components/utils/OpenURL.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +1 -0
- package/lib/engine-components/web/CursorFollow.js +1 -0
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +1 -0
- package/lib/engine-components/web/ScrollFollow.js +1 -0
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +2 -2
- package/lib/engine-components/web/ViewBox.js +2 -2
- package/lib/engine-components/web/ViewBox.js.map +1 -1
- package/lib/engine-components/webxr/WebARCameraBackground.d.ts +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +1 -0
- package/lib/engine-components/webxr/WebXR.js +1 -0
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/engine-components/webxr/WebXRPlaneTracking.js.map +1 -1
- package/lib/engine-components/webxr/controllers/XRControllerFollow.js.map +1 -1
- package/lib/engine-components/webxr/controllers/XRControllerMovement.js.map +1 -1
- package/package.json +5 -5
- package/plugins/vite/build-pipeline.js +16 -2
- package/src/engine/api.ts +1 -0
- package/src/engine/engine_context.ts +17 -3
- package/src/engine/engine_lightdata.ts +8 -6
- package/src/engine/engine_materialpropertyblock.ts +866 -0
- package/src/engine/engine_utils.ts +1 -0
- package/src/engine/engine_utils_screenshot.ts +241 -17
- package/src/engine/engine_utils_screenshot.xr.ts +1 -1
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +3 -0
- package/src/engine/xr/NeedleXRSession.ts +5 -0
- package/src/engine-components/Camera.ts +2 -2
- package/src/engine-components/ContactShadows.ts +1 -1
- package/src/engine-components/DropListener.ts +1 -1
- package/src/engine-components/Duplicatable.ts +1 -1
- package/src/engine-components/GroundProjection.ts +3 -0
- package/src/engine-components/NeedleMenu.ts +3 -0
- package/src/engine-components/NestedGltf.ts +1 -1
- package/src/engine-components/ReflectionProbe.ts +64 -105
- package/src/engine-components/Renderer.ts +34 -6
- package/src/engine-components/RendererLightmap.ts +75 -87
- package/src/engine-components/SeeThrough.ts +124 -109
- package/src/engine-components/SmoothFollow.ts +2 -2
- package/src/engine-components/VideoPlayer.ts +6 -0
- package/src/engine-components/ui/Button.ts +1 -1
- package/src/engine-components/ui/Raycaster.ts +1 -1
- package/src/engine-components/utils/OpenURL.ts +1 -0
- package/src/engine-components/web/CursorFollow.ts +1 -0
- package/src/engine-components/web/ScrollFollow.ts +1 -0
- package/src/engine-components/web/ViewBox.ts +9 -2
- package/src/engine-components/webxr/WebARCameraBackground.ts +12 -3
- package/src/engine-components/webxr/WebXR.ts +1 -0
- package/src/engine-components/webxr/WebXRPlaneTracking.ts +3 -3
- package/src/engine-components/webxr/controllers/XRControllerFollow.ts +1 -1
- package/src/engine-components/webxr/controllers/XRControllerMovement.ts +4 -4
- package/dist/generateMeshBVH.worker-iyfPIK6R.js +0 -21
- package/dist/gltf-progressive-BURrJW0U.umd.cjs +0 -8
- package/dist/gltf-progressive-DHLDFNvQ.min.js +0 -8
- package/dist/gltf-progressive-eiJCrjLb.js +0 -1400
- package/dist/loader.worker-C1GG9A7C.js +0 -23
- package/dist/needle-engine.bundle-BNIUpreS.min.js +0 -1653
- package/src/include/three/DragControls.js +0 -232
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const rw="169",_0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},M0={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},T0=0,qd=1,b0=2,nw=3,sw=0,Yd=1,$d=2,rr=3,an=0,si=1,Wr=2,Er=0,Tn=1,No=2,Jd=3,Kd=4,Zd=5,Bn=100,S0=101,w0=102,E0=103,Qd=104,A0=200,N0=201,C0=202,R0=203,Sc=204,wc=205,I0=206,L0=207,P0=208,D0=209,U0=210,O0=211,F0=212,V0=213,B0=214,Co=0,Ro=1,Io=2,zn=3,Lo=4,Po=5,Do=6,Uo=7,ma=0,ep=1,tp=2,mr=0,Ec=1,Ac=2,ip=3,Nc=4,z0=5,Cc=6,Rc=7,rp="attached",k0="detached",Ic=300,fr=301,Ar=302,kn=303,Hn=304,Gn=306,Wn=1e3,gr=1001,fa=1002,$t=1003,Lc=1004,H0=1004,bn=1005,aw=1005,Lt=1006,jn=1007,ow=1007,Xi=1008,np=1008,jr=1009,sp=1010,ap=1011,ga=1012,va=1013,Nr=1014,Oi=1015,wi=1016,Pc=1017,Dc=1018,Xn=1020,Uc=35902,Oc=35899,op=1021,Fc=1022,Ei=1023,lp=1024,cp=1025,qn=1026,Yn=1027,Oo=1028,Fo=1029,ya=1030,Vc=1031,lw=1032,Bc=1033,xa=33776,_a=33777,Ma=33778,Ta=33779,Vo=35840,zc=35841,Bo=35842,kc=35843,zo=36196,ko=37492,Ho=37496,Go=37808,Hc=37809,Gc=37810,Wc=37811,Wo=37812,jc=37813,Xc=37814,qc=37815,Yc=37816,$c=37817,Jc=37818,Kc=37819,Zc=37820,Qc=37821,ba=36492,eu=36494,jo=36495,up=36283,tu=36284,iu=36285,ru=36286,hp=2200,dp=2201,G0=2202,Sa=2300,Xo=2301,nu=2302,Ms=2400,Ts=2401,qo=2402,su=2500,pp=2501,W0=0,j0=1,X0=2,mp=3200,fp=3201,cw=3202,uw=3203,on=0,gp=1,Cr="",Fi="srgb",nr="srgb-linear",au="display-p3",Yo="display-p3-linear",$o="linear",Ot="srgb",Jo="rec709",Ko="p3",q0=0,$n=7680,Y0=7681,$0=7682,J0=7683,K0=34055,Z0=34056,Q0=5386,ev=512,tv=513,iv=514,rv=515,nv=516,sv=517,av=518,ou=519,ov=512,vp=513,lv=514,yp=515,cv=516,uv=517,hv=518,dv=519,wa=35044,bs=35048,hw=35040,dw=35045,pw=35049,mw=35041,fw=35046,gw=35050,vw=35042,yw="100",lu="300 es",Rr=2e3,Ss=2001;class vr{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){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const i=t.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}const Vi=["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 pv=1234567;const ws=Math.PI/180,Ea=180/Math.PI;function yr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Vi[n&255]+Vi[n>>8&255]+Vi[n>>16&255]+Vi[n>>24&255]+"-"+Vi[e&255]+Vi[e>>8&255]+"-"+Vi[e>>16&15|64]+Vi[e>>24&255]+"-"+Vi[t&63|128]+Vi[t>>8&255]+"-"+Vi[t>>16&255]+Vi[t>>24&255]+Vi[i&255]+Vi[i>>8&255]+Vi[i>>16&255]+Vi[i>>24&255]).toLowerCase()}function Jt(n,e,t){return Math.max(e,Math.min(t,n))}function xp(n,e){return(n%e+e)%e}function xw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function _w(n,e,t){return n!==e?(t-n)/(e-n):0}function Zo(n,e,t){return(1-t)*n+t*e}function Mw(n,e,t,i){return Zo(n,e,1-Math.exp(-t*i))}function Tw(n,e=1){return e-Math.abs(xp(n,e*2)-e)}function bw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function Sw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function ww(n,e){return n+Math.floor(Math.random()*(e-n+1))}function Ew(n,e){return n+Math.random()*(e-n)}function Aw(n){return n*(.5-Math.random())}function Nw(n){n!==void 0&&(pv=n);let e=pv+=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 Cw(n){return n*ws}function Rw(n){return n*Ea}function Iw(n){return(n&n-1)===0&&n!==0}function Lw(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Pw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Dw(n,e,t,i,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),u=a((e+i)/2),h=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":n.set(o*u,l*h,l*d,o*c);break;case"YZY":n.set(l*d,o*u,l*h,o*c);break;case"ZXZ":n.set(l*h,l*d,o*u,o*c);break;case"XZX":n.set(o*u,l*m,l*p,o*c);break;case"YXY":n.set(l*p,o*u,l*m,o*c);break;case"ZYZ":n.set(l*m,l*p,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function qi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function ht(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const cu={DEG2RAD:ws,RAD2DEG:Ea,generateUUID:yr,clamp:Jt,euclideanModulo:xp,mapLinear:xw,inverseLerp:_w,lerp:Zo,damp:Mw,pingpong:Tw,smoothstep:bw,smootherstep:Sw,randInt:ww,randFloat:Ew,randFloatSpread:Aw,seededRandom:Nw,degToRad:Cw,radToDeg:Rw,isPowerOfTwo:Iw,ceilPowerOfTwo:Lw,floorPowerOfTwo:Pw,setQuaternionFromProperEuler:Dw,normalize:ht,denormalize:qi};class J{constructor(e=0,t=0){J.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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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(Jt(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),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*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 Ke{constructor(e,t,i,r,s,a,o,l,c){Ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,r,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=a,u[8]=c,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,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],p=i[5],m=i[8],v=r[0],f=r[3],g=r[6],x=r[1],y=r[4],_=r[7],I=r[2],T=r[5],w=r[8];return s[0]=a*v+o*x+l*I,s[3]=a*f+o*y+l*T,s[6]=a*g+o*_+l*w,s[1]=c*v+u*x+h*I,s[4]=c*f+u*y+h*T,s[7]=c*g+u*_+h*w,s[2]=d*v+p*x+m*I,s[5]=d*f+p*y+m*T,s[8]=d*g+p*_+m*w,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],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*s*u+i*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*s,p=c*s-a*l,m=t*h+i*d+r*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=h*v,e[1]=(r*c-u*i)*v,e[2]=(o*i-r*a)*v,e[3]=d*v,e[4]=(u*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=p*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*s)*v,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,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(_p.makeScale(e,t)),this}rotate(e){return this.premultiply(_p.makeRotation(-e)),this}translate(e,t){return this.premultiply(_p.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 _p=new Ke;function mv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const Uw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Aa(n,e){return new Uw[n](e)}function Qo(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function fv(){const n=Qo("canvas");return n.style.display="block",n}const gv={};function uu(n){n in gv||(gv[n]=!0,console.warn(n))}function Ow(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}function Fw(n){const e=n.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Vw(n){const e=n.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const vv=new Ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),yv=new Ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),el={[nr]:{transfer:$o,primaries:Jo,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n,fromReference:n=>n},[Fi]:{transfer:Ot,primaries:Jo,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Yo]:{transfer:$o,primaries:Ko,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.applyMatrix3(yv),fromReference:n=>n.applyMatrix3(vv)},[au]:{transfer:Ot,primaries:Ko,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.convertSRGBToLinear().applyMatrix3(yv),fromReference:n=>n.applyMatrix3(vv).convertLinearToSRGB()}},Bw=new Set([nr,Yo]),vt={enabled:!0,_workingColorSpace:nr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Bw.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=el[e].toReference,r=el[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return el[n].primaries},getTransfer:function(n){return n===Cr?$o:el[n].transfer},getLuminanceCoefficients:function(n,e=this._workingColorSpace){return n.fromArray(el[e].luminanceCoefficients)}};function Na(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Mp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Ca;class xv{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ca===void 0&&(Ca=Qo("canvas")),Ca.width=e.width,Ca.height=e.height;const i=Ca.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Ca}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Qo("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),s=r.data;for(let a=0;a<s.length;a++)s[a]=Na(s[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(Na(t[i]/255)*255):t[i]=Na(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let zw=0;class Jn{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zw++}),this.uuid=yr(),this.data=e,this.dataReady=!0,this.version=0}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 s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Tp(r[a].image)):s.push(Tp(r[a]))}else s=Tp(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function Tp(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?xv.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let kw=0;class Wt extends vr{constructor(e=Wt.DEFAULT_IMAGE,t=Wt.DEFAULT_MAPPING,i=gr,r=gr,s=Lt,a=Xi,o=Ei,l=jr,c=Wt.DEFAULT_ANISOTROPY,u=Cr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kw++}),this.uuid=yr(),this.name="",this.source=new Jn(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new J(0,0),this.repeat=new J(1,1),this.center=new J(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}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.6,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!==Ic)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Wn:e.x=e.x-Math.floor(e.x);break;case gr:e.x=e.x<0?0:1;break;case fa: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 Wn:e.y=e.y-Math.floor(e.y);break;case gr:e.y=e.y<0?0:1;break;case fa: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++}}Wt.DEFAULT_IMAGE=null,Wt.DEFAULT_MAPPING=Ic,Wt.DEFAULT_ANISOTROPY=4;class st{constructor(e=0,t=0,i=0,r=1){st.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,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,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,s;const a=e.elements,o=a[0],l=a[4],c=a[8],u=a[1],h=a[5],d=a[9],p=a[2],m=a[6],v=a[10];if(Math.abs(l-u)<.01&&Math.abs(c-p)<.01&&Math.abs(d-m)<.01){if(Math.abs(l+u)<.1&&Math.abs(c+p)<.1&&Math.abs(d+m)<.1&&Math.abs(o+h+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const g=(o+1)/2,x=(h+1)/2,y=(v+1)/2,_=(l+u)/4,I=(c+p)/4,T=(d+m)/4;return g>x&&g>y?g<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(g),r=_/i,s=I/i):x>y?x<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(x),i=_/r,s=T/r):y<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(y),i=I/s,r=T/s),this.set(i,r,s,t),this}let f=Math.sqrt((m-d)*(m-d)+(c-p)*(c-p)+(u-l)*(u-l));return Math.abs(f)<.001&&(f=1),this.x=(m-d)/f,this.y=(c-p)/f,this.z=(u-l)/f,this.w=Math.acos((o+h+v-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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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}}class ui extends vr{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new st(0,0,e,t),this.scissorTest=!1,this.viewport=new st(0,0,e,t);const r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Lt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const s=new Wt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}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,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;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 i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Jn(t),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 Ir extends ui{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class tl extends Wt{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=$t,this.minFilter=$t,this.wrapR=gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Hw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new tl(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class hu extends Wt{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=$t,this.minFilter=$t,this.wrapR=gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Gw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new hu(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class Bi{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,s,a,o){let l=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3];const d=s[a+0],p=s[a+1],m=s[a+2],v=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(o===1){e[t+0]=d,e[t+1]=p,e[t+2]=m,e[t+3]=v;return}if(h!==v||l!==d||c!==p||u!==m){let f=1-o;const g=l*d+c*p+u*m+h*v,x=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){const I=Math.sqrt(y),T=Math.atan2(I,g*x);f=Math.sin(f*T)/I,o=Math.sin(o*T)/I}const _=o*x;if(l=l*f+d*_,c=c*f+p*_,u=u*f+m*_,h=h*f+v*_,f===1-o){const I=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=I,c*=I,u*=I,h*=I}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,r,s,a){const o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],h=s[a],d=s[a+1],p=s[a+2],m=s[a+3];return e[t]=o*m+u*h+l*p-c*d,e[t+1]=l*m+u*d+c*h-o*p,e[t+2]=c*m+u*p+o*d-l*h,e[t+3]=u*m-o*h-l*d-c*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,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(r/2),h=o(s/2),d=l(i/2),p=l(r/2),m=l(s/2);switch(a){case"XYZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"YXZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"ZXY":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"ZYX":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"YZX":this._x=d*u*h+c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h-d*p*m;break;case"XZY":this._x=d*u*h-c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h+d*p*m;break;default:console.warn("THREE.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],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+o+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(i>o&&i>h){const p=2*Math.sqrt(1+i-o-h);this._w=(u-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>h){const p=2*Math.sqrt(1+o-i-h);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+h-i-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(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(Jt(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,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+r*c-s*l,this._y=r*u+a*l+s*o-i*c,this._z=s*u+a*c+i*l-r*o,this._w=a*u-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+i*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-t;return this._w=p*a+t*this._w,this._x=p*i+t*this._x,this._y=p*r+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),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),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*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 N{constructor(e=0,t=0,i=0){N.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(_v.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_v.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),u=2*(o*t-s*r),h=2*(s*i-a*t);return this.x=t+l*c+a*h-o*u,this.y=i+l*u+o*c-s*h,this.z=r+l*h+s*u-a*c,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,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*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 bp.copy(this).projectOnVector(e),this.sub(bp)}reflect(e){return this.sub(bp.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(Jt(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 bp=new N,_v=new Bi;class zi{constructor(e=new N(1/0,1/0,1/0),t=new N(-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(Xr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Xr.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=Xr.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 s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Xr):Xr.fromBufferAttribute(s,a),Xr.applyMatrix4(e.matrixWorld),this.expandByPoint(Xr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),du.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),du.copy(i.boundingBox)),du.applyMatrix4(e.matrixWorld),this.union(du)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],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,Xr),Xr.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(il),pu.subVectors(this.max,il),Ra.subVectors(e.a,il),Ia.subVectors(e.b,il),La.subVectors(e.c,il),Kn.subVectors(Ia,Ra),Zn.subVectors(La,Ia),Es.subVectors(Ra,La);let t=[0,-Kn.z,Kn.y,0,-Zn.z,Zn.y,0,-Es.z,Es.y,Kn.z,0,-Kn.x,Zn.z,0,-Zn.x,Es.z,0,-Es.x,-Kn.y,Kn.x,0,-Zn.y,Zn.x,0,-Es.y,Es.x,0];return!Sp(t,Ra,Ia,La,pu)||(t=[1,0,0,0,1,0,0,0,1],!Sp(t,Ra,Ia,La,pu))?!1:(mu.crossVectors(Kn,Zn),t=[mu.x,mu.y,mu.z],Sp(t,Ra,Ia,La,pu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xr).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:(Sn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Sn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Sn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Sn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Sn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Sn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Sn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Sn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Sn),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 Sn=[new N,new N,new N,new N,new N,new N,new N,new N],Xr=new N,du=new zi,Ra=new N,Ia=new N,La=new N,Kn=new N,Zn=new N,Es=new N,il=new N,pu=new N,mu=new N,As=new N;function Sp(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){As.fromArray(n,s);const o=r.x*Math.abs(As.x)+r.y*Math.abs(As.y)+r.z*Math.abs(As.z),l=e.dot(As),c=t.dot(As),u=i.dot(As);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ww=new zi,rl=new N,wp=new N;class Ai{constructor(e=new N,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):Ww.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));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;rl.subVectors(e,this.center);const t=rl.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(rl,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):(wp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(rl.copy(e.center).add(wp)),this.expandByPoint(rl.copy(e.center).sub(wp))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const wn=new N,Ep=new N,fu=new N,Qn=new N,Ap=new N,gu=new N,Np=new N;class Ns{constructor(e=new N,t=new N(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,wn)),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=wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(wn.copy(this.origin).addScaledVector(this.direction,t),wn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Ep.copy(e).add(t).multiplyScalar(.5),fu.copy(t).sub(e).normalize(),Qn.copy(this.origin).sub(Ep);const s=e.distanceTo(t)*.5,a=-this.direction.dot(fu),o=Qn.dot(this.direction),l=-Qn.dot(fu),c=Qn.lengthSq(),u=Math.abs(1-a*a);let h,d,p,m;if(u>0)if(h=a*l-o,d=a*o-l,m=s*u,h>=0)if(d>=-m)if(d<=m){const v=1/u;h*=v,d*=v,p=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d<=-m?(h=Math.max(0,-(-a*s+o)),d=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c):d<=m?(h=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(h=Math.max(0,-(a*s+o)),d=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c);else d=a>0?-s:s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(Ep).addScaledVector(fu,d),p}intersectSphere(e,t){wn.subVectors(e.center,this.origin);const i=wn.dot(this.direction),r=wn.dot(wn)-i*i,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return 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,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),u>=0?(s=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),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,wn)!==null}intersectTriangle(e,t,i,r,s){Ap.subVectors(t,e),gu.subVectors(i,e),Np.crossVectors(Ap,gu);let a=this.direction.dot(Np),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Qn.subVectors(this.origin,e);const l=o*this.direction.dot(gu.crossVectors(Qn,gu));if(l<0)return null;const c=o*this.direction.dot(Ap.cross(Qn));if(c<0||l+c>a)return null;const u=-o*Qn.dot(Np);return u<0?null:this.at(u/a,s)}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)}}class Re{constructor(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f){Re.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,s,a,o,l,c,u,h,d,p,m,v,f)}set(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=d,g[3]=p,g[7]=m,g[11]=v,g[15]=f,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 Re().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 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){const t=this.elements,i=e.elements,r=1/Pa.setFromMatrixColumn(e,0).length(),s=1/Pa.setFromMatrixColumn(e,1).length(),a=1/Pa.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]*s,t[5]=i[5]*s,t[6]=i[6]*s,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,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const d=a*u,p=a*h,m=o*u,v=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+m*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=m+p*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,p=l*h,m=c*u,v=c*h;t[0]=d+v*o,t[4]=m*o-p,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=p*o-m,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,p=l*h,m=c*u,v=c*h;t[0]=d-v*o,t[4]=-a*h,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*u,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,p=a*h,m=o*u,v=o*h;t[0]=l*u,t[4]=m*c-p,t[8]=d*c+v,t[1]=l*h,t[5]=v*c+d,t[9]=p*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*u,t[4]=v-d*h,t[8]=m*h+p,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=p*h+m,t[10]=d-v*h}else if(e.order==="XZY"){const d=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+v,t[5]=a*u,t[9]=p*h-m,t[2]=m*h-p,t[6]=o*u,t[10]=v*h+d}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(jw,e,Xw)}lookAt(e,t,i){const r=this.elements;return xr.subVectors(e,t),xr.lengthSq()===0&&(xr.z=1),xr.normalize(),es.crossVectors(i,xr),es.lengthSq()===0&&(Math.abs(i.z)===1?xr.x+=1e-4:xr.z+=1e-4,xr.normalize(),es.crossVectors(i,xr)),es.normalize(),vu.crossVectors(xr,es),r[0]=es.x,r[4]=vu.x,r[8]=xr.x,r[1]=es.y,r[5]=vu.y,r[9]=xr.y,r[2]=es.z,r[6]=vu.z,r[10]=xr.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,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],p=i[13],m=i[2],v=i[6],f=i[10],g=i[14],x=i[3],y=i[7],_=i[11],I=i[15],T=r[0],w=r[4],C=r[8],H=r[12],M=r[1],b=r[5],k=r[9],j=r[13],Y=r[2],re=r[6],$=r[10],he=r[14],Q=r[3],ye=r[7],Te=r[11],Ve=r[15];return s[0]=a*T+o*M+l*Y+c*Q,s[4]=a*w+o*b+l*re+c*ye,s[8]=a*C+o*k+l*$+c*Te,s[12]=a*H+o*j+l*he+c*Ve,s[1]=u*T+h*M+d*Y+p*Q,s[5]=u*w+h*b+d*re+p*ye,s[9]=u*C+h*k+d*$+p*Te,s[13]=u*H+h*j+d*he+p*Ve,s[2]=m*T+v*M+f*Y+g*Q,s[6]=m*w+v*b+f*re+g*ye,s[10]=m*C+v*k+f*$+g*Te,s[14]=m*H+v*j+f*he+g*Ve,s[3]=x*T+y*M+_*Y+I*Q,s[7]=x*w+y*b+_*re+I*ye,s[11]=x*C+y*k+_*$+I*Te,s[15]=x*H+y*j+_*he+I*Ve,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],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],p=e[14],m=e[3],v=e[7],f=e[11],g=e[15];return m*(+s*l*h-r*c*h-s*o*d+i*c*d+r*o*p-i*l*p)+v*(+t*l*p-t*c*d+s*a*d-r*a*p+r*c*u-s*l*u)+f*(+t*c*h-t*o*p-s*a*h+i*a*p+s*o*u-i*c*u)+g*(-r*o*u-t*l*h+t*o*d+r*a*h-i*a*d+i*l*u)}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],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],m=e[12],v=e[13],f=e[14],g=e[15],x=h*f*c-v*d*c+v*l*p-o*f*p-h*l*g+o*d*g,y=m*d*c-u*f*c-m*l*p+a*f*p+u*l*g-a*d*g,_=u*v*c-m*h*c+m*o*p-a*v*p-u*o*g+a*h*g,I=m*h*l-u*v*l-m*o*d+a*v*d+u*o*f-a*h*f,T=t*x+i*y+r*_+s*I;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/T;return e[0]=x*w,e[1]=(v*d*s-h*f*s-v*r*p+i*f*p+h*r*g-i*d*g)*w,e[2]=(o*f*s-v*l*s+v*r*c-i*f*c-o*r*g+i*l*g)*w,e[3]=(h*l*s-o*d*s-h*r*c+i*d*c+o*r*p-i*l*p)*w,e[4]=y*w,e[5]=(u*f*s-m*d*s+m*r*p-t*f*p-u*r*g+t*d*g)*w,e[6]=(m*l*s-a*f*s-m*r*c+t*f*c+a*r*g-t*l*g)*w,e[7]=(a*d*s-u*l*s+u*r*c-t*d*c-a*r*p+t*l*p)*w,e[8]=_*w,e[9]=(m*h*s-u*v*s-m*i*p+t*v*p+u*i*g-t*h*g)*w,e[10]=(a*v*s-m*o*s+m*i*c-t*v*c-a*i*g+t*o*g)*w,e[11]=(u*o*s-a*h*s-u*i*c+t*h*c+a*i*p-t*o*p)*w,e[12]=I*w,e[13]=(u*v*r-m*h*r+m*i*d-t*v*d-u*i*f+t*h*f)*w,e[14]=(m*o*r-a*v*r-m*i*l+t*v*l+a*i*f-t*o*f)*w,e[15]=(a*h*r-u*o*r+u*i*l-t*h*l-a*i*d+t*o*d)*w,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,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),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*a,0,c*l-r*o,u*l+r*a,s*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,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,u=a+a,h=o+o,d=s*c,p=s*u,m=s*h,v=a*u,f=a*h,g=o*h,x=l*c,y=l*u,_=l*h,I=i.x,T=i.y,w=i.z;return r[0]=(1-(v+g))*I,r[1]=(p+_)*I,r[2]=(m-y)*I,r[3]=0,r[4]=(p-_)*T,r[5]=(1-(d+g))*T,r[6]=(f+x)*T,r[7]=0,r[8]=(m+y)*w,r[9]=(f-x)*w,r[10]=(1-(d+v))*w,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;let s=Pa.set(r[0],r[1],r[2]).length();const a=Pa.set(r[4],r[5],r[6]).length(),o=Pa.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],qr.copy(this);const l=1/s,c=1/a,u=1/o;return qr.elements[0]*=l,qr.elements[1]*=l,qr.elements[2]*=l,qr.elements[4]*=c,qr.elements[5]*=c,qr.elements[6]*=c,qr.elements[8]*=u,qr.elements[9]*=u,qr.elements[10]*=u,t.setFromRotationMatrix(qr),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,r,s,a,o=Rr){const l=this.elements,c=2*s/(t-e),u=2*s/(i-r),h=(t+e)/(t-e),d=(i+r)/(i-r);let p,m;if(o===Rr)p=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Ss)p=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,a,o=Rr){const l=this.elements,c=1/(t-e),u=1/(i-r),h=1/(a-s),d=(t+e)*c,p=(i+r)*u;let m,v;if(o===Rr)m=(a+s)*h,v=-2*h;else if(o===Ss)m=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=v,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[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 Pa=new N,qr=new Re,jw=new N(0,0,0),Xw=new N(1,1,1),es=new N,vu=new N,xr=new N,Mv=new Re,Tv=new Bi;class dr{constructor(e=0,t=0,i=0,r=dr.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,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],u=r[9],h=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Jt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Jt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Jt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Mv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Mv,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Tv.setFromEuler(this),this.setFromQuaternion(Tv,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}}dr.DEFAULT_ORDER="XYZ";class nl{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 qw=0;const bv=new N,Da=new Bi,En=new Re,yu=new N,sl=new N,Yw=new N,$w=new Bi,Sv=new N(1,0,0),wv=new N(0,1,0),Ev=new N(0,0,1),Av={type:"added"},Jw={type:"removed"},Ua={type:"childadded",child:null},Cp={type:"childremoved",child:null};class _t extends vr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qw++}),this.uuid=yr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new N,t=new dr,i=new Bi,r=new N(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),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 Re},normalMatrix:{value:new Ke}}),this.matrix=new Re,this.matrixWorld=new Re,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 Da.setFromAxisAngle(e,t),this.quaternion.multiply(Da),this}rotateOnWorldAxis(e,t){return Da.setFromAxisAngle(e,t),this.quaternion.premultiply(Da),this}rotateX(e){return this.rotateOnAxis(Sv,e)}rotateY(e){return this.rotateOnAxis(wv,e)}rotateZ(e){return this.rotateOnAxis(Ev,e)}translateOnAxis(e,t){return bv.copy(e).applyQuaternion(this.quaternion),this.position.add(bv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Sv,e)}translateY(e){return this.translateOnAxis(wv,e)}translateZ(e){return this.translateOnAxis(Ev,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(En.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?yu.copy(e):yu.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),sl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?En.lookAt(sl,yu,this.up):En.lookAt(yu,sl,this.up),this.quaternion.setFromRotationMatrix(En),r&&(En.extractRotation(r.matrixWorld),Da.setFromRotationMatrix(En),this.quaternion.premultiply(Da.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.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(Av),Ua.child=e,this.dispatchEvent(Ua),Ua.child=null):console.error("THREE.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(Jw),Cp.child=e,this.dispatchEvent(Cp),Cp.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),En.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),En.multiply(e.parent.matrixWorld)),e.applyMatrix4(En),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Av),Ua.child=e,this.dispatchEvent(Ua),Ua.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 s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].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(sl,e,Yw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(sl,$w,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),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 s=0,a=r.length;s<a;s++)r[s].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.6,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),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.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),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.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(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=s(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 c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(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(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),p=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}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),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.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 N(0,1,0),_t.DEFAULT_MATRIX_AUTO_UPDATE=!0,_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Yr=new N,An=new N,Rp=new N,Nn=new N,Oa=new N,Fa=new N,Nv=new N,Ip=new N,Lp=new N,Pp=new N,Dp=new st,Up=new st,Op=new st;class er{constructor(e=new N,t=new N,i=new N){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Yr.subVectors(e,t),r.cross(Yr);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Yr.subVectors(r,t),An.subVectors(i,t),Rp.subVectors(e,t);const a=Yr.dot(Yr),o=Yr.dot(An),l=Yr.dot(Rp),c=An.dot(An),u=An.dot(Rp),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const d=1/h,p=(c*l-o*u)*d,m=(a*u-o*l)*d;return s.set(1-p-m,m,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Nn)===null?!1:Nn.x>=0&&Nn.y>=0&&Nn.x+Nn.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,Nn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Nn.x),l.addScaledVector(a,Nn.y),l.addScaledVector(o,Nn.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return Dp.setScalar(0),Up.setScalar(0),Op.setScalar(0),Dp.fromBufferAttribute(e,t),Up.fromBufferAttribute(e,i),Op.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Dp,s.x),a.addScaledVector(Up,s.y),a.addScaledVector(Op,s.z),a}static isFrontFacing(e,t,i,r){return Yr.subVectors(i,t),An.subVectors(e,t),Yr.cross(An).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 Yr.subVectors(this.c,this.b),An.subVectors(this.a,this.b),Yr.cross(An).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return er.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return er.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return er.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return er.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return er.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let a,o;Oa.subVectors(r,i),Fa.subVectors(s,i),Ip.subVectors(e,i);const l=Oa.dot(Ip),c=Fa.dot(Ip);if(l<=0&&c<=0)return t.copy(i);Lp.subVectors(e,r);const u=Oa.dot(Lp),h=Fa.dot(Lp);if(u>=0&&h<=u)return t.copy(r);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(Oa,a);Pp.subVectors(e,s);const p=Oa.dot(Pp),m=Fa.dot(Pp);if(m>=0&&p<=m)return t.copy(s);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(Fa,o);const f=u*m-p*h;if(f<=0&&h-u>=0&&p-m>=0)return Nv.subVectors(s,r),o=(h-u)/(h-u+(p-m)),t.copy(r).addScaledVector(Nv,o);const g=1/(f+v+d);return a=v*g,o=d*g,t.copy(i).addScaledVector(Oa,a).addScaledVector(Fa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Cv={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},ts={h:0,s:0,l:0},xu={h:0,s:0,l:0};function Fp(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class xe{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=Fi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,vt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=vt.workingColorSpace){return this.r=e,this.g=t,this.b=i,vt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=vt.workingColorSpace){if(e=xp(e,1),t=Jt(t,0,1),i=Jt(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Fp(a,s,e+1/3),this.g=Fp(a,s,e),this.b=Fp(a,s,e-1/3)}return vt.toWorkingColorSpace(this,r),this}setStyle(e,t=Fi){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fi){const i=Cv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.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=Na(e.r),this.g=Na(e.g),this.b=Na(e.b),this}copyLinearToSRGB(e){return this.r=Mp(e.r),this.g=Mp(e.g),this.b=Mp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fi){return vt.fromWorkingColorSpace(ki.copy(this),e),Math.round(Jt(ki.r*255,0,255))*65536+Math.round(Jt(ki.g*255,0,255))*256+Math.round(Jt(ki.b*255,0,255))}getHexString(e=Fi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vt.workingColorSpace){vt.fromWorkingColorSpace(ki.copy(this),t);const i=ki.r,r=ki.g,s=ki.b,a=Math.max(i,r,s),o=Math.min(i,r,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case i:l=(r-s)/h+(r<s?6:0);break;case r:l=(s-i)/h+2;break;case s:l=(i-r)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=vt.workingColorSpace){return vt.fromWorkingColorSpace(ki.copy(this),t),e.r=ki.r,e.g=ki.g,e.b=ki.b,e}getStyle(e=Fi){vt.fromWorkingColorSpace(ki.copy(this),e);const t=ki.r,i=ki.g,r=ki.b;return e!==Fi?`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(ts),this.setHSL(ts.h+e,ts.s+t,ts.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(ts),e.getHSL(xu);const i=Zo(ts.h,xu.h,t),r=Zo(ts.s,xu.s,t),s=Zo(ts.l,xu.l,t);return this.setHSL(i,r,s),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,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[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 ki=new xe;xe.NAMES=Cv;let Kw=0;class hi extends vr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Kw++}),this.uuid=yr(),this.name="",this.type="Material",this.blending=Tn,this.side=an,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Sc,this.blendDst=wc,this.blendEquation=Bn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xe(0,0,0),this.blendAlpha=0,this.depthFunc=zn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ou,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$n,this.stencilZFail=$n,this.stencilZPass=$n,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.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){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.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.6,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.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!==Tn&&(i.blending=this.blending),this.side!==an&&(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!==Sc&&(i.blendSrc=this.blendSrc),this.blendDst!==wc&&(i.blendDst=this.blendDst),this.blendEquation!==Bn&&(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!==zn&&(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!==ou&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$n&&(i.stencilFail=this.stencilFail),this.stencilZFail!==$n&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==$n&&(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.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(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),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 s=0;s!==r;++s)i[s]=t[s].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.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++}}class $r extends hi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xe(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 dr,this.combine=ma,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 Cn=Zw();function Zw(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<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 s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[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:s,exponentTable:a,offsetTable:o}}function sr(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Jt(n,-65504,65504),Cn.floatView[0]=n;const e=Cn.uint32View[0],t=e>>23&511;return Cn.baseTable[t]+((e&8388607)>>Cn.shiftTable[t])}function al(n){const e=n>>10;return Cn.uint32View[0]=Cn.mantissaTable[Cn.offsetTable[e]+(n&1023)]+Cn.exponentTable[e],Cn.floatView[0]}const Rv={toHalfFloat:sr,fromHalfFloat:al},ai=new N,_u=new J;class wt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=wa,this.updateRanges=[],this.gpuType=Oi,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,s=this.itemSize;r<s;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++)_u.fromBufferAttribute(this,t),_u.applyMatrix3(e),this.setXY(t,_u.x,_u.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyMatrix3(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyMatrix4(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyNormalMatrix(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.transformDirection(e),this.setXYZ(t,ai.x,ai.y,ai.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=qi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=qi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=qi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(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=qi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(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=qi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(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=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,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!==wa&&(e.usage=this.usage),e}}class Qw extends wt{constructor(e,t,i){super(new Int8Array(e),t,i)}}class eE extends wt{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class tE extends wt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class iE extends wt{constructor(e,t,i){super(new Int16Array(e),t,i)}}class Mu extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class rE extends wt{constructor(e,t,i){super(new Int32Array(e),t,i)}}class Vp extends wt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Iv extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=al(this.array[e*this.itemSize]);return this.normalized&&(t=qi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=sr(t),this}getY(e){let t=al(this.array[e*this.itemSize+1]);return this.normalized&&(t=qi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=sr(t),this}getZ(e){let t=al(this.array[e*this.itemSize+2]);return this.normalized&&(t=qi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=sr(t),this}getW(e){let t=al(this.array[e*this.itemSize+3]);return this.normalized&&(t=qi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=sr(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this.array[e+2]=sr(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this.array[e+2]=sr(r),this.array[e+3]=sr(s),this}}class De extends wt{constructor(e,t,i){super(new Float32Array(e),t,i)}}let nE=0;const Lr=new Re,Bp=new _t,Va=new N,_r=new zi,ol=new zi,vi=new N;class ct extends vr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:nE++}),this.uuid=yr(),this.name="",this.type="BufferGeometry",this.index=null,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(mv(e)?Vp:Mu)(e,1):this.index=e,this}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 s=new Ke().getNormalMatrix(e);i.applyNormalMatrix(s),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 Lr.makeRotationFromQuaternion(e),this.applyMatrix4(Lr),this}rotateX(e){return Lr.makeRotationX(e),this.applyMatrix4(Lr),this}rotateY(e){return Lr.makeRotationY(e),this.applyMatrix4(Lr),this}rotateZ(e){return Lr.makeRotationZ(e),this.applyMatrix4(Lr),this}translate(e,t,i){return Lr.makeTranslation(e,t,i),this.applyMatrix4(Lr),this}scale(e,t,i){return Lr.makeScale(e,t,i),this.applyMatrix4(Lr),this}lookAt(e){return Bp.lookAt(e),Bp.updateMatrix(),this.applyMatrix4(Bp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Va).negate(),this.translate(Va.x,Va.y,Va.z),this}setFromPoints(e){const t=[];for(let i=0,r=e.length;i<r;i++){const s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new De(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(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 s=t[i];_r.setFromBufferAttribute(s),this.morphTargetsRelative?(vi.addVectors(this.boundingBox.min,_r.min),this.boundingBox.expandByPoint(vi),vi.addVectors(this.boundingBox.max,_r.max),this.boundingBox.expandByPoint(vi)):(this.boundingBox.expandByPoint(_r.min),this.boundingBox.expandByPoint(_r.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){const i=this.boundingSphere.center;if(_r.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];ol.setFromBufferAttribute(o),this.morphTargetsRelative?(vi.addVectors(_r.min,ol.min),_r.expandByPoint(vi),vi.addVectors(_r.max,ol.max),_r.expandByPoint(vi)):(_r.expandByPoint(ol.min),_r.expandByPoint(ol.max))}_r.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)vi.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(vi));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)vi.fromBufferAttribute(o,c),l&&(Va.fromBufferAttribute(e,c),vi.add(Va)),r=Math.max(r,i.distanceToSquared(vi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.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){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new wt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let C=0;C<i.count;C++)o[C]=new N,l[C]=new N;const c=new N,u=new N,h=new N,d=new J,p=new J,m=new J,v=new N,f=new N;function g(C,H,M){c.fromBufferAttribute(i,C),u.fromBufferAttribute(i,H),h.fromBufferAttribute(i,M),d.fromBufferAttribute(s,C),p.fromBufferAttribute(s,H),m.fromBufferAttribute(s,M),u.sub(c),h.sub(c),p.sub(d),m.sub(d);const b=1/(p.x*m.y-m.x*p.y);isFinite(b)&&(v.copy(u).multiplyScalar(m.y).addScaledVector(h,-p.y).multiplyScalar(b),f.copy(h).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(b),o[C].add(v),o[H].add(v),o[M].add(v),l[C].add(f),l[H].add(f),l[M].add(f))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let C=0,H=x.length;C<H;++C){const M=x[C],b=M.start,k=M.count;for(let j=b,Y=b+k;j<Y;j+=3)g(e.getX(j+0),e.getX(j+1),e.getX(j+2))}const y=new N,_=new N,I=new N,T=new N;function w(C){I.fromBufferAttribute(r,C),T.copy(I);const H=o[C];y.copy(H),y.sub(I.multiplyScalar(I.dot(H))).normalize(),_.crossVectors(T,H);const M=_.dot(l[C])<0?-1:1;a.setXYZW(C,y.x,y.y,y.z,M)}for(let C=0,H=x.length;C<H;++C){const M=x[C],b=M.start,k=M.count;for(let j=b,Y=b+k;j<Y;j+=3)w(e.getX(j+0)),w(e.getX(j+1)),w(e.getX(j+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 wt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const r=new N,s=new N,a=new N,o=new N,l=new N,c=new N,u=new N,h=new N;if(e)for(let d=0,p=e.count;d<p;d+=3){const m=e.getX(d+0),v=e.getX(d+1),f=e.getX(d+2);r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,f),u.subVectors(a,s),h.subVectors(r,s),u.cross(h),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,f),o.add(u),l.add(u),c.add(u),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(f,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,s),h.subVectors(r,s),u.cross(h),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)vi.fromBufferAttribute(e,t),vi.normalize(),e.setXYZ(t,vi.x,vi.y,vi.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let p=0,m=0;for(let v=0,f=l.length;v<f;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*u;for(let g=0;g<u;g++)d[m++]=c[p++]}return new wt(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ct,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],p=e(d,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 c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,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 c in l)l[c]!==void 0&&(e[c]=l[c]);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 c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(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={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.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 Lv=new Re,Cs=new Ns,Tu=new Ai,Pv=new N,bu=new N,Su=new N,wu=new N,zp=new N,Eu=new N,Dv=new N,Au=new N;class Ft extends _t{constructor(e=new ct,t=new $r){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,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,s=i.length;r<s;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,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Eu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],h=s[l];u!==0&&(zp.fromBufferAttribute(h,e),a?Eu.addScaledVector(zp,u):Eu.addScaledVector(zp.sub(t),u))}t.add(Eu)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Tu.copy(i.boundingSphere),Tu.applyMatrix4(s),Cs.copy(e.ray).recast(e.near),!(Tu.containsPoint(Cs.origin)===!1&&(Cs.intersectSphere(Tu,Pv)===null||Cs.origin.distanceToSquared(Pv)>(e.far-e.near)**2))&&(Lv.copy(s).invert(),Cs.copy(e.ray).applyMatrix4(Lv),!(i.boundingBox!==null&&Cs.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Cs)))}_computeIntersections(e,t,i){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,v=d.length;m<v;m++){const f=d[m],g=a[f.materialIndex],x=Math.max(f.start,p.start),y=Math.min(o.count,Math.min(f.start+f.count,p.start+p.count));for(let _=x,I=y;_<I;_+=3){const T=o.getX(_),w=o.getX(_+1),C=o.getX(_+2);r=Nu(this,g,e,i,c,u,h,T,w,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let f=m,g=v;f<g;f+=3){const x=o.getX(f),y=o.getX(f+1),_=o.getX(f+2);r=Nu(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,v=d.length;m<v;m++){const f=d[m],g=a[f.materialIndex],x=Math.max(f.start,p.start),y=Math.min(l.count,Math.min(f.start+f.count,p.start+p.count));for(let _=x,I=y;_<I;_+=3){const T=_,w=_+1,C=_+2;r=Nu(this,g,e,i,c,u,h,T,w,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let f=m,g=v;f<g;f+=3){const x=f,y=f+1,_=f+2;r=Nu(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}}function sE(n,e,t,i,r,s,a,o){let l;if(e.side===si?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===an,o),l===null)return null;Au.copy(o),Au.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Au);return c<t.near||c>t.far?null:{distance:c,point:Au.clone(),object:n}}function Nu(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,bu),n.getVertexPosition(l,Su),n.getVertexPosition(c,wu);const u=sE(n,e,t,i,bu,Su,wu,Dv);if(u){const h=new N;er.getBarycoord(Dv,bu,Su,wu,h),r&&(u.uv=er.getInterpolatedAttribute(r,o,l,c,h,new J)),s&&(u.uv1=er.getInterpolatedAttribute(s,o,l,c,h,new J)),a&&(u.normal=er.getInterpolatedAttribute(a,o,l,c,h,new N),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new N,materialIndex:0};er.getNormal(bu,Su,wu,d.normal),u.face=d,u.barycoord=h}return u}class _n extends ct{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,p=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,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,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(u,3)),this.setAttribute("uv",new De(h,2));function m(v,f,g,x,y,_,I,T,w,C,H){const M=_/w,b=I/C,k=_/2,j=I/2,Y=T/2,re=w+1,$=C+1;let he=0,Q=0;const ye=new N;for(let Te=0;Te<$;Te++){const Ve=Te*b-j;for(let at=0;at<re;at++){const et=at*M-k;ye[v]=et*x,ye[f]=Ve*y,ye[g]=Y,c.push(ye.x,ye.y,ye.z),ye[v]=0,ye[f]=0,ye[g]=T>0?1:-1,u.push(ye.x,ye.y,ye.z),h.push(at/w),h.push(1-Te/C),he+=1}}for(let Te=0;Te<C;Te++)for(let Ve=0;Ve<w;Ve++){const at=d+Ve+re*Te,et=d+Ve+re*(Te+1),ie=d+(Ve+1)+re*(Te+1),le=d+(Ve+1)+re*Te;l.push(at,et,le),l.push(et,ie,le),Q+=6}o.addGroup(p,Q,H),p+=Q,d+=he}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ba(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("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 Yi(n){const e={};for(let t=0;t<n.length;t++){const i=Ba(n[t]);for(const r in i)e[r]=i[r]}return e}function aE(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Uv(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:vt.workingColorSpace}const kp={clone:Ba,merge:Yi};var oE=`void main() {
|
|
1
|
+
const Bn="169.19",M0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},T0={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},b0=0,Yd=1,S0=2,nw=3,sw=0,$d=1,Jd=2,rr=3,an=0,si=1,Wr=2,Er=0,Tn=1,Co=2,Kd=3,Zd=4,Qd=5,zn=100,w0=101,E0=102,A0=103,ep=104,N0=200,C0=201,R0=202,I0=203,wc=204,Ec=205,L0=206,P0=207,D0=208,U0=209,O0=210,F0=211,V0=212,B0=213,z0=214,Ro=0,Io=1,Lo=2,kn=3,Po=4,Do=5,Uo=6,Oo=7,fa=0,tp=1,ip=2,mr=0,Ac=1,Nc=2,rp=3,Cc=4,k0=5,Rc=6,Ic=7,np="attached",H0="detached",Lc=300,fr=301,Ar=302,Hn=303,Gn=304,Wn=306,jn=1e3,gr=1001,ga=1002,$t=1003,Pc=1004,G0=1004,bn=1005,aw=1005,Lt=1006,Xn=1007,ow=1007,Xi=1008,sp=1008,jr=1009,ap=1010,op=1011,va=1012,ya=1013,Nr=1014,Oi=1015,wi=1016,Dc=1017,Uc=1018,qn=1020,Oc=35902,Fc=35899,lp=1021,Vc=1022,Ei=1023,cp=1024,up=1025,Yn=1026,$n=1027,Fo=1028,Vo=1029,xa=1030,Bc=1031,lw=1032,zc=1033,_a=33776,Ma=33777,Ta=33778,ba=33779,Bo=35840,kc=35841,zo=35842,Hc=35843,ko=36196,Ho=37492,Go=37496,Wo=37808,Gc=37809,Wc=37810,jc=37811,jo=37812,Xc=37813,qc=37814,Yc=37815,$c=37816,Jc=37817,Kc=37818,Zc=37819,Qc=37820,eu=37821,Sa=36492,tu=36494,Xo=36495,hp=36283,iu=36284,ru=36285,nu=36286,dp=2200,pp=2201,W0=2202,wa=2300,qo=2301,su=2302,Ts=2400,bs=2401,Yo=2402,au=2500,mp=2501,j0=0,X0=1,q0=2,fp=3200,gp=3201,cw=3202,uw=3203,on=0,vp=1,Cr="",Fi="srgb",nr="srgb-linear",ou="display-p3",$o="display-p3-linear",Jo="linear",Ot="srgb",Ko="rec709",Zo="p3",Y0=0,Jn=7680,$0=7681,J0=7682,K0=7683,Z0=34055,Q0=34056,ev=5386,tv=512,iv=513,rv=514,nv=515,sv=516,av=517,ov=518,lu=519,lv=512,yp=513,cv=514,xp=515,uv=516,hv=517,dv=518,pv=519,Ea=35044,Ss=35048,hw=35040,dw=35045,pw=35049,mw=35041,fw=35046,gw=35050,vw=35042,yw="100",cu="300 es",Rr=2e3,ws=2001;class vr{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){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const i=t.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}const Vi=["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 mv=1234567;const Es=Math.PI/180,Aa=180/Math.PI;function yr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Vi[n&255]+Vi[n>>8&255]+Vi[n>>16&255]+Vi[n>>24&255]+"-"+Vi[e&255]+Vi[e>>8&255]+"-"+Vi[e>>16&15|64]+Vi[e>>24&255]+"-"+Vi[t&63|128]+Vi[t>>8&255]+"-"+Vi[t>>16&255]+Vi[t>>24&255]+Vi[i&255]+Vi[i>>8&255]+Vi[i>>16&255]+Vi[i>>24&255]).toLowerCase()}function Jt(n,e,t){return Math.max(e,Math.min(t,n))}function _p(n,e){return(n%e+e)%e}function xw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function _w(n,e,t){return n!==e?(t-n)/(e-n):0}function Qo(n,e,t){return(1-t)*n+t*e}function Mw(n,e,t,i){return Qo(n,e,1-Math.exp(-t*i))}function Tw(n,e=1){return e-Math.abs(_p(n,e*2)-e)}function bw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function Sw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function ww(n,e){return n+Math.floor(Math.random()*(e-n+1))}function Ew(n,e){return n+Math.random()*(e-n)}function Aw(n){return n*(.5-Math.random())}function Nw(n){n!==void 0&&(mv=n);let e=mv+=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 Cw(n){return n*Es}function Rw(n){return n*Aa}function Iw(n){return(n&n-1)===0&&n!==0}function Lw(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Pw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Dw(n,e,t,i,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),u=a((e+i)/2),h=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":n.set(o*u,l*h,l*d,o*c);break;case"YZY":n.set(l*d,o*u,l*h,o*c);break;case"ZXZ":n.set(l*h,l*d,o*u,o*c);break;case"XZX":n.set(o*u,l*m,l*p,o*c);break;case"YXY":n.set(l*p,o*u,l*m,o*c);break;case"ZYZ":n.set(l*m,l*p,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function qi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function ht(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const uu={DEG2RAD:Es,RAD2DEG:Aa,generateUUID:yr,clamp:Jt,euclideanModulo:_p,mapLinear:xw,inverseLerp:_w,lerp:Qo,damp:Mw,pingpong:Tw,smoothstep:bw,smootherstep:Sw,randInt:ww,randFloat:Ew,randFloatSpread:Aw,seededRandom:Nw,degToRad:Cw,radToDeg:Rw,isPowerOfTwo:Iw,ceilPowerOfTwo:Lw,floorPowerOfTwo:Pw,setQuaternionFromProperEuler:Dw,normalize:ht,denormalize:qi};class J{constructor(e=0,t=0){J.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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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(Jt(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),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*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 Ke{constructor(e,t,i,r,s,a,o,l,c){Ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,r,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=a,u[8]=c,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,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],p=i[5],m=i[8],v=r[0],f=r[3],g=r[6],x=r[1],y=r[4],_=r[7],I=r[2],T=r[5],w=r[8];return s[0]=a*v+o*x+l*I,s[3]=a*f+o*y+l*T,s[6]=a*g+o*_+l*w,s[1]=c*v+u*x+h*I,s[4]=c*f+u*y+h*T,s[7]=c*g+u*_+h*w,s[2]=d*v+p*x+m*I,s[5]=d*f+p*y+m*T,s[8]=d*g+p*_+m*w,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],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*s*u+i*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*s,p=c*s-a*l,m=t*h+i*d+r*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=h*v,e[1]=(r*c-u*i)*v,e[2]=(o*i-r*a)*v,e[3]=d*v,e[4]=(u*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=p*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*s)*v,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,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Mp.makeScale(e,t)),this}rotate(e){return this.premultiply(Mp.makeRotation(-e)),this}translate(e,t){return this.premultiply(Mp.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 Mp=new Ke;function fv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const Uw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Na(n,e){return new Uw[n](e)}function el(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function gv(){const n=el("canvas");return n.style.display="block",n}const vv={};function hu(n){n in vv||(vv[n]=!0,console.warn(n))}function Ow(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}function Fw(n){const e=n.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Vw(n){const e=n.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const yv=new Ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),xv=new Ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),tl={[nr]:{transfer:Jo,primaries:Ko,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n,fromReference:n=>n},[Fi]:{transfer:Ot,primaries:Ko,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[$o]:{transfer:Jo,primaries:Zo,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.applyMatrix3(xv),fromReference:n=>n.applyMatrix3(yv)},[ou]:{transfer:Ot,primaries:Zo,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.convertSRGBToLinear().applyMatrix3(xv),fromReference:n=>n.applyMatrix3(yv).convertLinearToSRGB()}},Bw=new Set([nr,$o]),vt={enabled:!0,_workingColorSpace:nr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Bw.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=tl[e].toReference,r=tl[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return tl[n].primaries},getTransfer:function(n){return n===Cr?Jo:tl[n].transfer},getLuminanceCoefficients:function(n,e=this._workingColorSpace){return n.fromArray(tl[e].luminanceCoefficients)}};function Ca(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Tp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Ra;class _v{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ra===void 0&&(Ra=el("canvas")),Ra.width=e.width,Ra.height=e.height;const i=Ra.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Ra}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=el("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),s=r.data;for(let a=0;a<s.length;a++)s[a]=Ca(s[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(Ca(t[i]/255)*255):t[i]=Ca(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let zw=0;class Kn{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zw++}),this.uuid=yr(),this.data=e,this.dataReady=!0,this.version=0}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 s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(bp(r[a].image)):s.push(bp(r[a]))}else s=bp(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function bp(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?_v.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let kw=0;class Wt extends vr{constructor(e=Wt.DEFAULT_IMAGE,t=Wt.DEFAULT_MAPPING,i=gr,r=gr,s=Lt,a=Xi,o=Ei,l=jr,c=Wt.DEFAULT_ANISOTROPY,u=Cr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kw++}),this.uuid=yr(),this.name="",this.source=new Kn(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new J(0,0),this.repeat=new J(1,1),this.center=new J(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}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.6,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!==Lc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case jn:e.x=e.x-Math.floor(e.x);break;case gr:e.x=e.x<0?0:1;break;case ga: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 jn:e.y=e.y-Math.floor(e.y);break;case gr:e.y=e.y<0?0:1;break;case ga: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++}}Wt.DEFAULT_IMAGE=null,Wt.DEFAULT_MAPPING=Lc,Wt.DEFAULT_ANISOTROPY=4;class st{constructor(e=0,t=0,i=0,r=1){st.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,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,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,s;const a=e.elements,o=a[0],l=a[4],c=a[8],u=a[1],h=a[5],d=a[9],p=a[2],m=a[6],v=a[10];if(Math.abs(l-u)<.01&&Math.abs(c-p)<.01&&Math.abs(d-m)<.01){if(Math.abs(l+u)<.1&&Math.abs(c+p)<.1&&Math.abs(d+m)<.1&&Math.abs(o+h+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const g=(o+1)/2,x=(h+1)/2,y=(v+1)/2,_=(l+u)/4,I=(c+p)/4,T=(d+m)/4;return g>x&&g>y?g<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(g),r=_/i,s=I/i):x>y?x<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(x),i=_/r,s=T/r):y<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(y),i=I/s,r=T/s),this.set(i,r,s,t),this}let f=Math.sqrt((m-d)*(m-d)+(c-p)*(c-p)+(u-l)*(u-l));return Math.abs(f)<.001&&(f=1),this.x=(m-d)/f,this.y=(c-p)/f,this.z=(u-l)/f,this.w=Math.acos((o+h+v-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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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}}class ui extends vr{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new st(0,0,e,t),this.scissorTest=!1,this.viewport=new st(0,0,e,t);const r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Lt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const s=new Wt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}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,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;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 i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Kn(t),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 Ir extends ui{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class il extends Wt{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=$t,this.minFilter=$t,this.wrapR=gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Hw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new il(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class du extends Wt{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=$t,this.minFilter=$t,this.wrapR=gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Gw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new du(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class Bi{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,s,a,o){let l=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3];const d=s[a+0],p=s[a+1],m=s[a+2],v=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(o===1){e[t+0]=d,e[t+1]=p,e[t+2]=m,e[t+3]=v;return}if(h!==v||l!==d||c!==p||u!==m){let f=1-o;const g=l*d+c*p+u*m+h*v,x=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){const I=Math.sqrt(y),T=Math.atan2(I,g*x);f=Math.sin(f*T)/I,o=Math.sin(o*T)/I}const _=o*x;if(l=l*f+d*_,c=c*f+p*_,u=u*f+m*_,h=h*f+v*_,f===1-o){const I=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=I,c*=I,u*=I,h*=I}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,r,s,a){const o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],h=s[a],d=s[a+1],p=s[a+2],m=s[a+3];return e[t]=o*m+u*h+l*p-c*d,e[t+1]=l*m+u*d+c*h-o*p,e[t+2]=c*m+u*p+o*d-l*h,e[t+3]=u*m-o*h-l*d-c*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,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(r/2),h=o(s/2),d=l(i/2),p=l(r/2),m=l(s/2);switch(a){case"XYZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"YXZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"ZXY":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"ZYX":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"YZX":this._x=d*u*h+c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h-d*p*m;break;case"XZY":this._x=d*u*h-c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h+d*p*m;break;default:console.warn("THREE.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],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+o+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(i>o&&i>h){const p=2*Math.sqrt(1+i-o-h);this._w=(u-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>h){const p=2*Math.sqrt(1+o-i-h);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+h-i-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(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(Jt(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,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+r*c-s*l,this._y=r*u+a*l+s*o-i*c,this._z=s*u+a*c+i*l-r*o,this._w=a*u-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+i*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-t;return this._w=p*a+t*this._w,this._x=p*i+t*this._x,this._y=p*r+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),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),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*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 N{constructor(e=0,t=0,i=0){N.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(Mv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mv.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),u=2*(o*t-s*r),h=2*(s*i-a*t);return this.x=t+l*c+a*h-o*u,this.y=i+l*u+o*c-s*h,this.z=r+l*h+s*u-a*c,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,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*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 Sp.copy(this).projectOnVector(e),this.sub(Sp)}reflect(e){return this.sub(Sp.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(Jt(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 Sp=new N,Mv=new Bi;class zi{constructor(e=new N(1/0,1/0,1/0),t=new N(-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(Xr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Xr.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=Xr.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 s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Xr):Xr.fromBufferAttribute(s,a),Xr.applyMatrix4(e.matrixWorld),this.expandByPoint(Xr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),pu.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),pu.copy(i.boundingBox)),pu.applyMatrix4(e.matrixWorld),this.union(pu)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],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,Xr),Xr.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(rl),mu.subVectors(this.max,rl),Ia.subVectors(e.a,rl),La.subVectors(e.b,rl),Pa.subVectors(e.c,rl),Zn.subVectors(La,Ia),Qn.subVectors(Pa,La),As.subVectors(Ia,Pa);let t=[0,-Zn.z,Zn.y,0,-Qn.z,Qn.y,0,-As.z,As.y,Zn.z,0,-Zn.x,Qn.z,0,-Qn.x,As.z,0,-As.x,-Zn.y,Zn.x,0,-Qn.y,Qn.x,0,-As.y,As.x,0];return!wp(t,Ia,La,Pa,mu)||(t=[1,0,0,0,1,0,0,0,1],!wp(t,Ia,La,Pa,mu))?!1:(fu.crossVectors(Zn,Qn),t=[fu.x,fu.y,fu.z],wp(t,Ia,La,Pa,mu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xr).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:(Sn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Sn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Sn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Sn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Sn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Sn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Sn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Sn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Sn),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 Sn=[new N,new N,new N,new N,new N,new N,new N,new N],Xr=new N,pu=new zi,Ia=new N,La=new N,Pa=new N,Zn=new N,Qn=new N,As=new N,rl=new N,mu=new N,fu=new N,Ns=new N;function wp(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Ns.fromArray(n,s);const o=r.x*Math.abs(Ns.x)+r.y*Math.abs(Ns.y)+r.z*Math.abs(Ns.z),l=e.dot(Ns),c=t.dot(Ns),u=i.dot(Ns);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ww=new zi,nl=new N,Ep=new N;class Ai{constructor(e=new N,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):Ww.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));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;nl.subVectors(e,this.center);const t=nl.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(nl,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):(Ep.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(nl.copy(e.center).add(Ep)),this.expandByPoint(nl.copy(e.center).sub(Ep))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const wn=new N,Ap=new N,gu=new N,es=new N,Np=new N,vu=new N,Cp=new N;class Cs{constructor(e=new N,t=new N(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,wn)),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=wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(wn.copy(this.origin).addScaledVector(this.direction,t),wn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Ap.copy(e).add(t).multiplyScalar(.5),gu.copy(t).sub(e).normalize(),es.copy(this.origin).sub(Ap);const s=e.distanceTo(t)*.5,a=-this.direction.dot(gu),o=es.dot(this.direction),l=-es.dot(gu),c=es.lengthSq(),u=Math.abs(1-a*a);let h,d,p,m;if(u>0)if(h=a*l-o,d=a*o-l,m=s*u,h>=0)if(d>=-m)if(d<=m){const v=1/u;h*=v,d*=v,p=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d<=-m?(h=Math.max(0,-(-a*s+o)),d=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c):d<=m?(h=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(h=Math.max(0,-(a*s+o)),d=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c);else d=a>0?-s:s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(Ap).addScaledVector(gu,d),p}intersectSphere(e,t){wn.subVectors(e.center,this.origin);const i=wn.dot(this.direction),r=wn.dot(wn)-i*i,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return 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,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),u>=0?(s=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),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,wn)!==null}intersectTriangle(e,t,i,r,s){Np.subVectors(t,e),vu.subVectors(i,e),Cp.crossVectors(Np,vu);let a=this.direction.dot(Cp),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;es.subVectors(this.origin,e);const l=o*this.direction.dot(vu.crossVectors(es,vu));if(l<0)return null;const c=o*this.direction.dot(Np.cross(es));if(c<0||l+c>a)return null;const u=-o*es.dot(Cp);return u<0?null:this.at(u/a,s)}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)}}class Re{constructor(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f){Re.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,s,a,o,l,c,u,h,d,p,m,v,f)}set(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=d,g[3]=p,g[7]=m,g[11]=v,g[15]=f,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 Re().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 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){const t=this.elements,i=e.elements,r=1/Da.setFromMatrixColumn(e,0).length(),s=1/Da.setFromMatrixColumn(e,1).length(),a=1/Da.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]*s,t[5]=i[5]*s,t[6]=i[6]*s,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,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const d=a*u,p=a*h,m=o*u,v=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+m*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=m+p*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,p=l*h,m=c*u,v=c*h;t[0]=d+v*o,t[4]=m*o-p,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=p*o-m,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,p=l*h,m=c*u,v=c*h;t[0]=d-v*o,t[4]=-a*h,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*u,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,p=a*h,m=o*u,v=o*h;t[0]=l*u,t[4]=m*c-p,t[8]=d*c+v,t[1]=l*h,t[5]=v*c+d,t[9]=p*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*u,t[4]=v-d*h,t[8]=m*h+p,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=p*h+m,t[10]=d-v*h}else if(e.order==="XZY"){const d=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+v,t[5]=a*u,t[9]=p*h-m,t[2]=m*h-p,t[6]=o*u,t[10]=v*h+d}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(jw,e,Xw)}lookAt(e,t,i){const r=this.elements;return xr.subVectors(e,t),xr.lengthSq()===0&&(xr.z=1),xr.normalize(),ts.crossVectors(i,xr),ts.lengthSq()===0&&(Math.abs(i.z)===1?xr.x+=1e-4:xr.z+=1e-4,xr.normalize(),ts.crossVectors(i,xr)),ts.normalize(),yu.crossVectors(xr,ts),r[0]=ts.x,r[4]=yu.x,r[8]=xr.x,r[1]=ts.y,r[5]=yu.y,r[9]=xr.y,r[2]=ts.z,r[6]=yu.z,r[10]=xr.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,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],p=i[13],m=i[2],v=i[6],f=i[10],g=i[14],x=i[3],y=i[7],_=i[11],I=i[15],T=r[0],w=r[4],C=r[8],H=r[12],M=r[1],b=r[5],k=r[9],j=r[13],Y=r[2],re=r[6],$=r[10],he=r[14],Q=r[3],ye=r[7],Te=r[11],Ve=r[15];return s[0]=a*T+o*M+l*Y+c*Q,s[4]=a*w+o*b+l*re+c*ye,s[8]=a*C+o*k+l*$+c*Te,s[12]=a*H+o*j+l*he+c*Ve,s[1]=u*T+h*M+d*Y+p*Q,s[5]=u*w+h*b+d*re+p*ye,s[9]=u*C+h*k+d*$+p*Te,s[13]=u*H+h*j+d*he+p*Ve,s[2]=m*T+v*M+f*Y+g*Q,s[6]=m*w+v*b+f*re+g*ye,s[10]=m*C+v*k+f*$+g*Te,s[14]=m*H+v*j+f*he+g*Ve,s[3]=x*T+y*M+_*Y+I*Q,s[7]=x*w+y*b+_*re+I*ye,s[11]=x*C+y*k+_*$+I*Te,s[15]=x*H+y*j+_*he+I*Ve,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],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],p=e[14],m=e[3],v=e[7],f=e[11],g=e[15];return m*(+s*l*h-r*c*h-s*o*d+i*c*d+r*o*p-i*l*p)+v*(+t*l*p-t*c*d+s*a*d-r*a*p+r*c*u-s*l*u)+f*(+t*c*h-t*o*p-s*a*h+i*a*p+s*o*u-i*c*u)+g*(-r*o*u-t*l*h+t*o*d+r*a*h-i*a*d+i*l*u)}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],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],m=e[12],v=e[13],f=e[14],g=e[15],x=h*f*c-v*d*c+v*l*p-o*f*p-h*l*g+o*d*g,y=m*d*c-u*f*c-m*l*p+a*f*p+u*l*g-a*d*g,_=u*v*c-m*h*c+m*o*p-a*v*p-u*o*g+a*h*g,I=m*h*l-u*v*l-m*o*d+a*v*d+u*o*f-a*h*f,T=t*x+i*y+r*_+s*I;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/T;return e[0]=x*w,e[1]=(v*d*s-h*f*s-v*r*p+i*f*p+h*r*g-i*d*g)*w,e[2]=(o*f*s-v*l*s+v*r*c-i*f*c-o*r*g+i*l*g)*w,e[3]=(h*l*s-o*d*s-h*r*c+i*d*c+o*r*p-i*l*p)*w,e[4]=y*w,e[5]=(u*f*s-m*d*s+m*r*p-t*f*p-u*r*g+t*d*g)*w,e[6]=(m*l*s-a*f*s-m*r*c+t*f*c+a*r*g-t*l*g)*w,e[7]=(a*d*s-u*l*s+u*r*c-t*d*c-a*r*p+t*l*p)*w,e[8]=_*w,e[9]=(m*h*s-u*v*s-m*i*p+t*v*p+u*i*g-t*h*g)*w,e[10]=(a*v*s-m*o*s+m*i*c-t*v*c-a*i*g+t*o*g)*w,e[11]=(u*o*s-a*h*s-u*i*c+t*h*c+a*i*p-t*o*p)*w,e[12]=I*w,e[13]=(u*v*r-m*h*r+m*i*d-t*v*d-u*i*f+t*h*f)*w,e[14]=(m*o*r-a*v*r-m*i*l+t*v*l+a*i*f-t*o*f)*w,e[15]=(a*h*r-u*o*r+u*i*l-t*h*l-a*i*d+t*o*d)*w,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,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),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*a,0,c*l-r*o,u*l+r*a,s*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,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,u=a+a,h=o+o,d=s*c,p=s*u,m=s*h,v=a*u,f=a*h,g=o*h,x=l*c,y=l*u,_=l*h,I=i.x,T=i.y,w=i.z;return r[0]=(1-(v+g))*I,r[1]=(p+_)*I,r[2]=(m-y)*I,r[3]=0,r[4]=(p-_)*T,r[5]=(1-(d+g))*T,r[6]=(f+x)*T,r[7]=0,r[8]=(m+y)*w,r[9]=(f-x)*w,r[10]=(1-(d+v))*w,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;let s=Da.set(r[0],r[1],r[2]).length();const a=Da.set(r[4],r[5],r[6]).length(),o=Da.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],qr.copy(this);const l=1/s,c=1/a,u=1/o;return qr.elements[0]*=l,qr.elements[1]*=l,qr.elements[2]*=l,qr.elements[4]*=c,qr.elements[5]*=c,qr.elements[6]*=c,qr.elements[8]*=u,qr.elements[9]*=u,qr.elements[10]*=u,t.setFromRotationMatrix(qr),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,r,s,a,o=Rr){const l=this.elements,c=2*s/(t-e),u=2*s/(i-r),h=(t+e)/(t-e),d=(i+r)/(i-r);let p,m;if(o===Rr)p=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===ws)p=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,a,o=Rr){const l=this.elements,c=1/(t-e),u=1/(i-r),h=1/(a-s),d=(t+e)*c,p=(i+r)*u;let m,v;if(o===Rr)m=(a+s)*h,v=-2*h;else if(o===ws)m=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=v,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[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 Da=new N,qr=new Re,jw=new N(0,0,0),Xw=new N(1,1,1),ts=new N,yu=new N,xr=new N,Tv=new Re,bv=new Bi;class dr{constructor(e=0,t=0,i=0,r=dr.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,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],u=r[9],h=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Jt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Jt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Jt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Tv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Tv,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return bv.setFromEuler(this),this.setFromQuaternion(bv,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}}dr.DEFAULT_ORDER="XYZ";class sl{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 qw=0;const Sv=new N,Ua=new Bi,En=new Re,xu=new N,al=new N,Yw=new N,$w=new Bi,wv=new N(1,0,0),Ev=new N(0,1,0),Av=new N(0,0,1),Nv={type:"added"},Jw={type:"removed"},Oa={type:"childadded",child:null},Rp={type:"childremoved",child:null};class _t extends vr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qw++}),this.uuid=yr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new N,t=new dr,i=new Bi,r=new N(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),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 Re},normalMatrix:{value:new Ke}}),this.matrix=new Re,this.matrixWorld=new Re,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new sl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 Ua.setFromAxisAngle(e,t),this.quaternion.multiply(Ua),this}rotateOnWorldAxis(e,t){return Ua.setFromAxisAngle(e,t),this.quaternion.premultiply(Ua),this}rotateX(e){return this.rotateOnAxis(wv,e)}rotateY(e){return this.rotateOnAxis(Ev,e)}rotateZ(e){return this.rotateOnAxis(Av,e)}translateOnAxis(e,t){return Sv.copy(e).applyQuaternion(this.quaternion),this.position.add(Sv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(wv,e)}translateY(e){return this.translateOnAxis(Ev,e)}translateZ(e){return this.translateOnAxis(Av,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(En.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?xu.copy(e):xu.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),al.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?En.lookAt(al,xu,this.up):En.lookAt(xu,al,this.up),this.quaternion.setFromRotationMatrix(En),r&&(En.extractRotation(r.matrixWorld),Ua.setFromRotationMatrix(En),this.quaternion.premultiply(Ua.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.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(Nv),Oa.child=e,this.dispatchEvent(Oa),Oa.child=null):console.error("THREE.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(Jw),Rp.child=e,this.dispatchEvent(Rp),Rp.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),En.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),En.multiply(e.parent.matrixWorld)),e.applyMatrix4(En),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Nv),Oa.child=e,this.dispatchEvent(Oa),Oa.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 s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].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(al,e,Yw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(al,$w,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),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 s=0,a=r.length;s<a;s++)r[s].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.6,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),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.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),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.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(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=s(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 c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(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(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),p=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}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),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.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 N(0,1,0),_t.DEFAULT_MATRIX_AUTO_UPDATE=!0,_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Yr=new N,An=new N,Ip=new N,Nn=new N,Fa=new N,Va=new N,Cv=new N,Lp=new N,Pp=new N,Dp=new N,Up=new st,Op=new st,Fp=new st;class er{constructor(e=new N,t=new N,i=new N){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Yr.subVectors(e,t),r.cross(Yr);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Yr.subVectors(r,t),An.subVectors(i,t),Ip.subVectors(e,t);const a=Yr.dot(Yr),o=Yr.dot(An),l=Yr.dot(Ip),c=An.dot(An),u=An.dot(Ip),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const d=1/h,p=(c*l-o*u)*d,m=(a*u-o*l)*d;return s.set(1-p-m,m,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Nn)===null?!1:Nn.x>=0&&Nn.y>=0&&Nn.x+Nn.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,Nn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Nn.x),l.addScaledVector(a,Nn.y),l.addScaledVector(o,Nn.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return Up.setScalar(0),Op.setScalar(0),Fp.setScalar(0),Up.fromBufferAttribute(e,t),Op.fromBufferAttribute(e,i),Fp.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Up,s.x),a.addScaledVector(Op,s.y),a.addScaledVector(Fp,s.z),a}static isFrontFacing(e,t,i,r){return Yr.subVectors(i,t),An.subVectors(e,t),Yr.cross(An).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 Yr.subVectors(this.c,this.b),An.subVectors(this.a,this.b),Yr.cross(An).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return er.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return er.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return er.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return er.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return er.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let a,o;Fa.subVectors(r,i),Va.subVectors(s,i),Lp.subVectors(e,i);const l=Fa.dot(Lp),c=Va.dot(Lp);if(l<=0&&c<=0)return t.copy(i);Pp.subVectors(e,r);const u=Fa.dot(Pp),h=Va.dot(Pp);if(u>=0&&h<=u)return t.copy(r);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(Fa,a);Dp.subVectors(e,s);const p=Fa.dot(Dp),m=Va.dot(Dp);if(m>=0&&p<=m)return t.copy(s);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(Va,o);const f=u*m-p*h;if(f<=0&&h-u>=0&&p-m>=0)return Cv.subVectors(s,r),o=(h-u)/(h-u+(p-m)),t.copy(r).addScaledVector(Cv,o);const g=1/(f+v+d);return a=v*g,o=d*g,t.copy(i).addScaledVector(Fa,a).addScaledVector(Va,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Rv={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},is={h:0,s:0,l:0},_u={h:0,s:0,l:0};function Vp(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class xe{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=Fi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,vt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=vt.workingColorSpace){return this.r=e,this.g=t,this.b=i,vt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=vt.workingColorSpace){if(e=_p(e,1),t=Jt(t,0,1),i=Jt(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Vp(a,s,e+1/3),this.g=Vp(a,s,e),this.b=Vp(a,s,e-1/3)}return vt.toWorkingColorSpace(this,r),this}setStyle(e,t=Fi){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fi){const i=Rv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.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=Ca(e.r),this.g=Ca(e.g),this.b=Ca(e.b),this}copyLinearToSRGB(e){return this.r=Tp(e.r),this.g=Tp(e.g),this.b=Tp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fi){return vt.fromWorkingColorSpace(ki.copy(this),e),Math.round(Jt(ki.r*255,0,255))*65536+Math.round(Jt(ki.g*255,0,255))*256+Math.round(Jt(ki.b*255,0,255))}getHexString(e=Fi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vt.workingColorSpace){vt.fromWorkingColorSpace(ki.copy(this),t);const i=ki.r,r=ki.g,s=ki.b,a=Math.max(i,r,s),o=Math.min(i,r,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case i:l=(r-s)/h+(r<s?6:0);break;case r:l=(s-i)/h+2;break;case s:l=(i-r)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=vt.workingColorSpace){return vt.fromWorkingColorSpace(ki.copy(this),t),e.r=ki.r,e.g=ki.g,e.b=ki.b,e}getStyle(e=Fi){vt.fromWorkingColorSpace(ki.copy(this),e);const t=ki.r,i=ki.g,r=ki.b;return e!==Fi?`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(is),this.setHSL(is.h+e,is.s+t,is.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(is),e.getHSL(_u);const i=Qo(is.h,_u.h,t),r=Qo(is.s,_u.s,t),s=Qo(is.l,_u.l,t);return this.setHSL(i,r,s),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,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[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 ki=new xe;xe.NAMES=Rv;let Kw=0;class hi extends vr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Kw++}),this.uuid=yr(),this.name="",this.type="Material",this.blending=Tn,this.side=an,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=wc,this.blendDst=Ec,this.blendEquation=zn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xe(0,0,0),this.blendAlpha=0,this.depthFunc=kn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Jn,this.stencilZFail=Jn,this.stencilZPass=Jn,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.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){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.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.6,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.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!==Tn&&(i.blending=this.blending),this.side!==an&&(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!==wc&&(i.blendSrc=this.blendSrc),this.blendDst!==Ec&&(i.blendDst=this.blendDst),this.blendEquation!==zn&&(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!==kn&&(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!==lu&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Jn&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Jn&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Jn&&(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.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(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),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 s=0;s!==r;++s)i[s]=t[s].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.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++}}class $r extends hi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xe(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 dr,this.combine=fa,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 Cn=Zw();function Zw(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<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 s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[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:s,exponentTable:a,offsetTable:o}}function sr(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Jt(n,-65504,65504),Cn.floatView[0]=n;const e=Cn.uint32View[0],t=e>>23&511;return Cn.baseTable[t]+((e&8388607)>>Cn.shiftTable[t])}function ol(n){const e=n>>10;return Cn.uint32View[0]=Cn.mantissaTable[Cn.offsetTable[e]+(n&1023)]+Cn.exponentTable[e],Cn.floatView[0]}const Iv={toHalfFloat:sr,fromHalfFloat:ol},ai=new N,Mu=new J;class wt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Ea,this.updateRanges=[],this.gpuType=Oi,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,s=this.itemSize;r<s;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++)Mu.fromBufferAttribute(this,t),Mu.applyMatrix3(e),this.setXY(t,Mu.x,Mu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyMatrix3(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyMatrix4(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyNormalMatrix(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.transformDirection(e),this.setXYZ(t,ai.x,ai.y,ai.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=qi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=qi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=qi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(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=qi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(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=qi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(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=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,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!==Ea&&(e.usage=this.usage),e}}class Qw extends wt{constructor(e,t,i){super(new Int8Array(e),t,i)}}class eE extends wt{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class tE extends wt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class iE extends wt{constructor(e,t,i){super(new Int16Array(e),t,i)}}class Tu extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class rE extends wt{constructor(e,t,i){super(new Int32Array(e),t,i)}}class Bp extends wt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Lv extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=ol(this.array[e*this.itemSize]);return this.normalized&&(t=qi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=sr(t),this}getY(e){let t=ol(this.array[e*this.itemSize+1]);return this.normalized&&(t=qi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=sr(t),this}getZ(e){let t=ol(this.array[e*this.itemSize+2]);return this.normalized&&(t=qi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=sr(t),this}getW(e){let t=ol(this.array[e*this.itemSize+3]);return this.normalized&&(t=qi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=sr(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this.array[e+2]=sr(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this.array[e+2]=sr(r),this.array[e+3]=sr(s),this}}class De extends wt{constructor(e,t,i){super(new Float32Array(e),t,i)}}let nE=0;const Lr=new Re,zp=new _t,Ba=new N,_r=new zi,ll=new zi,vi=new N;class ct extends vr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:nE++}),this.uuid=yr(),this.name="",this.type="BufferGeometry",this.index=null,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(fv(e)?Bp:Tu)(e,1):this.index=e,this}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 s=new Ke().getNormalMatrix(e);i.applyNormalMatrix(s),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 Lr.makeRotationFromQuaternion(e),this.applyMatrix4(Lr),this}rotateX(e){return Lr.makeRotationX(e),this.applyMatrix4(Lr),this}rotateY(e){return Lr.makeRotationY(e),this.applyMatrix4(Lr),this}rotateZ(e){return Lr.makeRotationZ(e),this.applyMatrix4(Lr),this}translate(e,t,i){return Lr.makeTranslation(e,t,i),this.applyMatrix4(Lr),this}scale(e,t,i){return Lr.makeScale(e,t,i),this.applyMatrix4(Lr),this}lookAt(e){return zp.lookAt(e),zp.updateMatrix(),this.applyMatrix4(zp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ba).negate(),this.translate(Ba.x,Ba.y,Ba.z),this}setFromPoints(e){const t=[];for(let i=0,r=e.length;i<r;i++){const s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new De(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(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 s=t[i];_r.setFromBufferAttribute(s),this.morphTargetsRelative?(vi.addVectors(this.boundingBox.min,_r.min),this.boundingBox.expandByPoint(vi),vi.addVectors(this.boundingBox.max,_r.max),this.boundingBox.expandByPoint(vi)):(this.boundingBox.expandByPoint(_r.min),this.boundingBox.expandByPoint(_r.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){const i=this.boundingSphere.center;if(_r.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];ll.setFromBufferAttribute(o),this.morphTargetsRelative?(vi.addVectors(_r.min,ll.min),_r.expandByPoint(vi),vi.addVectors(_r.max,ll.max),_r.expandByPoint(vi)):(_r.expandByPoint(ll.min),_r.expandByPoint(ll.max))}_r.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)vi.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(vi));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)vi.fromBufferAttribute(o,c),l&&(Ba.fromBufferAttribute(e,c),vi.add(Ba)),r=Math.max(r,i.distanceToSquared(vi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.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){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new wt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let C=0;C<i.count;C++)o[C]=new N,l[C]=new N;const c=new N,u=new N,h=new N,d=new J,p=new J,m=new J,v=new N,f=new N;function g(C,H,M){c.fromBufferAttribute(i,C),u.fromBufferAttribute(i,H),h.fromBufferAttribute(i,M),d.fromBufferAttribute(s,C),p.fromBufferAttribute(s,H),m.fromBufferAttribute(s,M),u.sub(c),h.sub(c),p.sub(d),m.sub(d);const b=1/(p.x*m.y-m.x*p.y);isFinite(b)&&(v.copy(u).multiplyScalar(m.y).addScaledVector(h,-p.y).multiplyScalar(b),f.copy(h).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(b),o[C].add(v),o[H].add(v),o[M].add(v),l[C].add(f),l[H].add(f),l[M].add(f))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let C=0,H=x.length;C<H;++C){const M=x[C],b=M.start,k=M.count;for(let j=b,Y=b+k;j<Y;j+=3)g(e.getX(j+0),e.getX(j+1),e.getX(j+2))}const y=new N,_=new N,I=new N,T=new N;function w(C){I.fromBufferAttribute(r,C),T.copy(I);const H=o[C];y.copy(H),y.sub(I.multiplyScalar(I.dot(H))).normalize(),_.crossVectors(T,H);const M=_.dot(l[C])<0?-1:1;a.setXYZW(C,y.x,y.y,y.z,M)}for(let C=0,H=x.length;C<H;++C){const M=x[C],b=M.start,k=M.count;for(let j=b,Y=b+k;j<Y;j+=3)w(e.getX(j+0)),w(e.getX(j+1)),w(e.getX(j+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 wt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const r=new N,s=new N,a=new N,o=new N,l=new N,c=new N,u=new N,h=new N;if(e)for(let d=0,p=e.count;d<p;d+=3){const m=e.getX(d+0),v=e.getX(d+1),f=e.getX(d+2);r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,f),u.subVectors(a,s),h.subVectors(r,s),u.cross(h),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,f),o.add(u),l.add(u),c.add(u),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(f,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,s),h.subVectors(r,s),u.cross(h),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)vi.fromBufferAttribute(e,t),vi.normalize(),e.setXYZ(t,vi.x,vi.y,vi.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let p=0,m=0;for(let v=0,f=l.length;v<f;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*u;for(let g=0;g<u;g++)d[m++]=c[p++]}return new wt(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ct,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],p=e(d,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 c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,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 c in l)l[c]!==void 0&&(e[c]=l[c]);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 c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(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={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.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 Pv=new Re,Rs=new Cs,bu=new Ai,Dv=new N,Su=new N,wu=new N,Eu=new N,kp=new N,Au=new N,Uv=new N,Nu=new N;class Ft extends _t{constructor(e=new ct,t=new $r){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,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,s=i.length;r<s;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,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Au.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],h=s[l];u!==0&&(kp.fromBufferAttribute(h,e),a?Au.addScaledVector(kp,u):Au.addScaledVector(kp.sub(t),u))}t.add(Au)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),bu.copy(i.boundingSphere),bu.applyMatrix4(s),Rs.copy(e.ray).recast(e.near),!(bu.containsPoint(Rs.origin)===!1&&(Rs.intersectSphere(bu,Dv)===null||Rs.origin.distanceToSquared(Dv)>(e.far-e.near)**2))&&(Pv.copy(s).invert(),Rs.copy(e.ray).applyMatrix4(Pv),!(i.boundingBox!==null&&Rs.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Rs)))}_computeIntersections(e,t,i){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,v=d.length;m<v;m++){const f=d[m],g=a[f.materialIndex],x=Math.max(f.start,p.start),y=Math.min(o.count,Math.min(f.start+f.count,p.start+p.count));for(let _=x,I=y;_<I;_+=3){const T=o.getX(_),w=o.getX(_+1),C=o.getX(_+2);r=Cu(this,g,e,i,c,u,h,T,w,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let f=m,g=v;f<g;f+=3){const x=o.getX(f),y=o.getX(f+1),_=o.getX(f+2);r=Cu(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,v=d.length;m<v;m++){const f=d[m],g=a[f.materialIndex],x=Math.max(f.start,p.start),y=Math.min(l.count,Math.min(f.start+f.count,p.start+p.count));for(let _=x,I=y;_<I;_+=3){const T=_,w=_+1,C=_+2;r=Cu(this,g,e,i,c,u,h,T,w,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let f=m,g=v;f<g;f+=3){const x=f,y=f+1,_=f+2;r=Cu(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}}function sE(n,e,t,i,r,s,a,o){let l;if(e.side===si?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===an,o),l===null)return null;Nu.copy(o),Nu.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Nu);return c<t.near||c>t.far?null:{distance:c,point:Nu.clone(),object:n}}function Cu(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,Su),n.getVertexPosition(l,wu),n.getVertexPosition(c,Eu);const u=sE(n,e,t,i,Su,wu,Eu,Uv);if(u){const h=new N;er.getBarycoord(Uv,Su,wu,Eu,h),r&&(u.uv=er.getInterpolatedAttribute(r,o,l,c,h,new J)),s&&(u.uv1=er.getInterpolatedAttribute(s,o,l,c,h,new J)),a&&(u.normal=er.getInterpolatedAttribute(a,o,l,c,h,new N),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new N,materialIndex:0};er.getNormal(Su,wu,Eu,d.normal),u.face=d,u.barycoord=h}return u}class _n extends ct{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,p=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,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,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(u,3)),this.setAttribute("uv",new De(h,2));function m(v,f,g,x,y,_,I,T,w,C,H){const M=_/w,b=I/C,k=_/2,j=I/2,Y=T/2,re=w+1,$=C+1;let he=0,Q=0;const ye=new N;for(let Te=0;Te<$;Te++){const Ve=Te*b-j;for(let at=0;at<re;at++){const et=at*M-k;ye[v]=et*x,ye[f]=Ve*y,ye[g]=Y,c.push(ye.x,ye.y,ye.z),ye[v]=0,ye[f]=0,ye[g]=T>0?1:-1,u.push(ye.x,ye.y,ye.z),h.push(at/w),h.push(1-Te/C),he+=1}}for(let Te=0;Te<C;Te++)for(let Ve=0;Ve<w;Ve++){const at=d+Ve+re*Te,et=d+Ve+re*(Te+1),ie=d+(Ve+1)+re*(Te+1),le=d+(Ve+1)+re*Te;l.push(at,et,le),l.push(et,ie,le),Q+=6}o.addGroup(p,Q,H),p+=Q,d+=he}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function za(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("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 Yi(n){const e={};for(let t=0;t<n.length;t++){const i=za(n[t]);for(const r in i)e[r]=i[r]}return e}function aE(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Ov(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:vt.workingColorSpace}const Hp={clone:za,merge:Yi};var oE=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,lE=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`;class Pr extends hi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=oE,this.fragmentShader=lE,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=
|
|
5
|
+
}`;class Pr extends hi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=oE,this.fragmentShader=lE,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=za(e.uniforms),this.uniformsGroups=aE(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}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}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}}const Ru=new N,Iu=new Bi,ln=new N;class cl extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Re,this.projectionMatrix=new Re,this.projectionMatrixInverse=new Re,this.coordinateSystem=Rr}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(Ru,Iu,ln),ln.x===1&&ln.y===1&&ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ru,Iu,ln.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(Ru,Iu,ln),ln.x===1&&ln.y===1&&ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ru,Iu,ln.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const rs=new N,Fv=new J,Vv=new J;class di extends cl{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=Aa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Es*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Aa*2*Math.atan(Math.tan(Es*.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){rs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(rs.x,rs.y).multiplyScalar(-e/rs.z),rs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(rs.x,rs.y).multiplyScalar(-e/rs.z)}getViewSize(e,t){return this.getViewBounds(e,Fv,Vv),t.subVectors(Vv,Fv)}setViewOffset(e,t,i,r,s,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=s,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(Es*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*i/c,r*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),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}}const ka=-90,Ha=1;class Lu extends _t{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new di(ka,Ha,e,t);r.layers=this.layers,this.add(r);const s=new di(ka,Ha,e,t);s.layers=this.layers,this.add(s);const a=new di(ka,Ha,e,t);a.layers=this.layers,this.add(a);const o=new di(ka,Ha,e,t);o.layers=this.layers,this.add(o);const l=new di(ka,Ha,e,t);l.layers=this.layers,this.add(l);const c=new di(ka,Ha,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===Rr)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.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===ws)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.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 c of t)this.add(c),c.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[s,a,o,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,a),e.setRenderTarget(i,2,r),e.render(t,o),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(h,d,p),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}}class Is extends Wt{constructor(e,t,i,r,s,a,o,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:fr,super(e,t,i,r,s,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Pu extends Ir{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 Is(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Lt}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:`
|
|
6
6
|
|
|
7
7
|
varying vec3 vWorldDirection;
|
|
8
8
|
|
|
@@ -37,7 +37,7 @@ const rw="169",_0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},M0={ROTATE:0,
|
|
|
37
37
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
38
38
|
|
|
39
39
|
}
|
|
40
|
-
`},r=new _n(5,5,5),s=new Pr({name:"CubemapFromEquirect",uniforms:
|
|
40
|
+
`},r=new _n(5,5,5),s=new Pr({name:"CubemapFromEquirect",uniforms:za(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:si,blending:Er});s.uniforms.tEquirect.value=t;const a=new Ft(r,s),o=t.minFilter;return t.minFilter===Xi&&(t.minFilter=Lt),new Lu(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,i,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}}const Gp=new N,cE=new N,uE=new Ke;class cn{constructor(e=new N(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=Gp.subVectors(i,t).cross(cE.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(Gp),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}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||uE.getNormalMatrix(e),r=this.coplanarPoint(Gp).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ls=new Ai,Du=new N;class Ga{constructor(e=new cn,t=new cn,i=new cn,r=new cn,s=new cn,a=new cn){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,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(s),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=Rr){const i=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],m=r[9],v=r[10],f=r[11],g=r[12],x=r[13],y=r[14],_=r[15];if(i[0].setComponents(l-s,d-c,f-p,_-g).normalize(),i[1].setComponents(l+s,d+c,f+p,_+g).normalize(),i[2].setComponents(l+a,d+u,f+m,_+x).normalize(),i[3].setComponents(l-a,d-u,f-m,_-x).normalize(),i[4].setComponents(l-o,d-h,f-v,_-y).normalize(),t===Rr)i[5].setComponents(l+o,d+h,f+v,_+y).normalize();else if(t===ws)i[5].setComponents(o,h,v,y).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(),Ls.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ls.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ls)}intersectsSprite(e){return Ls.center.set(0,0,0),Ls.radius=.7071067811865476,Ls.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ls)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].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(Du.x=r.normal.x>0?e.max.x:e.min.x,Du.y=r.normal.y>0?e.max.y:e.min.y,Du.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Du)<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)}}function Bv(){let n=null,e=!1,t=null,i=null;function r(s,a){t(s,a),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function hE(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,h=c.byteLength,d=n.createBuffer();n.bindBuffer(l,d),n.bufferData(l,c,u),o.onUploadCallback();let p;if(c instanceof Float32Array)p=n.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=n.SHORT;else if(c instanceof Uint32Array)p=n.UNSIGNED_INT;else if(c instanceof Int32Array)p=n.INT;else if(c instanceof Int8Array)p=n.BYTE;else if(c instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function i(o,l,c){const u=l.array,h=l.updateRanges;if(n.bindBuffer(c,o),h.length===0)n.bufferSubData(c,0,u);else{h.sort((p,m)=>p.start-m.start);let d=0;for(let p=1;p<h.length;p++){const m=h[d],v=h[p];v.start<=m.start+m.count+1?m.count=Math.max(m.count,v.start+v.count-m.start):(++d,h[d]=v)}h.length=d+1;for(let p=0,m=h.length;p<m;p++){const v=h[p];n.bufferSubData(c,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.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(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}class da extends ct{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),c=o+1,u=l+1,h=e/o,d=t/l,p=[],m=[],v=[],f=[];for(let g=0;g<u;g++){const x=g*d-a;for(let y=0;y<c;y++){const _=y*h-s;m.push(_,-x,0),v.push(0,0,1),f.push(y/o),f.push(1-g/l)}}for(let g=0;g<l;g++)for(let x=0;x<o;x++){const y=x+c*g,_=x+c*(g+1),I=x+1+c*(g+1),T=x+1+c*g;p.push(y,_,T),p.push(_,I,T)}this.setIndex(p),this.setAttribute("position",new De(m,3)),this.setAttribute("normal",new De(v,3)),this.setAttribute("uv",new De(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new da(e.width,e.height,e.widthSegments,e.heightSegments)}}var dE=`#ifdef USE_ALPHAHASH
|
|
41
41
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
42
42
|
#endif`,pE=`#ifdef USE_ALPHAHASH
|
|
43
43
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
@@ -3588,7 +3588,7 @@ void main() {
|
|
|
3588
3588
|
#include <tonemapping_fragment>
|
|
3589
3589
|
#include <colorspace_fragment>
|
|
3590
3590
|
#include <fog_fragment>
|
|
3591
|
-
}`,dt={alphahash_fragment:dE,alphahash_pars_fragment:pE,alphamap_fragment:mE,alphamap_pars_fragment:fE,alphatest_fragment:gE,alphatest_pars_fragment:vE,aomap_fragment:yE,aomap_pars_fragment:xE,batching_pars_vertex:_E,batching_vertex:ME,begin_vertex:TE,beginnormal_vertex:bE,bsdfs:SE,iridescence_fragment:wE,bumpmap_pars_fragment:EE,clipping_planes_fragment:AE,clipping_planes_pars_fragment:NE,clipping_planes_pars_vertex:CE,clipping_planes_vertex:RE,color_fragment:IE,color_pars_fragment:LE,color_pars_vertex:PE,color_vertex:DE,common:UE,cube_uv_reflection_fragment:OE,defaultnormal_vertex:FE,displacementmap_pars_vertex:VE,displacementmap_vertex:BE,emissivemap_fragment:zE,emissivemap_pars_fragment:kE,colorspace_fragment:HE,colorspace_pars_fragment:GE,envmap_fragment:WE,envmap_common_pars_fragment:jE,envmap_pars_fragment:XE,envmap_pars_vertex:qE,envmap_physical_pars_fragment:nA,envmap_vertex:YE,fog_vertex:$E,fog_pars_vertex:JE,fog_fragment:KE,fog_pars_fragment:ZE,gradientmap_pars_fragment:QE,lightmap_pars_fragment:eA,lights_lambert_fragment:tA,lights_lambert_pars_fragment:iA,lights_pars_begin:rA,lights_toon_fragment:sA,lights_toon_pars_fragment:aA,lights_phong_fragment:oA,lights_phong_pars_fragment:lA,lights_physical_fragment:cA,lights_physical_pars_fragment:uA,lights_fragment_begin:hA,lights_fragment_maps:dA,lights_fragment_end:pA,logdepthbuf_fragment:mA,logdepthbuf_pars_fragment:fA,logdepthbuf_pars_vertex:gA,logdepthbuf_vertex:vA,map_fragment:yA,map_pars_fragment:xA,map_particle_fragment:_A,map_particle_pars_fragment:MA,metalnessmap_fragment:TA,metalnessmap_pars_fragment:bA,morphinstance_vertex:SA,morphcolor_vertex:wA,morphnormal_vertex:EA,morphtarget_pars_vertex:AA,morphtarget_vertex:NA,normal_fragment_begin:CA,normal_fragment_maps:RA,normal_pars_fragment:IA,normal_pars_vertex:LA,normal_vertex:PA,normalmap_pars_fragment:DA,clearcoat_normal_fragment_begin:UA,clearcoat_normal_fragment_maps:OA,clearcoat_pars_fragment:FA,iridescence_pars_fragment:VA,opaque_fragment:BA,packing:zA,premultiplied_alpha_fragment:kA,project_vertex:HA,dithering_fragment:GA,dithering_pars_fragment:WA,roughnessmap_fragment:jA,roughnessmap_pars_fragment:XA,shadowmap_pars_fragment:qA,shadowmap_pars_vertex:YA,shadowmap_vertex:$A,shadowmask_pars_fragment:JA,skinbase_vertex:KA,skinning_pars_vertex:ZA,skinning_vertex:QA,skinnormal_vertex:eN,specularmap_fragment:tN,specularmap_pars_fragment:iN,tonemapping_fragment:rN,tonemapping_pars_fragment:nN,transmission_fragment:sN,transmission_pars_fragment:aN,uv_pars_fragment:oN,uv_pars_vertex:lN,uv_vertex:cN,worldpos_vertex:uN,background_vert:hN,background_frag:dN,backgroundCube_vert:pN,backgroundCube_frag:mN,cube_vert:fN,cube_frag:gN,depth_vert:vN,depth_frag:yN,distanceRGBA_vert:xN,distanceRGBA_frag:_N,equirect_vert:MN,equirect_frag:TN,linedashed_vert:bN,linedashed_frag:SN,meshbasic_vert:wN,meshbasic_frag:EN,meshlambert_vert:AN,meshlambert_frag:NN,meshmatcap_vert:CN,meshmatcap_frag:RN,meshnormal_vert:IN,meshnormal_frag:LN,meshphong_vert:PN,meshphong_frag:DN,meshphysical_vert:UN,meshphysical_frag:ON,meshtoon_vert:FN,meshtoon_frag:VN,points_vert:BN,points_frag:zN,shadow_vert:kN,shadow_frag:HN,sprite_vert:GN,sprite_frag:WN},Me={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ke}},envmap:{envMap:{value:null},envMapRotation:{value:new Ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ke},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0},uvTransform:{value:new Ke}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}}},Dr={basic:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:dt.meshbasic_vert,fragmentShader:dt.meshbasic_frag},lambert:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new xe(0)}}]),vertexShader:dt.meshlambert_vert,fragmentShader:dt.meshlambert_frag},phong:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:dt.meshphong_vert,fragmentShader:dt.meshphong_frag},standard:{uniforms:Yi([Me.common,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.roughnessmap,Me.metalnessmap,Me.fog,Me.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag},toon:{uniforms:Yi([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new xe(0)}}]),vertexShader:dt.meshtoon_vert,fragmentShader:dt.meshtoon_frag},matcap:{uniforms:Yi([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:dt.meshmatcap_vert,fragmentShader:dt.meshmatcap_frag},points:{uniforms:Yi([Me.points,Me.fog]),vertexShader:dt.points_vert,fragmentShader:dt.points_frag},dashed:{uniforms:Yi([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:dt.linedashed_vert,fragmentShader:dt.linedashed_frag},depth:{uniforms:Yi([Me.common,Me.displacementmap]),vertexShader:dt.depth_vert,fragmentShader:dt.depth_frag},normal:{uniforms:Yi([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:dt.meshnormal_vert,fragmentShader:dt.meshnormal_frag},sprite:{uniforms:Yi([Me.sprite,Me.fog]),vertexShader:dt.sprite_vert,fragmentShader:dt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:dt.background_vert,fragmentShader:dt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ke}},vertexShader:dt.backgroundCube_vert,fragmentShader:dt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:dt.cube_vert,fragmentShader:dt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:dt.equirect_vert,fragmentShader:dt.equirect_frag},distanceRGBA:{uniforms:Yi([Me.common,Me.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:dt.distanceRGBA_vert,fragmentShader:dt.distanceRGBA_frag},shadow:{uniforms:Yi([Me.lights,Me.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:dt.shadow_vert,fragmentShader:dt.shadow_frag}};Dr.physical={uniforms:Yi([Dr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ke},clearcoatNormalScale:{value:new J(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ke},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ke},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ke},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ke},anisotropyVector:{value:new J},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ke}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag};const Du={r:0,b:0,g:0},Ls=new dr,jN=new Re;function XN(n,e,t,i,r,s,a){const o=new xe(0);let l=s===!0?0:1,c,u,h=null,d=0,p=null;function m(x){let y=x.isScene===!0?x.background:null;return y&&y.isTexture&&(y=(x.backgroundBlurriness>0?t:e).get(y)),y}function v(x){let y=!1;const _=m(x);_===null?g(o,l):_&&_.isColor&&(g(_,1),y=!0);const I=n.xr.getEnvironmentBlendMode();I==="additive"?i.buffers.color.setClear(0,0,0,1,a):I==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||y)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function f(x,y){const _=m(y);_&&(_.isCubeTexture||_.mapping===Gn)?(u===void 0&&(u=new Ft(new _n(1,1,1),new Pr({name:"BackgroundCubeMaterial",uniforms:Ba(Dr.backgroundCube.uniforms),vertexShader:Dr.backgroundCube.vertexShader,fragmentShader:Dr.backgroundCube.fragmentShader,side:si,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(I,T,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Ls.copy(y.backgroundRotation),Ls.x*=-1,Ls.y*=-1,Ls.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Ls.y*=-1,Ls.z*=-1),u.material.uniforms.envMap.value=_,u.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(jN.makeRotationFromEuler(Ls)),u.material.toneMapped=vt.getTransfer(_.colorSpace)!==Ot,(h!==_||d!==_.version||p!==n.toneMapping)&&(u.material.needsUpdate=!0,h=_,d=_.version,p=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new Ft(new ha(2,2),new Pr({name:"BackgroundMaterial",uniforms:Ba(Dr.background.uniforms),vertexShader:Dr.background.vertexShader,fragmentShader:Dr.background.fragmentShader,side:an,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=vt.getTransfer(_.colorSpace)!==Ot,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||d!==_.version||p!==n.toneMapping)&&(c.material.needsUpdate=!0,h=_,d=_.version,p=n.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function g(x,y){x.getRGB(Du,Uv(n)),i.buffers.color.setClear(Du.r,Du.g,Du.b,y,a)}return{getClearColor:function(){return o},setClearColor:function(x,y=1){o.set(x),l=y,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,g(o,l)},render:v,addToRenderList:f}}function qN(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=d(null);let s=r,a=!1;function o(M,b,k,j,Y){let re=!1;const $=h(j,k,b);s!==$&&(s=$,c(s.object)),re=p(M,j,k,Y),re&&m(M,j,k,Y),Y!==null&&e.update(Y,n.ELEMENT_ARRAY_BUFFER),(re||a)&&(a=!1,_(M,b,k,j),Y!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function l(){return n.createVertexArray()}function c(M){return n.bindVertexArray(M)}function u(M){return n.deleteVertexArray(M)}function h(M,b,k){const j=k.wireframe===!0;let Y=i[M.id];Y===void 0&&(Y={},i[M.id]=Y);let re=Y[b.id];re===void 0&&(re={},Y[b.id]=re);let $=re[j];return $===void 0&&($=d(l()),re[j]=$),$}function d(M){const b=[],k=[],j=[];for(let Y=0;Y<t;Y++)b[Y]=0,k[Y]=0,j[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:k,attributeDivisors:j,object:M,attributes:{},index:null}}function p(M,b,k,j){const Y=s.attributes,re=b.attributes;let $=0;const he=k.getAttributes();for(const Q in he)if(he[Q].location>=0){const ye=Y[Q];let Te=re[Q];if(Te===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(Te=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(Te=M.instanceColor)),ye===void 0||ye.attribute!==Te||Te&&ye.data!==Te.data)return!0;$++}return s.attributesNum!==$||s.index!==j}function m(M,b,k,j){const Y={},re=b.attributes;let $=0;const he=k.getAttributes();for(const Q in he)if(he[Q].location>=0){let ye=re[Q];ye===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor));const Te={};Te.attribute=ye,ye&&ye.data&&(Te.data=ye.data),Y[Q]=Te,$++}s.attributes=Y,s.attributesNum=$,s.index=j}function v(){const M=s.newAttributes;for(let b=0,k=M.length;b<k;b++)M[b]=0}function f(M){g(M,0)}function g(M,b){const k=s.newAttributes,j=s.enabledAttributes,Y=s.attributeDivisors;k[M]=1,j[M]===0&&(n.enableVertexAttribArray(M),j[M]=1),Y[M]!==b&&(n.vertexAttribDivisor(M,b),Y[M]=b)}function x(){const M=s.newAttributes,b=s.enabledAttributes;for(let k=0,j=b.length;k<j;k++)b[k]!==M[k]&&(n.disableVertexAttribArray(k),b[k]=0)}function y(M,b,k,j,Y,re,$){$===!0?n.vertexAttribIPointer(M,b,k,Y,re):n.vertexAttribPointer(M,b,k,j,Y,re)}function _(M,b,k,j){v();const Y=j.attributes,re=k.getAttributes(),$=b.defaultAttributeValues;for(const he in re){const Q=re[he];if(Q.location>=0){let ye=Y[he];if(ye===void 0&&(he==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),he==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor)),ye!==void 0){const Te=ye.normalized,Ve=ye.itemSize,at=e.get(ye);if(at===void 0)continue;const et=at.buffer,ie=at.type,le=at.bytesPerElement,be=ie===n.INT||ie===n.UNSIGNED_INT||ye.gpuType===va;if(ye.isInterleavedBufferAttribute){const Se=ye.data,Ye=Se.stride,We=ye.offset;if(Se.isInstancedInterleavedBuffer){for(let ot=0;ot<Q.locationSize;ot++)g(Q.location+ot,Se.meshPerAttribute);M.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=Se.meshPerAttribute*Se.count)}else for(let ot=0;ot<Q.locationSize;ot++)f(Q.location+ot);n.bindBuffer(n.ARRAY_BUFFER,et);for(let ot=0;ot<Q.locationSize;ot++)y(Q.location+ot,Ve/Q.locationSize,ie,Te,Ye*le,(We+Ve/Q.locationSize*ot)*le,be)}else{if(ye.isInstancedBufferAttribute){for(let Se=0;Se<Q.locationSize;Se++)g(Q.location+Se,ye.meshPerAttribute);M.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=ye.meshPerAttribute*ye.count)}else for(let Se=0;Se<Q.locationSize;Se++)f(Q.location+Se);n.bindBuffer(n.ARRAY_BUFFER,et);for(let Se=0;Se<Q.locationSize;Se++)y(Q.location+Se,Ve/Q.locationSize,ie,Te,Ve*le,Ve/Q.locationSize*Se*le,be)}}else if($!==void 0){const Te=$[he];if(Te!==void 0)switch(Te.length){case 2:n.vertexAttrib2fv(Q.location,Te);break;case 3:n.vertexAttrib3fv(Q.location,Te);break;case 4:n.vertexAttrib4fv(Q.location,Te);break;default:n.vertexAttrib1fv(Q.location,Te)}}}}x()}function I(){C();for(const M in i){const b=i[M];for(const k in b){const j=b[k];for(const Y in j)u(j[Y].object),delete j[Y];delete b[k]}delete i[M]}}function T(M){if(i[M.id]===void 0)return;const b=i[M.id];for(const k in b){const j=b[k];for(const Y in j)u(j[Y].object),delete j[Y];delete b[k]}delete i[M.id]}function w(M){for(const b in i){const k=i[b];if(k[M.id]===void 0)continue;const j=k[M.id];for(const Y in j)u(j[Y].object),delete j[Y];delete k[M.id]}}function C(){H(),a=!0,s!==r&&(s=r,c(s.object))}function H(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:C,resetDefaultState:H,dispose:I,releaseStatesOfGeometry:T,releaseStatesOfProgram:w,initAttributes:v,enableAttribute:f,disableUnusedAttributes:x}}function YN(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function a(c,u,h){h!==0&&(n.drawArraysInstanced(i,c,u,h),t.update(u,i,h))}function o(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,h);let d=0;for(let p=0;p<h;p++)d+=u[p];t.update(d,i,1)}function l(c,u,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<c.length;m++)a(c[m],u[m],d[m]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,u,0,d,0,h);let m=0;for(let v=0;v<h;v++)m+=u[v];for(let v=0;v<d.length;v++)t.update(m,i,d[v])}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function $N(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const w=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(w){return!(w!==Ei&&i.convert(w)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(w){const C=w===wi&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(w!==jr&&i.convert(w)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Oi&&!C)}function l(w){if(w==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(d===!0){const w=e.get("EXT_clip_control");w.clipControlEXT(w.LOWER_LEFT_EXT,w.ZERO_TO_ONE_EXT)}const p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),f=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),x=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),y=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),I=m>0,T=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:f,maxAttributes:g,maxVertexUniforms:x,maxVaryings:y,maxFragmentUniforms:_,vertexTextures:I,maxSamples:T}}function JN(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new cn,o=new Ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||i!==0||r;return r=d,i=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,p){const m=h.clippingPlanes,v=h.clipIntersection,f=h.clipShadows,g=n.get(h);if(!r||m===null||m.length===0||s&&!f)s?u(null):c();else{const x=s?0:i,y=x*4;let _=g.clippingState||null;l.value=_,_=u(m,d,y,p);for(let I=0;I!==y;++I)_[I]=t[I];g.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,m){const v=h!==null?h.length:0;let f=null;if(v!==0){if(f=l.value,m!==!0||f===null){const g=p+v*4,x=d.matrixWorldInverse;o.getNormalMatrix(x),(f===null||f.length<g)&&(f=new Float32Array(g));for(let y=0,_=p;y!==v;++y,_+=4)a.copy(h[y]).applyMatrix4(x,o),a.normal.toArray(f,_),f[_+3]=a.constant}l.value=f,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,f}}function KN(n){let e=new WeakMap;function t(a,o){return o===kn?a.mapping=fr:o===Hn&&(a.mapping=Ar),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===kn||o===Hn)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Lu(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class Ps extends ll{constructor(e=-1,t=1,i=1,r=-1,s=.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=s,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,s,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=s,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 s=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),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}}const Ga=4,Bv=[.125,.215,.35,.446,.526,.582],Ds=20,Gp=new Ps,zv=new xe;let Wp=null,jp=0,Xp=0,qp=!1;const Us=(1+Math.sqrt(5))/2,Wa=1/Us,kv=[new N(-Us,Wa,0),new N(Us,Wa,0),new N(-Wa,0,Us),new N(Wa,0,Us),new N(0,Us,-Wa),new N(0,Us,Wa),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)];let Uu=class{constructor(n){this._renderer=n,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(n,e=0,t=.1,i=100){Wp=this._renderer.getRenderTarget(),jp=this._renderer.getActiveCubeFace(),Xp=this._renderer.getActiveMipmapLevel(),qp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(n,t,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(n,e=null){return this._fromTexture(n,e)}fromCubemap(n,e=null){return this._fromTexture(n,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=jv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Wv(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(n){this._lodMax=Math.floor(Math.log2(n)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let n=0;n<this._lodPlanes.length;n++)this._lodPlanes[n].dispose()}_cleanup(n){this._renderer.setRenderTarget(Wp,jp,Xp),this._renderer.xr.enabled=qp,n.scissorTest=!1,Ou(n,0,0,n.width,n.height)}_fromTexture(n,e){n.mapping===fr||n.mapping===Ar?this._setSize(n.image.length===0?16:n.image[0].width||n.image[0].image.width):this._setSize(n.image.width/4),Wp=this._renderer.getRenderTarget(),jp=this._renderer.getActiveCubeFace(),Xp=this._renderer.getActiveMipmapLevel(),qp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const t=e||this._allocateTargets();return this._textureToCubeUV(n,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(){const n=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,t={magFilter:Lt,minFilter:Lt,generateMipmaps:!1,type:wi,format:Ei,colorSpace:nr,depthBuffer:!1},i=Gv(n,e,t),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Hv(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==n||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Gv(n,e,t);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Hv(s)),this._blurMaterial=ZN(s,n,e)}return i}_compileMaterial(n){const e=new Ft(this._lodPlanes[0],n);this._renderer.compile(e,Gp)}_sceneToCubeUV(n,e,t,i){const r=new di(90,1,e,t),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(zv),o.toneMapping=mr,o.autoClear=!1;const u=new $r({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1}),h=new Ft(new _n,u);let d=!1;const p=n.background;p?p.isColor&&(u.color.copy(p),n.background=null,d=!0):(u.color.copy(zv),d=!0);for(let m=0;m<6;m++){const v=m%3;v===0?(r.up.set(0,s[m],0),r.lookAt(a[m],0,0)):v===1?(r.up.set(0,0,s[m]),r.lookAt(0,a[m],0)):(r.up.set(0,s[m],0),r.lookAt(0,0,a[m]));const f=this._cubeSize;Ou(i,v*f,m>2?f:0,f,f),o.setRenderTarget(i),d&&o.render(h,r),o.render(n,r)}h.geometry.dispose(),h.material.dispose(),o.toneMapping=c,o.autoClear=l,n.background=p}_textureToCubeUV(n,e){const t=this._renderer,i=n.mapping===fr||n.mapping===Ar;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=jv()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Wv());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ft(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=n;const o=this._cubeSize;Ou(e,0,0,3*o,2*o),t.setRenderTarget(e),t.render(s,Gp)}_applyPMREM(n){const e=this._renderer,t=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const s=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=kv[(i-r-1)%kv.length];this._blur(n,r-1,r,s,a)}e.autoClear=t}_blur(n,e,t,i,r){const s=this._pingPongRenderTarget;this._halfBlur(n,s,e,t,i,"latitudinal",r),this._halfBlur(s,n,t,t,i,"longitudinal",r)}_halfBlur(n,e,t,i,r,s,a){const o=this._renderer,l=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const c=3,u=new Ft(this._lodPlanes[i],l),h=l.uniforms,d=this._sizeLods[t]-1,p=isFinite(r)?Math.PI/(2*d):2*Math.PI/(2*Ds-1),m=r/p,v=isFinite(r)?1+Math.floor(c*m):Ds;v>Ds&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Ds}`);const f=[];let g=0;for(let T=0;T<Ds;++T){const w=T/m,C=Math.exp(-w*w/2);f.push(C),T===0?g+=C:T<v&&(g+=2*C)}for(let T=0;T<f.length;T++)f[T]=f[T]/g;h.envMap.value=n.texture,h.samples.value=v,h.weights.value=f,h.latitudinal.value=s==="latitudinal",a&&(h.poleAxis.value=a);const{_lodMax:x}=this;h.dTheta.value=p,h.mipInt.value=x-t;const y=this._sizeLods[i],_=3*y*(i>x-Ga?i-x+Ga:0),I=4*(this._cubeSize-y);Ou(e,_,I,3*y,2*y),o.setRenderTarget(e),o.render(u,Gp)}};function Hv(n){const e=[],t=[],i=[];let r=n;const s=n-Ga+1+Bv.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>n-Ga?l=Bv[a-n+Ga-1]:a===0&&(l=0),i.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,m=6,v=3,f=2,g=1,x=new Float32Array(v*m*p),y=new Float32Array(f*m*p),_=new Float32Array(g*m*p);for(let T=0;T<p;T++){const w=T%3*2/3-1,C=T>2?0:-1,H=[w,C,0,w+2/3,C,0,w+2/3,C+1,0,w,C,0,w+2/3,C+1,0,w,C+1,0];x.set(H,v*m*T),y.set(d,f*m*T);const M=[T,T,T,T,T,T];_.set(M,g*m*T)}const I=new ct;I.setAttribute("position",new wt(x,v)),I.setAttribute("uv",new wt(y,f)),I.setAttribute("faceIndex",new wt(_,g)),e.push(I),r>Ga&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Gv(n,e,t){const i=new Ir(n,e,t);return i.texture.mapping=Gn,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ou(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function ZN(n,e,t){const i=new Float32Array(Ds),r=new N(0,1,0);return new Pr({name:"SphericalGaussianBlur",defines:{n:Ds,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Yp(),fragmentShader:`
|
|
3591
|
+
}`,dt={alphahash_fragment:dE,alphahash_pars_fragment:pE,alphamap_fragment:mE,alphamap_pars_fragment:fE,alphatest_fragment:gE,alphatest_pars_fragment:vE,aomap_fragment:yE,aomap_pars_fragment:xE,batching_pars_vertex:_E,batching_vertex:ME,begin_vertex:TE,beginnormal_vertex:bE,bsdfs:SE,iridescence_fragment:wE,bumpmap_pars_fragment:EE,clipping_planes_fragment:AE,clipping_planes_pars_fragment:NE,clipping_planes_pars_vertex:CE,clipping_planes_vertex:RE,color_fragment:IE,color_pars_fragment:LE,color_pars_vertex:PE,color_vertex:DE,common:UE,cube_uv_reflection_fragment:OE,defaultnormal_vertex:FE,displacementmap_pars_vertex:VE,displacementmap_vertex:BE,emissivemap_fragment:zE,emissivemap_pars_fragment:kE,colorspace_fragment:HE,colorspace_pars_fragment:GE,envmap_fragment:WE,envmap_common_pars_fragment:jE,envmap_pars_fragment:XE,envmap_pars_vertex:qE,envmap_physical_pars_fragment:nA,envmap_vertex:YE,fog_vertex:$E,fog_pars_vertex:JE,fog_fragment:KE,fog_pars_fragment:ZE,gradientmap_pars_fragment:QE,lightmap_pars_fragment:eA,lights_lambert_fragment:tA,lights_lambert_pars_fragment:iA,lights_pars_begin:rA,lights_toon_fragment:sA,lights_toon_pars_fragment:aA,lights_phong_fragment:oA,lights_phong_pars_fragment:lA,lights_physical_fragment:cA,lights_physical_pars_fragment:uA,lights_fragment_begin:hA,lights_fragment_maps:dA,lights_fragment_end:pA,logdepthbuf_fragment:mA,logdepthbuf_pars_fragment:fA,logdepthbuf_pars_vertex:gA,logdepthbuf_vertex:vA,map_fragment:yA,map_pars_fragment:xA,map_particle_fragment:_A,map_particle_pars_fragment:MA,metalnessmap_fragment:TA,metalnessmap_pars_fragment:bA,morphinstance_vertex:SA,morphcolor_vertex:wA,morphnormal_vertex:EA,morphtarget_pars_vertex:AA,morphtarget_vertex:NA,normal_fragment_begin:CA,normal_fragment_maps:RA,normal_pars_fragment:IA,normal_pars_vertex:LA,normal_vertex:PA,normalmap_pars_fragment:DA,clearcoat_normal_fragment_begin:UA,clearcoat_normal_fragment_maps:OA,clearcoat_pars_fragment:FA,iridescence_pars_fragment:VA,opaque_fragment:BA,packing:zA,premultiplied_alpha_fragment:kA,project_vertex:HA,dithering_fragment:GA,dithering_pars_fragment:WA,roughnessmap_fragment:jA,roughnessmap_pars_fragment:XA,shadowmap_pars_fragment:qA,shadowmap_pars_vertex:YA,shadowmap_vertex:$A,shadowmask_pars_fragment:JA,skinbase_vertex:KA,skinning_pars_vertex:ZA,skinning_vertex:QA,skinnormal_vertex:eN,specularmap_fragment:tN,specularmap_pars_fragment:iN,tonemapping_fragment:rN,tonemapping_pars_fragment:nN,transmission_fragment:sN,transmission_pars_fragment:aN,uv_pars_fragment:oN,uv_pars_vertex:lN,uv_vertex:cN,worldpos_vertex:uN,background_vert:hN,background_frag:dN,backgroundCube_vert:pN,backgroundCube_frag:mN,cube_vert:fN,cube_frag:gN,depth_vert:vN,depth_frag:yN,distanceRGBA_vert:xN,distanceRGBA_frag:_N,equirect_vert:MN,equirect_frag:TN,linedashed_vert:bN,linedashed_frag:SN,meshbasic_vert:wN,meshbasic_frag:EN,meshlambert_vert:AN,meshlambert_frag:NN,meshmatcap_vert:CN,meshmatcap_frag:RN,meshnormal_vert:IN,meshnormal_frag:LN,meshphong_vert:PN,meshphong_frag:DN,meshphysical_vert:UN,meshphysical_frag:ON,meshtoon_vert:FN,meshtoon_frag:VN,points_vert:BN,points_frag:zN,shadow_vert:kN,shadow_frag:HN,sprite_vert:GN,sprite_frag:WN},Me={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ke}},envmap:{envMap:{value:null},envMapRotation:{value:new Ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ke},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0},uvTransform:{value:new Ke}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}}},Dr={basic:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:dt.meshbasic_vert,fragmentShader:dt.meshbasic_frag},lambert:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new xe(0)}}]),vertexShader:dt.meshlambert_vert,fragmentShader:dt.meshlambert_frag},phong:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:dt.meshphong_vert,fragmentShader:dt.meshphong_frag},standard:{uniforms:Yi([Me.common,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.roughnessmap,Me.metalnessmap,Me.fog,Me.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag},toon:{uniforms:Yi([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new xe(0)}}]),vertexShader:dt.meshtoon_vert,fragmentShader:dt.meshtoon_frag},matcap:{uniforms:Yi([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:dt.meshmatcap_vert,fragmentShader:dt.meshmatcap_frag},points:{uniforms:Yi([Me.points,Me.fog]),vertexShader:dt.points_vert,fragmentShader:dt.points_frag},dashed:{uniforms:Yi([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:dt.linedashed_vert,fragmentShader:dt.linedashed_frag},depth:{uniforms:Yi([Me.common,Me.displacementmap]),vertexShader:dt.depth_vert,fragmentShader:dt.depth_frag},normal:{uniforms:Yi([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:dt.meshnormal_vert,fragmentShader:dt.meshnormal_frag},sprite:{uniforms:Yi([Me.sprite,Me.fog]),vertexShader:dt.sprite_vert,fragmentShader:dt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:dt.background_vert,fragmentShader:dt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ke}},vertexShader:dt.backgroundCube_vert,fragmentShader:dt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:dt.cube_vert,fragmentShader:dt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:dt.equirect_vert,fragmentShader:dt.equirect_frag},distanceRGBA:{uniforms:Yi([Me.common,Me.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:dt.distanceRGBA_vert,fragmentShader:dt.distanceRGBA_frag},shadow:{uniforms:Yi([Me.lights,Me.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:dt.shadow_vert,fragmentShader:dt.shadow_frag}};Dr.physical={uniforms:Yi([Dr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ke},clearcoatNormalScale:{value:new J(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ke},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ke},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ke},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ke},anisotropyVector:{value:new J},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ke}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag};const Uu={r:0,b:0,g:0},Ps=new dr,jN=new Re;function XN(n,e,t,i,r,s,a){const o=new xe(0);let l=s===!0?0:1,c,u,h=null,d=0,p=null;function m(x){let y=x.isScene===!0?x.background:null;return y&&y.isTexture&&(y=(x.backgroundBlurriness>0?t:e).get(y)),y}function v(x){let y=!1;const _=m(x);_===null?g(o,l):_&&_.isColor&&(g(_,1),y=!0);const I=n.xr.getEnvironmentBlendMode();I==="additive"?i.buffers.color.setClear(0,0,0,1,a):I==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||y)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function f(x,y){const _=m(y);_&&(_.isCubeTexture||_.mapping===Wn)?(u===void 0&&(u=new Ft(new _n(1,1,1),new Pr({name:"BackgroundCubeMaterial",uniforms:za(Dr.backgroundCube.uniforms),vertexShader:Dr.backgroundCube.vertexShader,fragmentShader:Dr.backgroundCube.fragmentShader,side:si,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(I,T,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Ps.copy(y.backgroundRotation),Ps.x*=-1,Ps.y*=-1,Ps.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Ps.y*=-1,Ps.z*=-1),u.material.uniforms.envMap.value=_,u.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(jN.makeRotationFromEuler(Ps)),u.material.toneMapped=vt.getTransfer(_.colorSpace)!==Ot,(h!==_||d!==_.version||p!==n.toneMapping)&&(u.material.needsUpdate=!0,h=_,d=_.version,p=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new Ft(new da(2,2),new Pr({name:"BackgroundMaterial",uniforms:za(Dr.background.uniforms),vertexShader:Dr.background.vertexShader,fragmentShader:Dr.background.fragmentShader,side:an,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=vt.getTransfer(_.colorSpace)!==Ot,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||d!==_.version||p!==n.toneMapping)&&(c.material.needsUpdate=!0,h=_,d=_.version,p=n.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function g(x,y){x.getRGB(Uu,Ov(n)),i.buffers.color.setClear(Uu.r,Uu.g,Uu.b,y,a)}return{getClearColor:function(){return o},setClearColor:function(x,y=1){o.set(x),l=y,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,g(o,l)},render:v,addToRenderList:f}}function qN(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=d(null);let s=r,a=!1;function o(M,b,k,j,Y){let re=!1;const $=h(j,k,b);s!==$&&(s=$,c(s.object)),re=p(M,j,k,Y),re&&m(M,j,k,Y),Y!==null&&e.update(Y,n.ELEMENT_ARRAY_BUFFER),(re||a)&&(a=!1,_(M,b,k,j),Y!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function l(){return n.createVertexArray()}function c(M){return n.bindVertexArray(M)}function u(M){return n.deleteVertexArray(M)}function h(M,b,k){const j=k.wireframe===!0;let Y=i[M.id];Y===void 0&&(Y={},i[M.id]=Y);let re=Y[b.id];re===void 0&&(re={},Y[b.id]=re);let $=re[j];return $===void 0&&($=d(l()),re[j]=$),$}function d(M){const b=[],k=[],j=[];for(let Y=0;Y<t;Y++)b[Y]=0,k[Y]=0,j[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:k,attributeDivisors:j,object:M,attributes:{},index:null}}function p(M,b,k,j){const Y=s.attributes,re=b.attributes;let $=0;const he=k.getAttributes();for(const Q in he)if(he[Q].location>=0){const ye=Y[Q];let Te=re[Q];if(Te===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(Te=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(Te=M.instanceColor)),ye===void 0||ye.attribute!==Te||Te&&ye.data!==Te.data)return!0;$++}return s.attributesNum!==$||s.index!==j}function m(M,b,k,j){const Y={},re=b.attributes;let $=0;const he=k.getAttributes();for(const Q in he)if(he[Q].location>=0){let ye=re[Q];ye===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor));const Te={};Te.attribute=ye,ye&&ye.data&&(Te.data=ye.data),Y[Q]=Te,$++}s.attributes=Y,s.attributesNum=$,s.index=j}function v(){const M=s.newAttributes;for(let b=0,k=M.length;b<k;b++)M[b]=0}function f(M){g(M,0)}function g(M,b){const k=s.newAttributes,j=s.enabledAttributes,Y=s.attributeDivisors;k[M]=1,j[M]===0&&(n.enableVertexAttribArray(M),j[M]=1),Y[M]!==b&&(n.vertexAttribDivisor(M,b),Y[M]=b)}function x(){const M=s.newAttributes,b=s.enabledAttributes;for(let k=0,j=b.length;k<j;k++)b[k]!==M[k]&&(n.disableVertexAttribArray(k),b[k]=0)}function y(M,b,k,j,Y,re,$){$===!0?n.vertexAttribIPointer(M,b,k,Y,re):n.vertexAttribPointer(M,b,k,j,Y,re)}function _(M,b,k,j){v();const Y=j.attributes,re=k.getAttributes(),$=b.defaultAttributeValues;for(const he in re){const Q=re[he];if(Q.location>=0){let ye=Y[he];if(ye===void 0&&(he==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),he==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor)),ye!==void 0){const Te=ye.normalized,Ve=ye.itemSize,at=e.get(ye);if(at===void 0)continue;const et=at.buffer,ie=at.type,le=at.bytesPerElement,be=ie===n.INT||ie===n.UNSIGNED_INT||ye.gpuType===ya;if(ye.isInterleavedBufferAttribute){const Se=ye.data,Ye=Se.stride,We=ye.offset;if(Se.isInstancedInterleavedBuffer){for(let ot=0;ot<Q.locationSize;ot++)g(Q.location+ot,Se.meshPerAttribute);M.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=Se.meshPerAttribute*Se.count)}else for(let ot=0;ot<Q.locationSize;ot++)f(Q.location+ot);n.bindBuffer(n.ARRAY_BUFFER,et);for(let ot=0;ot<Q.locationSize;ot++)y(Q.location+ot,Ve/Q.locationSize,ie,Te,Ye*le,(We+Ve/Q.locationSize*ot)*le,be)}else{if(ye.isInstancedBufferAttribute){for(let Se=0;Se<Q.locationSize;Se++)g(Q.location+Se,ye.meshPerAttribute);M.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=ye.meshPerAttribute*ye.count)}else for(let Se=0;Se<Q.locationSize;Se++)f(Q.location+Se);n.bindBuffer(n.ARRAY_BUFFER,et);for(let Se=0;Se<Q.locationSize;Se++)y(Q.location+Se,Ve/Q.locationSize,ie,Te,Ve*le,Ve/Q.locationSize*Se*le,be)}}else if($!==void 0){const Te=$[he];if(Te!==void 0)switch(Te.length){case 2:n.vertexAttrib2fv(Q.location,Te);break;case 3:n.vertexAttrib3fv(Q.location,Te);break;case 4:n.vertexAttrib4fv(Q.location,Te);break;default:n.vertexAttrib1fv(Q.location,Te)}}}}x()}function I(){C();for(const M in i){const b=i[M];for(const k in b){const j=b[k];for(const Y in j)u(j[Y].object),delete j[Y];delete b[k]}delete i[M]}}function T(M){if(i[M.id]===void 0)return;const b=i[M.id];for(const k in b){const j=b[k];for(const Y in j)u(j[Y].object),delete j[Y];delete b[k]}delete i[M.id]}function w(M){for(const b in i){const k=i[b];if(k[M.id]===void 0)continue;const j=k[M.id];for(const Y in j)u(j[Y].object),delete j[Y];delete k[M.id]}}function C(){H(),a=!0,s!==r&&(s=r,c(s.object))}function H(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:C,resetDefaultState:H,dispose:I,releaseStatesOfGeometry:T,releaseStatesOfProgram:w,initAttributes:v,enableAttribute:f,disableUnusedAttributes:x}}function YN(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function a(c,u,h){h!==0&&(n.drawArraysInstanced(i,c,u,h),t.update(u,i,h))}function o(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,h);let d=0;for(let p=0;p<h;p++)d+=u[p];t.update(d,i,1)}function l(c,u,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<c.length;m++)a(c[m],u[m],d[m]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,u,0,d,0,h);let m=0;for(let v=0;v<h;v++)m+=u[v];for(let v=0;v<d.length;v++)t.update(m,i,d[v])}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function $N(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const w=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(w){return!(w!==Ei&&i.convert(w)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(w){const C=w===wi&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(w!==jr&&i.convert(w)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Oi&&!C)}function l(w){if(w==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(d===!0){const w=e.get("EXT_clip_control");w.clipControlEXT(w.LOWER_LEFT_EXT,w.ZERO_TO_ONE_EXT)}const p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),f=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),x=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),y=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),I=m>0,T=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:f,maxAttributes:g,maxVertexUniforms:x,maxVaryings:y,maxFragmentUniforms:_,vertexTextures:I,maxSamples:T}}function JN(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new cn,o=new Ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||i!==0||r;return r=d,i=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,p){const m=h.clippingPlanes,v=h.clipIntersection,f=h.clipShadows,g=n.get(h);if(!r||m===null||m.length===0||s&&!f)s?u(null):c();else{const x=s?0:i,y=x*4;let _=g.clippingState||null;l.value=_,_=u(m,d,y,p);for(let I=0;I!==y;++I)_[I]=t[I];g.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,m){const v=h!==null?h.length:0;let f=null;if(v!==0){if(f=l.value,m!==!0||f===null){const g=p+v*4,x=d.matrixWorldInverse;o.getNormalMatrix(x),(f===null||f.length<g)&&(f=new Float32Array(g));for(let y=0,_=p;y!==v;++y,_+=4)a.copy(h[y]).applyMatrix4(x,o),a.normal.toArray(f,_),f[_+3]=a.constant}l.value=f,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,f}}function KN(n){let e=new WeakMap;function t(a,o){return o===Hn?a.mapping=fr:o===Gn&&(a.mapping=Ar),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===Hn||o===Gn)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Pu(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class Ds extends cl{constructor(e=-1,t=1,i=1,r=-1,s=.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=s,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,s,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=s,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 s=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),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}}const Wa=4,zv=[.125,.215,.35,.446,.526,.582],Us=20,Wp=new Ds,kv=new xe;let jp=null,Xp=0,qp=0,Yp=!1;const Os=(1+Math.sqrt(5))/2,ja=1/Os,Hv=[new N(-Os,ja,0),new N(Os,ja,0),new N(-ja,0,Os),new N(ja,0,Os),new N(0,Os,-ja),new N(0,Os,ja),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)];let Ou=class{constructor(n){this._renderer=n,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(n,e=0,t=.1,i=100){jp=this._renderer.getRenderTarget(),Xp=this._renderer.getActiveCubeFace(),qp=this._renderer.getActiveMipmapLevel(),Yp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(n,t,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(n,e=null){return this._fromTexture(n,e)}fromCubemap(n,e=null){return this._fromTexture(n,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Xv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jv(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(n){this._lodMax=Math.floor(Math.log2(n)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let n=0;n<this._lodPlanes.length;n++)this._lodPlanes[n].dispose()}_cleanup(n){this._renderer.setRenderTarget(jp,Xp,qp),this._renderer.xr.enabled=Yp,n.scissorTest=!1,Fu(n,0,0,n.width,n.height)}_fromTexture(n,e){n.mapping===fr||n.mapping===Ar?this._setSize(n.image.length===0?16:n.image[0].width||n.image[0].image.width):this._setSize(n.image.width/4),jp=this._renderer.getRenderTarget(),Xp=this._renderer.getActiveCubeFace(),qp=this._renderer.getActiveMipmapLevel(),Yp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const t=e||this._allocateTargets();return this._textureToCubeUV(n,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(){const n=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,t={magFilter:Lt,minFilter:Lt,generateMipmaps:!1,type:wi,format:Ei,colorSpace:nr,depthBuffer:!1},i=Wv(n,e,t),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Gv(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==n||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Wv(n,e,t);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Gv(s)),this._blurMaterial=ZN(s,n,e)}return i}_compileMaterial(n){const e=new Ft(this._lodPlanes[0],n);this._renderer.compile(e,Wp)}_sceneToCubeUV(n,e,t,i){const r=new di(90,1,e,t),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(kv),o.toneMapping=mr,o.autoClear=!1;const u=new $r({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1}),h=new Ft(new _n,u);let d=!1;const p=n.background;p?p.isColor&&(u.color.copy(p),n.background=null,d=!0):(u.color.copy(kv),d=!0);for(let m=0;m<6;m++){const v=m%3;v===0?(r.up.set(0,s[m],0),r.lookAt(a[m],0,0)):v===1?(r.up.set(0,0,s[m]),r.lookAt(0,a[m],0)):(r.up.set(0,s[m],0),r.lookAt(0,0,a[m]));const f=this._cubeSize;Fu(i,v*f,m>2?f:0,f,f),o.setRenderTarget(i),d&&o.render(h,r),o.render(n,r)}h.geometry.dispose(),h.material.dispose(),o.toneMapping=c,o.autoClear=l,n.background=p}_textureToCubeUV(n,e){const t=this._renderer,i=n.mapping===fr||n.mapping===Ar;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Xv()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jv());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ft(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=n;const o=this._cubeSize;Fu(e,0,0,3*o,2*o),t.setRenderTarget(e),t.render(s,Wp)}_applyPMREM(n){const e=this._renderer,t=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const s=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Hv[(i-r-1)%Hv.length];this._blur(n,r-1,r,s,a)}e.autoClear=t}_blur(n,e,t,i,r){const s=this._pingPongRenderTarget;this._halfBlur(n,s,e,t,i,"latitudinal",r),this._halfBlur(s,n,t,t,i,"longitudinal",r)}_halfBlur(n,e,t,i,r,s,a){const o=this._renderer,l=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const c=3,u=new Ft(this._lodPlanes[i],l),h=l.uniforms,d=this._sizeLods[t]-1,p=isFinite(r)?Math.PI/(2*d):2*Math.PI/(2*Us-1),m=r/p,v=isFinite(r)?1+Math.floor(c*m):Us;v>Us&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Us}`);const f=[];let g=0;for(let T=0;T<Us;++T){const w=T/m,C=Math.exp(-w*w/2);f.push(C),T===0?g+=C:T<v&&(g+=2*C)}for(let T=0;T<f.length;T++)f[T]=f[T]/g;h.envMap.value=n.texture,h.samples.value=v,h.weights.value=f,h.latitudinal.value=s==="latitudinal",a&&(h.poleAxis.value=a);const{_lodMax:x}=this;h.dTheta.value=p,h.mipInt.value=x-t;const y=this._sizeLods[i],_=3*y*(i>x-Wa?i-x+Wa:0),I=4*(this._cubeSize-y);Fu(e,_,I,3*y,2*y),o.setRenderTarget(e),o.render(u,Wp)}};function Gv(n){const e=[],t=[],i=[];let r=n;const s=n-Wa+1+zv.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>n-Wa?l=zv[a-n+Wa-1]:a===0&&(l=0),i.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,m=6,v=3,f=2,g=1,x=new Float32Array(v*m*p),y=new Float32Array(f*m*p),_=new Float32Array(g*m*p);for(let T=0;T<p;T++){const w=T%3*2/3-1,C=T>2?0:-1,H=[w,C,0,w+2/3,C,0,w+2/3,C+1,0,w,C,0,w+2/3,C+1,0,w,C+1,0];x.set(H,v*m*T),y.set(d,f*m*T);const M=[T,T,T,T,T,T];_.set(M,g*m*T)}const I=new ct;I.setAttribute("position",new wt(x,v)),I.setAttribute("uv",new wt(y,f)),I.setAttribute("faceIndex",new wt(_,g)),e.push(I),r>Wa&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Wv(n,e,t){const i=new Ir(n,e,t);return i.texture.mapping=Wn,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Fu(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function ZN(n,e,t){const i=new Float32Array(Us),r=new N(0,1,0);return new Pr({name:"SphericalGaussianBlur",defines:{n:Us,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:$p(),fragmentShader:`
|
|
3592
3592
|
|
|
3593
3593
|
precision mediump float;
|
|
3594
3594
|
precision mediump int;
|
|
@@ -3648,7 +3648,7 @@ void main() {
|
|
|
3648
3648
|
}
|
|
3649
3649
|
|
|
3650
3650
|
}
|
|
3651
|
-
`,blending:Er,depthTest:!1,depthWrite:!1})}function
|
|
3651
|
+
`,blending:Er,depthTest:!1,depthWrite:!1})}function jv(){return new Pr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:$p(),fragmentShader:`
|
|
3652
3652
|
|
|
3653
3653
|
precision mediump float;
|
|
3654
3654
|
precision mediump int;
|
|
@@ -3667,7 +3667,7 @@ void main() {
|
|
|
3667
3667
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3668
3668
|
|
|
3669
3669
|
}
|
|
3670
|
-
`,blending:Er,depthTest:!1,depthWrite:!1})}function
|
|
3670
|
+
`,blending:Er,depthTest:!1,depthWrite:!1})}function Xv(){return new Pr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:$p(),fragmentShader:`
|
|
3671
3671
|
|
|
3672
3672
|
precision mediump float;
|
|
3673
3673
|
precision mediump int;
|
|
@@ -3683,7 +3683,7 @@ void main() {
|
|
|
3683
3683
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3684
3684
|
|
|
3685
3685
|
}
|
|
3686
|
-
`,blending:Er,depthTest:!1,depthWrite:!1})}function
|
|
3686
|
+
`,blending:Er,depthTest:!1,depthWrite:!1})}function $p(){return`
|
|
3687
3687
|
|
|
3688
3688
|
precision mediump float;
|
|
3689
3689
|
precision mediump int;
|
|
@@ -3738,16 +3738,16 @@ void main() {
|
|
|
3738
3738
|
gl_Position = vec4( position, 1.0 );
|
|
3739
3739
|
|
|
3740
3740
|
}
|
|
3741
|
-
`}function QN(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===kn||l===Hn,u=l===fr||l===Ar;if(c||u){let h=e.get(o);const d=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Uu(n)),h=c?t.fromEquirectangular(o,h):t.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const p=o.image;return c&&p&&p.height>0||u&&p&&r(p)?(t=new Uu(n),h=c?t.fromEquirectangular(o):t.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",s),h.texture):null}}}return o}function r(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function eC(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.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&&uu("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function tC(n,e,t,i){const r={},s=new WeakMap;function a(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const m in d.attributes)e.remove(d.attributes[m]);for(const m in d.morphAttributes){const v=d.morphAttributes[m];for(let f=0,g=v.length;f<g;f++)e.remove(v[f])}d.removeEventListener("dispose",a),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const m in d)e.update(d[m],n.ARRAY_BUFFER);const p=h.morphAttributes;for(const m in p){const v=p[m];for(let f=0,g=v.length;f<g;f++)e.update(v[f],n.ARRAY_BUFFER)}}function c(h){const d=[],p=h.index,m=h.attributes.position;let v=0;if(p!==null){const x=p.array;v=p.version;for(let y=0,_=x.length;y<_;y+=3){const I=x[y+0],T=x[y+1],w=x[y+2];d.push(I,T,T,w,w,I)}}else if(m!==void 0){const x=m.array;v=m.version;for(let y=0,_=x.length/3-1;y<_;y+=3){const I=y+0,T=y+1,w=y+2;d.push(I,T,T,w,w,I)}}else return;const f=new(mv(d)?Vp:Mu)(d,1);f.version=v;const g=s.get(h);g&&e.remove(g),s.set(h,f)}function u(h){const d=s.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function iC(n,e,t){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,p){n.drawElements(i,p,s,d*a),t.update(p,i,1)}function c(d,p,m){m!==0&&(n.drawElementsInstanced(i,p,s,d*a,m),t.update(p,i,m))}function u(d,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,s,d,0,m);let v=0;for(let f=0;f<m;f++)v+=p[f];t.update(v,i,1)}function h(d,p,m,v){if(m===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<d.length;g++)c(d[g]/a,p[g],v[g]);else{f.multiDrawElementsInstancedWEBGL(i,p,0,s,d,0,v,0,m);let g=0;for(let x=0;x<m;x++)g+=p[x];for(let x=0;x<v.length;x++)t.update(g,i,v[x])}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function rC(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:console.error("THREE.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 nC(n,e,t){const i=new WeakMap,r=new st;function s(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=i.get(o);if(d===void 0||d.count!==h){let p=function(){C.dispose(),i.delete(o),o.removeEventListener("dispose",p)};d!==void 0&&d.texture.dispose();const m=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,f=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],x=o.morphAttributes.normal||[],y=o.morphAttributes.color||[];let _=0;m===!0&&(_=1),v===!0&&(_=2),f===!0&&(_=3);let I=o.attributes.position.count*_,T=1;I>e.maxTextureSize&&(T=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const w=new Float32Array(I*T*4*h),C=new tl(w,I,T,h);C.type=Oi,C.needsUpdate=!0;const H=_*4;for(let M=0;M<h;M++){const b=g[M],k=x[M],j=y[M],Y=I*T*4*M;for(let re=0;re<b.count;re++){const $=re*H;m===!0&&(r.fromBufferAttribute(b,re),w[Y+$+0]=r.x,w[Y+$+1]=r.y,w[Y+$+2]=r.z,w[Y+$+3]=0),v===!0&&(r.fromBufferAttribute(k,re),w[Y+$+4]=r.x,w[Y+$+5]=r.y,w[Y+$+6]=r.z,w[Y+$+7]=0),f===!0&&(r.fromBufferAttribute(j,re),w[Y+$+8]=r.x,w[Y+$+9]=r.y,w[Y+$+10]=r.z,w[Y+$+11]=j.itemSize===4?r.w:1)}}d={count:h,texture:C,size:new J(I,T)},i.set(o,d),o.addEventListener("dispose",p)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const m=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",m),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:s}}function sC(n,e,t,i){let r=new WeakMap;function s(l){const c=i.render.frame,u=l.geometry,h=e.get(l,u);if(r.get(h)!==c&&(e.update(h),r.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return h}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}class Os extends Wt{constructor(e,t,i,r,s,a,o,l,c,u=qn){if(u!==qn&&u!==Yn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===qn&&(i=Nr),i===void 0&&u===Yn&&(i=Xn),super(null,r,s,a,o,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:$t,this.minFilter=l!==void 0?l:$t,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const Xv=new Wt,qv=new Os(1,1),Yv=new tl,$v=new hu,Jv=new Rs,Kv=[],Zv=[],Qv=new Float32Array(16),ey=new Float32Array(9),ty=new Float32Array(4);function ja(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=Kv[r];if(s===void 0&&(s=new Float32Array(r),Kv[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function pi(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function mi(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Fu(n,e){let t=Zv[e];t===void 0&&(t=new Int32Array(e),Zv[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function aC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function oC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2fv(this.addr,e),mi(t,e)}}function lC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.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)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(pi(t,e))return;n.uniform3fv(this.addr,e),mi(t,e)}}function cC(n,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)&&(n.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(pi(t,e))return;n.uniform4fv(this.addr,e),mi(t,e)}}function uC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;ty.set(i),n.uniformMatrix2fv(this.addr,!1,ty),mi(t,i)}}function hC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;ey.set(i),n.uniformMatrix3fv(this.addr,!1,ey),mi(t,i)}}function dC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;Qv.set(i),n.uniformMatrix4fv(this.addr,!1,Qv),mi(t,i)}}function pC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function mC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2iv(this.addr,e),mi(t,e)}}function fC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pi(t,e))return;n.uniform3iv(this.addr,e),mi(t,e)}}function gC(n,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)&&(n.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(pi(t,e))return;n.uniform4iv(this.addr,e),mi(t,e)}}function vC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function yC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2uiv(this.addr,e),mi(t,e)}}function xC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pi(t,e))return;n.uniform3uiv(this.addr,e),mi(t,e)}}function _C(n,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)&&(n.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(pi(t,e))return;n.uniform4uiv(this.addr,e),mi(t,e)}}function MC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(qv.compareFunction=yp,s=qv):s=Xv,t.setTexture2D(e||s,r)}function TC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||$v,r)}function bC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Jv,r)}function SC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Yv,r)}function wC(n){switch(n){case 5126:return aC;case 35664:return oC;case 35665:return lC;case 35666:return cC;case 35674:return uC;case 35675:return hC;case 35676:return dC;case 5124:case 35670:return pC;case 35667:case 35671:return mC;case 35668:case 35672:return fC;case 35669:case 35673:return gC;case 5125:return vC;case 36294:return yC;case 36295:return xC;case 36296:return _C;case 35678:case 36198:case 36298:case 36306:case 35682:return MC;case 35679:case 36299:case 36307:return TC;case 35680:case 36300:case 36308:case 36293:return bC;case 36289:case 36303:case 36311:case 36292:return SC}}function EC(n,e){n.uniform1fv(this.addr,e)}function AC(n,e){const t=ja(e,this.size,2);n.uniform2fv(this.addr,t)}function NC(n,e){const t=ja(e,this.size,3);n.uniform3fv(this.addr,t)}function CC(n,e){const t=ja(e,this.size,4);n.uniform4fv(this.addr,t)}function RC(n,e){const t=ja(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function IC(n,e){const t=ja(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function LC(n,e){const t=ja(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function PC(n,e){n.uniform1iv(this.addr,e)}function DC(n,e){n.uniform2iv(this.addr,e)}function UC(n,e){n.uniform3iv(this.addr,e)}function OC(n,e){n.uniform4iv(this.addr,e)}function FC(n,e){n.uniform1uiv(this.addr,e)}function VC(n,e){n.uniform2uiv(this.addr,e)}function BC(n,e){n.uniform3uiv(this.addr,e)}function zC(n,e){n.uniform4uiv(this.addr,e)}function kC(n,e,t){const i=this.cache,r=e.length,s=Fu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Xv,s[a])}function HC(n,e,t){const i=this.cache,r=e.length,s=Fu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||$v,s[a])}function GC(n,e,t){const i=this.cache,r=e.length,s=Fu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Jv,s[a])}function WC(n,e,t){const i=this.cache,r=e.length,s=Fu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Yv,s[a])}function jC(n){switch(n){case 5126:return EC;case 35664:return AC;case 35665:return NC;case 35666:return CC;case 35674:return RC;case 35675:return IC;case 35676:return LC;case 5124:case 35670:return PC;case 35667:case 35671:return DC;case 35668:case 35672:return UC;case 35669:case 35673:return OC;case 5125:return FC;case 36294:return VC;case 36295:return BC;case 36296:return zC;case 35678:case 36198:case 36298:case 36306:case 35682:return kC;case 35679:case 36299:case 36307:return HC;case 35680:case 36300:case 36308:case 36293:return GC;case 36289:case 36303:case 36311:case 36292:return WC}}class XC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=wC(t.type)}}class qC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=jC(t.type)}}class YC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],i)}}}const $p=/(\w+)(\])?(\[|\.)?/g;function iy(n,e){n.seq.push(e),n.map[e.id]=e}function $C(n,e,t){const i=n.name,r=i.length;for($p.lastIndex=0;;){const s=$p.exec(i),a=$p.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){iy(t,c===void 0?new XC(o,n,e):new qC(o,n,e));break}else{let u=t.map[o];u===void 0&&(u=new YC(o),iy(t,u)),t=u}}}class Vu{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);$C(s,a,this)}}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.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 s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function ry(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const JC=37297;let KC=0;function ZC(n,e){const t=n.split(`
|
|
3741
|
+
`}function QN(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===Hn||l===Gn,u=l===fr||l===Ar;if(c||u){let h=e.get(o);const d=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Ou(n)),h=c?t.fromEquirectangular(o,h):t.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const p=o.image;return c&&p&&p.height>0||u&&p&&r(p)?(t=new Ou(n),h=c?t.fromEquirectangular(o):t.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",s),h.texture):null}}}return o}function r(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function eC(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.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&&hu("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function tC(n,e,t,i){const r={},s=new WeakMap;function a(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const m in d.attributes)e.remove(d.attributes[m]);for(const m in d.morphAttributes){const v=d.morphAttributes[m];for(let f=0,g=v.length;f<g;f++)e.remove(v[f])}d.removeEventListener("dispose",a),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const m in d)e.update(d[m],n.ARRAY_BUFFER);const p=h.morphAttributes;for(const m in p){const v=p[m];for(let f=0,g=v.length;f<g;f++)e.update(v[f],n.ARRAY_BUFFER)}}function c(h){const d=[],p=h.index,m=h.attributes.position;let v=0;if(p!==null){const x=p.array;v=p.version;for(let y=0,_=x.length;y<_;y+=3){const I=x[y+0],T=x[y+1],w=x[y+2];d.push(I,T,T,w,w,I)}}else if(m!==void 0){const x=m.array;v=m.version;for(let y=0,_=x.length/3-1;y<_;y+=3){const I=y+0,T=y+1,w=y+2;d.push(I,T,T,w,w,I)}}else return;const f=new(fv(d)?Bp:Tu)(d,1);f.version=v;const g=s.get(h);g&&e.remove(g),s.set(h,f)}function u(h){const d=s.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function iC(n,e,t){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,p){n.drawElements(i,p,s,d*a),t.update(p,i,1)}function c(d,p,m){m!==0&&(n.drawElementsInstanced(i,p,s,d*a,m),t.update(p,i,m))}function u(d,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,s,d,0,m);let v=0;for(let f=0;f<m;f++)v+=p[f];t.update(v,i,1)}function h(d,p,m,v){if(m===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<d.length;g++)c(d[g]/a,p[g],v[g]);else{f.multiDrawElementsInstancedWEBGL(i,p,0,s,d,0,v,0,m);let g=0;for(let x=0;x<m;x++)g+=p[x];for(let x=0;x<v.length;x++)t.update(g,i,v[x])}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function rC(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:console.error("THREE.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 nC(n,e,t){const i=new WeakMap,r=new st;function s(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=i.get(o);if(d===void 0||d.count!==h){let p=function(){C.dispose(),i.delete(o),o.removeEventListener("dispose",p)};d!==void 0&&d.texture.dispose();const m=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,f=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],x=o.morphAttributes.normal||[],y=o.morphAttributes.color||[];let _=0;m===!0&&(_=1),v===!0&&(_=2),f===!0&&(_=3);let I=o.attributes.position.count*_,T=1;I>e.maxTextureSize&&(T=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const w=new Float32Array(I*T*4*h),C=new il(w,I,T,h);C.type=Oi,C.needsUpdate=!0;const H=_*4;for(let M=0;M<h;M++){const b=g[M],k=x[M],j=y[M],Y=I*T*4*M;for(let re=0;re<b.count;re++){const $=re*H;m===!0&&(r.fromBufferAttribute(b,re),w[Y+$+0]=r.x,w[Y+$+1]=r.y,w[Y+$+2]=r.z,w[Y+$+3]=0),v===!0&&(r.fromBufferAttribute(k,re),w[Y+$+4]=r.x,w[Y+$+5]=r.y,w[Y+$+6]=r.z,w[Y+$+7]=0),f===!0&&(r.fromBufferAttribute(j,re),w[Y+$+8]=r.x,w[Y+$+9]=r.y,w[Y+$+10]=r.z,w[Y+$+11]=j.itemSize===4?r.w:1)}}d={count:h,texture:C,size:new J(I,T)},i.set(o,d),o.addEventListener("dispose",p)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const m=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",m),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:s}}function sC(n,e,t,i){let r=new WeakMap;function s(l){const c=i.render.frame,u=l.geometry,h=e.get(l,u);if(r.get(h)!==c&&(e.update(h),r.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return h}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}class Fs extends Wt{constructor(e,t,i,r,s,a,o,l,c,u=Yn){if(u!==Yn&&u!==$n)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Yn&&(i=Nr),i===void 0&&u===$n&&(i=qn),super(null,r,s,a,o,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:$t,this.minFilter=l!==void 0?l:$t,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const qv=new Wt,Yv=new Fs(1,1),$v=new il,Jv=new du,Kv=new Is,Zv=[],Qv=[],ey=new Float32Array(16),ty=new Float32Array(9),iy=new Float32Array(4);function Xa(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=Zv[r];if(s===void 0&&(s=new Float32Array(r),Zv[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function pi(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function mi(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Vu(n,e){let t=Qv[e];t===void 0&&(t=new Int32Array(e),Qv[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function aC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function oC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2fv(this.addr,e),mi(t,e)}}function lC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.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)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(pi(t,e))return;n.uniform3fv(this.addr,e),mi(t,e)}}function cC(n,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)&&(n.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(pi(t,e))return;n.uniform4fv(this.addr,e),mi(t,e)}}function uC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;iy.set(i),n.uniformMatrix2fv(this.addr,!1,iy),mi(t,i)}}function hC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;ty.set(i),n.uniformMatrix3fv(this.addr,!1,ty),mi(t,i)}}function dC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;ey.set(i),n.uniformMatrix4fv(this.addr,!1,ey),mi(t,i)}}function pC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function mC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2iv(this.addr,e),mi(t,e)}}function fC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pi(t,e))return;n.uniform3iv(this.addr,e),mi(t,e)}}function gC(n,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)&&(n.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(pi(t,e))return;n.uniform4iv(this.addr,e),mi(t,e)}}function vC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function yC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2uiv(this.addr,e),mi(t,e)}}function xC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pi(t,e))return;n.uniform3uiv(this.addr,e),mi(t,e)}}function _C(n,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)&&(n.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(pi(t,e))return;n.uniform4uiv(this.addr,e),mi(t,e)}}function MC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(Yv.compareFunction=xp,s=Yv):s=qv,t.setTexture2D(e||s,r)}function TC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Jv,r)}function bC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Kv,r)}function SC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||$v,r)}function wC(n){switch(n){case 5126:return aC;case 35664:return oC;case 35665:return lC;case 35666:return cC;case 35674:return uC;case 35675:return hC;case 35676:return dC;case 5124:case 35670:return pC;case 35667:case 35671:return mC;case 35668:case 35672:return fC;case 35669:case 35673:return gC;case 5125:return vC;case 36294:return yC;case 36295:return xC;case 36296:return _C;case 35678:case 36198:case 36298:case 36306:case 35682:return MC;case 35679:case 36299:case 36307:return TC;case 35680:case 36300:case 36308:case 36293:return bC;case 36289:case 36303:case 36311:case 36292:return SC}}function EC(n,e){n.uniform1fv(this.addr,e)}function AC(n,e){const t=Xa(e,this.size,2);n.uniform2fv(this.addr,t)}function NC(n,e){const t=Xa(e,this.size,3);n.uniform3fv(this.addr,t)}function CC(n,e){const t=Xa(e,this.size,4);n.uniform4fv(this.addr,t)}function RC(n,e){const t=Xa(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function IC(n,e){const t=Xa(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function LC(n,e){const t=Xa(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function PC(n,e){n.uniform1iv(this.addr,e)}function DC(n,e){n.uniform2iv(this.addr,e)}function UC(n,e){n.uniform3iv(this.addr,e)}function OC(n,e){n.uniform4iv(this.addr,e)}function FC(n,e){n.uniform1uiv(this.addr,e)}function VC(n,e){n.uniform2uiv(this.addr,e)}function BC(n,e){n.uniform3uiv(this.addr,e)}function zC(n,e){n.uniform4uiv(this.addr,e)}function kC(n,e,t){const i=this.cache,r=e.length,s=Vu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||qv,s[a])}function HC(n,e,t){const i=this.cache,r=e.length,s=Vu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Jv,s[a])}function GC(n,e,t){const i=this.cache,r=e.length,s=Vu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Kv,s[a])}function WC(n,e,t){const i=this.cache,r=e.length,s=Vu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||$v,s[a])}function jC(n){switch(n){case 5126:return EC;case 35664:return AC;case 35665:return NC;case 35666:return CC;case 35674:return RC;case 35675:return IC;case 35676:return LC;case 5124:case 35670:return PC;case 35667:case 35671:return DC;case 35668:case 35672:return UC;case 35669:case 35673:return OC;case 5125:return FC;case 36294:return VC;case 36295:return BC;case 36296:return zC;case 35678:case 36198:case 36298:case 36306:case 35682:return kC;case 35679:case 36299:case 36307:return HC;case 35680:case 36300:case 36308:case 36293:return GC;case 36289:case 36303:case 36311:case 36292:return WC}}class XC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=wC(t.type)}}class qC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=jC(t.type)}}class YC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],i)}}}const Jp=/(\w+)(\])?(\[|\.)?/g;function ry(n,e){n.seq.push(e),n.map[e.id]=e}function $C(n,e,t){const i=n.name,r=i.length;for(Jp.lastIndex=0;;){const s=Jp.exec(i),a=Jp.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){ry(t,c===void 0?new XC(o,n,e):new qC(o,n,e));break}else{let u=t.map[o];u===void 0&&(u=new YC(o),ry(t,u)),t=u}}}class Bu{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);$C(s,a,this)}}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.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 s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function ny(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const JC=37297;let KC=0;function ZC(n,e){const t=n.split(`
|
|
3742
3742
|
`),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
|
3743
|
-
`)}function QC(n){const e=vt.getPrimaries(vt.workingColorSpace),t=vt.getPrimaries(n);let i;switch(e===t?i="":e===
|
|
3743
|
+
`)}function QC(n){const e=vt.getPrimaries(vt.workingColorSpace),t=vt.getPrimaries(n);let i;switch(e===t?i="":e===Zo&&t===Ko?i="LinearDisplayP3ToLinearSRGB":e===Ko&&t===Zo&&(i="LinearSRGBToLinearDisplayP3"),n){case nr:case $o:return[i,"LinearTransferOETF"];case Fi:case ou:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function sy(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
|
|
3744
3744
|
|
|
3745
3745
|
`+r+`
|
|
3746
3746
|
|
|
3747
|
-
`+ZC(n.getShaderSource(e),a)}else return r}function eR(n,e){const t=QC(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function tR(n,e){let t;switch(e){case
|
|
3748
|
-
`)}function rR(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(
|
|
3747
|
+
`+ZC(n.getShaderSource(e),a)}else return r}function eR(n,e){const t=QC(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function tR(n,e){let t;switch(e){case Ac:t="Linear";break;case Nc:t="Reinhard";break;case rp:t="Cineon";break;case Cc:t="ACESFilmic";break;case Rc:t="AgX";break;case Ic:t="Neutral";break;case k0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const zu=new N;function iR(){vt.getLuminanceCoefficients(zu);const n=zu.x.toFixed(4),e=zu.y.toFixed(4),t=zu.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
3748
|
+
`)}function rR(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ul).join(`
|
|
3749
3749
|
`)}function nR(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
3750
|
-
`)}function sR(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),a=s.name;let o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function
|
|
3750
|
+
`)}function sR(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),a=s.name;let o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function ul(n){return n!==""}function ay(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.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 oy(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const aR=/^[ \t]*#include +<([\w\d./]+)>/gm;function Kp(n){return n.replace(aR,lR)}const oR=new Map;function lR(n,e){let t=dt[e];if(t===void 0){const i=oR.get(e);if(i!==void 0)t=dt[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Kp(t)}const cR=/#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 ly(n){return n.replace(cR,uR)}function uR(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function cy(n){let e=`precision ${n.precision} float;
|
|
3751
3751
|
precision ${n.precision} int;
|
|
3752
3752
|
precision ${n.precision} sampler2D;
|
|
3753
3753
|
precision ${n.precision} samplerCube;
|
|
@@ -3767,28 +3767,28 @@ void main() {
|
|
|
3767
3767
|
`;return n.precision==="highp"?e+=`
|
|
3768
3768
|
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
|
|
3769
3769
|
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
|
|
3770
|
-
#define LOW_PRECISION`),e}function hR(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType
|
|
3771
|
-
`:"";t.isRawShaderMaterial?(f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(
|
|
3770
|
+
#define LOW_PRECISION`),e}function hR(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===$d?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===Jd?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===rr&&(e="SHADOWMAP_TYPE_VSM"),e}function dR(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case fr:case Ar:e="ENVMAP_TYPE_CUBE";break;case Wn:e="ENVMAP_TYPE_CUBE_UV";break}return e}function pR(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Ar&&(e="ENVMAP_MODE_REFRACTION"),e}function mR(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case fa:e="ENVMAP_BLENDING_MULTIPLY";break;case tp:e="ENVMAP_BLENDING_MIX";break;case ip:e="ENVMAP_BLENDING_ADD";break}return e}function fR(n){const e=n.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 gR(n,e,t,i){const r=n.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=hR(t),c=dR(t),u=pR(t),h=mR(t),d=fR(t),p=rR(t),m=nR(s),v=r.createProgram();let f,g,x=t.glslVersion?"#version "+t.glslVersion+`
|
|
3771
|
+
`:"";t.isRawShaderMaterial?(f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(ul).join(`
|
|
3772
3772
|
`),f.length>0&&(f+=`
|
|
3773
|
-
`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(
|
|
3773
|
+
`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(ul).join(`
|
|
3774
3774
|
`),g.length>0&&(g+=`
|
|
3775
|
-
`)):(f=[
|
|
3776
|
-
`].filter(
|
|
3777
|
-
`),g=[
|
|
3778
|
-
`].filter(
|
|
3779
|
-
`)),a=
|
|
3775
|
+
`)):(f=[cy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",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.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",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.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#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.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
3776
|
+
`].filter(ul).join(`
|
|
3777
|
+
`),g=[cy(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 "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#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.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==mr?"#define TONE_MAPPING":"",t.toneMapping!==mr?dt.tonemapping_pars_fragment:"",t.toneMapping!==mr?tR("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",dt.colorspace_pars_fragment,eR("linearToOutputTexel",t.outputColorSpace),iR(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
3778
|
+
`].filter(ul).join(`
|
|
3779
|
+
`)),a=Kp(a),a=ay(a,t),a=oy(a,t),o=Kp(o),o=ay(o,t),o=oy(o,t),a=ly(a),o=ly(o),t.isRawShaderMaterial!==!0&&(x=`#version 300 es
|
|
3780
3780
|
`,f=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3781
3781
|
`)+`
|
|
3782
|
-
`+f,g=["#define varying in",t.glslVersion===
|
|
3782
|
+
`+f,g=["#define varying in",t.glslVersion===cu?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===cu?"":"#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(`
|
|
3783
3783
|
`)+`
|
|
3784
|
-
`+g);const y=x+f+a,_=x+g+o,I=
|
|
3784
|
+
`+g);const y=x+f+a,_=x+g+o,I=ny(r,r.VERTEX_SHADER,y),T=ny(r,r.FRAGMENT_SHADER,_);r.attachShader(v,I),r.attachShader(v,T),t.index0AttributeName!==void 0?r.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function w(b){if(n.debug.checkShaderErrors){const k=r.getProgramInfoLog(v).trim(),j=r.getShaderInfoLog(I).trim(),Y=r.getShaderInfoLog(T).trim();let re=!0,$=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(re=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,v,I,T);else{const he=sy(r,I,"vertex"),Q=sy(r,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
|
|
3785
3785
|
|
|
3786
3786
|
Material Name: `+b.name+`
|
|
3787
3787
|
Material Type: `+b.type+`
|
|
3788
3788
|
|
|
3789
3789
|
Program Info Log: `+k+`
|
|
3790
3790
|
`+he+`
|
|
3791
|
-
`+Q)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(j===""||Y==="")&&($=!1);$&&(b.diagnostics={runnable:re,programLog:k,vertexShader:{log:j,prefix:f},fragmentShader:{log:Y,prefix:g}})}r.deleteShader(I),r.deleteShader(T),C=new Vu(r,v),H=sR(r,v)}let C;this.getUniforms=function(){return C===void 0&&w(this),C};let H;this.getAttributes=function(){return H===void 0&&w(this),H};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,JC)),M},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=KC++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=I,this.fragmentShader=T,this}let vR=0;class yR{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.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 xR(e),t.set(e,i)),i}}class xR{constructor(e){this.id=vR++,this.code=e,this.usedTimes=0}}function _R(n,e,t,i,r,s,a){const o=new nl,l=new yR,c=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.reverseDepthBuffer,p=r.vertexTextures;let m=r.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 f(M){return c.add(M),M===0?"uv":`uv${M}`}function g(M,b,k,j,Y){const re=j.fog,$=Y.geometry,he=M.isMeshStandardMaterial?j.environment:null,Q=(M.isMeshStandardMaterial?t:e).get(M.envMap||he),ye=Q&&Q.mapping===Gn?Q.image.height:null,Te=v[M.type];M.precision!==null&&(m=r.getMaxPrecision(M.precision),m!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",m,"instead."));const Ve=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,at=Ve!==void 0?Ve.length:0;let et=0;$.morphAttributes.position!==void 0&&(et=1),$.morphAttributes.normal!==void 0&&(et=2),$.morphAttributes.color!==void 0&&(et=3);let ie,le,be,Se;if(Te){const ir=Dr[Te];ie=ir.vertexShader,le=ir.fragmentShader}else ie=M.vertexShader,le=M.fragmentShader,l.update(M),be=l.getVertexShaderID(M),Se=l.getFragmentShaderID(M);const Ye=n.getRenderTarget(),We=Y.isInstancedMesh===!0,ot=Y.isBatchedMesh===!0,ce=!!M.map,ue=!!M.matcap,L=!!Q,He=!!M.aoMap,pe=!!M.lightMap,Ue=!!M.bumpMap,we=!!M.normalMap,$e=!!M.displacementMap,Be=!!M.emissiveMap,R=!!M.metalnessMap,S=!!M.roughnessMap,W=M.anisotropy>0,ne=M.clearcoat>0,de=M.dispersion>0,se=M.iridescence>0,ke=M.sheen>0,Ee=M.transmission>0,Pe=W&&!!M.anisotropyMap,mt=ne&&!!M.clearcoatMap,ve=ne&&!!M.clearcoatNormalMap,ze=ne&&!!M.clearcoatRoughnessMap,tt=se&&!!M.iridescenceMap,it=se&&!!M.iridescenceThicknessMap,Oe=ke&&!!M.sheenColorMap,Mt=ke&&!!M.sheenRoughnessMap,ut=!!M.specularMap,Dt=!!M.specularColorMap,O=!!M.specularIntensityMap,Ce=Ee&&!!M.transmissionMap,ee=Ee&&!!M.thicknessMap,oe=!!M.gradientMap,Ne=!!M.alphaMap,Ae=M.alphaTest>0,Ut=!!M.alphaHash,ni=!!M.extensions;let tr=mr;M.toneMapped&&(Ye===null||Ye.isXRRenderTarget===!0)&&(tr=n.toneMapping);const At={shaderID:Te,shaderType:M.type,shaderName:M.name,vertexShader:ie,fragmentShader:le,defines:M.defines,customVertexShaderID:be,customFragmentShaderID:Se,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:m,batching:ot,batchingColor:ot&&Y._colorsTexture!==null,instancing:We,instancingColor:We&&Y.instanceColor!==null,instancingMorph:We&&Y.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:Ye===null?n.outputColorSpace:Ye.isXRRenderTarget===!0?Ye.texture.colorSpace:nr,alphaToCoverage:!!M.alphaToCoverage,map:ce,matcap:ue,envMap:L,envMapMode:L&&Q.mapping,envMapCubeUVHeight:ye,aoMap:He,lightMap:pe,bumpMap:Ue,normalMap:we,displacementMap:p&&$e,emissiveMap:Be,normalMapObjectSpace:we&&M.normalMapType===gp,normalMapTangentSpace:we&&M.normalMapType===on,metalnessMap:R,roughnessMap:S,anisotropy:W,anisotropyMap:Pe,clearcoat:ne,clearcoatMap:mt,clearcoatNormalMap:ve,clearcoatRoughnessMap:ze,dispersion:de,iridescence:se,iridescenceMap:tt,iridescenceThicknessMap:it,sheen:ke,sheenColorMap:Oe,sheenRoughnessMap:Mt,specularMap:ut,specularColorMap:Dt,specularIntensityMap:O,transmission:Ee,transmissionMap:Ce,thicknessMap:ee,gradientMap:oe,opaque:M.transparent===!1&&M.blending===Tn&&M.alphaToCoverage===!1,alphaMap:Ne,alphaTest:Ae,alphaHash:Ut,combine:M.combine,mapUv:ce&&f(M.map.channel),aoMapUv:He&&f(M.aoMap.channel),lightMapUv:pe&&f(M.lightMap.channel),bumpMapUv:Ue&&f(M.bumpMap.channel),normalMapUv:we&&f(M.normalMap.channel),displacementMapUv:$e&&f(M.displacementMap.channel),emissiveMapUv:Be&&f(M.emissiveMap.channel),metalnessMapUv:R&&f(M.metalnessMap.channel),roughnessMapUv:S&&f(M.roughnessMap.channel),anisotropyMapUv:Pe&&f(M.anisotropyMap.channel),clearcoatMapUv:mt&&f(M.clearcoatMap.channel),clearcoatNormalMapUv:ve&&f(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ze&&f(M.clearcoatRoughnessMap.channel),iridescenceMapUv:tt&&f(M.iridescenceMap.channel),iridescenceThicknessMapUv:it&&f(M.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&f(M.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&f(M.sheenRoughnessMap.channel),specularMapUv:ut&&f(M.specularMap.channel),specularColorMapUv:Dt&&f(M.specularColorMap.channel),specularIntensityMapUv:O&&f(M.specularIntensityMap.channel),transmissionMapUv:Ce&&f(M.transmissionMap.channel),thicknessMapUv:ee&&f(M.thicknessMap.channel),alphaMapUv:Ne&&f(M.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(we||W),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!$.attributes.uv&&(ce||Ne),fog:!!re,useFog:M.fog===!0,fogExp2:!!re&&re.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:d,skinning:Y.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:at,morphTextureStride:et,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&k.length>0,shadowMapType:n.shadowMap.type,toneMapping:tr,decodeVideoTexture:ce&&M.map.isVideoTexture===!0&&vt.getTransfer(M.map.colorSpace)===Ot,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Wr,flipSided:M.side===si,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ni&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ni&&M.extensions.multiDraw===!0||ot)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function x(M){const b=[];if(M.shaderID?b.push(M.shaderID):(b.push(M.customVertexShaderID),b.push(M.customFragmentShaderID)),M.defines!==void 0)for(const k in M.defines)b.push(k),b.push(M.defines[k]);return M.isRawShaderMaterial===!1&&(y(b,M),_(b,M),b.push(n.outputColorSpace)),b.push(M.customProgramCacheKey),b.join()}function y(M,b){M.push(b.precision),M.push(b.outputColorSpace),M.push(b.envMapMode),M.push(b.envMapCubeUVHeight),M.push(b.mapUv),M.push(b.alphaMapUv),M.push(b.lightMapUv),M.push(b.aoMapUv),M.push(b.bumpMapUv),M.push(b.normalMapUv),M.push(b.displacementMapUv),M.push(b.emissiveMapUv),M.push(b.metalnessMapUv),M.push(b.roughnessMapUv),M.push(b.anisotropyMapUv),M.push(b.clearcoatMapUv),M.push(b.clearcoatNormalMapUv),M.push(b.clearcoatRoughnessMapUv),M.push(b.iridescenceMapUv),M.push(b.iridescenceThicknessMapUv),M.push(b.sheenColorMapUv),M.push(b.sheenRoughnessMapUv),M.push(b.specularMapUv),M.push(b.specularColorMapUv),M.push(b.specularIntensityMapUv),M.push(b.transmissionMapUv),M.push(b.thicknessMapUv),M.push(b.combine),M.push(b.fogExp2),M.push(b.sizeAttenuation),M.push(b.morphTargetsCount),M.push(b.morphAttributeCount),M.push(b.numDirLights),M.push(b.numPointLights),M.push(b.numSpotLights),M.push(b.numSpotLightMaps),M.push(b.numHemiLights),M.push(b.numRectAreaLights),M.push(b.numDirLightShadows),M.push(b.numPointLightShadows),M.push(b.numSpotLightShadows),M.push(b.numSpotLightShadowsWithMaps),M.push(b.numLightProbes),M.push(b.shadowMapType),M.push(b.toneMapping),M.push(b.numClippingPlanes),M.push(b.numClipIntersection),M.push(b.depthPacking)}function _(M,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),M.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reverseDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.alphaToCoverage&&o.enable(20),M.push(o.mask)}function I(M){const b=v[M.type];let k;if(b){const j=Dr[b];k=kp.clone(j.uniforms)}else k=M.uniforms;return k}function T(M,b){let k;for(let j=0,Y=u.length;j<Y;j++){const re=u[j];if(re.cacheKey===b){k=re,++k.usedTimes;break}}return k===void 0&&(k=new gR(n,b,M,s),u.push(k)),k}function w(M){if(--M.usedTimes===0){const b=u.indexOf(M);u[b]=u[u.length-1],u.pop(),M.destroy()}}function C(M){l.remove(M)}function H(){l.dispose()}return{getParameters:g,getProgramCacheKey:x,getUniforms:I,acquireProgram:T,releaseProgram:w,releaseShaderCache:C,programs:u,dispose:H}}function MR(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function r(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function TR(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function cy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function uy(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(h,d,p,m,v,f){let g=n[e];return g===void 0?(g={id:h.id,object:h,geometry:d,material:p,groupOrder:m,renderOrder:h.renderOrder,z:v,group:f},n[e]=g):(g.id=h.id,g.object=h,g.geometry=d,g.material=p,g.groupOrder=m,g.renderOrder=h.renderOrder,g.z=v,g.group=f),e++,g}function o(h,d,p,m,v,f){const g=a(h,d,p,m,v,f);p.transmission>0?i.push(g):p.transparent===!0?r.push(g):t.push(g)}function l(h,d,p,m,v,f){const g=a(h,d,p,m,v,f);p.transmission>0?i.unshift(g):p.transparent===!0?r.unshift(g):t.unshift(g)}function c(h,d){t.length>1&&t.sort(h||TR),i.length>1&&i.sort(d||cy),r.length>1&&r.sort(d||cy)}function u(){for(let h=e,d=n.length;h<d;h++){const p=n[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:o,unshift:l,finish:u,sort:c}}function bR(){let n=new WeakMap;function e(i,r){const s=n.get(i);let a;return s===void 0?(a=new uy,n.set(i,[a])):r>=s.length?(a=new uy,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function SR(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new xe};break;case"SpotLight":t={position:new N,direction:new N,color:new xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new xe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new xe,groundColor:new xe};break;case"RectAreaLight":t={color:new xe,position:new N,halfWidth:new N,halfHeight:new N};break}return n[e.id]=t,t}}}function wR(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let ER=0;function AR(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function NR(n){const e=new SR,t=wR(),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 c=0;c<9;c++)i.probe.push(new N);const r=new N,s=new Re,a=new Re;function o(c){let u=0,h=0,d=0;for(let H=0;H<9;H++)i.probe[H].set(0,0,0);let p=0,m=0,v=0,f=0,g=0,x=0,y=0,_=0,I=0,T=0,w=0;c.sort(AR);for(let H=0,M=c.length;H<M;H++){const b=c[H],k=b.color,j=b.intensity,Y=b.distance,re=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)u+=k.r*j,h+=k.g*j,d+=k.b*j;else if(b.isLightProbe){for(let $=0;$<9;$++)i.probe[$].addScaledVector(b.sh.coefficients[$],j);w++}else if(b.isDirectionalLight){const $=e.get(b);if($.color.copy(b.color).multiplyScalar(b.intensity),b.castShadow){const he=b.shadow,Q=t.get(b);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=re,i.directionalShadowMatrix[p]=b.shadow.matrix,x++}i.directional[p]=$,p++}else if(b.isSpotLight){const $=e.get(b);$.position.setFromMatrixPosition(b.matrixWorld),$.color.copy(k).multiplyScalar(j),$.distance=Y,$.coneCos=Math.cos(b.angle),$.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),$.decay=b.decay,i.spot[v]=$;const he=b.shadow;if(b.map&&(i.spotLightMap[I]=b.map,I++,he.updateMatrices(b),b.castShadow&&T++),i.spotLightMatrix[v]=he.matrix,b.castShadow){const Q=t.get(b);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,i.spotShadow[v]=Q,i.spotShadowMap[v]=re,_++}v++}else if(b.isRectAreaLight){const $=e.get(b);$.color.copy(k).multiplyScalar(j),$.halfWidth.set(b.width*.5,0,0),$.halfHeight.set(0,b.height*.5,0),i.rectArea[f]=$,f++}else if(b.isPointLight){const $=e.get(b);if($.color.copy(b.color).multiplyScalar(b.intensity),$.distance=b.distance,$.decay=b.decay,b.castShadow){const he=b.shadow,Q=t.get(b);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,Q.shadowCameraNear=he.camera.near,Q.shadowCameraFar=he.camera.far,i.pointShadow[m]=Q,i.pointShadowMap[m]=re,i.pointShadowMatrix[m]=b.shadow.matrix,y++}i.point[m]=$,m++}else if(b.isHemisphereLight){const $=e.get(b);$.skyColor.copy(b.color).multiplyScalar(j),$.groundColor.copy(b.groundColor).multiplyScalar(j),i.hemi[g]=$,g++}}f>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_FLOAT_1,i.rectAreaLTC2=Me.LTC_FLOAT_2):(i.rectAreaLTC1=Me.LTC_HALF_1,i.rectAreaLTC2=Me.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;const C=i.hash;(C.directionalLength!==p||C.pointLength!==m||C.spotLength!==v||C.rectAreaLength!==f||C.hemiLength!==g||C.numDirectionalShadows!==x||C.numPointShadows!==y||C.numSpotShadows!==_||C.numSpotMaps!==I||C.numLightProbes!==w)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=f,i.point.length=m,i.hemi.length=g,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=_+I-T,i.spotLightMap.length=I,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=w,C.directionalLength=p,C.pointLength=m,C.spotLength=v,C.rectAreaLength=f,C.hemiLength=g,C.numDirectionalShadows=x,C.numPointShadows=y,C.numSpotShadows=_,C.numSpotMaps=I,C.numLightProbes=w,i.version=ER++)}function l(c,u){let h=0,d=0,p=0,m=0,v=0;const f=u.matrixWorldInverse;for(let g=0,x=c.length;g<x;g++){const y=c[g];if(y.isDirectionalLight){const _=i.directional[h];_.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(f),h++}else if(y.isSpotLight){const _=i.spot[p];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),_.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(f),p++}else if(y.isRectAreaLight){const _=i.rectArea[m];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),a.identity(),s.copy(y.matrixWorld),s.premultiply(f),a.extractRotation(s),_.halfWidth.set(y.width*.5,0,0),_.halfHeight.set(0,y.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),m++}else if(y.isPointLight){const _=i.point[d];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),d++}else if(y.isHemisphereLight){const _=i.hemi[v];_.direction.setFromMatrixPosition(y.matrixWorld),_.direction.transformDirection(f),v++}}}return{setup:o,setupView:l,state:i}}function hy(n){const e=new NR(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function a(u){i.push(u)}function o(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function CR(n){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new hy(n),e.set(r,[o])):s>=a.length?(o=new hy(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}class zu extends hi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=mp,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 Kp extends hi{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}}const RR=`void main() {
|
|
3791
|
+
`+Q)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(j===""||Y==="")&&($=!1);$&&(b.diagnostics={runnable:re,programLog:k,vertexShader:{log:j,prefix:f},fragmentShader:{log:Y,prefix:g}})}r.deleteShader(I),r.deleteShader(T),C=new Bu(r,v),H=sR(r,v)}let C;this.getUniforms=function(){return C===void 0&&w(this),C};let H;this.getAttributes=function(){return H===void 0&&w(this),H};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,JC)),M},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=KC++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=I,this.fragmentShader=T,this}let vR=0;class yR{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.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 xR(e),t.set(e,i)),i}}class xR{constructor(e){this.id=vR++,this.code=e,this.usedTimes=0}}function _R(n,e,t,i,r,s,a){const o=new sl,l=new yR,c=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.reverseDepthBuffer,p=r.vertexTextures;let m=r.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 f(M){return c.add(M),M===0?"uv":`uv${M}`}function g(M,b,k,j,Y){const re=j.fog,$=Y.geometry,he=M.isMeshStandardMaterial?j.environment:null,Q=(M.isMeshStandardMaterial?t:e).get(M.envMap||he),ye=Q&&Q.mapping===Wn?Q.image.height:null,Te=v[M.type];M.precision!==null&&(m=r.getMaxPrecision(M.precision),m!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",m,"instead."));const Ve=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,at=Ve!==void 0?Ve.length:0;let et=0;$.morphAttributes.position!==void 0&&(et=1),$.morphAttributes.normal!==void 0&&(et=2),$.morphAttributes.color!==void 0&&(et=3);let ie,le,be,Se;if(Te){const ir=Dr[Te];ie=ir.vertexShader,le=ir.fragmentShader}else ie=M.vertexShader,le=M.fragmentShader,l.update(M),be=l.getVertexShaderID(M),Se=l.getFragmentShaderID(M);const Ye=n.getRenderTarget(),We=Y.isInstancedMesh===!0,ot=Y.isBatchedMesh===!0,ce=!!M.map,ue=!!M.matcap,L=!!Q,He=!!M.aoMap,pe=!!M.lightMap,Ue=!!M.bumpMap,we=!!M.normalMap,$e=!!M.displacementMap,Be=!!M.emissiveMap,R=!!M.metalnessMap,S=!!M.roughnessMap,W=M.anisotropy>0,ne=M.clearcoat>0,de=M.dispersion>0,se=M.iridescence>0,ke=M.sheen>0,Ee=M.transmission>0,Pe=W&&!!M.anisotropyMap,mt=ne&&!!M.clearcoatMap,ve=ne&&!!M.clearcoatNormalMap,ze=ne&&!!M.clearcoatRoughnessMap,tt=se&&!!M.iridescenceMap,it=se&&!!M.iridescenceThicknessMap,Oe=ke&&!!M.sheenColorMap,Mt=ke&&!!M.sheenRoughnessMap,ut=!!M.specularMap,Dt=!!M.specularColorMap,O=!!M.specularIntensityMap,Ce=Ee&&!!M.transmissionMap,ee=Ee&&!!M.thicknessMap,oe=!!M.gradientMap,Ne=!!M.alphaMap,Ae=M.alphaTest>0,Ut=!!M.alphaHash,ni=!!M.extensions;let tr=mr;M.toneMapped&&(Ye===null||Ye.isXRRenderTarget===!0)&&(tr=n.toneMapping);const At={shaderID:Te,shaderType:M.type,shaderName:M.name,vertexShader:ie,fragmentShader:le,defines:M.defines,customVertexShaderID:be,customFragmentShaderID:Se,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:m,batching:ot,batchingColor:ot&&Y._colorsTexture!==null,instancing:We,instancingColor:We&&Y.instanceColor!==null,instancingMorph:We&&Y.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:Ye===null?n.outputColorSpace:Ye.isXRRenderTarget===!0?Ye.texture.colorSpace:nr,alphaToCoverage:!!M.alphaToCoverage,map:ce,matcap:ue,envMap:L,envMapMode:L&&Q.mapping,envMapCubeUVHeight:ye,aoMap:He,lightMap:pe,bumpMap:Ue,normalMap:we,displacementMap:p&&$e,emissiveMap:Be,normalMapObjectSpace:we&&M.normalMapType===vp,normalMapTangentSpace:we&&M.normalMapType===on,metalnessMap:R,roughnessMap:S,anisotropy:W,anisotropyMap:Pe,clearcoat:ne,clearcoatMap:mt,clearcoatNormalMap:ve,clearcoatRoughnessMap:ze,dispersion:de,iridescence:se,iridescenceMap:tt,iridescenceThicknessMap:it,sheen:ke,sheenColorMap:Oe,sheenRoughnessMap:Mt,specularMap:ut,specularColorMap:Dt,specularIntensityMap:O,transmission:Ee,transmissionMap:Ce,thicknessMap:ee,gradientMap:oe,opaque:M.transparent===!1&&M.blending===Tn&&M.alphaToCoverage===!1,alphaMap:Ne,alphaTest:Ae,alphaHash:Ut,combine:M.combine,mapUv:ce&&f(M.map.channel),aoMapUv:He&&f(M.aoMap.channel),lightMapUv:pe&&f(M.lightMap.channel),bumpMapUv:Ue&&f(M.bumpMap.channel),normalMapUv:we&&f(M.normalMap.channel),displacementMapUv:$e&&f(M.displacementMap.channel),emissiveMapUv:Be&&f(M.emissiveMap.channel),metalnessMapUv:R&&f(M.metalnessMap.channel),roughnessMapUv:S&&f(M.roughnessMap.channel),anisotropyMapUv:Pe&&f(M.anisotropyMap.channel),clearcoatMapUv:mt&&f(M.clearcoatMap.channel),clearcoatNormalMapUv:ve&&f(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ze&&f(M.clearcoatRoughnessMap.channel),iridescenceMapUv:tt&&f(M.iridescenceMap.channel),iridescenceThicknessMapUv:it&&f(M.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&f(M.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&f(M.sheenRoughnessMap.channel),specularMapUv:ut&&f(M.specularMap.channel),specularColorMapUv:Dt&&f(M.specularColorMap.channel),specularIntensityMapUv:O&&f(M.specularIntensityMap.channel),transmissionMapUv:Ce&&f(M.transmissionMap.channel),thicknessMapUv:ee&&f(M.thicknessMap.channel),alphaMapUv:Ne&&f(M.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(we||W),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!$.attributes.uv&&(ce||Ne),fog:!!re,useFog:M.fog===!0,fogExp2:!!re&&re.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:d,skinning:Y.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:at,morphTextureStride:et,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&k.length>0,shadowMapType:n.shadowMap.type,toneMapping:tr,decodeVideoTexture:ce&&M.map.isVideoTexture===!0&&vt.getTransfer(M.map.colorSpace)===Ot,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Wr,flipSided:M.side===si,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ni&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ni&&M.extensions.multiDraw===!0||ot)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function x(M){const b=[];if(M.shaderID?b.push(M.shaderID):(b.push(M.customVertexShaderID),b.push(M.customFragmentShaderID)),M.defines!==void 0)for(const k in M.defines)b.push(k),b.push(M.defines[k]);return M.isRawShaderMaterial===!1&&(y(b,M),_(b,M),b.push(n.outputColorSpace)),b.push(M.customProgramCacheKey),b.join()}function y(M,b){M.push(b.precision),M.push(b.outputColorSpace),M.push(b.envMapMode),M.push(b.envMapCubeUVHeight),M.push(b.mapUv),M.push(b.alphaMapUv),M.push(b.lightMapUv),M.push(b.aoMapUv),M.push(b.bumpMapUv),M.push(b.normalMapUv),M.push(b.displacementMapUv),M.push(b.emissiveMapUv),M.push(b.metalnessMapUv),M.push(b.roughnessMapUv),M.push(b.anisotropyMapUv),M.push(b.clearcoatMapUv),M.push(b.clearcoatNormalMapUv),M.push(b.clearcoatRoughnessMapUv),M.push(b.iridescenceMapUv),M.push(b.iridescenceThicknessMapUv),M.push(b.sheenColorMapUv),M.push(b.sheenRoughnessMapUv),M.push(b.specularMapUv),M.push(b.specularColorMapUv),M.push(b.specularIntensityMapUv),M.push(b.transmissionMapUv),M.push(b.thicknessMapUv),M.push(b.combine),M.push(b.fogExp2),M.push(b.sizeAttenuation),M.push(b.morphTargetsCount),M.push(b.morphAttributeCount),M.push(b.numDirLights),M.push(b.numPointLights),M.push(b.numSpotLights),M.push(b.numSpotLightMaps),M.push(b.numHemiLights),M.push(b.numRectAreaLights),M.push(b.numDirLightShadows),M.push(b.numPointLightShadows),M.push(b.numSpotLightShadows),M.push(b.numSpotLightShadowsWithMaps),M.push(b.numLightProbes),M.push(b.shadowMapType),M.push(b.toneMapping),M.push(b.numClippingPlanes),M.push(b.numClipIntersection),M.push(b.depthPacking)}function _(M,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),M.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reverseDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.alphaToCoverage&&o.enable(20),M.push(o.mask)}function I(M){const b=v[M.type];let k;if(b){const j=Dr[b];k=Hp.clone(j.uniforms)}else k=M.uniforms;return k}function T(M,b){let k;for(let j=0,Y=u.length;j<Y;j++){const re=u[j];if(re.cacheKey===b){k=re,++k.usedTimes;break}}return k===void 0&&(k=new gR(n,b,M,s),u.push(k)),k}function w(M){if(--M.usedTimes===0){const b=u.indexOf(M);u[b]=u[u.length-1],u.pop(),M.destroy()}}function C(M){l.remove(M)}function H(){l.dispose()}return{getParameters:g,getProgramCacheKey:x,getUniforms:I,acquireProgram:T,releaseProgram:w,releaseShaderCache:C,programs:u,dispose:H}}function MR(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function r(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function TR(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function uy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function hy(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(h,d,p,m,v,f){let g=n[e];return g===void 0?(g={id:h.id,object:h,geometry:d,material:p,groupOrder:m,renderOrder:h.renderOrder,z:v,group:f},n[e]=g):(g.id=h.id,g.object=h,g.geometry=d,g.material=p,g.groupOrder=m,g.renderOrder=h.renderOrder,g.z=v,g.group=f),e++,g}function o(h,d,p,m,v,f){const g=a(h,d,p,m,v,f);h.onBeforeRenderListPush?.(h,d,p,f),p.transmission>0?i.push(g):p.transparent===!0?r.push(g):t.push(g),h.onAfterRenderListPush?.(h,d,p,f)}function l(h,d,p,m,v,f){const g=a(h,d,p,m,v,f);p.transmission>0?i.unshift(g):p.transparent===!0?r.unshift(g):t.unshift(g)}function c(h,d){t.length>1&&t.sort(h||TR),i.length>1&&i.sort(d||uy),r.length>1&&r.sort(d||uy)}function u(){for(let h=e,d=n.length;h<d;h++){const p=n[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:o,unshift:l,finish:u,sort:c}}function bR(){let n=new WeakMap;function e(i,r){const s=n.get(i);let a;return s===void 0?(a=new hy,n.set(i,[a])):r>=s.length?(a=new hy,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function SR(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new xe};break;case"SpotLight":t={position:new N,direction:new N,color:new xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new xe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new xe,groundColor:new xe};break;case"RectAreaLight":t={color:new xe,position:new N,halfWidth:new N,halfHeight:new N};break}return n[e.id]=t,t}}}function wR(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let ER=0;function AR(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function NR(n){const e=new SR,t=wR(),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 c=0;c<9;c++)i.probe.push(new N);const r=new N,s=new Re,a=new Re;function o(c){let u=0,h=0,d=0;for(let H=0;H<9;H++)i.probe[H].set(0,0,0);let p=0,m=0,v=0,f=0,g=0,x=0,y=0,_=0,I=0,T=0,w=0;c.sort(AR);for(let H=0,M=c.length;H<M;H++){const b=c[H],k=b.color,j=b.intensity,Y=b.distance,re=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)u+=k.r*j,h+=k.g*j,d+=k.b*j;else if(b.isLightProbe){for(let $=0;$<9;$++)i.probe[$].addScaledVector(b.sh.coefficients[$],j);w++}else if(b.isDirectionalLight){const $=e.get(b);if($.color.copy(b.color).multiplyScalar(b.intensity),b.castShadow){const he=b.shadow,Q=t.get(b);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=re,i.directionalShadowMatrix[p]=b.shadow.matrix,x++}i.directional[p]=$,p++}else if(b.isSpotLight){const $=e.get(b);$.position.setFromMatrixPosition(b.matrixWorld),$.color.copy(k).multiplyScalar(j),$.distance=Y,$.coneCos=Math.cos(b.angle),$.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),$.decay=b.decay,i.spot[v]=$;const he=b.shadow;if(b.map&&(i.spotLightMap[I]=b.map,I++,he.updateMatrices(b),b.castShadow&&T++),i.spotLightMatrix[v]=he.matrix,b.castShadow){const Q=t.get(b);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,i.spotShadow[v]=Q,i.spotShadowMap[v]=re,_++}v++}else if(b.isRectAreaLight){const $=e.get(b);$.color.copy(k).multiplyScalar(j),$.halfWidth.set(b.width*.5,0,0),$.halfHeight.set(0,b.height*.5,0),i.rectArea[f]=$,f++}else if(b.isPointLight){const $=e.get(b);if($.color.copy(b.color).multiplyScalar(b.intensity),$.distance=b.distance,$.decay=b.decay,b.castShadow){const he=b.shadow,Q=t.get(b);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,Q.shadowCameraNear=he.camera.near,Q.shadowCameraFar=he.camera.far,i.pointShadow[m]=Q,i.pointShadowMap[m]=re,i.pointShadowMatrix[m]=b.shadow.matrix,y++}i.point[m]=$,m++}else if(b.isHemisphereLight){const $=e.get(b);$.skyColor.copy(b.color).multiplyScalar(j),$.groundColor.copy(b.groundColor).multiplyScalar(j),i.hemi[g]=$,g++}}f>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_FLOAT_1,i.rectAreaLTC2=Me.LTC_FLOAT_2):(i.rectAreaLTC1=Me.LTC_HALF_1,i.rectAreaLTC2=Me.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;const C=i.hash;(C.directionalLength!==p||C.pointLength!==m||C.spotLength!==v||C.rectAreaLength!==f||C.hemiLength!==g||C.numDirectionalShadows!==x||C.numPointShadows!==y||C.numSpotShadows!==_||C.numSpotMaps!==I||C.numLightProbes!==w)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=f,i.point.length=m,i.hemi.length=g,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=_+I-T,i.spotLightMap.length=I,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=w,C.directionalLength=p,C.pointLength=m,C.spotLength=v,C.rectAreaLength=f,C.hemiLength=g,C.numDirectionalShadows=x,C.numPointShadows=y,C.numSpotShadows=_,C.numSpotMaps=I,C.numLightProbes=w,i.version=ER++)}function l(c,u){let h=0,d=0,p=0,m=0,v=0;const f=u.matrixWorldInverse;for(let g=0,x=c.length;g<x;g++){const y=c[g];if(y.isDirectionalLight){const _=i.directional[h];_.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(f),h++}else if(y.isSpotLight){const _=i.spot[p];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),_.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(f),p++}else if(y.isRectAreaLight){const _=i.rectArea[m];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),a.identity(),s.copy(y.matrixWorld),s.premultiply(f),a.extractRotation(s),_.halfWidth.set(y.width*.5,0,0),_.halfHeight.set(0,y.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),m++}else if(y.isPointLight){const _=i.point[d];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),d++}else if(y.isHemisphereLight){const _=i.hemi[v];_.direction.setFromMatrixPosition(y.matrixWorld),_.direction.transformDirection(f),v++}}}return{setup:o,setupView:l,state:i}}function dy(n){const e=new NR(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function a(u){i.push(u)}function o(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function CR(n){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new dy(n),e.set(r,[o])):s>=a.length?(o=new dy(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}class ku extends hi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=fp,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 Zp extends hi{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}}const RR=`void main() {
|
|
3792
3792
|
gl_Position = vec4( position, 1.0 );
|
|
3793
3793
|
}`,IR=`uniform sampler2D shadow_pass;
|
|
3794
3794
|
uniform vec2 resolution;
|
|
@@ -3816,7 +3816,7 @@ void main() {
|
|
|
3816
3816
|
squared_mean = squared_mean / samples;
|
|
3817
3817
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3818
3818
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3819
|
-
}`;function LR(n,e,t){let i=new Ha;const r=new J,s=new J,a=new st,o=new zu({depthPacking:fp}),l=new Kp,c={},u=t.maxTextureSize,h={[an]:si,[si]:an,[Wr]:Wr},d=new Pr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:RR,fragmentShader:IR}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new ct;m.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ft(m,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Yd;let g=this.type;this.render=function(T,w,C){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||T.length===0)return;const H=n.getRenderTarget(),M=n.getActiveCubeFace(),b=n.getActiveMipmapLevel(),k=n.state;k.setBlending(Er),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const j=g!==rr&&this.type===rr,Y=g===rr&&this.type!==rr;for(let re=0,$=T.length;re<$;re++){const he=T[re],Q=he.shadow;if(Q===void 0){console.warn("THREE.WebGLShadowMap:",he,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;r.copy(Q.mapSize);const ye=Q.getFrameExtents();if(r.multiply(ye),s.copy(Q.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ye.x),r.x=s.x*ye.x,Q.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ye.y),r.y=s.y*ye.y,Q.mapSize.y=s.y)),Q.map===null||j===!0||Y===!0){const Ve=this.type!==rr?{minFilter:$t,magFilter:$t}:{};Q.map!==null&&Q.map.dispose(),Q.map=new Ir(r.x,r.y,Ve),Q.map.texture.name=he.name+".shadowMap",Q.camera.updateProjectionMatrix()}n.setRenderTarget(Q.map),n.clear();const Te=Q.getViewportCount();for(let Ve=0;Ve<Te;Ve++){const at=Q.getViewport(Ve);a.set(s.x*at.x,s.y*at.y,s.x*at.z,s.y*at.w),k.viewport(a),Q.updateMatrices(he,Ve),i=Q.getFrustum(),_(w,C,Q.camera,he,this.type)}Q.isPointLightShadow!==!0&&this.type===rr&&x(Q,C),Q.needsUpdate=!1}g=this.type,f.needsUpdate=!1,n.setRenderTarget(H,M,b)};function x(T,w){const C=e.update(v);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Ir(r.x,r.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,n.setRenderTarget(T.mapPass),n.clear(),n.renderBufferDirect(w,null,C,d,v,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,n.setRenderTarget(T.map),n.clear(),n.renderBufferDirect(w,null,C,p,v,null)}function y(T,w,C,H){let M=null;const b=C.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(b!==void 0)M=b;else if(M=C.isPointLight===!0?l:o,n.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const k=M.uuid,j=w.uuid;let Y=c[k];Y===void 0&&(Y={},c[k]=Y);let re=Y[j];re===void 0&&(re=M.clone(),Y[j]=re,w.addEventListener("dispose",I)),M=re}if(M.visible=w.visible,M.wireframe=w.wireframe,H===rr?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const k=n.properties.get(M);k.light=C}return M}function _(T,w,C,H,M){if(T.visible===!1)return;if(T.layers.test(w.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===rr)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,T.matrixWorld);const k=e.update(T),j=T.material;if(Array.isArray(j)){const Y=k.groups;for(let re=0,$=Y.length;re<$;re++){const he=Y[re],Q=j[he.materialIndex];if(Q&&Q.visible){const ye=y(T,Q,H,M);T.onBeforeShadow(n,T,w,C,k,ye,he),n.renderBufferDirect(C,null,k,ye,T,he),T.onAfterShadow(n,T,w,C,k,ye,he)}}}else if(j.visible){const Y=y(T,j,H,M);T.onBeforeShadow(n,T,w,C,k,Y,null),n.renderBufferDirect(C,null,k,Y,T,null),T.onAfterShadow(n,T,w,C,k,Y,null)}}const b=T.children;for(let k=0,j=b.length;k<j;k++)_(b[k],w,C,H,M)}function I(T){T.target.removeEventListener("dispose",I);for(const w in c){const C=c[w],H=T.target.uuid;H in C&&(C[H].dispose(),delete C[H])}}}const PR={[Co]:Ro,[Io]:Do,[Lo]:Uo,[zn]:Po,[Ro]:Co,[Do]:Io,[Uo]:Lo,[Po]:zn};function DR(n){function e(){let O=!1;const Ce=new st;let ee=null;const oe=new st(0,0,0,0);return{setMask:function(Ne){ee!==Ne&&!O&&(n.colorMask(Ne,Ne,Ne,Ne),ee=Ne)},setLocked:function(Ne){O=Ne},setClear:function(Ne,Ae,Ut,ni,tr){tr===!0&&(Ne*=ni,Ae*=ni,Ut*=ni),Ce.set(Ne,Ae,Ut,ni),oe.equals(Ce)===!1&&(n.clearColor(Ne,Ae,Ut,ni),oe.copy(Ce))},reset:function(){O=!1,ee=null,oe.set(-1,0,0,0)}}}function t(){let O=!1,Ce=!1,ee=null,oe=null,Ne=null;return{setReversed:function(Ae){Ce=Ae},setTest:function(Ae){Ae?be(n.DEPTH_TEST):Se(n.DEPTH_TEST)},setMask:function(Ae){ee!==Ae&&!O&&(n.depthMask(Ae),ee=Ae)},setFunc:function(Ae){if(Ce&&(Ae=PR[Ae]),oe!==Ae){switch(Ae){case Co:n.depthFunc(n.NEVER);break;case Ro:n.depthFunc(n.ALWAYS);break;case Io:n.depthFunc(n.LESS);break;case zn:n.depthFunc(n.LEQUAL);break;case Lo:n.depthFunc(n.EQUAL);break;case Po:n.depthFunc(n.GEQUAL);break;case Do:n.depthFunc(n.GREATER);break;case Uo:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}oe=Ae}},setLocked:function(Ae){O=Ae},setClear:function(Ae){Ne!==Ae&&(n.clearDepth(Ae),Ne=Ae)},reset:function(){O=!1,ee=null,oe=null,Ne=null}}}function i(){let O=!1,Ce=null,ee=null,oe=null,Ne=null,Ae=null,Ut=null,ni=null,tr=null;return{setTest:function(At){O||(At?be(n.STENCIL_TEST):Se(n.STENCIL_TEST))},setMask:function(At){Ce!==At&&!O&&(n.stencilMask(At),Ce=At)},setFunc:function(At,ir,Mn){(ee!==At||oe!==ir||Ne!==Mn)&&(n.stencilFunc(At,ir,Mn),ee=At,oe=ir,Ne=Mn)},setOp:function(At,ir,Mn){(Ae!==At||Ut!==ir||ni!==Mn)&&(n.stencilOp(At,ir,Mn),Ae=At,Ut=ir,ni=Mn)},setLocked:function(At){O=At},setClear:function(At){tr!==At&&(n.clearStencil(At),tr=At)},reset:function(){O=!1,Ce=null,ee=null,oe=null,Ne=null,Ae=null,Ut=null,ni=null,tr=null}}}const r=new e,s=new t,a=new i,o=new WeakMap,l=new WeakMap;let c={},u={},h=new WeakMap,d=[],p=null,m=!1,v=null,f=null,g=null,x=null,y=null,_=null,I=null,T=new xe(0,0,0),w=0,C=!1,H=null,M=null,b=null,k=null,j=null;const Y=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let re=!1,$=0;const he=n.getParameter(n.VERSION);he.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(he)[1]),re=$>=1):he.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),re=$>=2);let Q=null,ye={};const Te=n.getParameter(n.SCISSOR_BOX),Ve=n.getParameter(n.VIEWPORT),at=new st().fromArray(Te),et=new st().fromArray(Ve);function ie(O,Ce,ee,oe){const Ne=new Uint8Array(4),Ae=n.createTexture();n.bindTexture(O,Ae),n.texParameteri(O,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(O,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ut=0;Ut<ee;Ut++)O===n.TEXTURE_3D||O===n.TEXTURE_2D_ARRAY?n.texImage3D(Ce,0,n.RGBA,1,1,oe,0,n.RGBA,n.UNSIGNED_BYTE,Ne):n.texImage2D(Ce+Ut,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ne);return Ae}const le={};le[n.TEXTURE_2D]=ie(n.TEXTURE_2D,n.TEXTURE_2D,1),le[n.TEXTURE_CUBE_MAP]=ie(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),le[n.TEXTURE_2D_ARRAY]=ie(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),le[n.TEXTURE_3D]=ie(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),be(n.DEPTH_TEST),s.setFunc(zn),pe(!1),Ue(qd),be(n.CULL_FACE),L(Er);function be(O){c[O]!==!0&&(n.enable(O),c[O]=!0)}function Se(O){c[O]!==!1&&(n.disable(O),c[O]=!1)}function Ye(O,Ce){return u[O]!==Ce?(n.bindFramebuffer(O,Ce),u[O]=Ce,O===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=Ce),O===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=Ce),!0):!1}function We(O,Ce){let ee=d,oe=!1;if(O){ee=h.get(Ce),ee===void 0&&(ee=[],h.set(Ce,ee));const Ne=O.textures;if(ee.length!==Ne.length||ee[0]!==n.COLOR_ATTACHMENT0){for(let Ae=0,Ut=Ne.length;Ae<Ut;Ae++)ee[Ae]=n.COLOR_ATTACHMENT0+Ae;ee.length=Ne.length,oe=!0}}else ee[0]!==n.BACK&&(ee[0]=n.BACK,oe=!0);oe&&n.drawBuffers(ee)}function ot(O){return p!==O?(n.useProgram(O),p=O,!0):!1}const ce={[Bn]:n.FUNC_ADD,[S0]:n.FUNC_SUBTRACT,[w0]:n.FUNC_REVERSE_SUBTRACT};ce[E0]=n.MIN,ce[Qd]=n.MAX;const ue={[A0]:n.ZERO,[N0]:n.ONE,[C0]:n.SRC_COLOR,[Sc]:n.SRC_ALPHA,[U0]:n.SRC_ALPHA_SATURATE,[P0]:n.DST_COLOR,[I0]:n.DST_ALPHA,[R0]:n.ONE_MINUS_SRC_COLOR,[wc]:n.ONE_MINUS_SRC_ALPHA,[D0]:n.ONE_MINUS_DST_COLOR,[L0]:n.ONE_MINUS_DST_ALPHA,[O0]:n.CONSTANT_COLOR,[F0]:n.ONE_MINUS_CONSTANT_COLOR,[V0]:n.CONSTANT_ALPHA,[B0]:n.ONE_MINUS_CONSTANT_ALPHA};function L(O,Ce,ee,oe,Ne,Ae,Ut,ni,tr,At){if(O===Er){m===!0&&(Se(n.BLEND),m=!1);return}if(m===!1&&(be(n.BLEND),m=!0),O!==Zd){if(O!==v||At!==C){if((f!==Bn||y!==Bn)&&(n.blendEquation(n.FUNC_ADD),f=Bn,y=Bn),At)switch(O){case Tn:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case No:n.blendFunc(n.ONE,n.ONE);break;case Jd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Kd:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}else switch(O){case Tn:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case No:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Jd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Kd:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}g=null,x=null,_=null,I=null,T.set(0,0,0),w=0,v=O,C=At}return}Ne=Ne||Ce,Ae=Ae||ee,Ut=Ut||oe,(Ce!==f||Ne!==y)&&(n.blendEquationSeparate(ce[Ce],ce[Ne]),f=Ce,y=Ne),(ee!==g||oe!==x||Ae!==_||Ut!==I)&&(n.blendFuncSeparate(ue[ee],ue[oe],ue[Ae],ue[Ut]),g=ee,x=oe,_=Ae,I=Ut),(ni.equals(T)===!1||tr!==w)&&(n.blendColor(ni.r,ni.g,ni.b,tr),T.copy(ni),w=tr),v=O,C=!1}function He(O,Ce){O.side===Wr?Se(n.CULL_FACE):be(n.CULL_FACE);let ee=O.side===si;Ce&&(ee=!ee),pe(ee),O.blending===Tn&&O.transparent===!1?L(Er):L(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),s.setFunc(O.depthFunc),s.setTest(O.depthTest),s.setMask(O.depthWrite),r.setMask(O.colorWrite);const oe=O.stencilWrite;a.setTest(oe),oe&&(a.setMask(O.stencilWriteMask),a.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),a.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),$e(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?be(n.SAMPLE_ALPHA_TO_COVERAGE):Se(n.SAMPLE_ALPHA_TO_COVERAGE)}function pe(O){H!==O&&(O?n.frontFace(n.CW):n.frontFace(n.CCW),H=O)}function Ue(O){O!==T0?(be(n.CULL_FACE),O!==M&&(O===qd?n.cullFace(n.BACK):O===b0?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Se(n.CULL_FACE),M=O}function we(O){O!==b&&(re&&n.lineWidth(O),b=O)}function $e(O,Ce,ee){O?(be(n.POLYGON_OFFSET_FILL),(k!==Ce||j!==ee)&&(n.polygonOffset(Ce,ee),k=Ce,j=ee)):Se(n.POLYGON_OFFSET_FILL)}function Be(O){O?be(n.SCISSOR_TEST):Se(n.SCISSOR_TEST)}function R(O){O===void 0&&(O=n.TEXTURE0+Y-1),Q!==O&&(n.activeTexture(O),Q=O)}function S(O,Ce,ee){ee===void 0&&(Q===null?ee=n.TEXTURE0+Y-1:ee=Q);let oe=ye[ee];oe===void 0&&(oe={type:void 0,texture:void 0},ye[ee]=oe),(oe.type!==O||oe.texture!==Ce)&&(Q!==ee&&(n.activeTexture(ee),Q=ee),n.bindTexture(O,Ce||le[O]),oe.type=O,oe.texture=Ce)}function W(){const O=ye[Q];O!==void 0&&O.type!==void 0&&(n.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function ne(){try{n.compressedTexImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function de(){try{n.compressedTexImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function se(){try{n.texSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ke(){try{n.texSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Ee(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Pe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function mt(){try{n.texStorage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ve(){try{n.texStorage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ze(){try{n.texImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function tt(){try{n.texImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function it(O){at.equals(O)===!1&&(n.scissor(O.x,O.y,O.z,O.w),at.copy(O))}function Oe(O){et.equals(O)===!1&&(n.viewport(O.x,O.y,O.z,O.w),et.copy(O))}function Mt(O,Ce){let ee=l.get(Ce);ee===void 0&&(ee=new WeakMap,l.set(Ce,ee));let oe=ee.get(O);oe===void 0&&(oe=n.getUniformBlockIndex(Ce,O.name),ee.set(O,oe))}function ut(O,Ce){const ee=l.get(Ce).get(O);o.get(Ce)!==ee&&(n.uniformBlockBinding(Ce,ee,O.__bindingPointIndex),o.set(Ce,ee))}function Dt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),c={},Q=null,ye={},u={},h=new WeakMap,d=[],p=null,m=!1,v=null,f=null,g=null,x=null,y=null,_=null,I=null,T=new xe(0,0,0),w=0,C=!1,H=null,M=null,b=null,k=null,j=null,at.set(0,0,n.canvas.width,n.canvas.height),et.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),a.reset()}return{buffers:{color:r,depth:s,stencil:a},enable:be,disable:Se,bindFramebuffer:Ye,drawBuffers:We,useProgram:ot,setBlending:L,setMaterial:He,setFlipSided:pe,setCullFace:Ue,setLineWidth:we,setPolygonOffset:$e,setScissorTest:Be,activeTexture:R,bindTexture:S,unbindTexture:W,compressedTexImage2D:ne,compressedTexImage3D:de,texImage2D:ze,texImage3D:tt,updateUBOMapping:Mt,uniformBlockBinding:ut,texStorage2D:mt,texStorage3D:ve,texSubImage2D:se,texSubImage3D:ke,compressedTexSubImage2D:Ee,compressedTexSubImage3D:Pe,scissor:it,viewport:Oe,reset:Dt}}function UR(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function OR(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function FR(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function Zp(n,e,t,i){const r=VR(i);switch(t){case op:return n*e;case lp:return n*e;case cp:return n*e*2;case Oo:return n*e/r.components*r.byteLength;case Fo:return n*e/r.components*r.byteLength;case ya:return n*e*2/r.components*r.byteLength;case Vc:return n*e*2/r.components*r.byteLength;case Fc:return n*e*3/r.components*r.byteLength;case Ei:return n*e*4/r.components*r.byteLength;case Bc:return n*e*4/r.components*r.byteLength;case xa:case _a:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ma:case Ta:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case zc:case kc:return Math.max(n,16)*Math.max(e,8)/4;case Vo:case Bo:return Math.max(n,8)*Math.max(e,8)/2;case zo:case ko:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ho:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Go:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Hc:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Gc:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Wc:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Wo:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case jc:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Xc:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case qc:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Yc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case $c:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Jc:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Kc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Zc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Qc:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case ba:case eu:case jo:return Math.ceil(n/4)*Math.ceil(e/4)*16;case up:case tu:return Math.ceil(n/4)*Math.ceil(e/4)*8;case iu:case ru:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function VR(n){switch(n){case jr:case sp:return{byteLength:1,components:1};case ga:case ap:case wi:return{byteLength:2,components:1};case Pc:case Dc:return{byteLength:2,components:4};case Nr:case va:case Oi:return{byteLength:4,components:1};case Uc:case Oc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}const BR={contain:UR,cover:OR,fill:FR,getByteLength:Zp};function zR(n,e,t,i,r,s,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),c=new J,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(R,S){return p?new OffscreenCanvas(R,S):Qo("canvas")}function v(R,S,W){let ne=1;const de=Be(R);if((de.width>W||de.height>W)&&(ne=W/Math.max(de.width,de.height)),ne<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const se=Math.floor(ne*de.width),ke=Math.floor(ne*de.height);h===void 0&&(h=m(se,ke));const Ee=S?m(se,ke):h;return Ee.width=se,Ee.height=ke,Ee.getContext("2d").drawImage(R,0,0,se,ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+de.width+"x"+de.height+") to ("+se+"x"+ke+")."),Ee}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+de.width+"x"+de.height+")."),R;return R}function f(R){return R.generateMipmaps&&R.minFilter!==$t&&R.minFilter!==Lt}function g(R){n.generateMipmap(R)}function x(R,S,W,ne,de=!1){if(R!==null){if(n[R]!==void 0)return n[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let se=S;if(S===n.RED&&(W===n.FLOAT&&(se=n.R32F),W===n.HALF_FLOAT&&(se=n.R16F),W===n.UNSIGNED_BYTE&&(se=n.R8)),S===n.RED_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.R8UI),W===n.UNSIGNED_SHORT&&(se=n.R16UI),W===n.UNSIGNED_INT&&(se=n.R32UI),W===n.BYTE&&(se=n.R8I),W===n.SHORT&&(se=n.R16I),W===n.INT&&(se=n.R32I)),S===n.RG&&(W===n.FLOAT&&(se=n.RG32F),W===n.HALF_FLOAT&&(se=n.RG16F),W===n.UNSIGNED_BYTE&&(se=n.RG8)),S===n.RG_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RG8UI),W===n.UNSIGNED_SHORT&&(se=n.RG16UI),W===n.UNSIGNED_INT&&(se=n.RG32UI),W===n.BYTE&&(se=n.RG8I),W===n.SHORT&&(se=n.RG16I),W===n.INT&&(se=n.RG32I)),S===n.RGB_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RGB8UI),W===n.UNSIGNED_SHORT&&(se=n.RGB16UI),W===n.UNSIGNED_INT&&(se=n.RGB32UI),W===n.BYTE&&(se=n.RGB8I),W===n.SHORT&&(se=n.RGB16I),W===n.INT&&(se=n.RGB32I)),S===n.RGBA_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RGBA8UI),W===n.UNSIGNED_SHORT&&(se=n.RGBA16UI),W===n.UNSIGNED_INT&&(se=n.RGBA32UI),W===n.BYTE&&(se=n.RGBA8I),W===n.SHORT&&(se=n.RGBA16I),W===n.INT&&(se=n.RGBA32I)),S===n.RGB&&(W===n.UNSIGNED_INT_5_9_9_9_REV&&(se=n.RGB9_E5),W===n.UNSIGNED_INT_10F_11F_11F_REV&&(se=n.R11F_G11F_B10F)),S===n.RGBA){const ke=de?$o:vt.getTransfer(ne);W===n.FLOAT&&(se=n.RGBA32F),W===n.HALF_FLOAT&&(se=n.RGBA16F),W===n.UNSIGNED_BYTE&&(se=ke===Ot?n.SRGB8_ALPHA8:n.RGBA8),W===n.UNSIGNED_SHORT_4_4_4_4&&(se=n.RGBA4),W===n.UNSIGNED_SHORT_5_5_5_1&&(se=n.RGB5_A1)}return(se===n.R16F||se===n.R32F||se===n.RG16F||se===n.RG32F||se===n.RGBA16F||se===n.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function y(R,S){let W;return R?S===null||S===Nr||S===Xn?W=n.DEPTH24_STENCIL8:S===Oi?W=n.DEPTH32F_STENCIL8:S===ga&&(W=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Nr||S===Xn?W=n.DEPTH_COMPONENT24:S===Oi?W=n.DEPTH_COMPONENT32F:S===ga&&(W=n.DEPTH_COMPONENT16),W}function _(R,S){return f(R)===!0||R.isFramebufferTexture&&R.minFilter!==$t&&R.minFilter!==Lt?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function I(R){const S=R.target;S.removeEventListener("dispose",I),w(S),S.isVideoTexture&&u.delete(S)}function T(R){const S=R.target;S.removeEventListener("dispose",T),H(S)}function w(R){const S=i.get(R);if(S.__webglInit===void 0)return;const W=R.source,ne=d.get(W);if(ne){const de=ne[S.__cacheKey];de.usedTimes--,de.usedTimes===0&&C(R),Object.keys(ne).length===0&&d.delete(W)}i.remove(R)}function C(R){const S=i.get(R);n.deleteTexture(S.__webglTexture);const W=R.source,ne=d.get(W);delete ne[S.__cacheKey],a.memory.textures--}function H(R){const S=i.get(R);if(R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let ne=0;ne<6;ne++){if(Array.isArray(S.__webglFramebuffer[ne]))for(let de=0;de<S.__webglFramebuffer[ne].length;de++)n.deleteFramebuffer(S.__webglFramebuffer[ne][de]);else n.deleteFramebuffer(S.__webglFramebuffer[ne]);S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer[ne])}else{if(Array.isArray(S.__webglFramebuffer))for(let ne=0;ne<S.__webglFramebuffer.length;ne++)n.deleteFramebuffer(S.__webglFramebuffer[ne]);else n.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&n.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let ne=0;ne<S.__webglColorRenderbuffer.length;ne++)S.__webglColorRenderbuffer[ne]&&n.deleteRenderbuffer(S.__webglColorRenderbuffer[ne]);S.__webglDepthRenderbuffer&&n.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const W=R.textures;for(let ne=0,de=W.length;ne<de;ne++){const se=i.get(W[ne]);se.__webglTexture&&(n.deleteTexture(se.__webglTexture),a.memory.textures--),i.remove(W[ne])}i.remove(R)}let M=0;function b(){M=0}function k(){const R=M;return R>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+r.maxTextures),M+=1,R}function j(R){const S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function Y(R,S){const W=i.get(R);if(R.isVideoTexture&&we(R),R.isRenderTargetTexture===!1&&R.version>0&&W.__version!==R.version){const ne=R.image;if(ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{et(W,R,S);return}}t.bindTexture(n.TEXTURE_2D,W.__webglTexture,n.TEXTURE0+S)}function re(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){et(W,R,S);return}t.bindTexture(n.TEXTURE_2D_ARRAY,W.__webglTexture,n.TEXTURE0+S)}function $(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){et(W,R,S);return}t.bindTexture(n.TEXTURE_3D,W.__webglTexture,n.TEXTURE0+S)}function he(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){ie(W,R,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,W.__webglTexture,n.TEXTURE0+S)}const Q={[Wn]:n.REPEAT,[gr]:n.CLAMP_TO_EDGE,[fa]:n.MIRRORED_REPEAT},ye={[$t]:n.NEAREST,[Lc]:n.NEAREST_MIPMAP_NEAREST,[bn]:n.NEAREST_MIPMAP_LINEAR,[Lt]:n.LINEAR,[jn]:n.LINEAR_MIPMAP_NEAREST,[Xi]:n.LINEAR_MIPMAP_LINEAR},Te={[ov]:n.NEVER,[dv]:n.ALWAYS,[vp]:n.LESS,[yp]:n.LEQUAL,[lv]:n.EQUAL,[hv]:n.GEQUAL,[cv]:n.GREATER,[uv]:n.NOTEQUAL};function Ve(R,S){if(S.type===Oi&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Lt||S.magFilter===jn||S.magFilter===bn||S.magFilter===Xi||S.minFilter===Lt||S.minFilter===jn||S.minFilter===bn||S.minFilter===Xi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,Q[S.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,Q[S.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,Q[S.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,ye[S.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,ye[S.minFilter]),S.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,Te[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===$t||S.minFilter!==bn&&S.minFilter!==Xi||S.type===Oi&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){const W=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,r.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function at(R,S){let W=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",I));const ne=S.source;let de=d.get(ne);de===void 0&&(de={},d.set(ne,de));const se=j(S);if(se!==R.__cacheKey){de[se]===void 0&&(de[se]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,W=!0),de[se].usedTimes++;const ke=de[R.__cacheKey];ke!==void 0&&(de[R.__cacheKey].usedTimes--,ke.usedTimes===0&&C(S)),R.__cacheKey=se,R.__webglTexture=de[se].texture}return W}function et(R,S,W){let ne=n.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(ne=n.TEXTURE_2D_ARRAY),S.isData3DTexture&&(ne=n.TEXTURE_3D);const de=at(R,S),se=S.source;t.bindTexture(ne,R.__webglTexture,n.TEXTURE0+W);const ke=i.get(se);if(se.version!==ke.__version||de===!0){t.activeTexture(n.TEXTURE0+W);const Ee=vt.getPrimaries(vt.workingColorSpace),Pe=S.colorSpace===Cr?null:vt.getPrimaries(S.colorSpace),mt=S.colorSpace===Cr||Ee===Pe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,mt);let ve=v(S.image,!1,r.maxTextureSize);ve=$e(S,ve);const ze=s.convert(S.format,S.colorSpace),tt=s.convert(S.type);let it=x(S.internalFormat,ze,tt,S.colorSpace,S.isVideoTexture);Ve(ne,S);let Oe;const Mt=S.mipmaps,ut=S.isVideoTexture!==!0,Dt=ke.__version===void 0||de===!0,O=se.dataReady,Ce=_(S,ve);if(S.isDepthTexture)it=y(S.format===Yn,S.type),Dt&&(ut?t.texStorage2D(n.TEXTURE_2D,1,it,ve.width,ve.height):t.texImage2D(n.TEXTURE_2D,0,it,ve.width,ve.height,0,ze,tt,null));else if(S.isDataTexture)if(Mt.length>0){ut&&Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,Mt[0].width,Mt[0].height);for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,tt,Oe.data):t.texImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,ze,tt,Oe.data);S.generateMipmaps=!1}else ut?(Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,ve.width,ve.height),O&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ve.width,ve.height,ze,tt,ve.data)):t.texImage2D(n.TEXTURE_2D,0,it,ve.width,ve.height,0,ze,tt,ve.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){ut&&Dt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ce,it,Mt[0].width,Mt[0].height,ve.depth);for(let ee=0,oe=Mt.length;ee<oe;ee++)if(Oe=Mt[ee],S.format!==Ei)if(ze!==null)if(ut){if(O)if(S.layerUpdates.size>0){const Ne=Zp(Oe.width,Oe.height,S.format,S.type);for(const Ae of S.layerUpdates){const Ut=Oe.data.subarray(Ae*Ne/Oe.data.BYTES_PER_ELEMENT,(Ae+1)*Ne/Oe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,Ae,Oe.width,Oe.height,1,ze,Ut,0,0)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,Oe.width,Oe.height,ve.depth,ze,Oe.data,0,0)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ee,it,Oe.width,Oe.height,ve.depth,0,Oe.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ut?O&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,Oe.width,Oe.height,ve.depth,ze,tt,Oe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ee,it,Oe.width,Oe.height,ve.depth,0,ze,tt,Oe.data)}else{ut&&Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,Mt[0].width,Mt[0].height);for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],S.format!==Ei?ze!==null?ut?O&&t.compressedTexSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,Oe.data):t.compressedTexImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,Oe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,tt,Oe.data):t.texImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,ze,tt,Oe.data)}else if(S.isDataArrayTexture)if(ut){if(Dt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ce,it,ve.width,ve.height,ve.depth),O)if(S.layerUpdates.size>0){const ee=Zp(ve.width,ve.height,S.format,S.type);for(const oe of S.layerUpdates){const Ne=ve.data.subarray(oe*ee/ve.data.BYTES_PER_ELEMENT,(oe+1)*ee/ve.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,oe,ve.width,ve.height,1,ze,tt,Ne)}S.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ve.width,ve.height,ve.depth,ze,tt,ve.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,it,ve.width,ve.height,ve.depth,0,ze,tt,ve.data);else if(S.isData3DTexture)ut?(Dt&&t.texStorage3D(n.TEXTURE_3D,Ce,it,ve.width,ve.height,ve.depth),O&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ve.width,ve.height,ve.depth,ze,tt,ve.data)):t.texImage3D(n.TEXTURE_3D,0,it,ve.width,ve.height,ve.depth,0,ze,tt,ve.data);else if(S.isFramebufferTexture){if(Dt)if(ut)t.texStorage2D(n.TEXTURE_2D,Ce,it,ve.width,ve.height);else{let ee=ve.width,oe=ve.height;for(let Ne=0;Ne<Ce;Ne++)t.texImage2D(n.TEXTURE_2D,Ne,it,ee,oe,0,ze,tt,null),ee>>=1,oe>>=1}}else if(Mt.length>0){if(ut&&Dt){const ee=Be(Mt[0]);t.texStorage2D(n.TEXTURE_2D,Ce,it,ee.width,ee.height)}for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,ze,tt,Oe):t.texImage2D(n.TEXTURE_2D,ee,it,ze,tt,Oe);S.generateMipmaps=!1}else if(ut){if(Dt){const ee=Be(ve);t.texStorage2D(n.TEXTURE_2D,Ce,it,ee.width,ee.height)}O&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ze,tt,ve)}else t.texImage2D(n.TEXTURE_2D,0,it,ze,tt,ve);f(S)&&g(ne),ke.__version=se.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function ie(R,S,W){if(S.image.length!==6)return;const ne=at(R,S),de=S.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+W);const se=i.get(de);if(de.version!==se.__version||ne===!0){t.activeTexture(n.TEXTURE0+W);const ke=vt.getPrimaries(vt.workingColorSpace),Ee=S.colorSpace===Cr?null:vt.getPrimaries(S.colorSpace),Pe=S.colorSpace===Cr||ke===Ee?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pe);const mt=S.isCompressedTexture||S.image[0].isCompressedTexture,ve=S.image[0]&&S.image[0].isDataTexture,ze=[];for(let oe=0;oe<6;oe++)!mt&&!ve?ze[oe]=v(S.image[oe],!0,r.maxCubemapSize):ze[oe]=ve?S.image[oe].image:S.image[oe],ze[oe]=$e(S,ze[oe]);const tt=ze[0],it=s.convert(S.format,S.colorSpace),Oe=s.convert(S.type),Mt=x(S.internalFormat,it,Oe,S.colorSpace),ut=S.isVideoTexture!==!0,Dt=se.__version===void 0||ne===!0,O=de.dataReady;let Ce=_(S,tt);Ve(n.TEXTURE_CUBE_MAP,S);let ee;if(mt){ut&&Dt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Ce,Mt,tt.width,tt.height);for(let oe=0;oe<6;oe++){ee=ze[oe].mipmaps;for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne];S.format!==Ei?it!==null?ut?O&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,0,0,Ae.width,Ae.height,it,Ae.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,Mt,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,0,0,Ae.width,Ae.height,it,Oe,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,Mt,Ae.width,Ae.height,0,it,Oe,Ae.data)}}}else{if(ee=S.mipmaps,ut&&Dt){ee.length>0&&Ce++;const oe=Be(ze[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,Ce,Mt,oe.width,oe.height)}for(let oe=0;oe<6;oe++)if(ve){ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,ze[oe].width,ze[oe].height,it,Oe,ze[oe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Mt,ze[oe].width,ze[oe].height,0,it,Oe,ze[oe].data);for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne].image[oe].image;ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,0,0,Ae.width,Ae.height,it,Oe,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,Mt,Ae.width,Ae.height,0,it,Oe,Ae.data)}}else{ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,it,Oe,ze[oe]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Mt,it,Oe,ze[oe]);for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne];ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,0,0,it,Oe,Ae.image[oe]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,Mt,it,Oe,Ae.image[oe])}}}f(S)&&g(n.TEXTURE_CUBE_MAP),se.__version=de.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function le(R,S,W,ne,de,se){const ke=s.convert(W.format,W.colorSpace),Ee=s.convert(W.type),Pe=x(W.internalFormat,ke,Ee,W.colorSpace);if(!i.get(S).__hasExternalTextures){const mt=Math.max(1,S.width>>se),ve=Math.max(1,S.height>>se);de===n.TEXTURE_3D||de===n.TEXTURE_2D_ARRAY?t.texImage3D(de,se,Pe,mt,ve,S.depth,0,ke,Ee,null):t.texImage2D(de,se,Pe,mt,ve,0,ke,Ee,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ne,de,i.get(W).__webglTexture,0,pe(S)):(de===n.TEXTURE_2D||de>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&de<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ne,de,i.get(W).__webglTexture,se),t.bindFramebuffer(n.FRAMEBUFFER,null)}function be(R,S,W){if(n.bindRenderbuffer(n.RENDERBUFFER,R),S.depthBuffer){const ne=S.depthTexture,de=ne&&ne.isDepthTexture?ne.type:null,se=y(S.stencilBuffer,de),ke=S.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ee=pe(S);Ue(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ee,se,S.width,S.height):W?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,se,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,se,S.width,S.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,ke,n.RENDERBUFFER,R)}else{const ne=S.textures;for(let de=0;de<ne.length;de++){const se=ne[de],ke=s.convert(se.format,se.colorSpace),Ee=s.convert(se.type),Pe=x(se.internalFormat,ke,Ee,se.colorSpace),mt=pe(S);W&&Ue(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,mt,Pe,S.width,S.height):Ue(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,mt,Pe,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,Pe,S.width,S.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Se(R,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),Y(S.depthTexture,0);const W=i.get(S.depthTexture).__webglTexture,ne=pe(S);if(S.depthTexture.format===qn)Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,W,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,W,0);else if(S.depthTexture.format===Yn)Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,W,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,W,0);else throw new Error("Unknown depthTexture format")}function Ye(R){const S=i.get(R),W=R.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==R.depthTexture){const ne=R.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),ne){const de=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,ne.removeEventListener("dispose",de)};ne.addEventListener("dispose",de),S.__depthDisposeCallback=de}S.__boundDepthTexture=ne}if(R.depthTexture&&!S.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");Se(S.__webglFramebuffer,R)}else if(W){S.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer[ne]),S.__webglDepthbuffer[ne]===void 0)S.__webglDepthbuffer[ne]=n.createRenderbuffer(),be(S.__webglDepthbuffer[ne],R,!1);else{const de=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,se=S.__webglDepthbuffer[ne];n.bindRenderbuffer(n.RENDERBUFFER,se),n.framebufferRenderbuffer(n.FRAMEBUFFER,de,n.RENDERBUFFER,se)}}else if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=n.createRenderbuffer(),be(S.__webglDepthbuffer,R,!1);else{const ne=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,de=S.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,de),n.framebufferRenderbuffer(n.FRAMEBUFFER,ne,n.RENDERBUFFER,de)}t.bindFramebuffer(n.FRAMEBUFFER,null)}function We(R,S,W){const ne=i.get(R);S!==void 0&&le(ne.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),W!==void 0&&Ye(R)}function ot(R){const S=R.texture,W=i.get(R),ne=i.get(S);R.addEventListener("dispose",T);const de=R.textures,se=R.isWebGLCubeRenderTarget===!0,ke=de.length>1;if(ke||(ne.__webglTexture===void 0&&(ne.__webglTexture=n.createTexture()),ne.__version=S.version,a.memory.textures++),se){W.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer[Ee]=[];for(let Pe=0;Pe<S.mipmaps.length;Pe++)W.__webglFramebuffer[Ee][Pe]=n.createFramebuffer()}else W.__webglFramebuffer[Ee]=n.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer=[];for(let Ee=0;Ee<S.mipmaps.length;Ee++)W.__webglFramebuffer[Ee]=n.createFramebuffer()}else W.__webglFramebuffer=n.createFramebuffer();if(ke)for(let Ee=0,Pe=de.length;Ee<Pe;Ee++){const mt=i.get(de[Ee]);mt.__webglTexture===void 0&&(mt.__webglTexture=n.createTexture(),a.memory.textures++)}if(R.samples>0&&Ue(R)===!1){W.__webglMultisampledFramebuffer=n.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let Ee=0;Ee<de.length;Ee++){const Pe=de[Ee];W.__webglColorRenderbuffer[Ee]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,W.__webglColorRenderbuffer[Ee]);const mt=s.convert(Pe.format,Pe.colorSpace),ve=s.convert(Pe.type),ze=x(Pe.internalFormat,mt,ve,Pe.colorSpace,R.isXRRenderTarget===!0),tt=pe(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,tt,ze,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,W.__webglColorRenderbuffer[Ee])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(W.__webglDepthRenderbuffer=n.createRenderbuffer(),be(W.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(se){t.bindTexture(n.TEXTURE_CUBE_MAP,ne.__webglTexture),Ve(n.TEXTURE_CUBE_MAP,S);for(let Ee=0;Ee<6;Ee++)if(S.mipmaps&&S.mipmaps.length>0)for(let Pe=0;Pe<S.mipmaps.length;Pe++)le(W.__webglFramebuffer[Ee][Pe],R,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,Pe);else le(W.__webglFramebuffer[Ee],R,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,0);f(S)&&g(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ke){for(let Ee=0,Pe=de.length;Ee<Pe;Ee++){const mt=de[Ee],ve=i.get(mt);t.bindTexture(n.TEXTURE_2D,ve.__webglTexture),Ve(n.TEXTURE_2D,mt),le(W.__webglFramebuffer,R,mt,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,0),f(mt)&&g(n.TEXTURE_2D)}t.unbindTexture()}else{let Ee=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Ee=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ee,ne.__webglTexture),Ve(Ee,S),S.mipmaps&&S.mipmaps.length>0)for(let Pe=0;Pe<S.mipmaps.length;Pe++)le(W.__webglFramebuffer[Pe],R,S,n.COLOR_ATTACHMENT0,Ee,Pe);else le(W.__webglFramebuffer,R,S,n.COLOR_ATTACHMENT0,Ee,0);f(S)&&g(Ee),t.unbindTexture()}R.depthBuffer&&Ye(R)}function ce(R){const S=R.textures;for(let W=0,ne=S.length;W<ne;W++){const de=S[W];if(f(de)){const se=R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,ke=i.get(de).__webglTexture;t.bindTexture(se,ke),g(se),t.unbindTexture()}}}const ue=[],L=[];function He(R){if(R.samples>0){if(Ue(R)===!1){const S=R.textures,W=R.width,ne=R.height;let de=n.COLOR_BUFFER_BIT;const se=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ke=i.get(R),Ee=S.length>1;if(Ee)for(let Pe=0;Pe<S.length;Pe++)t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ke.__webglFramebuffer);for(let Pe=0;Pe<S.length;Pe++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(de|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(de|=n.STENCIL_BUFFER_BIT)),Ee){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,ke.__webglColorRenderbuffer[Pe]);const mt=i.get(S[Pe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,mt,0)}n.blitFramebuffer(0,0,W,ne,0,0,W,ne,de,n.NEAREST),l===!0&&(ue.length=0,L.length=0,ue.push(n.COLOR_ATTACHMENT0+Pe),R.depthBuffer&&R.resolveDepthBuffer===!1&&(ue.push(se),L.push(se),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,L)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,ue))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ee)for(let Pe=0;Pe<S.length;Pe++){t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,ke.__webglColorRenderbuffer[Pe]);const mt=i.get(S[Pe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,mt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ke.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const S=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[S])}}}function pe(R){return Math.min(r.maxSamples,R.samples)}function Ue(R){const S=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function we(R){const S=a.render.frame;u.get(R)!==S&&(u.set(R,S),R.update())}function $e(R,S){const W=R.colorSpace,ne=R.format,de=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||W!==nr&&W!==Cr&&(vt.getTransfer(W)===Ot?(ne!==Ei||de!==jr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),S}function Be(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=b,this.setTexture2D=Y,this.setTexture2DArray=re,this.setTexture3D=$,this.setTextureCube=he,this.rebindTextures=We,this.setupRenderTarget=ot,this.updateRenderTargetMipmap=ce,this.updateMultisampleRenderTarget=He,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=le,this.useMultisampledRTT=Ue}function dy(n,e){function t(i,r=Cr){let s;const a=vt.getTransfer(r);if(i===jr)return n.UNSIGNED_BYTE;if(i===Pc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Dc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Uc)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Oc)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===sp)return n.BYTE;if(i===ap)return n.SHORT;if(i===ga)return n.UNSIGNED_SHORT;if(i===va)return n.INT;if(i===Nr)return n.UNSIGNED_INT;if(i===Oi)return n.FLOAT;if(i===wi)return n.HALF_FLOAT;if(i===op)return n.ALPHA;if(i===Fc)return n.RGB;if(i===Ei)return n.RGBA;if(i===lp)return n.LUMINANCE;if(i===cp)return n.LUMINANCE_ALPHA;if(i===qn)return n.DEPTH_COMPONENT;if(i===Yn)return n.DEPTH_STENCIL;if(i===Oo)return n.RED;if(i===Fo)return n.RED_INTEGER;if(i===ya)return n.RG;if(i===Vc)return n.RG_INTEGER;if(i===Bc)return n.RGBA_INTEGER;if(i===xa||i===_a||i===Ma||i===Ta)if(a===Ot)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===xa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===_a)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ma)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ta)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===xa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===_a)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ma)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ta)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Vo||i===zc||i===Bo||i===kc)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Vo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===zc)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bo)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===kc)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zo||i===ko||i===Ho)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===zo||i===ko)return a===Ot?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Ho)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Go||i===Hc||i===Gc||i===Wc||i===Wo||i===jc||i===Xc||i===qc||i===Yc||i===$c||i===Jc||i===Kc||i===Zc||i===Qc)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Go)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Hc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Wc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Wo)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Xc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===qc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Yc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===$c)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Kc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Zc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Qc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ba||i===eu||i===jo)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===ba)return a===Ot?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===eu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===jo)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===up||i===tu||i===iu||i===ru)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===ba)return s.COMPRESSED_RED_RGTC1_EXT;if(i===tu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===iu)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ru)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Xn?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class Qp extends di{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Fs extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const kR={type:"move"};class em{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Fs,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 Fs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Fs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),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,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const f=t.getJointPose(v,i),g=this._getHandJoint(c,v);f!==null&&(g.matrix.fromArray(f.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=f.radius),g.visible=f!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,m=.005;c.inputState.pinching&&d>p+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),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(kR)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Fs;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const HR=`
|
|
3819
|
+
}`;function LR(n,e,t){let i=new Ga;const r=new J,s=new J,a=new st,o=new ku({depthPacking:gp}),l=new Zp,c={},u=t.maxTextureSize,h={[an]:si,[si]:an,[Wr]:Wr},d=new Pr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:RR,fragmentShader:IR}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new ct;m.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ft(m,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=$d;let g=this.type;this.render=function(T,w,C){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||T.length===0)return;const H=n.getRenderTarget(),M=n.getActiveCubeFace(),b=n.getActiveMipmapLevel(),k=n.state;k.setBlending(Er),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const j=g!==rr&&this.type===rr,Y=g===rr&&this.type!==rr;for(let re=0,$=T.length;re<$;re++){const he=T[re],Q=he.shadow;if(Q===void 0){console.warn("THREE.WebGLShadowMap:",he,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;r.copy(Q.mapSize);const ye=Q.getFrameExtents();if(r.multiply(ye),s.copy(Q.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ye.x),r.x=s.x*ye.x,Q.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ye.y),r.y=s.y*ye.y,Q.mapSize.y=s.y)),Q.map===null||j===!0||Y===!0){const Ve=this.type!==rr?{minFilter:$t,magFilter:$t}:{};Q.map!==null&&Q.map.dispose(),Q.map=new Ir(r.x,r.y,Ve),Q.map.texture.name=he.name+".shadowMap",Q.camera.updateProjectionMatrix()}n.setRenderTarget(Q.map),n.clear();const Te=Q.getViewportCount();for(let Ve=0;Ve<Te;Ve++){const at=Q.getViewport(Ve);a.set(s.x*at.x,s.y*at.y,s.x*at.z,s.y*at.w),k.viewport(a),Q.updateMatrices(he,Ve),i=Q.getFrustum(),_(w,C,Q.camera,he,this.type)}Q.isPointLightShadow!==!0&&this.type===rr&&x(Q,C),Q.needsUpdate=!1}g=this.type,f.needsUpdate=!1,n.setRenderTarget(H,M,b)};function x(T,w){const C=e.update(v);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Ir(r.x,r.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,n.setRenderTarget(T.mapPass),n.clear(),n.renderBufferDirect(w,null,C,d,v,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,n.setRenderTarget(T.map),n.clear(),n.renderBufferDirect(w,null,C,p,v,null)}function y(T,w,C,H){let M=null;const b=C.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(b!==void 0)M=b;else if(M=C.isPointLight===!0?l:o,n.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const k=M.uuid,j=w.uuid;let Y=c[k];Y===void 0&&(Y={},c[k]=Y);let re=Y[j];re===void 0&&(re=M.clone(),Y[j]=re,w.addEventListener("dispose",I)),M=re}if(M.visible=w.visible,M.wireframe=w.wireframe,H===rr?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const k=n.properties.get(M);k.light=C}return M}function _(T,w,C,H,M){if(T.visible===!1)return;if(T.layers.test(w.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===rr)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,T.matrixWorld);const k=e.update(T),j=T.material;if(Array.isArray(j)){const Y=k.groups;for(let re=0,$=Y.length;re<$;re++){const he=Y[re],Q=j[he.materialIndex];if(Q&&Q.visible){const ye=y(T,Q,H,M);T.onBeforeShadow(n,T,w,C,k,ye,he),n.renderBufferDirect(C,null,k,ye,T,he),T.onAfterShadow(n,T,w,C,k,ye,he)}}}else if(j.visible){const Y=y(T,j,H,M);T.onBeforeShadow(n,T,w,C,k,Y,null),n.renderBufferDirect(C,null,k,Y,T,null),T.onAfterShadow(n,T,w,C,k,Y,null)}}const b=T.children;for(let k=0,j=b.length;k<j;k++)_(b[k],w,C,H,M)}function I(T){T.target.removeEventListener("dispose",I);for(const w in c){const C=c[w],H=T.target.uuid;H in C&&(C[H].dispose(),delete C[H])}}}const PR={[Ro]:Io,[Lo]:Uo,[Po]:Oo,[kn]:Do,[Io]:Ro,[Uo]:Lo,[Oo]:Po,[Do]:kn};function DR(n){function e(){let O=!1;const Ce=new st;let ee=null;const oe=new st(0,0,0,0);return{setMask:function(Ne){ee!==Ne&&!O&&(n.colorMask(Ne,Ne,Ne,Ne),ee=Ne)},setLocked:function(Ne){O=Ne},setClear:function(Ne,Ae,Ut,ni,tr){tr===!0&&(Ne*=ni,Ae*=ni,Ut*=ni),Ce.set(Ne,Ae,Ut,ni),oe.equals(Ce)===!1&&(n.clearColor(Ne,Ae,Ut,ni),oe.copy(Ce))},reset:function(){O=!1,ee=null,oe.set(-1,0,0,0)}}}function t(){let O=!1,Ce=!1,ee=null,oe=null,Ne=null;return{setReversed:function(Ae){Ce=Ae},setTest:function(Ae){Ae?be(n.DEPTH_TEST):Se(n.DEPTH_TEST)},setMask:function(Ae){ee!==Ae&&!O&&(n.depthMask(Ae),ee=Ae)},setFunc:function(Ae){if(Ce&&(Ae=PR[Ae]),oe!==Ae){switch(Ae){case Ro:n.depthFunc(n.NEVER);break;case Io:n.depthFunc(n.ALWAYS);break;case Lo:n.depthFunc(n.LESS);break;case kn:n.depthFunc(n.LEQUAL);break;case Po:n.depthFunc(n.EQUAL);break;case Do:n.depthFunc(n.GEQUAL);break;case Uo:n.depthFunc(n.GREATER);break;case Oo:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}oe=Ae}},setLocked:function(Ae){O=Ae},setClear:function(Ae){Ne!==Ae&&(n.clearDepth(Ae),Ne=Ae)},reset:function(){O=!1,ee=null,oe=null,Ne=null}}}function i(){let O=!1,Ce=null,ee=null,oe=null,Ne=null,Ae=null,Ut=null,ni=null,tr=null;return{setTest:function(At){O||(At?be(n.STENCIL_TEST):Se(n.STENCIL_TEST))},setMask:function(At){Ce!==At&&!O&&(n.stencilMask(At),Ce=At)},setFunc:function(At,ir,Mn){(ee!==At||oe!==ir||Ne!==Mn)&&(n.stencilFunc(At,ir,Mn),ee=At,oe=ir,Ne=Mn)},setOp:function(At,ir,Mn){(Ae!==At||Ut!==ir||ni!==Mn)&&(n.stencilOp(At,ir,Mn),Ae=At,Ut=ir,ni=Mn)},setLocked:function(At){O=At},setClear:function(At){tr!==At&&(n.clearStencil(At),tr=At)},reset:function(){O=!1,Ce=null,ee=null,oe=null,Ne=null,Ae=null,Ut=null,ni=null,tr=null}}}const r=new e,s=new t,a=new i,o=new WeakMap,l=new WeakMap;let c={},u={},h=new WeakMap,d=[],p=null,m=!1,v=null,f=null,g=null,x=null,y=null,_=null,I=null,T=new xe(0,0,0),w=0,C=!1,H=null,M=null,b=null,k=null,j=null;const Y=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let re=!1,$=0;const he=n.getParameter(n.VERSION);he.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(he)[1]),re=$>=1):he.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),re=$>=2);let Q=null,ye={};const Te=n.getParameter(n.SCISSOR_BOX),Ve=n.getParameter(n.VIEWPORT),at=new st().fromArray(Te),et=new st().fromArray(Ve);function ie(O,Ce,ee,oe){const Ne=new Uint8Array(4),Ae=n.createTexture();n.bindTexture(O,Ae),n.texParameteri(O,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(O,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ut=0;Ut<ee;Ut++)O===n.TEXTURE_3D||O===n.TEXTURE_2D_ARRAY?n.texImage3D(Ce,0,n.RGBA,1,1,oe,0,n.RGBA,n.UNSIGNED_BYTE,Ne):n.texImage2D(Ce+Ut,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ne);return Ae}const le={};le[n.TEXTURE_2D]=ie(n.TEXTURE_2D,n.TEXTURE_2D,1),le[n.TEXTURE_CUBE_MAP]=ie(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),le[n.TEXTURE_2D_ARRAY]=ie(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),le[n.TEXTURE_3D]=ie(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),be(n.DEPTH_TEST),s.setFunc(kn),pe(!1),Ue(Yd),be(n.CULL_FACE),L(Er);function be(O){c[O]!==!0&&(n.enable(O),c[O]=!0)}function Se(O){c[O]!==!1&&(n.disable(O),c[O]=!1)}function Ye(O,Ce){return u[O]!==Ce?(n.bindFramebuffer(O,Ce),u[O]=Ce,O===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=Ce),O===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=Ce),!0):!1}function We(O,Ce){let ee=d,oe=!1;if(O){ee=h.get(Ce),ee===void 0&&(ee=[],h.set(Ce,ee));const Ne=O.textures;if(ee.length!==Ne.length||ee[0]!==n.COLOR_ATTACHMENT0){for(let Ae=0,Ut=Ne.length;Ae<Ut;Ae++)ee[Ae]=n.COLOR_ATTACHMENT0+Ae;ee.length=Ne.length,oe=!0}}else ee[0]!==n.BACK&&(ee[0]=n.BACK,oe=!0);oe&&n.drawBuffers(ee)}function ot(O){return p!==O?(n.useProgram(O),p=O,!0):!1}const ce={[zn]:n.FUNC_ADD,[w0]:n.FUNC_SUBTRACT,[E0]:n.FUNC_REVERSE_SUBTRACT};ce[A0]=n.MIN,ce[ep]=n.MAX;const ue={[N0]:n.ZERO,[C0]:n.ONE,[R0]:n.SRC_COLOR,[wc]:n.SRC_ALPHA,[O0]:n.SRC_ALPHA_SATURATE,[D0]:n.DST_COLOR,[L0]:n.DST_ALPHA,[I0]:n.ONE_MINUS_SRC_COLOR,[Ec]:n.ONE_MINUS_SRC_ALPHA,[U0]:n.ONE_MINUS_DST_COLOR,[P0]:n.ONE_MINUS_DST_ALPHA,[F0]:n.CONSTANT_COLOR,[V0]:n.ONE_MINUS_CONSTANT_COLOR,[B0]:n.CONSTANT_ALPHA,[z0]:n.ONE_MINUS_CONSTANT_ALPHA};function L(O,Ce,ee,oe,Ne,Ae,Ut,ni,tr,At){if(O===Er){m===!0&&(Se(n.BLEND),m=!1);return}if(m===!1&&(be(n.BLEND),m=!0),O!==Qd){if(O!==v||At!==C){if((f!==zn||y!==zn)&&(n.blendEquation(n.FUNC_ADD),f=zn,y=zn),At)switch(O){case Tn:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Co:n.blendFunc(n.ONE,n.ONE);break;case Kd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Zd:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}else switch(O){case Tn:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Co:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Kd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Zd:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}g=null,x=null,_=null,I=null,T.set(0,0,0),w=0,v=O,C=At}return}Ne=Ne||Ce,Ae=Ae||ee,Ut=Ut||oe,(Ce!==f||Ne!==y)&&(n.blendEquationSeparate(ce[Ce],ce[Ne]),f=Ce,y=Ne),(ee!==g||oe!==x||Ae!==_||Ut!==I)&&(n.blendFuncSeparate(ue[ee],ue[oe],ue[Ae],ue[Ut]),g=ee,x=oe,_=Ae,I=Ut),(ni.equals(T)===!1||tr!==w)&&(n.blendColor(ni.r,ni.g,ni.b,tr),T.copy(ni),w=tr),v=O,C=!1}function He(O,Ce){O.side===Wr?Se(n.CULL_FACE):be(n.CULL_FACE);let ee=O.side===si;Ce&&(ee=!ee),pe(ee),O.blending===Tn&&O.transparent===!1?L(Er):L(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),s.setFunc(O.depthFunc),s.setTest(O.depthTest),s.setMask(O.depthWrite),r.setMask(O.colorWrite);const oe=O.stencilWrite;a.setTest(oe),oe&&(a.setMask(O.stencilWriteMask),a.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),a.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),$e(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?be(n.SAMPLE_ALPHA_TO_COVERAGE):Se(n.SAMPLE_ALPHA_TO_COVERAGE)}function pe(O){H!==O&&(O?n.frontFace(n.CW):n.frontFace(n.CCW),H=O)}function Ue(O){O!==b0?(be(n.CULL_FACE),O!==M&&(O===Yd?n.cullFace(n.BACK):O===S0?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Se(n.CULL_FACE),M=O}function we(O){O!==b&&(re&&n.lineWidth(O),b=O)}function $e(O,Ce,ee){O?(be(n.POLYGON_OFFSET_FILL),(k!==Ce||j!==ee)&&(n.polygonOffset(Ce,ee),k=Ce,j=ee)):Se(n.POLYGON_OFFSET_FILL)}function Be(O){O?be(n.SCISSOR_TEST):Se(n.SCISSOR_TEST)}function R(O){O===void 0&&(O=n.TEXTURE0+Y-1),Q!==O&&(n.activeTexture(O),Q=O)}function S(O,Ce,ee){ee===void 0&&(Q===null?ee=n.TEXTURE0+Y-1:ee=Q);let oe=ye[ee];oe===void 0&&(oe={type:void 0,texture:void 0},ye[ee]=oe),(oe.type!==O||oe.texture!==Ce)&&(Q!==ee&&(n.activeTexture(ee),Q=ee),n.bindTexture(O,Ce||le[O]),oe.type=O,oe.texture=Ce)}function W(){const O=ye[Q];O!==void 0&&O.type!==void 0&&(n.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function ne(){try{n.compressedTexImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function de(){try{n.compressedTexImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function se(){try{n.texSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ke(){try{n.texSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Ee(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Pe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function mt(){try{n.texStorage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ve(){try{n.texStorage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ze(){try{n.texImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function tt(){try{n.texImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function it(O){at.equals(O)===!1&&(n.scissor(O.x,O.y,O.z,O.w),at.copy(O))}function Oe(O){et.equals(O)===!1&&(n.viewport(O.x,O.y,O.z,O.w),et.copy(O))}function Mt(O,Ce){let ee=l.get(Ce);ee===void 0&&(ee=new WeakMap,l.set(Ce,ee));let oe=ee.get(O);oe===void 0&&(oe=n.getUniformBlockIndex(Ce,O.name),ee.set(O,oe))}function ut(O,Ce){const ee=l.get(Ce).get(O);o.get(Ce)!==ee&&(n.uniformBlockBinding(Ce,ee,O.__bindingPointIndex),o.set(Ce,ee))}function Dt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),c={},Q=null,ye={},u={},h=new WeakMap,d=[],p=null,m=!1,v=null,f=null,g=null,x=null,y=null,_=null,I=null,T=new xe(0,0,0),w=0,C=!1,H=null,M=null,b=null,k=null,j=null,at.set(0,0,n.canvas.width,n.canvas.height),et.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),a.reset()}return{buffers:{color:r,depth:s,stencil:a},enable:be,disable:Se,bindFramebuffer:Ye,drawBuffers:We,useProgram:ot,setBlending:L,setMaterial:He,setFlipSided:pe,setCullFace:Ue,setLineWidth:we,setPolygonOffset:$e,setScissorTest:Be,activeTexture:R,bindTexture:S,unbindTexture:W,compressedTexImage2D:ne,compressedTexImage3D:de,texImage2D:ze,texImage3D:tt,updateUBOMapping:Mt,uniformBlockBinding:ut,texStorage2D:mt,texStorage3D:ve,texSubImage2D:se,texSubImage3D:ke,compressedTexSubImage2D:Ee,compressedTexSubImage3D:Pe,scissor:it,viewport:Oe,reset:Dt}}function UR(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function OR(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function FR(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function Qp(n,e,t,i){const r=VR(i);switch(t){case lp:return n*e;case cp:return n*e;case up:return n*e*2;case Fo:return n*e/r.components*r.byteLength;case Vo:return n*e/r.components*r.byteLength;case xa:return n*e*2/r.components*r.byteLength;case Bc:return n*e*2/r.components*r.byteLength;case Vc:return n*e*3/r.components*r.byteLength;case Ei:return n*e*4/r.components*r.byteLength;case zc:return n*e*4/r.components*r.byteLength;case _a:case Ma:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ta:case ba:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case kc:case Hc:return Math.max(n,16)*Math.max(e,8)/4;case Bo:case zo:return Math.max(n,8)*Math.max(e,8)/2;case ko:case Ho:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Go:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Wo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Gc:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Wc:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case jc:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case jo:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Xc:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case qc:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Yc:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case $c:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Jc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Kc:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Zc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Qc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case eu:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Sa:case tu:case Xo:return Math.ceil(n/4)*Math.ceil(e/4)*16;case hp:case iu:return Math.ceil(n/4)*Math.ceil(e/4)*8;case ru:case nu:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function VR(n){switch(n){case jr:case ap:return{byteLength:1,components:1};case va:case op:case wi:return{byteLength:2,components:1};case Dc:case Uc:return{byteLength:2,components:4};case Nr:case ya:case Oi:return{byteLength:4,components:1};case Oc:case Fc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}const BR={contain:UR,cover:OR,fill:FR,getByteLength:Qp};function zR(n,e,t,i,r,s,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),c=new J,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(R,S){return p?new OffscreenCanvas(R,S):el("canvas")}function v(R,S,W){let ne=1;const de=Be(R);if((de.width>W||de.height>W)&&(ne=W/Math.max(de.width,de.height)),ne<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const se=Math.floor(ne*de.width),ke=Math.floor(ne*de.height);h===void 0&&(h=m(se,ke));const Ee=S?m(se,ke):h;return Ee.width=se,Ee.height=ke,Ee.getContext("2d").drawImage(R,0,0,se,ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+de.width+"x"+de.height+") to ("+se+"x"+ke+")."),Ee}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+de.width+"x"+de.height+")."),R;return R}function f(R){return R.generateMipmaps&&R.minFilter!==$t&&R.minFilter!==Lt}function g(R){n.generateMipmap(R)}function x(R,S,W,ne,de=!1){if(R!==null){if(n[R]!==void 0)return n[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let se=S;if(S===n.RED&&(W===n.FLOAT&&(se=n.R32F),W===n.HALF_FLOAT&&(se=n.R16F),W===n.UNSIGNED_BYTE&&(se=n.R8)),S===n.RED_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.R8UI),W===n.UNSIGNED_SHORT&&(se=n.R16UI),W===n.UNSIGNED_INT&&(se=n.R32UI),W===n.BYTE&&(se=n.R8I),W===n.SHORT&&(se=n.R16I),W===n.INT&&(se=n.R32I)),S===n.RG&&(W===n.FLOAT&&(se=n.RG32F),W===n.HALF_FLOAT&&(se=n.RG16F),W===n.UNSIGNED_BYTE&&(se=n.RG8)),S===n.RG_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RG8UI),W===n.UNSIGNED_SHORT&&(se=n.RG16UI),W===n.UNSIGNED_INT&&(se=n.RG32UI),W===n.BYTE&&(se=n.RG8I),W===n.SHORT&&(se=n.RG16I),W===n.INT&&(se=n.RG32I)),S===n.RGB_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RGB8UI),W===n.UNSIGNED_SHORT&&(se=n.RGB16UI),W===n.UNSIGNED_INT&&(se=n.RGB32UI),W===n.BYTE&&(se=n.RGB8I),W===n.SHORT&&(se=n.RGB16I),W===n.INT&&(se=n.RGB32I)),S===n.RGBA_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RGBA8UI),W===n.UNSIGNED_SHORT&&(se=n.RGBA16UI),W===n.UNSIGNED_INT&&(se=n.RGBA32UI),W===n.BYTE&&(se=n.RGBA8I),W===n.SHORT&&(se=n.RGBA16I),W===n.INT&&(se=n.RGBA32I)),S===n.RGB&&(W===n.UNSIGNED_INT_5_9_9_9_REV&&(se=n.RGB9_E5),W===n.UNSIGNED_INT_10F_11F_11F_REV&&(se=n.R11F_G11F_B10F)),S===n.RGBA){const ke=de?Jo:vt.getTransfer(ne);W===n.FLOAT&&(se=n.RGBA32F),W===n.HALF_FLOAT&&(se=n.RGBA16F),W===n.UNSIGNED_BYTE&&(se=ke===Ot?n.SRGB8_ALPHA8:n.RGBA8),W===n.UNSIGNED_SHORT_4_4_4_4&&(se=n.RGBA4),W===n.UNSIGNED_SHORT_5_5_5_1&&(se=n.RGB5_A1)}return(se===n.R16F||se===n.R32F||se===n.RG16F||se===n.RG32F||se===n.RGBA16F||se===n.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function y(R,S){let W;return R?S===null||S===Nr||S===qn?W=n.DEPTH24_STENCIL8:S===Oi?W=n.DEPTH32F_STENCIL8:S===va&&(W=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Nr||S===qn?W=n.DEPTH_COMPONENT24:S===Oi?W=n.DEPTH_COMPONENT32F:S===va&&(W=n.DEPTH_COMPONENT16),W}function _(R,S){return f(R)===!0||R.isFramebufferTexture&&R.minFilter!==$t&&R.minFilter!==Lt?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function I(R){const S=R.target;S.removeEventListener("dispose",I),w(S),S.isVideoTexture&&u.delete(S)}function T(R){const S=R.target;S.removeEventListener("dispose",T),H(S)}function w(R){const S=i.get(R);if(S.__webglInit===void 0)return;const W=R.source,ne=d.get(W);if(ne){const de=ne[S.__cacheKey];de.usedTimes--,de.usedTimes===0&&C(R),Object.keys(ne).length===0&&d.delete(W)}i.remove(R)}function C(R){const S=i.get(R);n.deleteTexture(S.__webglTexture);const W=R.source,ne=d.get(W);delete ne[S.__cacheKey],a.memory.textures--}function H(R){const S=i.get(R);if(R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let ne=0;ne<6;ne++){if(Array.isArray(S.__webglFramebuffer[ne]))for(let de=0;de<S.__webglFramebuffer[ne].length;de++)n.deleteFramebuffer(S.__webglFramebuffer[ne][de]);else n.deleteFramebuffer(S.__webglFramebuffer[ne]);S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer[ne])}else{if(Array.isArray(S.__webglFramebuffer))for(let ne=0;ne<S.__webglFramebuffer.length;ne++)n.deleteFramebuffer(S.__webglFramebuffer[ne]);else n.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&n.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let ne=0;ne<S.__webglColorRenderbuffer.length;ne++)S.__webglColorRenderbuffer[ne]&&n.deleteRenderbuffer(S.__webglColorRenderbuffer[ne]);S.__webglDepthRenderbuffer&&n.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const W=R.textures;for(let ne=0,de=W.length;ne<de;ne++){const se=i.get(W[ne]);se.__webglTexture&&(n.deleteTexture(se.__webglTexture),a.memory.textures--),i.remove(W[ne])}i.remove(R)}let M=0;function b(){M=0}function k(){const R=M;return R>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+r.maxTextures),M+=1,R}function j(R){const S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function Y(R,S){const W=i.get(R);if(R.isVideoTexture&&we(R),R.isRenderTargetTexture===!1&&R.version>0&&W.__version!==R.version){const ne=R.image;if(ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{et(W,R,S);return}}t.bindTexture(n.TEXTURE_2D,W.__webglTexture,n.TEXTURE0+S)}function re(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){et(W,R,S);return}t.bindTexture(n.TEXTURE_2D_ARRAY,W.__webglTexture,n.TEXTURE0+S)}function $(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){et(W,R,S);return}t.bindTexture(n.TEXTURE_3D,W.__webglTexture,n.TEXTURE0+S)}function he(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){ie(W,R,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,W.__webglTexture,n.TEXTURE0+S)}const Q={[jn]:n.REPEAT,[gr]:n.CLAMP_TO_EDGE,[ga]:n.MIRRORED_REPEAT},ye={[$t]:n.NEAREST,[Pc]:n.NEAREST_MIPMAP_NEAREST,[bn]:n.NEAREST_MIPMAP_LINEAR,[Lt]:n.LINEAR,[Xn]:n.LINEAR_MIPMAP_NEAREST,[Xi]:n.LINEAR_MIPMAP_LINEAR},Te={[lv]:n.NEVER,[pv]:n.ALWAYS,[yp]:n.LESS,[xp]:n.LEQUAL,[cv]:n.EQUAL,[dv]:n.GEQUAL,[uv]:n.GREATER,[hv]:n.NOTEQUAL};function Ve(R,S){if(S.type===Oi&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Lt||S.magFilter===Xn||S.magFilter===bn||S.magFilter===Xi||S.minFilter===Lt||S.minFilter===Xn||S.minFilter===bn||S.minFilter===Xi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,Q[S.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,Q[S.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,Q[S.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,ye[S.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,ye[S.minFilter]),S.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,Te[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===$t||S.minFilter!==bn&&S.minFilter!==Xi||S.type===Oi&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){const W=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,r.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function at(R,S){let W=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",I));const ne=S.source;let de=d.get(ne);de===void 0&&(de={},d.set(ne,de));const se=j(S);if(se!==R.__cacheKey){de[se]===void 0&&(de[se]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,W=!0),de[se].usedTimes++;const ke=de[R.__cacheKey];ke!==void 0&&(de[R.__cacheKey].usedTimes--,ke.usedTimes===0&&C(S)),R.__cacheKey=se,R.__webglTexture=de[se].texture}return W}function et(R,S,W){let ne=n.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(ne=n.TEXTURE_2D_ARRAY),S.isData3DTexture&&(ne=n.TEXTURE_3D);const de=at(R,S),se=S.source;t.bindTexture(ne,R.__webglTexture,n.TEXTURE0+W);const ke=i.get(se);if(se.version!==ke.__version||de===!0){t.activeTexture(n.TEXTURE0+W);const Ee=vt.getPrimaries(vt.workingColorSpace),Pe=S.colorSpace===Cr?null:vt.getPrimaries(S.colorSpace),mt=S.colorSpace===Cr||Ee===Pe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,mt);let ve=v(S.image,!1,r.maxTextureSize);ve=$e(S,ve);const ze=s.convert(S.format,S.colorSpace),tt=s.convert(S.type);let it=x(S.internalFormat,ze,tt,S.colorSpace,S.isVideoTexture);Ve(ne,S);let Oe;const Mt=S.mipmaps,ut=S.isVideoTexture!==!0,Dt=ke.__version===void 0||de===!0,O=se.dataReady,Ce=_(S,ve);if(S.isDepthTexture)it=y(S.format===$n,S.type),Dt&&(ut?t.texStorage2D(n.TEXTURE_2D,1,it,ve.width,ve.height):t.texImage2D(n.TEXTURE_2D,0,it,ve.width,ve.height,0,ze,tt,null));else if(S.isDataTexture)if(Mt.length>0){ut&&Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,Mt[0].width,Mt[0].height);for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,tt,Oe.data):t.texImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,ze,tt,Oe.data);S.generateMipmaps=!1}else ut?(Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,ve.width,ve.height),O&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ve.width,ve.height,ze,tt,ve.data)):t.texImage2D(n.TEXTURE_2D,0,it,ve.width,ve.height,0,ze,tt,ve.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){ut&&Dt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ce,it,Mt[0].width,Mt[0].height,ve.depth);for(let ee=0,oe=Mt.length;ee<oe;ee++)if(Oe=Mt[ee],S.format!==Ei)if(ze!==null)if(ut){if(O)if(S.layerUpdates.size>0){const Ne=Qp(Oe.width,Oe.height,S.format,S.type);for(const Ae of S.layerUpdates){const Ut=Oe.data.subarray(Ae*Ne/Oe.data.BYTES_PER_ELEMENT,(Ae+1)*Ne/Oe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,Ae,Oe.width,Oe.height,1,ze,Ut,0,0)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,Oe.width,Oe.height,ve.depth,ze,Oe.data,0,0)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ee,it,Oe.width,Oe.height,ve.depth,0,Oe.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ut?O&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,Oe.width,Oe.height,ve.depth,ze,tt,Oe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ee,it,Oe.width,Oe.height,ve.depth,0,ze,tt,Oe.data)}else{ut&&Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,Mt[0].width,Mt[0].height);for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],S.format!==Ei?ze!==null?ut?O&&t.compressedTexSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,Oe.data):t.compressedTexImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,Oe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,tt,Oe.data):t.texImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,ze,tt,Oe.data)}else if(S.isDataArrayTexture)if(ut){if(Dt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ce,it,ve.width,ve.height,ve.depth),O)if(S.layerUpdates.size>0){const ee=Qp(ve.width,ve.height,S.format,S.type);for(const oe of S.layerUpdates){const Ne=ve.data.subarray(oe*ee/ve.data.BYTES_PER_ELEMENT,(oe+1)*ee/ve.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,oe,ve.width,ve.height,1,ze,tt,Ne)}S.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ve.width,ve.height,ve.depth,ze,tt,ve.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,it,ve.width,ve.height,ve.depth,0,ze,tt,ve.data);else if(S.isData3DTexture)ut?(Dt&&t.texStorage3D(n.TEXTURE_3D,Ce,it,ve.width,ve.height,ve.depth),O&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ve.width,ve.height,ve.depth,ze,tt,ve.data)):t.texImage3D(n.TEXTURE_3D,0,it,ve.width,ve.height,ve.depth,0,ze,tt,ve.data);else if(S.isFramebufferTexture){if(Dt)if(ut)t.texStorage2D(n.TEXTURE_2D,Ce,it,ve.width,ve.height);else{let ee=ve.width,oe=ve.height;for(let Ne=0;Ne<Ce;Ne++)t.texImage2D(n.TEXTURE_2D,Ne,it,ee,oe,0,ze,tt,null),ee>>=1,oe>>=1}}else if(Mt.length>0){if(ut&&Dt){const ee=Be(Mt[0]);t.texStorage2D(n.TEXTURE_2D,Ce,it,ee.width,ee.height)}for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,ze,tt,Oe):t.texImage2D(n.TEXTURE_2D,ee,it,ze,tt,Oe);S.generateMipmaps=!1}else if(ut){if(Dt){const ee=Be(ve);t.texStorage2D(n.TEXTURE_2D,Ce,it,ee.width,ee.height)}O&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ze,tt,ve)}else t.texImage2D(n.TEXTURE_2D,0,it,ze,tt,ve);f(S)&&g(ne),ke.__version=se.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function ie(R,S,W){if(S.image.length!==6)return;const ne=at(R,S),de=S.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+W);const se=i.get(de);if(de.version!==se.__version||ne===!0){t.activeTexture(n.TEXTURE0+W);const ke=vt.getPrimaries(vt.workingColorSpace),Ee=S.colorSpace===Cr?null:vt.getPrimaries(S.colorSpace),Pe=S.colorSpace===Cr||ke===Ee?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pe);const mt=S.isCompressedTexture||S.image[0].isCompressedTexture,ve=S.image[0]&&S.image[0].isDataTexture,ze=[];for(let oe=0;oe<6;oe++)!mt&&!ve?ze[oe]=v(S.image[oe],!0,r.maxCubemapSize):ze[oe]=ve?S.image[oe].image:S.image[oe],ze[oe]=$e(S,ze[oe]);const tt=ze[0],it=s.convert(S.format,S.colorSpace),Oe=s.convert(S.type),Mt=x(S.internalFormat,it,Oe,S.colorSpace),ut=S.isVideoTexture!==!0,Dt=se.__version===void 0||ne===!0,O=de.dataReady;let Ce=_(S,tt);Ve(n.TEXTURE_CUBE_MAP,S);let ee;if(mt){ut&&Dt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Ce,Mt,tt.width,tt.height);for(let oe=0;oe<6;oe++){ee=ze[oe].mipmaps;for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne];S.format!==Ei?it!==null?ut?O&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,0,0,Ae.width,Ae.height,it,Ae.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,Mt,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,0,0,Ae.width,Ae.height,it,Oe,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,Mt,Ae.width,Ae.height,0,it,Oe,Ae.data)}}}else{if(ee=S.mipmaps,ut&&Dt){ee.length>0&&Ce++;const oe=Be(ze[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,Ce,Mt,oe.width,oe.height)}for(let oe=0;oe<6;oe++)if(ve){ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,ze[oe].width,ze[oe].height,it,Oe,ze[oe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Mt,ze[oe].width,ze[oe].height,0,it,Oe,ze[oe].data);for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne].image[oe].image;ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,0,0,Ae.width,Ae.height,it,Oe,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,Mt,Ae.width,Ae.height,0,it,Oe,Ae.data)}}else{ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,it,Oe,ze[oe]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Mt,it,Oe,ze[oe]);for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne];ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,0,0,it,Oe,Ae.image[oe]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,Mt,it,Oe,Ae.image[oe])}}}f(S)&&g(n.TEXTURE_CUBE_MAP),se.__version=de.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function le(R,S,W,ne,de,se){const ke=s.convert(W.format,W.colorSpace),Ee=s.convert(W.type),Pe=x(W.internalFormat,ke,Ee,W.colorSpace);if(!i.get(S).__hasExternalTextures){const mt=Math.max(1,S.width>>se),ve=Math.max(1,S.height>>se);de===n.TEXTURE_3D||de===n.TEXTURE_2D_ARRAY?t.texImage3D(de,se,Pe,mt,ve,S.depth,0,ke,Ee,null):t.texImage2D(de,se,Pe,mt,ve,0,ke,Ee,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ne,de,i.get(W).__webglTexture,0,pe(S)):(de===n.TEXTURE_2D||de>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&de<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ne,de,i.get(W).__webglTexture,se),t.bindFramebuffer(n.FRAMEBUFFER,null)}function be(R,S,W){if(n.bindRenderbuffer(n.RENDERBUFFER,R),S.depthBuffer){const ne=S.depthTexture,de=ne&&ne.isDepthTexture?ne.type:null,se=y(S.stencilBuffer,de),ke=S.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ee=pe(S);Ue(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ee,se,S.width,S.height):W?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,se,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,se,S.width,S.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,ke,n.RENDERBUFFER,R)}else{const ne=S.textures;for(let de=0;de<ne.length;de++){const se=ne[de],ke=s.convert(se.format,se.colorSpace),Ee=s.convert(se.type),Pe=x(se.internalFormat,ke,Ee,se.colorSpace),mt=pe(S);W&&Ue(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,mt,Pe,S.width,S.height):Ue(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,mt,Pe,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,Pe,S.width,S.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Se(R,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),Y(S.depthTexture,0);const W=i.get(S.depthTexture).__webglTexture,ne=pe(S);if(S.depthTexture.format===Yn)Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,W,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,W,0);else if(S.depthTexture.format===$n)Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,W,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,W,0);else throw new Error("Unknown depthTexture format")}function Ye(R){const S=i.get(R),W=R.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==R.depthTexture){const ne=R.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),ne){const de=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,ne.removeEventListener("dispose",de)};ne.addEventListener("dispose",de),S.__depthDisposeCallback=de}S.__boundDepthTexture=ne}if(R.depthTexture&&!S.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");Se(S.__webglFramebuffer,R)}else if(W){S.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer[ne]),S.__webglDepthbuffer[ne]===void 0)S.__webglDepthbuffer[ne]=n.createRenderbuffer(),be(S.__webglDepthbuffer[ne],R,!1);else{const de=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,se=S.__webglDepthbuffer[ne];n.bindRenderbuffer(n.RENDERBUFFER,se),n.framebufferRenderbuffer(n.FRAMEBUFFER,de,n.RENDERBUFFER,se)}}else if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=n.createRenderbuffer(),be(S.__webglDepthbuffer,R,!1);else{const ne=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,de=S.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,de),n.framebufferRenderbuffer(n.FRAMEBUFFER,ne,n.RENDERBUFFER,de)}t.bindFramebuffer(n.FRAMEBUFFER,null)}function We(R,S,W){const ne=i.get(R);S!==void 0&&le(ne.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),W!==void 0&&Ye(R)}function ot(R){const S=R.texture,W=i.get(R),ne=i.get(S);R.addEventListener("dispose",T);const de=R.textures,se=R.isWebGLCubeRenderTarget===!0,ke=de.length>1;if(ke||(ne.__webglTexture===void 0&&(ne.__webglTexture=n.createTexture()),ne.__version=S.version,a.memory.textures++),se){W.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer[Ee]=[];for(let Pe=0;Pe<S.mipmaps.length;Pe++)W.__webglFramebuffer[Ee][Pe]=n.createFramebuffer()}else W.__webglFramebuffer[Ee]=n.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer=[];for(let Ee=0;Ee<S.mipmaps.length;Ee++)W.__webglFramebuffer[Ee]=n.createFramebuffer()}else W.__webglFramebuffer=n.createFramebuffer();if(ke)for(let Ee=0,Pe=de.length;Ee<Pe;Ee++){const mt=i.get(de[Ee]);mt.__webglTexture===void 0&&(mt.__webglTexture=n.createTexture(),a.memory.textures++)}if(R.samples>0&&Ue(R)===!1){W.__webglMultisampledFramebuffer=n.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let Ee=0;Ee<de.length;Ee++){const Pe=de[Ee];W.__webglColorRenderbuffer[Ee]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,W.__webglColorRenderbuffer[Ee]);const mt=s.convert(Pe.format,Pe.colorSpace),ve=s.convert(Pe.type),ze=x(Pe.internalFormat,mt,ve,Pe.colorSpace,R.isXRRenderTarget===!0),tt=pe(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,tt,ze,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,W.__webglColorRenderbuffer[Ee])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(W.__webglDepthRenderbuffer=n.createRenderbuffer(),be(W.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(se){t.bindTexture(n.TEXTURE_CUBE_MAP,ne.__webglTexture),Ve(n.TEXTURE_CUBE_MAP,S);for(let Ee=0;Ee<6;Ee++)if(S.mipmaps&&S.mipmaps.length>0)for(let Pe=0;Pe<S.mipmaps.length;Pe++)le(W.__webglFramebuffer[Ee][Pe],R,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,Pe);else le(W.__webglFramebuffer[Ee],R,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,0);f(S)&&g(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ke){for(let Ee=0,Pe=de.length;Ee<Pe;Ee++){const mt=de[Ee],ve=i.get(mt);t.bindTexture(n.TEXTURE_2D,ve.__webglTexture),Ve(n.TEXTURE_2D,mt),le(W.__webglFramebuffer,R,mt,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,0),f(mt)&&g(n.TEXTURE_2D)}t.unbindTexture()}else{let Ee=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Ee=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ee,ne.__webglTexture),Ve(Ee,S),S.mipmaps&&S.mipmaps.length>0)for(let Pe=0;Pe<S.mipmaps.length;Pe++)le(W.__webglFramebuffer[Pe],R,S,n.COLOR_ATTACHMENT0,Ee,Pe);else le(W.__webglFramebuffer,R,S,n.COLOR_ATTACHMENT0,Ee,0);f(S)&&g(Ee),t.unbindTexture()}R.depthBuffer&&Ye(R)}function ce(R){const S=R.textures;for(let W=0,ne=S.length;W<ne;W++){const de=S[W];if(f(de)){const se=R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,ke=i.get(de).__webglTexture;t.bindTexture(se,ke),g(se),t.unbindTexture()}}}const ue=[],L=[];function He(R){if(R.samples>0){if(Ue(R)===!1){const S=R.textures,W=R.width,ne=R.height;let de=n.COLOR_BUFFER_BIT;const se=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ke=i.get(R),Ee=S.length>1;if(Ee)for(let Pe=0;Pe<S.length;Pe++)t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ke.__webglFramebuffer);for(let Pe=0;Pe<S.length;Pe++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(de|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(de|=n.STENCIL_BUFFER_BIT)),Ee){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,ke.__webglColorRenderbuffer[Pe]);const mt=i.get(S[Pe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,mt,0)}n.blitFramebuffer(0,0,W,ne,0,0,W,ne,de,n.NEAREST),l===!0&&(ue.length=0,L.length=0,ue.push(n.COLOR_ATTACHMENT0+Pe),R.depthBuffer&&R.resolveDepthBuffer===!1&&(ue.push(se),L.push(se),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,L)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,ue))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ee)for(let Pe=0;Pe<S.length;Pe++){t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,ke.__webglColorRenderbuffer[Pe]);const mt=i.get(S[Pe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,mt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ke.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const S=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[S])}}}function pe(R){return Math.min(r.maxSamples,R.samples)}function Ue(R){const S=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function we(R){const S=a.render.frame;u.get(R)!==S&&(u.set(R,S),R.update())}function $e(R,S){const W=R.colorSpace,ne=R.format,de=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||W!==nr&&W!==Cr&&(vt.getTransfer(W)===Ot?(ne!==Ei||de!==jr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),S}function Be(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=b,this.setTexture2D=Y,this.setTexture2DArray=re,this.setTexture3D=$,this.setTextureCube=he,this.rebindTextures=We,this.setupRenderTarget=ot,this.updateRenderTargetMipmap=ce,this.updateMultisampleRenderTarget=He,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=le,this.useMultisampledRTT=Ue}function py(n,e){function t(i,r=Cr){let s;const a=vt.getTransfer(r);if(i===jr)return n.UNSIGNED_BYTE;if(i===Dc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Uc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Oc)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Fc)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===ap)return n.BYTE;if(i===op)return n.SHORT;if(i===va)return n.UNSIGNED_SHORT;if(i===ya)return n.INT;if(i===Nr)return n.UNSIGNED_INT;if(i===Oi)return n.FLOAT;if(i===wi)return n.HALF_FLOAT;if(i===lp)return n.ALPHA;if(i===Vc)return n.RGB;if(i===Ei)return n.RGBA;if(i===cp)return n.LUMINANCE;if(i===up)return n.LUMINANCE_ALPHA;if(i===Yn)return n.DEPTH_COMPONENT;if(i===$n)return n.DEPTH_STENCIL;if(i===Fo)return n.RED;if(i===Vo)return n.RED_INTEGER;if(i===xa)return n.RG;if(i===Bc)return n.RG_INTEGER;if(i===zc)return n.RGBA_INTEGER;if(i===_a||i===Ma||i===Ta||i===ba)if(a===Ot)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===_a)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ma)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ta)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===ba)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===_a)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ma)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ta)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===ba)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Bo||i===kc||i===zo||i===Hc)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Bo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===kc)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===zo)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hc)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===ko||i===Ho||i===Go)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===ko||i===Ho)return a===Ot?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Go)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Wo||i===Gc||i===Wc||i===jc||i===jo||i===Xc||i===qc||i===Yc||i===$c||i===Jc||i===Kc||i===Zc||i===Qc||i===eu)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Wo)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Gc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Wc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===jo)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Xc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===qc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Yc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===$c)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Kc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Zc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Qc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===eu)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Sa||i===tu||i===Xo)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Sa)return a===Ot?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===tu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Xo)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===hp||i===iu||i===ru||i===nu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Sa)return s.COMPRESSED_RED_RGTC1_EXT;if(i===iu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ru)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===nu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===qn?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class em extends di{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Vs extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const kR={type:"move"};class tm{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Vs,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 Vs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Vs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),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,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const f=t.getJointPose(v,i),g=this._getHandJoint(c,v);f!==null&&(g.matrix.fromArray(f.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=f.radius),g.visible=f!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,m=.005;c.inputState.pinching&&d>p+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),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(kR)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Vs;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const HR=`
|
|
3820
3820
|
void main() {
|
|
3821
3821
|
|
|
3822
3822
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -3840,7 +3840,7 @@ void main() {
|
|
|
3840
3840
|
|
|
3841
3841
|
}
|
|
3842
3842
|
|
|
3843
|
-
}`;class WR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new Wt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Pr({vertexShader:HR,fragmentShader:GR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ft(new ha(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class jR extends vr{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,m=null;const v=new WR,f=t.getContextAttributes();let g=null,x=null;const y=[],_=[],I=new J;let T=null;const w=new di;w.layers.enable(1),w.viewport=new st;const C=new di;C.layers.enable(2),C.viewport=new st;const H=[w,C],M=new Qp;M.layers.enable(1),M.layers.enable(2);let b=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(ie){let le=y[ie];return le===void 0&&(le=new em,y[ie]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ie){let le=y[ie];return le===void 0&&(le=new em,y[ie]=le),le.getGripSpace()},this.getHand=function(ie){let le=y[ie];return le===void 0&&(le=new em,y[ie]=le),le.getHandSpace()};function j(ie){const le=_.indexOf(ie.inputSource);if(le===-1)return;const be=y[le];be!==void 0&&(be.update(ie.inputSource,ie.frame,c||a),be.dispatchEvent({type:ie.type,data:ie.inputSource}))}function Y(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",re);for(let ie=0;ie<y.length;ie++){const le=_[ie];le!==null&&(_[ie]=null,y[ie]&&y[ie].disconnect(le))}b=null,k=null,v.reset(),e.setRenderTarget(g),p=null,d=null,h=null,r=null,x=null,et.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(I.width,I.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){s=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){o=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(ie){if(r=ie,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",j),r.addEventListener("selectstart",j),r.addEventListener("selectend",j),r.addEventListener("squeeze",j),r.addEventListener("squeezestart",j),r.addEventListener("squeezeend",j),r.addEventListener("end",Y),r.addEventListener("inputsourceschange",re),f.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(I),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let le=null,be=null,Se=null;f.depth&&(Se=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,le=f.stencil?Yn:qn,be=f.stencil?Xn:Nr);const Ye={colorFormat:t.RGBA8,depthFormat:Se,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(Ye),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new Ir(d.textureWidth,d.textureHeight,{format:Ei,type:jr,depthTexture:new Os(d.textureWidth,d.textureHeight,be,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}else{const le={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,le),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),x=new Ir(p.framebufferWidth,p.framebufferHeight,{format:Ei,type:jr,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}x.isXRRenderTarget=!0,this.setFoveation(l),c=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 v.getDepthTexture()};function re(ie){for(let le=0;le<ie.removed.length;le++){const be=ie.removed[le],Se=_.indexOf(be);Se>=0&&(_[Se]=null,y[Se]&&y[Se].disconnect(be))}for(let le=0;le<ie.added.length;le++){const be=ie.added[le];let Se=_.indexOf(be);if(Se===-1){for(let We=0;We<y.length;We++)if(We>=_.length){_.push(be),Se=We;break}else if(_[We]===null){_[We]=be,Se=We;break}if(Se===-1)break}const Ye=y[Se];Ye&&Ye.connect(be)}}const $=new N,he=new N;function Q(ie,le,be){$.setFromMatrixPosition(le.matrixWorld),he.setFromMatrixPosition(be.matrixWorld);const Se=$.distanceTo(he),Ye=le.projectionMatrix.elements,We=be.projectionMatrix.elements,ot=Ye[14]/(Ye[10]-1),ce=Ye[14]/(Ye[10]+1),ue=(Ye[9]+1)/Ye[5],L=(Ye[9]-1)/Ye[5],He=(Ye[8]-1)/Ye[0],pe=(We[8]+1)/We[0],Ue=ot*He,we=ot*pe,$e=Se/(-He+pe),Be=$e*-He;if(le.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(Be),ie.translateZ($e),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert(),Ye[10]===-1)ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const R=ot+$e,S=ce+$e,W=Ue-Be,ne=we+(Se-Be),de=ue*ce/S*R,se=L*ce/S*R;ie.projectionMatrix.makePerspective(W,ne,de,se,R,S),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}}function ye(ie,le){le===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(le.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(r===null)return;let le=ie.near,be=ie.far;v.texture!==null&&(v.depthNear>0&&(le=v.depthNear),v.depthFar>0&&(be=v.depthFar)),M.near=C.near=w.near=le,M.far=C.far=w.far=be,(b!==M.near||k!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),b=M.near,k=M.far);const Se=ie.parent,Ye=M.cameras;ye(M,Se);for(let We=0;We<Ye.length;We++)ye(Ye[We],Se);Ye.length===2?Q(M,w,C):M.projectionMatrix.copy(w.projectionMatrix),Te(ie,M,Se)};function Te(ie,le,be){be===null?ie.matrix.copy(le.matrixWorld):(ie.matrix.copy(be.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(le.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=Ea*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(ie){l=ie,d!==null&&(d.fixedFoveation=ie),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ie)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let Ve=null;function at(ie,le){if(u=le.getViewerPose(c||a),m=le,u!==null){const be=u.views;p!==null&&(e.setRenderTargetFramebuffer(x,p.framebuffer),e.setRenderTarget(x));let Se=!1;be.length!==M.cameras.length&&(M.cameras.length=0,Se=!0);for(let We=0;We<be.length;We++){const ot=be[We];let ce=null;if(p!==null)ce=p.getViewport(ot);else{const L=h.getViewSubImage(d,ot);ce=L.viewport,We===0&&(e.setRenderTargetTextures(x,L.colorTexture,d.ignoreDepthValues?void 0:L.depthStencilTexture),e.setRenderTarget(x))}let ue=H[We];ue===void 0&&(ue=new di,ue.layers.enable(We),ue.viewport=new st,H[We]=ue),ue.matrix.fromArray(ot.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(ot.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(ce.x,ce.y,ce.width,ce.height),We===0&&(M.matrix.copy(ue.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Se===!0&&M.cameras.push(ue)}const Ye=r.enabledFeatures;if(Ye&&Ye.includes("depth-sensing")){const We=h.getDepthInformation(be[0]);We&&We.isValid&&We.texture&&v.init(e,We,r.renderState)}}if(i.controllerAutoUpdate)for(let be=0;be<y.length;be++){const Se=_[be],Ye=y[be];Se!==null&&Ye!==void 0&&Ye.update(Se,le,c||a)}Ve&&Ve(ie,le),le.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:le}),m=null}const et=new Vv;et.setAnimationLoop(at),this.setAnimationLoop=function(ie){Ve=ie},this.dispose=function(){}}}const Vs=new dr,XR=new Re;function qR(n,e){function t(f,g){f.matrixAutoUpdate===!0&&f.updateMatrix(),g.value.copy(f.matrix)}function i(f,g){g.color.getRGB(f.fogColor.value,Uv(n)),g.isFog?(f.fogNear.value=g.near,f.fogFar.value=g.far):g.isFogExp2&&(f.fogDensity.value=g.density)}function r(f,g,x,y,_){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(f,g):g.isMeshToonMaterial?(s(f,g),h(f,g)):g.isMeshPhongMaterial?(s(f,g),u(f,g)):g.isMeshStandardMaterial?(s(f,g),d(f,g),g.isMeshPhysicalMaterial&&p(f,g,_)):g.isMeshMatcapMaterial?(s(f,g),m(f,g)):g.isMeshDepthMaterial?s(f,g):g.isMeshDistanceMaterial?(s(f,g),v(f,g)):g.isMeshNormalMaterial?s(f,g):g.isLineBasicMaterial?(a(f,g),g.isLineDashedMaterial&&o(f,g)):g.isPointsMaterial?l(f,g,x,y):g.isSpriteMaterial?c(f,g):g.isShadowMaterial?(f.color.value.copy(g.color),f.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(f,g){f.opacity.value=g.opacity,g.color&&f.diffuse.value.copy(g.color),g.emissive&&f.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.bumpMap&&(f.bumpMap.value=g.bumpMap,t(g.bumpMap,f.bumpMapTransform),f.bumpScale.value=g.bumpScale,g.side===si&&(f.bumpScale.value*=-1)),g.normalMap&&(f.normalMap.value=g.normalMap,t(g.normalMap,f.normalMapTransform),f.normalScale.value.copy(g.normalScale),g.side===si&&f.normalScale.value.negate()),g.displacementMap&&(f.displacementMap.value=g.displacementMap,t(g.displacementMap,f.displacementMapTransform),f.displacementScale.value=g.displacementScale,f.displacementBias.value=g.displacementBias),g.emissiveMap&&(f.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,f.emissiveMapTransform)),g.specularMap&&(f.specularMap.value=g.specularMap,t(g.specularMap,f.specularMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest);const x=e.get(g),y=x.envMap,_=x.envMapRotation;y&&(f.envMap.value=y,Vs.copy(_),Vs.x*=-1,Vs.y*=-1,Vs.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Vs.y*=-1,Vs.z*=-1),f.envMapRotation.value.setFromMatrix4(XR.makeRotationFromEuler(Vs)),f.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=g.reflectivity,f.ior.value=g.ior,f.refractionRatio.value=g.refractionRatio),g.lightMap&&(f.lightMap.value=g.lightMap,f.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,f.lightMapTransform)),g.aoMap&&(f.aoMap.value=g.aoMap,f.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,f.aoMapTransform))}function a(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform))}function o(f,g){f.dashSize.value=g.dashSize,f.totalSize.value=g.dashSize+g.gapSize,f.scale.value=g.scale}function l(f,g,x,y){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.size.value=g.size*x,f.scale.value=y*.5,g.map&&(f.map.value=g.map,t(g.map,f.uvTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function c(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.rotation.value=g.rotation,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function u(f,g){f.specular.value.copy(g.specular),f.shininess.value=Math.max(g.shininess,1e-4)}function h(f,g){g.gradientMap&&(f.gradientMap.value=g.gradientMap)}function d(f,g){f.metalness.value=g.metalness,g.metalnessMap&&(f.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,f.metalnessMapTransform)),f.roughness.value=g.roughness,g.roughnessMap&&(f.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,f.roughnessMapTransform)),g.envMap&&(f.envMapIntensity.value=g.envMapIntensity)}function p(f,g,x){f.ior.value=g.ior,g.sheen>0&&(f.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),f.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(f.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,f.sheenColorMapTransform)),g.sheenRoughnessMap&&(f.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,f.sheenRoughnessMapTransform))),g.clearcoat>0&&(f.clearcoat.value=g.clearcoat,f.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(f.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,f.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(f.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===si&&f.clearcoatNormalScale.value.negate())),g.dispersion>0&&(f.dispersion.value=g.dispersion),g.iridescence>0&&(f.iridescence.value=g.iridescence,f.iridescenceIOR.value=g.iridescenceIOR,f.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(f.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,f.iridescenceMapTransform)),g.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),g.transmission>0&&(f.transmission.value=g.transmission,f.transmissionSamplerMap.value=x.texture,f.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(f.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,f.transmissionMapTransform)),f.thickness.value=g.thickness,g.thicknessMap&&(f.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=g.attenuationDistance,f.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(f.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(f.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=g.specularIntensity,f.specularColor.value.copy(g.specularColor),g.specularColorMap&&(f.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,f.specularColorMapTransform)),g.specularIntensityMap&&(f.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,f.specularIntensityMapTransform))}function m(f,g){g.matcap&&(f.matcap.value=g.matcap)}function v(f,g){const x=e.get(g).light;f.referencePosition.value.setFromMatrixPosition(x.matrixWorld),f.nearDistance.value=x.shadow.camera.near,f.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function YR(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,y){const _=y.program;i.uniformBlockBinding(x,_)}function c(x,y){let _=r[x.id];_===void 0&&(m(x),_=u(x),r[x.id]=_,x.addEventListener("dispose",f));const I=y.program;i.updateUBOMapping(x,I);const T=e.render.frame;s[x.id]!==T&&(d(x),s[x.id]=T)}function u(x){const y=h();x.__bindingPointIndex=y;const _=n.createBuffer(),I=x.__size,T=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,I,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,y,_),_}function h(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){const y=r[x.id],_=x.uniforms,I=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,y);for(let T=0,w=_.length;T<w;T++){const C=Array.isArray(_[T])?_[T]:[_[T]];for(let H=0,M=C.length;H<M;H++){const b=C[H];if(p(b,T,H,I)===!0){const k=b.__offset,j=Array.isArray(b.value)?b.value:[b.value];let Y=0;for(let re=0;re<j.length;re++){const $=j[re],he=v($);typeof $=="number"||typeof $=="boolean"?(b.__data[0]=$,n.bufferSubData(n.UNIFORM_BUFFER,k+Y,b.__data)):$.isMatrix3?(b.__data[0]=$.elements[0],b.__data[1]=$.elements[1],b.__data[2]=$.elements[2],b.__data[3]=0,b.__data[4]=$.elements[3],b.__data[5]=$.elements[4],b.__data[6]=$.elements[5],b.__data[7]=0,b.__data[8]=$.elements[6],b.__data[9]=$.elements[7],b.__data[10]=$.elements[8],b.__data[11]=0):($.toArray(b.__data,Y),Y+=he.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,k,b.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(x,y,_,I){const T=x.value,w=y+"_"+_;if(I[w]===void 0)return typeof T=="number"||typeof T=="boolean"?I[w]=T:I[w]=T.clone(),!0;{const C=I[w];if(typeof T=="number"||typeof T=="boolean"){if(C!==T)return I[w]=T,!0}else if(C.equals(T)===!1)return C.copy(T),!0}return!1}function m(x){const y=x.uniforms;let _=0;const I=16;for(let w=0,C=y.length;w<C;w++){const H=Array.isArray(y[w])?y[w]:[y[w]];for(let M=0,b=H.length;M<b;M++){const k=H[M],j=Array.isArray(k.value)?k.value:[k.value];for(let Y=0,re=j.length;Y<re;Y++){const $=j[Y],he=v($),Q=_%I,ye=Q%he.boundary,Te=Q+ye;_+=ye,Te!==0&&I-Te<he.storage&&(_+=I-Te),k.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=_,_+=he.storage}}}const T=_%I;return T>0&&(_+=I-T),x.__size=_,x.__cache={},this}function v(x){const y={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(y.boundary=4,y.storage=4):x.isVector2?(y.boundary=8,y.storage=8):x.isVector3||x.isColor?(y.boundary=16,y.storage=12):x.isVector4?(y.boundary=16,y.storage=16):x.isMatrix3?(y.boundary=48,y.storage=48):x.isMatrix4?(y.boundary=64,y.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),y}function f(x){const y=x.target;y.removeEventListener("dispose",f);const _=a.indexOf(y.__bindingPointIndex);a.splice(_,1),n.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function g(){for(const x in r)n.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:l,update:c,dispose:g}}class py{constructor(e={}){const{canvas:t=fv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=i.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let v=null,f=null;const g=[],x=[];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._outputColorSpace=Fi,this.toneMapping=mr,this.toneMappingExposure=1;const y=this;let _=!1,I=0,T=0,w=null,C=-1,H=null;const M=new st,b=new st;let k=null;const j=new xe(0);let Y=0,re=t.width,$=t.height,he=1,Q=null,ye=null;const Te=new st(0,0,re,$),Ve=new st(0,0,re,$);let at=!1;const et=new Ha;let ie=!1,le=!1;const be=new Re,Se=new Re,Ye=new N,We=new st,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ce=!1;function ue(){return w===null?he:1}let L=i;function He(A,B){return t.getContext(A,B)}try{const A={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r169"),t.addEventListener("webglcontextlost",oe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Ae,!1),L===null){const B="webgl2";if(L=He(B,A),L===null)throw He(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let pe,Ue,we,$e,Be,R,S,W,ne,de,se,ke,Ee,Pe,mt,ve,ze,tt,it,Oe,Mt,ut,Dt,O;function Ce(){pe=new eC(L),pe.init(),ut=new dy(L,pe),Ue=new $N(L,pe,e,ut),we=new DR(L),Ue.reverseDepthBuffer&&we.buffers.depth.setReversed(!0),$e=new rC(L),Be=new MR,R=new zR(L,pe,we,Be,Ue,ut,$e),S=new KN(y),W=new QN(y),ne=new hE(L),Dt=new qN(L,ne),de=new tC(L,ne,$e,Dt),se=new sC(L,de,ne,$e),it=new nC(L,Ue,R),ve=new JN(Be),ke=new _R(y,S,W,pe,Ue,Dt,ve),Ee=new qR(y,Be),Pe=new bR,mt=new CR(pe),tt=new XN(y,S,W,we,se,d,l),ze=new LR(y,se,Ue),O=new YR(L,$e,Ue,we),Oe=new YN(L,pe,$e),Mt=new iC(L,pe,$e),$e.programs=ke.programs,y.capabilities=Ue,y.extensions=pe,y.properties=Be,y.renderLists=Pe,y.shadowMap=ze,y.state=we,y.info=$e}Ce();const ee=new jR(y,L);this.xr=ee,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const A=pe.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=pe.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return he},this.setPixelRatio=function(A){A!==void 0&&(he=A,this.setSize(re,$,!1))},this.getSize=function(A){return A.set(re,$)},this.setSize=function(A,B,X=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}re=A,$=B,t.width=Math.floor(A*he),t.height=Math.floor(B*he),X===!0&&(t.style.width=A+"px",t.style.height=B+"px"),this.setViewport(0,0,A,B)},this.getDrawingBufferSize=function(A){return A.set(re*he,$*he).floor()},this.setDrawingBufferSize=function(A,B,X){re=A,$=B,he=X,t.width=Math.floor(A*X),t.height=Math.floor(B*X),this.setViewport(0,0,A,B)},this.getCurrentViewport=function(A){return A.copy(M)},this.getViewport=function(A){return A.copy(Te)},this.setViewport=function(A,B,X,q){A.isVector4?Te.set(A.x,A.y,A.z,A.w):Te.set(A,B,X,q),we.viewport(M.copy(Te).multiplyScalar(he).round())},this.getScissor=function(A){return A.copy(Ve)},this.setScissor=function(A,B,X,q){A.isVector4?Ve.set(A.x,A.y,A.z,A.w):Ve.set(A,B,X,q),we.scissor(b.copy(Ve).multiplyScalar(he).round())},this.getScissorTest=function(){return at},this.setScissorTest=function(A){we.setScissorTest(at=A)},this.setOpaqueSort=function(A){Q=A},this.setTransparentSort=function(A){ye=A},this.getClearColor=function(A){return A.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(A=!0,B=!0,X=!0){let q=0;if(A){let F=!1;if(w!==null){const me=w.texture.format;F=me===Bc||me===Vc||me===Fo}if(F){const me=w.texture.type,Ie=me===jr||me===Nr||me===ga||me===Xn||me===Pc||me===Dc,Fe=tt.getClearColor(),Ge=tt.getClearAlpha(),Qe=Fe.r,Ze=Fe.g,Je=Fe.b;Ie?(p[0]=Qe,p[1]=Ze,p[2]=Je,p[3]=Ge,L.clearBufferuiv(L.COLOR,0,p)):(m[0]=Qe,m[1]=Ze,m[2]=Je,m[3]=Ge,L.clearBufferiv(L.COLOR,0,m))}else q|=L.COLOR_BUFFER_BIT}B&&(q|=L.DEPTH_BUFFER_BIT,L.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),X&&(q|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(q)},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",oe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Ae,!1),Pe.dispose(),mt.dispose(),Be.dispose(),S.dispose(),W.dispose(),se.dispose(),Dt.dispose(),O.dispose(),ke.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",d0),ee.removeEventListener("sessionend",p0),xs.stop()};function oe(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const A=$e.autoReset,B=ze.enabled,X=ze.autoUpdate,q=ze.needsUpdate,F=ze.type;Ce(),$e.autoReset=A,ze.enabled=B,ze.autoUpdate=X,ze.needsUpdate=q,ze.type=F}function Ae(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ut(A){const B=A.target;B.removeEventListener("dispose",Ut),ni(B)}function ni(A){tr(A),Be.remove(A)}function tr(A){const B=Be.get(A).programs;B!==void 0&&(B.forEach(function(X){ke.releaseProgram(X)}),A.isShaderMaterial&&ke.releaseShaderCache(A))}this.renderBufferDirect=function(A,B,X,q,F,me){B===null&&(B=ot);const Ie=F.isMesh&&F.matrixWorld.determinant()<0,Fe=QS(A,B,X,q,F);we.setMaterial(q,Ie);let Ge=X.index,Qe=1;if(q.wireframe===!0){if(Ge=de.getWireframeAttribute(X),Ge===void 0)return;Qe=2}const Ze=X.drawRange,Je=X.attributes.position;let Rt=Ze.start*Qe,jt=(Ze.start+Ze.count)*Qe;me!==null&&(Rt=Math.max(Rt,me.start*Qe),jt=Math.min(jt,(me.start+me.count)*Qe)),Ge!==null?(Rt=Math.max(Rt,0),jt=Math.min(jt,Ge.count)):Je!=null&&(Rt=Math.max(Rt,0),jt=Math.min(jt,Je.count));const Qt=jt-Rt;if(Qt<0||Qt===1/0)return;Dt.setup(F,q,Fe,X,Ge);let ci,Ht=Oe;if(Ge!==null&&(ci=ne.get(Ge),Ht=Mt,Ht.setIndex(ci)),F.isMesh)q.wireframe===!0?(we.setLineWidth(q.wireframeLinewidth*ue()),Ht.setMode(L.LINES)):Ht.setMode(L.TRIANGLES);else if(F.isLine){let Xe=q.linewidth;Xe===void 0&&(Xe=1),we.setLineWidth(Xe*ue()),F.isLineSegments?Ht.setMode(L.LINES):F.isLineLoop?Ht.setMode(L.LINE_LOOP):Ht.setMode(L.LINE_STRIP)}else F.isPoints?Ht.setMode(L.POINTS):F.isSprite&&Ht.setMode(L.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)Ht.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(pe.get("WEBGL_multi_draw"))Ht.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Xe=F._multiDrawStarts,ji=F._multiDrawCounts,_s=F._multiDrawCount,Gr=Ge?ne.get(Ge).bytesPerElement:1,pa=Be.get(q).currentProgram.getUniforms();for(let pr=0;pr<_s;pr++)pa.setValue(L,"_gl_DrawID",pr),Ht.render(Xe[pr]/Gr,ji[pr])}else if(F.isInstancedMesh)Ht.renderInstances(Rt,Qt,F.count);else if(X.isInstancedBufferGeometry){const Xe=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,ji=Math.min(X.instanceCount,Xe);Ht.renderInstances(Rt,Qt,ji)}else Ht.render(Rt,Qt)};function At(A,B,X){A.transparent===!0&&A.side===Wr&&A.forceSinglePass===!1?(A.side=si,A.needsUpdate=!0,bc(A,B,X),A.side=an,A.needsUpdate=!0,bc(A,B,X),A.side=Wr):bc(A,B,X)}this.compile=function(A,B,X=null){X===null&&(X=A),f=mt.get(X),f.init(B),x.push(f),X.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),A!==X&&A.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),f.setupLights();const q=new Set;return A.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const me=F.material;if(me)if(Array.isArray(me))for(let Ie=0;Ie<me.length;Ie++){const Fe=me[Ie];At(Fe,X,F),q.add(Fe)}else At(me,X,F),q.add(me)}),x.pop(),f=null,q},this.compileAsync=function(A,B,X=null){const q=this.compile(A,B,X);return new Promise(F=>{function me(){if(q.forEach(function(Ie){Be.get(Ie).currentProgram.isReady()&&q.delete(Ie)}),q.size===0){F(A);return}setTimeout(me,10)}pe.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let ir=null;function Mn(A){ir&&ir(A)}function d0(){xs.stop()}function p0(){xs.start()}const xs=new Vv;xs.setAnimationLoop(Mn),typeof self<"u"&&xs.setContext(self),this.setAnimationLoop=function(A){ir=A,ee.setAnimationLoop(A),A===null?xs.stop():xs.start()},ee.addEventListener("sessionstart",d0),ee.addEventListener("sessionend",p0),this.render=function(A,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(B),B=ee.getCamera()),A.isScene===!0&&A.onBeforeRender(y,A,B,w),f=mt.get(A,x.length),f.init(B),x.push(f),Se.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),et.setFromProjectionMatrix(Se),le=this.localClippingEnabled,ie=ve.init(this.clippingPlanes,le),v=Pe.get(A,g.length),v.init(),g.push(v),ee.enabled===!0&&ee.isPresenting===!0){const me=y.xr.getDepthSensingMesh();me!==null&&Gd(me,B,-1/0,y.sortObjects)}Gd(A,B,0,y.sortObjects),v.finish(),y.sortObjects===!0&&v.sort(Q,ye),ce=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,ce&&tt.addToRenderList(v,A),this.info.render.frame++,ie===!0&&ve.beginShadows();const X=f.state.shadowsArray;ze.render(X,A,B),ie===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const q=v.opaque,F=v.transmissive;if(f.setupLights(),B.isArrayCamera){const me=B.cameras;if(F.length>0)for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];f0(q,F,A,Ge)}ce&&tt.render(A);for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];m0(v,A,Ge,Ge.viewport)}}else F.length>0&&f0(q,F,A,B),ce&&tt.render(A),m0(v,A,B);w!==null&&(R.updateMultisampleRenderTarget(w),R.updateRenderTargetMipmap(w)),A.isScene===!0&&A.onAfterRender(y,A,B),Dt.resetDefaultState(),C=-1,H=null,x.pop(),x.length>0?(f=x[x.length-1],ie===!0&&ve.setGlobalState(y.clippingPlanes,f.state.camera)):f=null,g.pop(),g.length>0?v=g[g.length-1]:v=null};function Gd(A,B,X,q){if(A.visible===!1)return;if(A.layers.test(B.layers)){if(A.isGroup)X=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(B);else if(A.isLight)f.pushLight(A),A.castShadow&&f.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||et.intersectsSprite(A)){q&&We.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Se);const me=se.update(A),Ie=A.material;Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||et.intersectsObject(A))){const me=se.update(A),Ie=A.material;if(q&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),We.copy(A.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),We.copy(me.boundingSphere.center)),We.applyMatrix4(A.matrixWorld).applyMatrix4(Se)),Array.isArray(Ie)){const Fe=me.groups;for(let Ge=0,Qe=Fe.length;Ge<Qe;Ge++){const Ze=Fe[Ge],Je=Ie[Ze.materialIndex];Je&&Je.visible&&v.push(A,me,Je,X,We.z,Ze)}}else Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}const F=A.children;for(let me=0,Ie=F.length;me<Ie;me++)Gd(F[me],B,X,q)}function m0(A,B,X,q){const F=A.opaque,me=A.transmissive,Ie=A.transparent;f.setupLightsView(X),ie===!0&&ve.setGlobalState(y.clippingPlanes,X),q&&we.viewport(M.copy(q)),F.length>0&&Tc(F,B,X),me.length>0&&Tc(me,B,X),Ie.length>0&&Tc(Ie,B,X),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function f0(A,B,X,q){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[q.id]===void 0&&(f.state.transmissionRenderTarget[q.id]=new Ir(1,1,{generateMipmaps:!0,type:pe.has("EXT_color_buffer_half_float")||pe.has("EXT_color_buffer_float")?wi:jr,minFilter:Xi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:vt.workingColorSpace}));const F=f.state.transmissionRenderTarget[q.id],me=q.viewport||M;F.setSize(me.z,me.w);const Ie=y.getRenderTarget();y.setRenderTarget(F),y.getClearColor(j),Y=y.getClearAlpha(),Y<1&&y.setClearColor(16777215,.5),y.clear(),ce&&tt.render(X);const Fe=y.toneMapping;y.toneMapping=mr;const Ge=q.viewport;if(q.viewport!==void 0&&(q.viewport=void 0),f.setupLightsView(q),ie===!0&&ve.setGlobalState(y.clippingPlanes,q),Tc(A,X,q),R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F),pe.has("WEBGL_multisampled_render_to_texture")===!1){let Qe=!1;for(let Ze=0,Je=B.length;Ze<Je;Ze++){const Rt=B[Ze],jt=Rt.object,Qt=Rt.geometry,ci=Rt.material,Ht=Rt.group;if(ci.side===Wr&&jt.layers.test(q.layers)){const Xe=ci.side;ci.side=si,ci.needsUpdate=!0,g0(jt,X,q,Qt,ci,Ht),ci.side=Xe,ci.needsUpdate=!0,Qe=!0}}Qe===!0&&(R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F))}y.setRenderTarget(Ie),y.setClearColor(j,Y),Ge!==void 0&&(q.viewport=Ge),y.toneMapping=Fe}function Tc(A,B,X){const q=B.isScene===!0?B.overrideMaterial:null;for(let F=0,me=A.length;F<me;F++){const Ie=A[F],Fe=Ie.object,Ge=Ie.geometry,Qe=q===null?Ie.material:q,Ze=Ie.group;Fe.layers.test(X.layers)&&g0(Fe,B,X,Ge,Qe,Ze)}}function g0(A,B,X,q,F,me){A.onBeforeRender(y,B,X,q,F,me),A.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),F.onBeforeRender(y,B,X,q,A,me),F.transparent===!0&&F.side===Wr&&F.forceSinglePass===!1?(F.side=si,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=an,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=Wr):y.renderBufferDirect(X,B,q,F,A,me),A.onAfterRender(y,B,X,q,F,me)}function bc(A,B,X){B.isScene!==!0&&(B=ot);const q=Be.get(A),F=f.state.lights,me=f.state.shadowsArray,Ie=F.state.version,Fe=ke.getParameters(A,F.state,me,B,X),Ge=ke.getProgramCacheKey(Fe);let Qe=q.programs;q.environment=A.isMeshStandardMaterial?B.environment:null,q.fog=B.fog,q.envMap=(A.isMeshStandardMaterial?W:S).get(A.envMap||q.environment),q.envMapRotation=q.environment!==null&&A.envMap===null?B.environmentRotation:A.envMapRotation,Qe===void 0&&(A.addEventListener("dispose",Ut),Qe=new Map,q.programs=Qe);let Ze=Qe.get(Ge);if(Ze!==void 0){if(q.currentProgram===Ze&&q.lightsStateVersion===Ie)return y0(A,Fe),Ze}else Fe.uniforms=ke.getUniforms(A),A.onBuild(X,Fe,y),A.onBeforeCompile(Fe,y),Ze=ke.acquireProgram(Fe,Ge),Qe.set(Ge,Ze),q.uniforms=Fe.uniforms;const Je=q.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Je.clippingPlanes=ve.uniform),y0(A,Fe),q.needsLights=tw(A),q.lightsStateVersion=Ie,q.needsLights&&(Je.ambientLightColor.value=F.state.ambient,Je.lightProbe.value=F.state.probe,Je.directionalLights.value=F.state.directional,Je.directionalLightShadows.value=F.state.directionalShadow,Je.spotLights.value=F.state.spot,Je.spotLightShadows.value=F.state.spotShadow,Je.rectAreaLights.value=F.state.rectArea,Je.ltc_1.value=F.state.rectAreaLTC1,Je.ltc_2.value=F.state.rectAreaLTC2,Je.pointLights.value=F.state.point,Je.pointLightShadows.value=F.state.pointShadow,Je.hemisphereLights.value=F.state.hemi,Je.directionalShadowMap.value=F.state.directionalShadowMap,Je.directionalShadowMatrix.value=F.state.directionalShadowMatrix,Je.spotShadowMap.value=F.state.spotShadowMap,Je.spotLightMatrix.value=F.state.spotLightMatrix,Je.spotLightMap.value=F.state.spotLightMap,Je.pointShadowMap.value=F.state.pointShadowMap,Je.pointShadowMatrix.value=F.state.pointShadowMatrix),q.currentProgram=Ze,q.uniformsList=null,Ze}function v0(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=Vu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function y0(A,B){const X=Be.get(A);X.outputColorSpace=B.outputColorSpace,X.batching=B.batching,X.batchingColor=B.batchingColor,X.instancing=B.instancing,X.instancingColor=B.instancingColor,X.instancingMorph=B.instancingMorph,X.skinning=B.skinning,X.morphTargets=B.morphTargets,X.morphNormals=B.morphNormals,X.morphColors=B.morphColors,X.morphTargetsCount=B.morphTargetsCount,X.numClippingPlanes=B.numClippingPlanes,X.numIntersection=B.numClipIntersection,X.vertexAlphas=B.vertexAlphas,X.vertexTangents=B.vertexTangents,X.toneMapping=B.toneMapping}function QS(A,B,X,q,F){B.isScene!==!0&&(B=ot),R.resetTextureUnits();const me=B.fog,Ie=q.isMeshStandardMaterial?B.environment:null,Fe=w===null?y.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:nr,Ge=(q.isMeshStandardMaterial?W:S).get(q.envMap||Ie),Qe=q.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ze=!!X.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),Je=!!X.morphAttributes.position,Rt=!!X.morphAttributes.normal,jt=!!X.morphAttributes.color;let Qt=mr;q.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Qt=y.toneMapping);const ci=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ht=ci!==void 0?ci.length:0,Xe=Be.get(q),ji=f.state.lights;if(ie===!0&&(le===!0||A!==H)){const wr=A===H&&q.id===C;ve.setState(q,A,wr)}let _s=!1;q.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==ji.state.version||Xe.outputColorSpace!==Fe||F.isBatchedMesh&&Xe.batching===!1||!F.isBatchedMesh&&Xe.batching===!0||F.isBatchedMesh&&Xe.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Xe.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Xe.instancing===!1||!F.isInstancedMesh&&Xe.instancing===!0||F.isSkinnedMesh&&Xe.skinning===!1||!F.isSkinnedMesh&&Xe.skinning===!0||F.isInstancedMesh&&Xe.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Xe.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Xe.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Xe.instancingMorph===!1&&F.morphTexture!==null||Xe.envMap!==Ge||q.fog===!0&&Xe.fog!==me||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==ve.numPlanes||Xe.numIntersection!==ve.numIntersection)||Xe.vertexAlphas!==Qe||Xe.vertexTangents!==Ze||Xe.morphTargets!==Je||Xe.morphNormals!==Rt||Xe.morphColors!==jt||Xe.toneMapping!==Qt||Xe.morphTargetsCount!==Ht)&&(_s=!0):(_s=!0,Xe.__version=q.version);let Gr=Xe.currentProgram;_s===!0&&(Gr=bc(q,B,F));let pa=!1,pr=!1,Wd=!1;const ei=Gr.getUniforms(),Vn=Xe.uniforms;if(we.useProgram(Gr.program)&&(pa=!0,pr=!0,Wd=!0),q.id!==C&&(C=q.id,pr=!0),pa||H!==A){Ue.reverseDepthBuffer?(be.copy(A.projectionMatrix),Fw(be),Vw(be),ei.setValue(L,"projectionMatrix",be)):ei.setValue(L,"projectionMatrix",A.projectionMatrix),ei.setValue(L,"viewMatrix",A.matrixWorldInverse);const wr=ei.map.cameraPosition;wr!==void 0&&wr.setValue(L,Ye.setFromMatrixPosition(A.matrixWorld)),Ue.logarithmicDepthBuffer&&ei.setValue(L,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&ei.setValue(L,"isOrthographic",A.isOrthographicCamera===!0),H!==A&&(H=A,pr=!0,Wd=!0)}if(F.isSkinnedMesh){ei.setOptional(L,F,"bindMatrix"),ei.setOptional(L,F,"bindMatrixInverse");const wr=F.skeleton;wr&&(wr.boneTexture===null&&wr.computeBoneTexture(),ei.setValue(L,"boneTexture",wr.boneTexture,R))}F.isBatchedMesh&&(ei.setOptional(L,F,"batchingTexture"),ei.setValue(L,"batchingTexture",F._matricesTexture,R),ei.setOptional(L,F,"batchingIdTexture"),ei.setValue(L,"batchingIdTexture",F._indirectTexture,R),ei.setOptional(L,F,"batchingColorTexture"),F._colorsTexture!==null&&ei.setValue(L,"batchingColorTexture",F._colorsTexture,R));const jd=X.morphAttributes;if((jd.position!==void 0||jd.normal!==void 0||jd.color!==void 0)&&it.update(F,X,Gr),(pr||Xe.receiveShadow!==F.receiveShadow)&&(Xe.receiveShadow=F.receiveShadow,ei.setValue(L,"receiveShadow",F.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(Vn.envMap.value=Ge,Vn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&B.environment!==null&&(Vn.envMapIntensity.value=B.environmentIntensity),pr&&(ei.setValue(L,"toneMappingExposure",y.toneMappingExposure),Xe.needsLights&&ew(Vn,Wd),me&&q.fog===!0&&Ee.refreshFogUniforms(Vn,me),Ee.refreshMaterialUniforms(Vn,q,he,$,f.state.transmissionRenderTarget[A.id]),Vu.upload(L,v0(Xe),Vn,R)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Vu.upload(L,v0(Xe),Vn,R),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&ei.setValue(L,"center",F.center),ei.setValue(L,"modelViewMatrix",F.modelViewMatrix),ei.setValue(L,"normalMatrix",F.normalMatrix),ei.setValue(L,"modelMatrix",F.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const wr=q.uniformsGroups;for(let Xd=0,iw=wr.length;Xd<iw;Xd++){const x0=wr[Xd];O.update(x0,Gr),O.bind(x0,Gr)}}return Gr}function ew(A,B){A.ambientLightColor.needsUpdate=B,A.lightProbe.needsUpdate=B,A.directionalLights.needsUpdate=B,A.directionalLightShadows.needsUpdate=B,A.pointLights.needsUpdate=B,A.pointLightShadows.needsUpdate=B,A.spotLights.needsUpdate=B,A.spotLightShadows.needsUpdate=B,A.rectAreaLights.needsUpdate=B,A.hemisphereLights.needsUpdate=B}function tw(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(A,B,X){Be.get(A.texture).__webglTexture=B,Be.get(A.depthTexture).__webglTexture=X;const q=Be.get(A);q.__hasExternalTextures=!0,q.__autoAllocateDepthBuffer=X===void 0,q.__autoAllocateDepthBuffer||pe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),q.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(A,B){const X=Be.get(A);X.__webglFramebuffer=B,X.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(A,B=0,X=0){w=A,I=B,T=X;let q=!0,F=null,me=!1,Ie=!1;if(A){const Fe=Be.get(A);if(Fe.__useDefaultFramebuffer!==void 0)we.bindFramebuffer(L.FRAMEBUFFER,null),q=!1;else if(Fe.__webglFramebuffer===void 0)R.setupRenderTarget(A);else if(Fe.__hasExternalTextures)R.rebindTextures(A,Be.get(A.texture).__webglTexture,Be.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const Ze=A.depthTexture;if(Fe.__boundDepthTexture!==Ze){if(Ze!==null&&Be.has(Ze)&&(A.width!==Ze.image.width||A.height!==Ze.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(A)}}const Ge=A.texture;(Ge.isData3DTexture||Ge.isDataArrayTexture||Ge.isCompressedArrayTexture)&&(Ie=!0);const Qe=Be.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Qe[B])?F=Qe[B][X]:F=Qe[B],me=!0):A.samples>0&&R.useMultisampledRTT(A)===!1?F=Be.get(A).__webglMultisampledFramebuffer:Array.isArray(Qe)?F=Qe[X]:F=Qe,M.copy(A.viewport),b.copy(A.scissor),k=A.scissorTest}else M.copy(Te).multiplyScalar(he).floor(),b.copy(Ve).multiplyScalar(he).floor(),k=at;if(we.bindFramebuffer(L.FRAMEBUFFER,F)&&q&&we.drawBuffers(A,F),we.viewport(M),we.scissor(b),we.setScissorTest(k),me){const Fe=Be.get(A.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+B,Fe.__webglTexture,X)}else if(Ie){const Fe=Be.get(A.texture),Ge=B||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,Fe.__webglTexture,X||0,Ge)}C=-1},this.readRenderTargetPixels=function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){we.bindFramebuffer(L.FRAMEBUFFER,Fe);try{const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ue.textureTypeReadable(Ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F&&L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),me)}finally{const Ge=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ue.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F){we.bindFramebuffer(L.FRAMEBUFFER,Fe);const Je=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),0);const Rt=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Rt);const jt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Ow(L,jt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.deleteBuffer(Je),L.deleteSync(jt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(A,B=null,X=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,A=arguments[1]);const q=Math.pow(2,-X),F=Math.floor(A.image.width*q),me=Math.floor(A.image.height*q),Ie=B!==null?B.x:0,Fe=B!==null?B.y:0;R.setTexture2D(A,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,Ie,Fe,F,me),we.unbindTexture()},this.copyTextureToTexture=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyTextureToTexture function signature has changed."),q=arguments[0]||null,A=arguments[1],B=arguments[2],F=arguments[3]||0,X=null);let me,Ie,Fe,Ge,Qe,Ze;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.min.x,Ge=X.min.y):(me=A.image.width,Ie=A.image.height,Fe=0,Ge=0),q!==null?(Qe=q.x,Ze=q.y):(Qe=0,Ze=0);const Je=ut.convert(B.format),Rt=ut.convert(B.type);R.setTexture2D(B,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const jt=L.getParameter(L.UNPACK_ROW_LENGTH),Qt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),ci=L.getParameter(L.UNPACK_SKIP_PIXELS),Ht=L.getParameter(L.UNPACK_SKIP_ROWS),Xe=L.getParameter(L.UNPACK_SKIP_IMAGES),ji=A.isCompressedTexture?A.mipmaps[F]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,ji.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ji.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Fe),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ge),A.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,ji.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,F,Qe,Ze,ji.width,ji.height,Je,ji.data):L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,ji),L.pixelStorei(L.UNPACK_ROW_LENGTH,jt),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,ci),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Xe),F===0&&B.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),we.unbindTexture()},this.copyTextureToTexture3D=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyTextureToTexture3D function signature has changed."),X=arguments[0]||null,q=arguments[1]||null,A=arguments[2],B=arguments[3],F=arguments[4]||0);let me,Ie,Fe,Ge,Qe,Ze,Je,Rt,jt;const Qt=A.isCompressedTexture?A.mipmaps[F]:A.image;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.max.z-X.min.z,Ge=X.min.x,Qe=X.min.y,Ze=X.min.z):(me=Qt.width,Ie=Qt.height,Fe=Qt.depth,Ge=0,Qe=0,Ze=0),q!==null?(Je=q.x,Rt=q.y,jt=q.z):(Je=0,Rt=0,jt=0);const ci=ut.convert(B.format),Ht=ut.convert(B.type);let Xe;if(B.isData3DTexture)R.setTexture3D(B,0),Xe=L.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)R.setTexture2DArray(B,0),Xe=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const ji=L.getParameter(L.UNPACK_ROW_LENGTH),_s=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Gr=L.getParameter(L.UNPACK_SKIP_PIXELS),pa=L.getParameter(L.UNPACK_SKIP_ROWS),pr=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,Qt.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Ge),L.pixelStorei(L.UNPACK_SKIP_ROWS,Qe),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Ze),A.isDataTexture||A.isData3DTexture?L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt.data):B.isCompressedArrayTexture?L.compressedTexSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Qt.data):L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt),L.pixelStorei(L.UNPACK_ROW_LENGTH,ji),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,_s),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Gr),L.pixelStorei(L.UNPACK_SKIP_ROWS,pa),L.pixelStorei(L.UNPACK_SKIP_IMAGES,pr),F===0&&B.generateMipmaps&&L.generateMipmap(Xe),we.unbindTexture()},this.initRenderTarget=function(A){Be.get(A).__webglFramebuffer===void 0&&R.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?R.setTextureCube(A,0):A.isData3DTexture?R.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?R.setTexture2DArray(A,0):R.setTexture2D(A,0),we.unbindTexture()},this.resetState=function(){I=0,T=0,w=null,we.reset(),Dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===au?"display-p3":"srgb",t.unpackColorSpace=vt.workingColorSpace===Yo?"display-p3":"srgb"}}class Pd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Pd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let tm=class KS{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new KS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class ku 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 dr,this.environmentIntensity=1,this.environmentRotation=new dr,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}}class Xa{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=wa,this.updateRanges=[],this.version=0,this.uuid=yr()}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,s=this.stride;r<s;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=yr()),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=yr()),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 $i=new N;class Fn{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++)$i.fromBufferAttribute(this,t),$i.applyMatrix4(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyNormalMatrix(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.transformDirection(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=qi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(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=qi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=qi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=qi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=qi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(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=ht(t,this.array),i=ht(i,this.array),r=ht(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,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,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]=s,this}clone(e){if(e===void 0){console.log("THREE.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 s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new wt(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 Fn(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.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 s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}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 ul extends hi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(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 qa;const hl=new N,Ya=new N,$a=new N,Ja=new J,dl=new J,my=new Re,Hu=new N,pl=new N,Gu=new N,fy=new J,im=new J,gy=new J;class rm extends _t{constructor(e=new ul){if(super(),this.isSprite=!0,this.type="Sprite",qa===void 0){qa=new ct;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 Xa(t,5);qa.setIndex([0,1,2,0,2,3]),qa.setAttribute("position",new Fn(i,3,0,!1)),qa.setAttribute("uv",new Fn(i,2,3,!1))}this.geometry=qa,this.material=e,this.center=new J(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ya.setFromMatrixScale(this.matrixWorld),my.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),$a.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ya.multiplyScalar(-$a.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const a=this.center;Wu(Hu.set(-.5,-.5,0),$a,a,Ya,r,s),Wu(pl.set(.5,-.5,0),$a,a,Ya,r,s),Wu(Gu.set(.5,.5,0),$a,a,Ya,r,s),fy.set(0,0),im.set(1,0),gy.set(1,1);let o=e.ray.intersectTriangle(Hu,pl,Gu,!1,hl);if(o===null&&(Wu(pl.set(-.5,.5,0),$a,a,Ya,r,s),im.set(0,1),o=e.ray.intersectTriangle(Hu,Gu,pl,!1,hl),o===null))return;const l=e.ray.origin.distanceTo(hl);l<e.near||l>e.far||t.push({distance:l,point:hl.clone(),uv:er.getInterpolation(hl,Hu,pl,Gu,fy,im,gy,new J),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 Wu(n,e,t,i,r,s){Ja.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(dl.x=s*Ja.x-r*Ja.y,dl.y=r*Ja.x+s*Ja.y):dl.copy(Ja),n.copy(e),n.x+=dl.x,n.y+=dl.y,n.applyMatrix4(my)}const ju=new N,vy=new N;class nm extends _t{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,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 s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){ju.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(ju);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){ju.setFromMatrixPosition(e.matrixWorld),vy.setFromMatrixPosition(this.matrixWorld);const i=ju.distanceTo(vy)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;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<s;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,s=i.length;r<s;r++){const a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const yy=new N,xy=new st,_y=new st,$R=new N,My=new Re,Xu=new N,sm=new Ai,Ty=new Re,am=new Ns;class om extends Ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=rp,this.bindMatrix=new Re,this.bindMatrixInverse=new Re,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new zi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Xu),this.boundingBox.expandByPoint(Xu)}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,Xu),this.boundingSphere.expandByPoint(Xu)}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(),sm.copy(this.boundingSphere),sm.applyMatrix4(r),e.ray.intersectsSphere(sm)!==!1&&(Ty.copy(r).invert(),am.copy(e.ray).applyMatrix4(Ty),!(this.boundingBox!==null&&am.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,am)))}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 st,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===rp?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===k0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;xy.fromBufferAttribute(r.attributes.skinIndex,e),_y.fromBufferAttribute(r.attributes.skinWeight,e),yy.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=_y.getComponent(s);if(a!==0){const o=xy.getComponent(s);My.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector($R.copy(yy).applyMatrix4(My),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class qu extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ur extends Wt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=$t,u=$t,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const by=new Re,JR=new Re;class gc{constructor(e=[],t=[]){this.uuid=yr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=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){console.warn("THREE.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 Re)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Re;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 s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:JR;by.multiplyMatrices(o,t[s]),by.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new gc(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 Ur(t,e,e,Ei,Oi);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 s=e.bones[i];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new qu),this.bones.push(a),this.boneInverses.push(new Re().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}class Rn extends wt{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}}const Ka=new Re,Sy=new Re,Yu=[],wy=new zi,KR=new Re,ml=new Ft,fl=new Ai;class lm extends Ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Rn(new Float32Array(i*16),16),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,KR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new zi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ka),wy.copy(e.boundingBox).applyMatrix4(Ka),this.boundingBox.union(wy)}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,Ka),fl.copy(e.boundingSphere).applyMatrix4(Ka),this.boundingSphere.union(fl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),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,s=i.length+1,a=e*s+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(ml.geometry=this.geometry,ml.material=this.material,ml.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),fl.copy(this.boundingSphere),fl.applyMatrix4(i),e.ray.intersectsSphere(fl)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Ka),Sy.multiplyMatrices(i,Ka),ml.matrixWorld=Sy,ml.raycast(e,Yu);for(let a=0,o=Yu.length;a<o;a++){const l=Yu[a];l.instanceId=s,l.object=this,t.push(l)}Yu.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 Ur(new Float32Array(r*this.count),r,this.count,Oo,Oi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function ZR(n,e){return n.z-e.z}function QR(n,e){return e.z-n.z}class eI{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=t,a.index=i}reset(){this.list.length=0,this.index=0}}const rs=new Re,cm=new Re,tI=new Re,iI=new xe(1,1,1),Ey=new Re,um=new Ha,$u=new zi,Bs=new Ai,gl=new N,Ay=new N,rI=new N,hm=new eI,Hi=new Ft,Ju=[];function nI(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s<r;s++)for(let a=0;a<i;a++)e.setComponent(s+t,a,n.getComponent(s,a))}else e.array.set(n.array,t*i);e.needsUpdate=!0}class dm extends Ft{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,i=t*2,r){super(new ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_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 Ur(t,e,e,Ei,Oi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new Ur(t,e,e,Fo,Nr);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 Ur(t,e,e,Ei,Oi);i.colorSpace=vt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,u=new o.constructor(i*l),h=new wt(u,l,c);t.setAttribute(s,h)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new wt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zi);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,rs),this.getBoundingBoxAt(s,$u).applyMatrix4(rs),e.union($u)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,rs),this.getBoundingSphereAt(s,Bs).applyMatrix4(rs),e.union(Bs)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(i=this._availableInstanceIds.pop(),this._drawInfo[i]=t):(i=this._drawInfo.length,this._drawInfo.push(t));const r=this._matricesTexture,s=r.image.data;tI.toArray(s,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(iI.toArray(a.image.data,i*4),a.needsUpdate=!0),i}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,a.push(r),o.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new zi,sphereInitialized:!1,sphere:new Ai}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in i.attributes){const m=t.getAttribute(p),v=i.getAttribute(p);nI(m,v,l);const f=m.itemSize;for(let g=m.count,x=c;g<x;g++){const y=l+g;for(let _=0;_<f;_++)v.setComponent(y,_,0)}v.needsUpdate=!0,v.addUpdateRange(l*f,c*f)}if(r){const p=o.indexStart;for(let m=0;m<a.count;m++)s.setX(p+m,l+a.getX(m));for(let m=a.count,v=o.indexCount;m<v;m++)s.setX(p+m,l);s.needsUpdate=!0,s.addUpdateRange(p,o.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=r?a.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.box,s=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const a=s.index,o=s.attributes.position,l=this._drawRanges[e];for(let c=l.start,u=l.start+l.count;c<u;c++){let h=c;a&&(h=a.getX(h)),r.expandByPoint(gl.fromBufferAttribute(o,h))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,$u),$u.getCenter(r.center);const a=s.index,o=s.attributes.position,l=this._drawRanges[e];let c=0;for(let u=l.start,h=l.start+l.count;u<h;u++){let d=u;a&&(d=a.getX(d)),gl.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(gl))}r.radius=Math.sqrt(c),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture,s=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const i=this._colorsTexture,r=this._colorsTexture.image.data,s=this._drawInfo;return e>=s.length||s[e].active===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||i[e].visible===t?this:(i[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||t<0||t>=this._geometryCount?null:(i[e].geometryIndex=t,this)}getGeometryIdAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;const i=this._drawRanges[e];return t.start=i.start,t.count=i.count,t}raycast(e,t){const i=this._drawInfo,r=this._drawRanges,s=this.matrixWorld,a=this.geometry;Hi.material=this.material,Hi.geometry.index=a.index,Hi.geometry.attributes=a.attributes,Hi.geometry.boundingBox===null&&(Hi.geometry.boundingBox=new zi),Hi.geometry.boundingSphere===null&&(Hi.geometry.boundingSphere=new Ai);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const c=i[o].geometryIndex,u=r[c];Hi.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,Hi.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,Hi.geometry.boundingBox),this.getBoundingSphereAt(c,Hi.geometry.boundingSphere),Hi.raycast(e,Ju);for(let h=0,d=Ju.length;h<d;h++){const p=Ju[h];p.object=this,p.batchId=o,t.push(p)}Ju.length=0}Hi.material=null,Hi.geometry.index=null,Hi.geometry.attributes={},Hi.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._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.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(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data;d&&(Ey.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),um.setFromProjectionMatrix(Ey,e.coordinateSystem));let v=0;if(this.sortObjects){cm.copy(this.matrixWorld).invert(),gl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(cm),Ay.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(cm);for(let x=0,y=l.length;x<y;x++)if(l[x].visible&&l[x].active){const _=l[x].geometryIndex;this.getMatrixAt(x,rs),this.getBoundingSphereAt(_,Bs).applyMatrix4(rs);let I=!1;if(d&&(I=!um.intersectsSphere(Bs)),!I){const T=rI.subVectors(Bs.center,gl).dot(Ay);hm.push(h[_],T,x)}}const f=hm.list,g=this.customSort;g===null?f.sort(s.transparent?QR:ZR):g.call(this,f,i);for(let x=0,y=f.length;x<y;x++){const _=f[x];c[v]=_.start*o,u[v]=_.count,m[v]=_.index,v++}hm.reset()}else for(let f=0,g=l.length;f<g;f++)if(l[f].visible&&l[f].active){const x=l[f].geometryIndex;let y=!1;if(d&&(this.getMatrixAt(f,rs),this.getBoundingSphereAt(x,Bs).applyMatrix4(rs),y=!um.intersectsSphere(Bs)),!y){const _=h[x];c[v]=_.start*o,u[v]=_.count,m[v]=f,v++}}p.needsUpdate=!0,this._multiDrawCount=v,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class Ni extends hi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(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 Ku=new N,Zu=new N,Ny=new Re,vl=new Ns,Qu=new Ai,pm=new N,Cy=new N;class In extends _t{constructor(e=new ct,t=new Ni){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,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,s=t.count;r<s;r++)Ku.fromBufferAttribute(t,r-1),Zu.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Ku.distanceTo(Zu);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Qu.copy(i.boundingSphere),Qu.applyMatrix4(r),Qu.radius+=s,e.ray.intersectsSphere(Qu)===!1)return;Ny.copy(r).invert(),vl.copy(e.ray).applyMatrix4(Ny);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=u.getX(m),g=u.getX(m+1),x=eh(this,e,vl,l,f,g);x&&t.push(x)}if(this.isLineLoop){const m=u.getX(p-1),v=u.getX(d),f=eh(this,e,vl,l,m,v);f&&t.push(f)}}else{const d=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=eh(this,e,vl,l,m,m+1);f&&t.push(f)}if(this.isLineLoop){const m=eh(this,e,vl,l,p-1,d);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,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function eh(n,e,t,i,r,s){const a=n.geometry.attributes.position;if(Ku.fromBufferAttribute(a,r),Zu.fromBufferAttribute(a,s),t.distanceSqToSegment(Ku,Zu,pm,Cy)>i)return;pm.applyMatrix4(n.matrixWorld);const o=e.ray.origin.distanceTo(pm);if(!(o<e.near||o>e.far))return{distance:o,point:Cy.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const Ry=new N,Iy=new N;class Jr extends In{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,s=t.count;r<s;r+=2)Ry.fromBufferAttribute(t,r),Iy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ry.distanceTo(Iy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mm extends In{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Za extends hi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(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 Ly=new Re,fm=new Ns,th=new Ai,ih=new N;class gm extends _t{constructor(e=new ct,t=new Za){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,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,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),th.copy(i.boundingSphere),th.applyMatrix4(r),th.radius+=s,e.ray.intersectsSphere(th)===!1)return;Ly.copy(r).invert(),fm.copy(e.ray).applyMatrix4(Ly);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,u=i.attributes.position;if(c!==null){const h=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=h,m=d;p<m;p++){const v=c.getX(p);ih.fromBufferAttribute(u,v),Py(ih,v,l,r,e,t,this)}}else{const h=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=h,m=d;p<m;p++)ih.fromBufferAttribute(u,p),Py(ih,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,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Py(n,e,t,i,r,s,a){const o=fm.distanceSqToPoint(n);if(o<t){const l=new N;fm.closestPointToPoint(n,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Dy extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Lt,this.magFilter=s!==void 0?s:Lt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class vm extends Wt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=$t,this.minFilter=$t,this.generateMipmaps=!1,this.needsUpdate=!0}}class yl extends Wt{constructor(e,t,i,r,s,a,o,l,c,u,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Uy extends yl{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=gr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Oy extends yl{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,fr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Fy extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Or{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}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),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(s-1);const u=i[r],h=i[r+1]-u,d=(a-u)/h;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new J:new N);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new N,r=[],s=[],a=[],o=new N,l=new Re;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new N)}s[0]=new N,a[0]=new N;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[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(Jt(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(Jt(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class rh extends Or{constructor(e=0,t=0,i=1,r=1,s=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=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new J){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*u-p*h+this.aX,c=d*h+p*u+this.aY}return i.set(l,c)}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 Vy extends rh{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function ym(){let n=0,e=0,t=0,i=0;function r(s,a,o,l){n=s,e=o,t=-3*s+3*a-2*o-l,i=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,u,h){let d=(a-s)/c-(o-s)/(c+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+h)+(l-o)/h;d*=u,p*=u,r(a,o,d,p)},calc:function(s){const a=s*s,o=a*s;return n+e*s+t*a+i*o}}}const nh=new N,xm=new ym,_m=new ym,Mm=new ym;class Tm extends Or{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 N){const i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,u;this.closed||o>0?c=r[(o-1)%s]:(nh.subVectors(r[0],r[1]).add(r[0]),c=nh);const h=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(nh.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=nh),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(d),p),f=Math.pow(d.distanceToSquared(u),p);v<1e-4&&(v=1),m<1e-4&&(m=v),f<1e-4&&(f=v),xm.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,v,f),_m.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,v,f),Mm.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,v,f)}else this.curveType==="catmullrom"&&(xm.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),_m.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),Mm.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(xm.calc(l),_m.calc(l),Mm.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 N().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function By(n,e,t,i,r){const s=(i-e)*.5,a=(r-t)*.5,o=n*n,l=n*o;return(2*t-2*i+s+a)*l+(-3*t+3*i-2*s-a)*o+s*n+t}function sI(n,e){const t=1-n;return t*t*e}function aI(n,e){return 2*(1-n)*n*e}function oI(n,e){return n*n*e}function xl(n,e,t,i){return sI(n,e)+aI(n,t)+oI(n,i)}function lI(n,e){const t=1-n;return t*t*t*e}function cI(n,e){const t=1-n;return 3*t*t*n*e}function uI(n,e){return 3*(1-n)*n*n*e}function hI(n,e){return n*n*n*e}function _l(n,e,t,i,r){return lI(n,e)+cI(n,t)+uI(n,i)+hI(n,r)}class bm extends Or{constructor(e=new J,t=new J,i=new J,r=new J){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(_l(e,r.x,s.x,a.x,o.x),_l(e,r.y,s.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 zy extends Or{constructor(e=new N,t=new N,i=new N,r=new N){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(_l(e,r.x,s.x,a.x,o.x),_l(e,r.y,s.y,a.y,o.y),_l(e,r.z,s.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 Sm extends Or{constructor(e=new J,t=new J){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new J){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 J){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 ky extends Or{constructor(e=new N,t=new N){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new N){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 N){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 wm extends Or{constructor(e=new J,t=new J,i=new J){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(xl(e,r.x,s.x,a.x),xl(e,r.y,s.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 Em extends Or{constructor(e=new N,t=new N,i=new N){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(xl(e,r.x,s.x,a.x),xl(e,r.y,s.y,a.y),xl(e,r.z,s.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 Am extends Or{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new J){const i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],u=r[a>r.length-2?r.length-1:a+1],h=r[a>r.length-3?r.length-1:a+2];return i.set(By(o,l.x,c.x,u.x,h.x),By(o,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;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 J().fromArray(r))}return this}}var sh=Object.freeze({__proto__:null,ArcCurve:Vy,CatmullRomCurve3:Tm,CubicBezierCurve:bm,CubicBezierCurve3:zy,EllipseCurve:rh,LineCurve:Sm,LineCurve3:ky,QuadraticBezierCurve:wm,QuadraticBezierCurve3:Em,SplineCurve:Am});class Hy extends Or{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 sh[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const a=r[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}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,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}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 sh[r.type]().fromJSON(r))}return this}}class Ml extends Hy{constructor(e){super(),this.type="Path",this.currentPoint=new J,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 Sm(this.currentPoint.clone(),new J(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new wm(this.currentPoint.clone(),new J(e,t),new J(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){const o=new bm(this.currentPoint.clone(),new J(e,t),new J(i,r),new J(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Am(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,o,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,a,o,l),this}absellipse(e,t,i,r,s,a,o,l){const c=new rh(e,t,i,r,s,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),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 vc extends ct{constructor(e=[new J(0,-.5),new J(.5,0),new J(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=Jt(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],u=1/t,h=new N,d=new J,p=new N,m=new N,v=new N;let f=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let x=0;x<=t;x++){const y=i+x*u*r,_=Math.sin(y),I=Math.cos(y);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*_,h.y=e[T].y,h.z=e[T].x*I,a.push(h.x,h.y,h.z),d.x=x/t,d.y=T/(e.length-1),o.push(d.x,d.y);const w=l[3*T+0]*_,C=l[3*T+1],H=l[3*T+0]*I;c.push(w,C,H)}}for(let x=0;x<t;x++)for(let y=0;y<e.length-1;y++){const _=y+x*e.length,I=_,T=_+e.length,w=_+e.length+1,C=_+1;s.push(I,T,C),s.push(w,C,T)}this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("uv",new De(o,2)),this.setAttribute("normal",new De(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vc(e.points,e.segments,e.phiStart,e.phiLength)}}class Dd extends vc{constructor(e=1,t=1,i=4,r=8){const s=new Ml;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new Dd(e.radius,e.length,e.capSegments,e.radialSegments)}}class Ud extends ct{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 s=[],a=[],o=[],l=[],c=new N,u=new J;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=i+h/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[d]/e+1)/2,u.y=(a[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ud(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class da extends ct{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let m=0;const v=[],f=i/2;let g=0;x(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function x(){const _=new N,I=new N;let T=0;const w=(t-e)/i;for(let C=0;C<=s;C++){const H=[],M=C/s,b=M*(t-e)+e;for(let k=0;k<=r;k++){const j=k/r,Y=j*l+o,re=Math.sin(Y),$=Math.cos(Y);I.x=b*re,I.y=-M*i+f,I.z=b*$,h.push(I.x,I.y,I.z),_.set(re,w,$).normalize(),d.push(_.x,_.y,_.z),p.push(j,1-M),H.push(m++)}v.push(H)}for(let C=0;C<r;C++)for(let H=0;H<s;H++){const M=v[H][C],b=v[H+1][C],k=v[H+1][C+1],j=v[H][C+1];e>0&&(u.push(M,b,j),T+=3),t>0&&(u.push(b,k,j),T+=3)}c.addGroup(g,T,0),g+=T}function y(_){const I=m,T=new J,w=new N;let C=0;const H=_===!0?e:t,M=_===!0?1:-1;for(let k=1;k<=r;k++)h.push(0,f*M,0),d.push(0,M,0),p.push(.5,.5),m++;const b=m;for(let k=0;k<=r;k++){const j=k/r*l+o,Y=Math.cos(j),re=Math.sin(j);w.x=H*re,w.y=f*M,w.z=H*Y,h.push(w.x,w.y,w.z),d.push(0,M,0),T.x=Y*.5+.5,T.y=re*.5*M+.5,p.push(T.x,T.y),m++}for(let k=0;k<r;k++){const j=I+k,Y=b+k;_===!0?u.push(Y,Y+1,j):u.push(Y+1,Y,j),C+=3}c.addGroup(g,C,_===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new da(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Od extends da{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Od(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class vs extends ct{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],a=[];o(r),c(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){const y=new N,_=new N,I=new N;for(let T=0;T<t.length;T+=3)p(t[T+0],y),p(t[T+1],_),p(t[T+2],I),l(y,_,I,x)}function l(x,y,_,I){const T=I+1,w=[];for(let C=0;C<=T;C++){w[C]=[];const H=x.clone().lerp(_,C/T),M=y.clone().lerp(_,C/T),b=T-C;for(let k=0;k<=b;k++)k===0&&C===T?w[C][k]=H:w[C][k]=H.clone().lerp(M,k/b)}for(let C=0;C<T;C++)for(let H=0;H<2*(T-C)-1;H++){const M=Math.floor(H/2);H%2===0?(d(w[C][M+1]),d(w[C+1][M]),d(w[C][M])):(d(w[C][M+1]),d(w[C+1][M+1]),d(w[C+1][M]))}}function c(x){const y=new N;for(let _=0;_<s.length;_+=3)y.x=s[_+0],y.y=s[_+1],y.z=s[_+2],y.normalize().multiplyScalar(x),s[_+0]=y.x,s[_+1]=y.y,s[_+2]=y.z}function u(){const x=new N;for(let y=0;y<s.length;y+=3){x.x=s[y+0],x.y=s[y+1],x.z=s[y+2];const _=f(x)/2/Math.PI+.5,I=g(x)/Math.PI+.5;a.push(_,1-I)}m(),h()}function h(){for(let x=0;x<a.length;x+=6){const y=a[x+0],_=a[x+2],I=a[x+4],T=Math.max(y,_,I),w=Math.min(y,_,I);T>.9&&w<.1&&(y<.2&&(a[x+0]+=1),_<.2&&(a[x+2]+=1),I<.2&&(a[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function p(x,y){const _=x*3;y.x=e[_+0],y.y=e[_+1],y.z=e[_+2]}function m(){const x=new N,y=new N,_=new N,I=new N,T=new J,w=new J,C=new J;for(let H=0,M=0;H<s.length;H+=9,M+=6){x.set(s[H+0],s[H+1],s[H+2]),y.set(s[H+3],s[H+4],s[H+5]),_.set(s[H+6],s[H+7],s[H+8]),T.set(a[M+0],a[M+1]),w.set(a[M+2],a[M+3]),C.set(a[M+4],a[M+5]),I.copy(x).add(y).add(_).divideScalar(3);const b=f(I);v(T,M+0,x,b),v(w,M+2,y,b),v(C,M+4,_,b)}}function v(x,y,_,I){I<0&&x.x===1&&(a[y]=x.x-1),_.x===0&&_.z===0&&(a[y]=I/2/Math.PI+.5)}function f(x){return Math.atan2(x.z,-x.x)}function g(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 vs(e.vertices,e.indices,e.radius,e.details)}}class Fd extends vs{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-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(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Fd(e.radius,e.detail)}}const ah=new N,oh=new N,Nm=new N,lh=new er;class Cm extends ct{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(ws*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let p=0;p<o;p+=3){s?(l[0]=s.getX(p),l[1]=s.getX(p+1),l[2]=s.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:m,b:v,c:f}=lh;if(m.fromBufferAttribute(a,l[0]),v.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),lh.getNormal(Nm),u[0]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,u[1]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,u[2]=`${Math.round(f.x*i)},${Math.round(f.y*i)},${Math.round(f.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let g=0;g<3;g++){const x=(g+1)%3,y=u[g],_=u[x],I=lh[c[g]],T=lh[c[x]],w=`${y}_${_}`,C=`${_}_${y}`;C in h&&h[C]?(Nm.dot(h[C].normal)<=r&&(d.push(I.x,I.y,I.z),d.push(T.x,T.y,T.z)),h[C]=null):w in h||(h[w]={index0:l[g],index1:l[x],normal:Nm.clone()})}}for(const p in h)if(h[p]){const{index0:m,index1:v}=h[p];ah.fromBufferAttribute(a,m),oh.fromBufferAttribute(a,v),d.push(ah.x,ah.y,ah.z),d.push(oh.x,oh.y,oh.z)}this.setAttribute("position",new De(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class ns extends Ml{constructor(e){super(e),this.uuid=yr(),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 Ml().fromJSON(r))}return this}}const dI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=Gy(n,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,u,h,d,p;if(i&&(s=vI(n,e,s,t)),n.length>80*t){o=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)h=n[m],d=n[m+1],h<o&&(o=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-o,u-l),p=p!==0?32767/p:0}return Tl(s,a,t,o,l,p,0),a}};function Gy(n,e,t,i,r){let s,a;if(r===NI(n,e,t,i)>0)for(s=e;s<t;s+=i)a=Xy(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=Xy(s,n[s],n[s+1],a);return a&&ch(a,a.next)&&(Sl(a),a=a.next),a}function zs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(ch(t,t.next)||Xt(t.prev,t,t.next)===0)){if(Sl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Tl(n,e,t,i,r,s,a){if(!n)return;!a&&s&&TI(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?mI(n,i,r,s):pI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),Sl(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=fI(zs(n),e,t),Tl(n,e,t,i,r,s,2)):a===2&&gI(n,e,t,i,r,s):Tl(zs(n),e,t,i,r,s,1);break}}}function pI(n){const e=n.prev,t=n,i=n.next;if(Xt(e,t,i)>=0)return!1;const r=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=r<s?r<a?r:a:s<a?s:a,h=o<l?o<c?o:c:l<c?l:c,d=r>s?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=p&&Qa(r,o,s,l,a,c,m.x,m.y)&&Xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function mI(n,e,t,i){const r=n.prev,s=n,a=n.next;if(Xt(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,u=r.y,h=s.y,d=a.y,p=o<l?o<c?o:c:l<c?l:c,m=u<h?u<d?u:d:h<d?h:d,v=o>l?o>c?o:c:l>c?l:c,f=u>h?u>d?u:d:h>d?h:d,g=Rm(p,m,e,t,i),x=Rm(v,f,e,t,i);let y=n.prevZ,_=n.nextZ;for(;y&&y.z>=g&&_&&_.z<=x;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Qa(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Qa(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Qa(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Qa(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function fI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!ch(r,s)&&Wy(r,i,i.next,s)&&bl(r,s)&&bl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Sl(i),Sl(i.next),i=n=s),i=i.next}while(i!==n);return zs(i)}function gI(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&wI(a,o)){let l=jy(a,o);a=zs(a,a.next),l=zs(l,l.next),Tl(a,e,t,i,r,s,0),Tl(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function vI(n,e,t,i){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*i,l=s<a-1?e[s+1]*i:n.length,c=Gy(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(SI(c));for(r.sort(yI),s=0;s<r.length;s++)t=xI(r[s],t);return t}function yI(n,e){return n.x-e.x}function xI(n,e){const t=_I(n,e);if(!t)return e;const i=jy(t,n);return zs(i,i.next),zs(t,t.next)}function _I(n,e){let t=e,i=-1/0,r;const s=n.x,a=n.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>i&&(i=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;const o=r,l=r.x,c=r.y;let u=1/0,h;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&Qa(a<c?s:i,a,l,c,a<c?i:s,a,t.x,t.y)&&(h=Math.abs(a-t.y)/(s-t.x),bl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&MI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function MI(n,e){return Xt(n.prev,n,e.prev)<0&&Xt(e.next,n,n.next)<0}function TI(n,e,t,i){let r=n;do r.z===0&&(r.z=Rm(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,bI(r)}function bI(n){let e,t,i,r,s,a,o,l,c=1;do{for(t=n,n=null,s=null,a=0;t;){for(a++,i=t,o=0,e=0;e<c&&(o++,i=i.nextZ,!!i);e++);for(l=c;o>0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(a>1);return n}function Rm(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function SI(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Qa(n,e,t,i,r,s,a,o){return(r-a)*(e-o)>=(n-a)*(s-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(i-o)}function wI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!EI(n,e)&&(bl(n,e)&&bl(e,n)&&AI(n,e)&&(Xt(n.prev,n,e.prev)||Xt(n,e.prev,e))||ch(n,e)&&Xt(n.prev,n,n.next)>0&&Xt(e.prev,e,e.next)>0)}function Xt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ch(n,e){return n.x===e.x&&n.y===e.y}function Wy(n,e,t,i){const r=hh(Xt(n,e,t)),s=hh(Xt(n,e,i)),a=hh(Xt(t,i,n)),o=hh(Xt(t,i,e));return!!(r!==s&&a!==o||r===0&&uh(n,t,e)||s===0&&uh(n,i,e)||a===0&&uh(t,n,i)||o===0&&uh(t,e,i))}function uh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function hh(n){return n>0?1:n<0?-1:0}function EI(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&Wy(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function bl(n,e){return Xt(n.prev,n,n.next)<0?Xt(n,e,n.next)>=0&&Xt(n,n.prev,e)>=0:Xt(n,e,n.prev)<0||Xt(n,n.next,e)<0}function AI(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function jy(n,e){const t=new Im(n.i,n.x,n.y),i=new Im(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Xy(n,e,t,i){const r=new Im(n,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 Sl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Im(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function NI(n,e,t,i){let r=0;for(let s=e,a=t-i;s<t;s+=i)r+=(n[a]-n[s])*(n[s+1]+n[a+1]),a=s;return r}class nn{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return nn.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];qy(e),Yy(i,e);let a=e.length;t.forEach(qy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,Yy(i,t[l]);const o=dI.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function qy(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Yy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class yc extends ct{constructor(e=new ns([new J(.5,.5),new J(-.5,.5),new J(-.5,-.5),new J(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,f=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:CI;let y,_=!1,I,T,w,C;g&&(y=g.getSpacedPoints(u),_=!0,d=!1,I=g.computeFrenetFrames(u,!1),T=new N,w=new N,C=new N),d||(f=0,p=0,m=0,v=0);const H=o.extractPoints(c);let M=H.shape;const b=H.holes;if(!nn.isClockWise(M)){M=M.reverse();for(let ce=0,ue=b.length;ce<ue;ce++){const L=b[ce];nn.isClockWise(L)&&(b[ce]=L.reverse())}}const k=nn.triangulateShape(M,b),j=M;for(let ce=0,ue=b.length;ce<ue;ce++){const L=b[ce];M=M.concat(L)}function Y(ce,ue,L){return ue||console.error("THREE.ExtrudeGeometry: vec does not exist"),ce.clone().addScaledVector(ue,L)}const re=M.length,$=k.length;function he(ce,ue,L){let He,pe,Ue;const we=ce.x-ue.x,$e=ce.y-ue.y,Be=L.x-ce.x,R=L.y-ce.y,S=we*we+$e*$e,W=we*R-$e*Be;if(Math.abs(W)>Number.EPSILON){const ne=Math.sqrt(S),de=Math.sqrt(Be*Be+R*R),se=ue.x-$e/ne,ke=ue.y+we/ne,Ee=L.x-R/de,Pe=L.y+Be/de,mt=((Ee-se)*R-(Pe-ke)*Be)/(we*R-$e*Be);He=se+we*mt-ce.x,pe=ke+$e*mt-ce.y;const ve=He*He+pe*pe;if(ve<=2)return new J(He,pe);Ue=Math.sqrt(ve/2)}else{let ne=!1;we>Number.EPSILON?Be>Number.EPSILON&&(ne=!0):we<-Number.EPSILON?Be<-Number.EPSILON&&(ne=!0):Math.sign($e)===Math.sign(R)&&(ne=!0),ne?(He=-$e,pe=we,Ue=Math.sqrt(S)):(He=we,pe=$e,Ue=Math.sqrt(S/2))}return new J(He/Ue,pe/Ue)}const Q=[];for(let ce=0,ue=j.length,L=ue-1,He=ce+1;ce<ue;ce++,L++,He++)L===ue&&(L=0),He===ue&&(He=0),Q[ce]=he(j[ce],j[L],j[He]);const ye=[];let Te,Ve=Q.concat();for(let ce=0,ue=b.length;ce<ue;ce++){const L=b[ce];Te=[];for(let He=0,pe=L.length,Ue=pe-1,we=He+1;He<pe;He++,Ue++,we++)Ue===pe&&(Ue=0),we===pe&&(we=0),Te[He]=he(L[He],L[Ue],L[we]);ye.push(Te),Ve=Ve.concat(Te)}for(let ce=0;ce<f;ce++){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);be(we.x,we.y,-L)}for(let pe=0,Ue=b.length;pe<Ue;pe++){const we=b[pe];Te=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],Te[$e],He);be(R.x,R.y,-L)}}}const at=m+v;for(let ce=0;ce<re;ce++){const ue=d?Y(M[ce],Ve[ce],at):M[ce];_?(w.copy(I.normals[0]).multiplyScalar(ue.x),T.copy(I.binormals[0]).multiplyScalar(ue.y),C.copy(y[0]).add(w).add(T),be(C.x,C.y,C.z)):be(ue.x,ue.y,0)}for(let ce=1;ce<=u;ce++)for(let ue=0;ue<re;ue++){const L=d?Y(M[ue],Ve[ue],at):M[ue];_?(w.copy(I.normals[ce]).multiplyScalar(L.x),T.copy(I.binormals[ce]).multiplyScalar(L.y),C.copy(y[ce]).add(w).add(T),be(C.x,C.y,C.z)):be(L.x,L.y,h/u*ce)}for(let ce=f-1;ce>=0;ce--){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);be(we.x,we.y,h+L)}for(let pe=0,Ue=b.length;pe<Ue;pe++){const we=b[pe];Te=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],Te[$e],He);_?be(R.x,R.y+y[u-1].y,y[u-1].x+L):be(R.x,R.y,h+L)}}}et(),ie();function et(){const ce=r.length/3;if(d){let ue=0,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[2]+L,pe[1]+L,pe[0]+L)}ue=u+f*2,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[0]+L,pe[1]+L,pe[2]+L)}}else{for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[2],L[1],L[0])}for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[0]+re*u,L[1]+re*u,L[2]+re*u)}}i.addGroup(ce,r.length/3-ce,0)}function ie(){const ce=r.length/3;let ue=0;le(j,ue),ue+=j.length;for(let L=0,He=b.length;L<He;L++){const pe=b[L];le(pe,ue),ue+=pe.length}i.addGroup(ce,r.length/3-ce,1)}function le(ce,ue){let L=ce.length;for(;--L>=0;){const He=L;let pe=L-1;pe<0&&(pe=ce.length-1);for(let Ue=0,we=u+f*2;Ue<we;Ue++){const $e=re*Ue,Be=re*(Ue+1),R=ue+He+$e,S=ue+pe+$e,W=ue+pe+Be,ne=ue+He+Be;Ye(R,S,W,ne)}}}function be(ce,ue,L){l.push(ce),l.push(ue),l.push(L)}function Se(ce,ue,L){We(ce),We(ue),We(L);const He=r.length/3,pe=x.generateTopUV(i,r,He-3,He-2,He-1);ot(pe[0]),ot(pe[1]),ot(pe[2])}function Ye(ce,ue,L,He){We(ce),We(ue),We(He),We(ue),We(L),We(He);const pe=r.length/3,Ue=x.generateSideWallUV(i,r,pe-6,pe-3,pe-2,pe-1);ot(Ue[0]),ot(Ue[1]),ot(Ue[3]),ot(Ue[1]),ot(Ue[2]),ot(Ue[3])}function We(ce){r.push(l[ce*3+0]),r.push(l[ce*3+1]),r.push(l[ce*3+2])}function ot(ce){s.push(ce.x),s.push(ce.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 RI(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new sh[r.type]().fromJSON(r)),new yc(i,e.options)}}const CI={generateTopUV:function(n,e,t,i,r){const s=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new J(s,a),new J(o,l),new J(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],h=e[i*3+2],d=e[r*3],p=e[r*3+1],m=e[r*3+2],v=e[s*3],f=e[s*3+1],g=e[s*3+2];return Math.abs(o-u)<Math.abs(a-c)?[new J(a,1-l),new J(c,1-h),new J(d,1-m),new J(v,1-g)]:[new J(o,1-l),new J(u,1-h),new J(p,1-m),new J(f,1-g)]}};function RI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Vd extends vs{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],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Vd(e.radius,e.detail)}}class Eo extends vs{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 Eo(e.radius,e.detail)}}class xc extends ct{constructor(e=.5,t=1,i=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],c=[],u=[];let h=e;const d=(t-e)/r,p=new N,m=new J;for(let v=0;v<=r;v++){for(let f=0;f<=i;f++){const g=s+f/i*a;p.x=h*Math.cos(g),p.y=h*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}h+=d}for(let v=0;v<r;v++){const f=v*(i+1);for(let g=0;g<i;g++){const x=g+f,y=x,_=x+i+1,I=x+i+2,T=x+1;o.push(y,_,T),o.push(_,I,T)}}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Bd extends ct{constructor(e=new ns([new J(0,.5),new J(-.5,-.5),new J(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(a,2));function c(u){const h=r.length/3,d=u.extractPoints(t);let p=d.shape;const m=d.holes;nn.isClockWise(p)===!1&&(p=p.reverse());for(let f=0,g=m.length;f<g;f++){const x=m[f];nn.isClockWise(x)===!0&&(m[f]=x.reverse())}const v=nn.triangulateShape(p,m);for(let f=0,g=m.length;f<g;f++){const x=m[f];p=p.concat(x)}for(let f=0,g=p.length;f<g;f++){const x=p[f];r.push(x.x,x.y,0),s.push(0,0,1),a.push(x.x,x.y)}for(let f=0,g=v.length;f<g;f++){const x=v[f],y=x[0]+h,_=x[1]+h,I=x[2]+h;i.push(y,_,I),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 II(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];i.push(a)}return new Bd(i,e.curveSegments)}}function II(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class Ao extends ct{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,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 c=0;const u=[],h=new N,d=new N,p=[],m=[],v=[],f=[];for(let g=0;g<=i;g++){const x=[],y=g/i;let _=0;g===0&&a===0?_=.5/t:g===i&&l===Math.PI&&(_=-.5/t);for(let I=0;I<=t;I++){const T=I/t;h.x=-e*Math.cos(r+T*s)*Math.sin(a+y*o),h.y=e*Math.cos(a+y*o),h.z=e*Math.sin(r+T*s)*Math.sin(a+y*o),m.push(h.x,h.y,h.z),d.copy(h).normalize(),v.push(d.x,d.y,d.z),f.push(T+_,1-y),x.push(c++)}u.push(x)}for(let g=0;g<i;g++)for(let x=0;x<t;x++){const y=u[g][x+1],_=u[g][x],I=u[g+1][x],T=u[g+1][x+1];(g!==0||a>0)&&p.push(y,_,T),(g!==i-1||l<Math.PI)&&p.push(_,I,T)}this.setIndex(p),this.setAttribute("position",new De(m,3)),this.setAttribute("normal",new De(v,3)),this.setAttribute("uv",new De(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ao(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class zd extends vs{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 zd(e.radius,e.detail)}}class _c extends ct{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const a=[],o=[],l=[],c=[],u=new N,h=new N,d=new N;for(let p=0;p<=i;p++)for(let m=0;m<=r;m++){const v=m/r*s,f=p/i*Math.PI*2;h.x=(e+t*Math.cos(f))*Math.cos(v),h.y=(e+t*Math.cos(f))*Math.sin(v),h.z=t*Math.sin(f),o.push(h.x,h.y,h.z),u.x=e*Math.cos(v),u.y=e*Math.sin(v),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=r;m++){const v=(r+1)*p+m-1,f=(r+1)*(p-1)+m-1,g=(r+1)*(p-1)+m,x=(r+1)*p+m;a.push(v,f,x),a.push(f,g,x)}this.setIndex(a),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _c(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class kd extends ct{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],c=[],u=[],h=new N,d=new N,p=new N,m=new N,v=new N,f=new N,g=new N;for(let y=0;y<=i;++y){const _=y/i*s*Math.PI*2;x(_,s,a,e,p),x(_+.01,s,a,e,m),f.subVectors(m,p),g.addVectors(m,p),v.crossVectors(f,g),g.crossVectors(v,f),v.normalize(),g.normalize();for(let I=0;I<=r;++I){const T=I/r*Math.PI*2,w=-t*Math.cos(T),C=t*Math.sin(T);h.x=p.x+(w*g.x+C*v.x),h.y=p.y+(w*g.y+C*v.y),h.z=p.z+(w*g.z+C*v.z),l.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),c.push(d.x,d.y,d.z),u.push(y/i),u.push(I/r)}}for(let y=1;y<=i;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),T=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;o.push(I,T,C),o.push(T,w,C)}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function x(y,_,I,T,w){const C=Math.cos(y),H=Math.sin(y),M=I/_*y,b=Math.cos(M);w.x=T*(2+b)*.5*C,w.y=T*(2+b)*H*.5,w.z=T*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Hd extends ct{constructor(e=new Em(new N(-1,-1,0),new N(-1,1,0),new N(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new N,l=new N,c=new J;let u=new N;const h=[],d=[],p=[],m=[];v(),this.setIndex(m),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function v(){for(let y=0;y<t;y++)f(y);f(s===!1?t:0),x(),g()}function f(y){u=e.getPointAt(y/t,u);const _=a.normals[y],I=a.binormals[y];for(let T=0;T<=r;T++){const w=T/r*Math.PI*2,C=Math.sin(w),H=-Math.cos(w);l.x=H*_.x+C*I.x,l.y=H*_.y+C*I.y,l.z=H*_.z+C*I.z,l.normalize(),d.push(l.x,l.y,l.z),o.x=u.x+i*l.x,o.y=u.y+i*l.y,o.z=u.z+i*l.z,h.push(o.x,o.y,o.z)}}function g(){for(let y=1;y<=t;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),T=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;m.push(I,T,C),m.push(T,w,C)}}function x(){for(let y=0;y<=t;y++)for(let _=0;_<=r;_++)c.x=y/t,c.y=_/r,p.push(c.x,c.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 Hd(new sh[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Lm extends ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new N,s=new N;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 c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,p=h.count;for(let m=d,v=d+p;m<v;m+=3)for(let f=0;f<3;f++){const g=o.getX(m+f),x=o.getX(m+(f+1)%3);r.fromBufferAttribute(a,g),s.fromBufferAttribute(a,x),$y(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;r.fromBufferAttribute(a,u),s.fromBufferAttribute(a,h),$y(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function $y(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var Jy=Object.freeze({__proto__:null,BoxGeometry:_n,CapsuleGeometry:Dd,CircleGeometry:Ud,ConeGeometry:Od,CylinderGeometry:da,DodecahedronGeometry:Fd,EdgesGeometry:Cm,ExtrudeGeometry:yc,IcosahedronGeometry:Vd,LatheGeometry:vc,OctahedronGeometry:Eo,PlaneGeometry:ha,PolyhedronGeometry:vs,RingGeometry:xc,ShapeGeometry:Bd,SphereGeometry:Ao,TetrahedronGeometry:zd,TorusGeometry:_c,TorusKnotGeometry:kd,TubeGeometry:Hd,WireframeGeometry:Lm});class dh extends hi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new xe(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}}class Pm extends Pr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class wl extends hi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xe(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 xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(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 dr,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 ph extends wl{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 J(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(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 xe(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 xe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xe(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 mh extends hi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=ma,this.reflectivity=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.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 Dm extends hi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(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 fh extends hi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(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 gh extends hi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=ma,this.reflectivity=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.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 Um extends hi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.flatShading=e.flatShading,this.fog=e.fog,this}}class vh extends Ni{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 ks(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Ky(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Zy(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Om(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=n[o+l]}return r}function Fm(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=n[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=n[r++];while(s!==void 0)}function LI(n,e,t,i,r=30){const s=n.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),h=[],d=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*r;if(!(m<t||m>=i)){h.push(c.times[p]);for(let v=0;v<u;++v)d.push(c.values[p*u+v])}}h.length!==0&&(c.times=ks(h,c.times.constructor),c.values=ks(d,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function PI(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=n.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const m=o.times.length-1;let v;if(s<=o.times[0]){const g=u,x=h-u;v=o.values.slice(g,x)}else if(s>=o.times[m]){const g=m*h+u,x=g+h-u;v=o.values.slice(g,x)}else{const g=o.createInterpolant(),x=u,y=h-u;g.evaluate(s),v=g.resultBuffer.slice(x,y)}l==="quaternion"&&new Bi().fromArray(v).normalize().conjugate().toArray(v);const f=c.times.length;for(let g=0;g<f;++g){const x=g*p+d;if(l==="quaternion")Bi.multiplyQuaternionsFlat(c.values,x,v,0,c.values,x);else{const y=p-d*2;for(let _=0;_<y;++_)c.values[x+_]-=v[_]}}}return n.blendMode=pp,n}const DI={convertArray:ks,isTypedArray:Ky,getKeyframeOrder:Zy,sortedArray:Om,flattenJSON:Fm,subclip:LI,makeClipAdditive:PI};class eo{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],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)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],s=t[i-1],s===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,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Qy extends eo{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:Ms,endingEnd:Ms}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ts:s=e,o=2*t-i;break;case qo:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Ts:a=e,l=2*i-t;break;case qo:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=a*u}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),v=m*m,f=v*m,g=-d*f+2*d*v-d*m,x=(1+d)*f+(-1.5-2*d)*v+(-.5+d)*m+1,y=(-1-p)*f+(1.5+p)*v+.5*m,_=p*f-p*v;for(let I=0;I!==o;++I)s[I]=g*a[u+I]+x*a[c+I]+y*a[l+I]+_*a[h+I];return s}}class Vm extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(i-t)/(r-t),h=1-u;for(let d=0;d!==o;++d)s[d]=a[c+d]*h+a[l+d]*u;return s}}class ex extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Fr{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=ks(t,this.TimeBufferType),this.values=ks(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:ks(e.times,Array),values:ks(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 Vm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Qy(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Sa:t=this.InterpolantFactoryMethodDiscrete;break;case Xo:t=this.InterpolantFactoryMethodLinear;break;case nu:t=this.InterpolantFactoryMethodSmooth;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 console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Sa;case this.InterpolantFactoryMethodLinear:return Xo;case this.InterpolantFactoryMethodSmooth:return nu}}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 s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Ky(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===nu,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(r)l=!0;else{const h=o*i,d=h-i,p=h+i;for(let m=0;m!==i;++m){const v=t[h+m];if(v!==t[d+m]||v!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*i,d=a*i;for(let p=0;p!==i;++p)t[d+p]=t[h+p]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++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}}Fr.prototype.TimeBufferType=Float32Array,Fr.prototype.ValueBufferType=Float32Array,Fr.prototype.DefaultInterpolation=Xo;class ss extends Fr{constructor(e,t,i){super(e,t,i)}}ss.prototype.ValueTypeName="bool",ss.prototype.ValueBufferType=Array,ss.prototype.DefaultInterpolation=Sa,ss.prototype.InterpolantFactoryMethodLinear=void 0,ss.prototype.InterpolantFactoryMethodSmooth=void 0;class yh extends Fr{}yh.prototype.ValueTypeName="color";class to extends Fr{}to.prototype.ValueTypeName="number";class tx extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let c=e*o;for(let u=c+o;c!==u;c+=4)Bi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class io extends Fr{InterpolantFactoryMethodLinear(e){return new tx(this.times,this.values,this.getValueSize(),e)}}io.prototype.ValueTypeName="quaternion",io.prototype.InterpolantFactoryMethodSmooth=void 0;class Hs extends Fr{constructor(e,t,i){super(e,t,i)}}Hs.prototype.ValueTypeName="string",Hs.prototype.ValueBufferType=Array,Hs.prototype.DefaultInterpolation=Sa,Hs.prototype.InterpolantFactoryMethodLinear=void 0,Hs.prototype.InterpolantFactoryMethodSmooth=void 0;class ro extends Fr{}ro.prototype.ValueTypeName="vector";class no{constructor(e="",t=-1,i=[],r=su){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=yr(),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(OI(i[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Fr.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const u=Zy(l);l=Om(l,1,u),c=Om(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new to(".morphTargetInfluences["+t[o].name+"]",l,c).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={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(s);if(u&&u.length>1){const h=u[1];let d=r[h];d||(r[h]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,h,d,p,m){if(d.length!==0){const v=[],f=[];Fm(d,v,f,p),v.length!==0&&m.push(new u(h,v,f))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const h=c[u].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const d={};let p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let m=0;m<h[p].morphTargets.length;m++)d[h[p].morphTargets[m]]=-1;for(const m in d){const v=[],f=[];for(let g=0;g!==h[p].morphTargets.length;++g){const x=h[p];v.push(x.time),f.push(x.morphTarget===m?1:0)}r.push(new to(".morphTargetInfluence["+m+"]",v,f))}l=d.length*a}else{const d=".bones["+t[u].name+"]";i(ro,d+".position",h,"pos",r),i(io,d+".quaternion",h,"rot",r),i(ro,d+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.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 t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function UI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return to;case"vector":case"vector2":case"vector3":case"vector4":return ro;case"color":return yh;case"quaternion":return io;case"bool":case"boolean":return ss;case"string":return Hs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function OI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=UI(n.type);if(n.times===void 0){const t=[],i=[];Fm(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const un={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class xh{constructor(e,t,i){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){o++,s===!1&&r.onStart!==void 0&&r.onStart(u,a,o),s=!0},this.itemEnd=function(u){a++,r.onProgress!==void 0&&r.onProgress(u,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const p=c[h],m=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const Bm=new xh;class Gi{constructor(e){this.manager=e!==void 0?e:Bm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}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}}Gi.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ln={};class FI extends Error{constructor(e,t){super(e),this.response=t}}class Kr extends Gi{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=un.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ln[e]!==void 0){Ln[e].push({onLoad:t,onProgress:i,onError:r});return}Ln[e]=[],Ln[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Ln[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let v=0;const f=new ReadableStream({start(g){x();function x(){h.read().then(({done:y,value:_})=>{if(y)g.close();else{v+=_.byteLength;const I=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let T=0,w=u.length;T<w;T++){const C=u[T];C.onProgress&&C.onProgress(I)}g.enqueue(_),x()}},y=>{g.error(y)})}}});return new Response(f)}else throw new FI(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{un.add(e,c);const u=Ln[e];delete Ln[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=Ln[e];if(u===void 0)throw this.manager.itemError(e),c;delete Ln[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.onError(c)}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}}class VI extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=no.parse(e[i]);t.push(r)}return t}}class BI extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=[],o=new yl,l=new Kr(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(h){l.load(e[h],function(d){const p=s.parse(d,!0);a[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(o.minFilter=Lt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else l.load(e,function(h){const d=s.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<d.mipmapCount;v++)a[m].mipmaps.push(d.mipmaps[m*d.mipmapCount+v]),a[m].format=d.format,a[m].width=d.width,a[m].height=d.height}o.image=a}else o.image.width=d.width,o.image.height=d.height,o.mipmaps=d.mipmaps;d.mipmapCount===1&&(o.minFilter=Lt),o.format=d.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}class El extends Gi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=un.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Qo("img");function l(){u(),un.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class zI extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=new Rs;s.colorSpace=Fi;const a=new El(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(u){s.images[c]=u,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class ix extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Ur,o=new Kr(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:gr,a.wrapT=c.wrapT!==void 0?c.wrapT:gr,a.magFilter=c.magFilter!==void 0?c.magFilter:Lt,a.minFilter=c.minFilter!==void 0?c.minFilter:Lt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Xi),c.mipmapCount===1&&(a.minFilter=Lt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,r),a}}class rx extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=new Wt,a=new El(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class as extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}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,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class _h extends as{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const zm=new Re,nx=new N,sx=new N;class km{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new Re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ha,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;nx.setFromMatrixPosition(e.matrixWorld),t.position.copy(nx),sx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(sx),t.updateMatrixWorld(),zm.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zm),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(zm)}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.mapSize.copy(e.mapSize),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 kI extends km{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Ea*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Al extends as{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new kI}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}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.shadow=e.shadow.clone(),this}}const ax=new Re,Nl=new N,Hm=new N;class HI extends km{constructor(){super(new di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new N(1,0,0),new N(-1,0,0),new N(0,0,1),new N(0,0,-1),new N(0,1,0),new N(0,-1,0)],this._cubeUps=[new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,0,1),new N(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Nl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Nl),Hm.copy(i.position),Hm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Hm),i.updateMatrixWorld(),r.makeTranslation(-Nl.x,-Nl.y,-Nl.z),ax.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ax)}}class Mh extends as{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 HI}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}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}}class GI extends km{constructor(){super(new Ps(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Th extends as{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new GI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class bh extends as{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Gm extends as{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 ox{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new N)}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,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(i*s)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=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*s),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*i*s),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,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}class Wm extends as{constructor(e=new ox,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Mc extends Gi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}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 xe().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.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 s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=i(a.value);break;case"c":r.uniforms[s].value=new xe().setHex(a.value);break;case"v2":r.uniforms[s].value=new J().fromArray(a.value);break;case"v3":r.uniforms[s].value=new N().fromArray(a.value);break;case"v4":r.uniforms[s].value=new st().fromArray(a.value);break;case"m3":r.uniforms[s].value=new Ke().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Re().fromArray(a.value);break;default:r.uniforms[s].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 s in e.extensions)r.extensions[s]=e.extensions[s];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 s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new J().fromArray(s)}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 J().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 Mc.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:dh,SpriteMaterial:ul,RawShaderMaterial:Pm,ShaderMaterial:Pr,PointsMaterial:Za,MeshPhysicalMaterial:ph,MeshStandardMaterial:wl,MeshPhongMaterial:mh,MeshToonMaterial:Dm,MeshNormalMaterial:fh,MeshLambertMaterial:gh,MeshDepthMaterial:zu,MeshDistanceMaterial:Kp,MeshBasicMaterial:$r,MeshMatcapMaterial:Um,LineDashedMaterial:vh,LineBasicMaterial:Ni,Material:hi};return new t[e]}}class Sh{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}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 jm extends ct{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 lx extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(d,p){if(t[p]!==void 0)return t[p];const m=d.interleavedBuffers[p],v=s(d,m.buffer),f=Aa(m.type,v),g=new Xa(f,m.stride);return g.uuid=m.uuid,t[p]=g,g}function s(d,p){if(i[p]!==void 0)return i[p];const m=d.arrayBuffers[p],v=new Uint32Array(m).buffer;return i[p]=v,v}const a=e.isInstancedBufferGeometry?new jm:new ct,o=e.data.index;if(o!==void 0){const d=Aa(o.type,o.array);a.setIndex(new wt(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let m;if(p.isInterleavedBufferAttribute){const v=r(e.data,p.data);m=new Fn(v,p.itemSize,p.offset,p.normalized)}else{const v=Aa(p.type,p.array),f=p.isInstancedBufferAttribute?Rn:wt;m=new f(v,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),a.setAttribute(d,m)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],m=[];for(let v=0,f=p.length;v<f;v++){const g=p[v];let x;if(g.isInterleavedBufferAttribute){const y=r(e.data,g.data);x=new Fn(y,g.itemSize,g.offset,g.normalized)}else{const y=Aa(g.type,g.array);x=new wt(y,g.itemSize,g.normalized)}g.name!==void 0&&(x.name=g.name),m.push(x)}a.morphAttributes[d]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const m=u[d];a.addGroup(m.start,m.count,m.materialIndex)}const h=e.data.boundingSphere;if(h!==void 0){const d=new N;h.center!==void 0&&d.fromArray(h.center),a.boundingSphere=new Ai(d,h.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class cx extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=this.path===""?Sh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new Kr(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?Sh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),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),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),this.bindLightTargets(c),t!==void 0){let h=!1;for(const d in a)if(a[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new ns().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new gc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new lx;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in Jy?o=Jy[l.type].fromJSON(l,t):console.warn(`THREE.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 s=new Mc;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=s.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],s=no.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function a(l){return i.manager.itemStart(l),s.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 c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return a(u)}else return l.data?{data:Aa(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new xh(t);s=new El(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],d=h.url;if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m],g=o(f);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Ur(g.data,g.width,g.height)))}r[h.uuid]=new Jn(p)}else{const p=o(h.url);r[h.uuid]=new Jn(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(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:Aa(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new El(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=await s(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Ur(m.data,m.width,m.height)))}i[l.uuid]=new Jn(u)}else{const u=await s(l.url);i[l.uuid]=new Jn(u)}}}return i}parseTextures(e,t){function i(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let u;Array.isArray(c)?(u=new Rs,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Ur:u=new Wt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=o.uuid,o.name!==void 0&&(u.name=o.name),o.mapping!==void 0&&(u.mapping=i(o.mapping,WI)),o.channel!==void 0&&(u.channel=o.channel),o.offset!==void 0&&u.offset.fromArray(o.offset),o.repeat!==void 0&&u.repeat.fromArray(o.repeat),o.center!==void 0&&u.center.fromArray(o.center),o.rotation!==void 0&&(u.rotation=o.rotation),o.wrap!==void 0&&(u.wrapS=i(o.wrap[0],ux),u.wrapT=i(o.wrap[1],ux)),o.format!==void 0&&(u.format=o.format),o.internalFormat!==void 0&&(u.internalFormat=o.internalFormat),o.type!==void 0&&(u.type=o.type),o.colorSpace!==void 0&&(u.colorSpace=o.colorSpace),o.minFilter!==void 0&&(u.minFilter=i(o.minFilter,hx)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,hx)),o.anisotropy!==void 0&&(u.anisotropy=o.anisotropy),o.flipY!==void 0&&(u.flipY=o.flipY),o.generateMipmaps!==void 0&&(u.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(u.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(u.compareFunction=o.compareFunction),o.userData!==void 0&&(u.userData=o.userData),r[o.uuid]=u}return r}parseObject(e,t,i,r,s){let a;function o(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m];i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),p.push(i[f])}return p}return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),i[d]}}function c(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":a=new ku,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new xe(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new tm(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Pd(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 di(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 Ps(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 bh(e.color,e.intensity);break;case"DirectionalLight":a=new Th(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Mh(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Gm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Al(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new _h(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Wm().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),h=l(e.material),a=new om(u,h),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":u=o(e.geometry),h=l(e.material),a=new Ft(u,h);break;case"InstancedMesh":u=o(e.geometry),h=l(e.material);const d=e.count,p=e.instanceMatrix,m=e.instanceColor;a=new lm(u,h,d),a.instanceMatrix=new Rn(new Float32Array(p.array),16),m!==void 0&&(a.instanceColor=new Rn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),h=l(e.material),a=new dm(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),a.geometry=u,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(v=>{const f=new zi;f.min.fromArray(v.boxMin),f.max.fromArray(v.boxMax);const g=new Ai;return g.radius=v.sphereRadius,g.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:f,sphereInitialized:v.sphereInitialized,sphere:g}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new nm;break;case"Line":a=new In(o(e.geometry),l(e.material));break;case"LineLoop":a=new mm(o(e.geometry),l(e.material));break;case"LineSegments":a=new Jr(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new gm(o(e.geometry),l(e.material));break;case"Sprite":a=new rm(l(e.material));break;case"Group":a=new Fs;break;case"Bone":a=new qu;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.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.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)a.add(this.parseObject(d[p],t,i,r,s))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const m=d[p];a.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const m=d[p],v=a.getObjectByProperty("uuid",m.object);v!==void 0&&a.addLevel(v,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?console.warn("THREE.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 WI={UVMapping:Ic,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,EquirectangularReflectionMapping:kn,EquirectangularRefractionMapping:Hn,CubeUVReflectionMapping:Gn},ux={RepeatWrapping:Wn,ClampToEdgeWrapping:gr,MirroredRepeatWrapping:fa},hx={NearestFilter:$t,NearestMipmapNearestFilter:Lc,NearestMipmapLinearFilter:bn,LinearFilter:Lt,LinearMipmapNearestFilter:jn,LinearMipmapLinearFilter:Xi};class dx extends Gi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=un.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return un.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),un.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});un.add(e,l),s.manager.itemStart(e)}}let wh;class Eh{static getContext(){return wh===void 0&&(wh=new(window.AudioContext||window.webkitAudioContext)),wh}static setContext(e){wh=e}}class px extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Eh.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},i,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const mx=new Re,fx=new Re,Gs=new Re;class Xm{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new di,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new di,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,Gs.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,s=t.near*Math.tan(ws*t.fov*.5)/t.zoom;let a,o;fx.elements[12]=-i,mx.elements[12]=i,a=-s*t.aspect+r,o=s*t.aspect+r,Gs.elements[0]=2*t.near/(o-a),Gs.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Gs),a=-s*t.aspect-r,o=s*t.aspect-r,Gs.elements[0]=2*t.near/(o-a),Gs.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Gs)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(fx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(mx)}}class qm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=gx(),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=gx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function gx(){return performance.now()}const hn=new N,vx=new Bi,jI=new N,Ws=new N;let yx=class extends _t{constructor(){super(),this.type="AudioListener",this.context=Eh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new qm}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(n){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=n,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(n){return this.gain.gain.setTargetAtTime(n,this.context.currentTime,.01),this}updateMatrixWorld(n){super.updateMatrixWorld(n);const e=this.context.listener,t=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(hn,vx,jI),!(!Number.isFinite(hn.x)||!Number.isFinite(hn.y)||!Number.isFinite(hn.z)))if(Ws.set(0,0,-1).applyQuaternion(vx),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(hn.x,i),e.positionY.linearRampToValueAtTime(hn.y,i),e.positionZ.linearRampToValueAtTime(hn.z,i),e.forwardX.linearRampToValueAtTime(Ws.x,i),e.forwardY.linearRampToValueAtTime(Ws.y,i),e.forwardZ.linearRampToValueAtTime(Ws.z,i),e.upX.linearRampToValueAtTime(t.x,i),e.upY.linearRampToValueAtTime(t.y,i),e.upZ.linearRampToValueAtTime(t.z,i)}else e.setPosition(hn.x,hn.y,hn.z),e.setOrientation(Ws.x,Ws.y,Ws.z,t.x,t.y,t.z)}};class Ym 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){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;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){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.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){console.warn("THREE.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}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.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}}const js=new N,xx=new Bi,XI=new N,Xs=new N;class _x extends Ym{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}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(js,xx,XI),Xs.set(0,0,1).applyQuaternion(xx);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(js.x,i),t.positionY.linearRampToValueAtTime(js.y,i),t.positionZ.linearRampToValueAtTime(js.z,i),t.orientationX.linearRampToValueAtTime(Xs.x,i),t.orientationY.linearRampToValueAtTime(Xs.y,i),t.orientationZ.linearRampToValueAtTime(Xs.z,i)}else t.setPosition(js.x,js.y,js.z),t.setOrientation(Xs.x,Xs.y,Xs.z)}}class qI{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 Mx{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,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,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[s+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,s,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,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++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 s=i,a=r;s!==a;++s)t[s]=t[r+s%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,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){Bi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;Bi.multiplyQuaternionsFlat(e,a,e,t,e,i),Bi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const $m="\\[\\]\\.:\\/",YI=new RegExp("["+$m+"]","g"),Jm="[^"+$m+"]",$I="[^"+$m.replace("\\.","")+"]",JI=/((?:WC+[\/:])*)/.source.replace("WC",Jm),KI=/(WCOD+)?/.source.replace("WCOD",$I),ZI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Jm),QI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Jm),e2=new RegExp("^"+JI+KI+ZI+QI+"$"),t2=["material","materials","bones","map"];class i2{constructor(e,t,i){const r=i||bt.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_,s=i.length;r!==s;++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 bt{constructor(e,t,i){this.path=t,this.parsedPath=i||bt.parseTrackName(t),this.node=bt.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 bt.Composite(e,t,i):new bt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(YI,"")}static parseTrackName(e){const t=e2.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 s=i.nodeName.substring(r+1);t2.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===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(s,a){for(let o=0;o<s.length;o++){const l=s[o];if(!a&&(l.name===t||l.uuid===t)||a&&l.userData&&l.userData.name===t)return l;const c=i(l.children,a);if(c)return c}return null},r=i(e.children);if(r)return r;{const s=i(e.children,!0);if(s)return s}}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,s=i.length;r!==s;++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,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++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 s=t.propertyIndex;if(e||(e=bt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}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}}bt.Composite=i2,bt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},bt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},bt.prototype.GetterByBindingType=[bt.prototype._getValue_direct,bt.prototype._getValue_array,bt.prototype._getValue_arrayElement,bt.prototype._getValue_toArray],bt.prototype.SetterByBindingTypeAndVersioning=[[bt.prototype._setValue_direct,bt.prototype._setValue_direct_setNeedsUpdate,bt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_array,bt.prototype._setValue_array_setNeedsUpdate,bt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_arrayElement,bt.prototype._setValue_arrayElement_setNeedsUpdate,bt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_fromArray,bt.prototype._setValue_fromArray_setNeedsUpdate,bt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class r2{constructor(){this.isAnimationObjectGroup=!0,this.uuid=yr(),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,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(d);for(let v=0,f=a;v!==f;++v)s[v].push(new bt(d,i[v],r[v]))}else if(m<c){o=e[m];const v=--c,f=e[v];t[f.uuid]=m,e[m]=f,t[p]=v,e[v]=d;for(let g=0,x=a;g!==x;++g){const y=s[g],_=y[v];let I=y[m];y[m]=_,I===void 0&&(I=new bt(d,i[g],r[g])),y[v]=I}}else e[m]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=r;p!==m;++p){const v=i[p],f=v[h],g=v[u];v[u]=f,v[h]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const d=--s,p=e[d],m=--a,v=e[m];t[p.uuid]=h,e[h]=p,t[v.uuid]=d,e[d]=v,e.pop();for(let f=0,g=r;f!==g;++f){const x=i[f],y=x[d],_=x[m];x[h]=y,x[d]=_,x.pop()}}else{const d=--a,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,v=r;m!==v;++m){const f=i[m];f[h]=f[d],f.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);r=s.length,i[e]=r,a.push(e),o.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){const m=l[d];h[d]=new bt(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),r[i]=r[o],r.pop()}}}class Tx{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:Ms,endingEnd:Ms};for(let c=0;c!==a;++c){const u=s[c].createInterpolant(null);o[c]=u,u.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=dp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){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,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[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 s=this._startTime;if(s!==null){const l=(e-s)*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,c=this._propertyBindings;switch(this.blendMode){case pp:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case su:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].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,s=this._loopCount;const a=i===G0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===hp){s===-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(s===-1&&(e>=0?(s=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,s+=Math.abs(o);const l=this.repetitions-s;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 c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=Ts,r.endingEnd=Ts):(e?r.endingStart=this.zeroSlopeAtStart?Ts:Ms:r.endingStart=qo,t?r.endingEnd=this.zeroSlopeAtEnd?Ts:Ms:r.endingEnd=qo)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}}const n2=new Float32Array(1);class bx extends vr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const d=r[h],p=d.name;let m=u[p];if(m!==void 0)++m.referenceCount,a[h]=m;else{if(m=a[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[h].binding.parsedPath;m=new Mx(bt.create(i,p,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[h]=m}o[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.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 s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;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,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[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 s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Vm(new Float32Array(2),new Float32Array(2),1,n2),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?no.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(i===void 0&&(a!==null?i=a.blendMode:i=su),l!==void 0){const h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const u=new Tx(this,a,t,i);return this._bindAction(u,c),this._addInactiveAction(u,o,s),u}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?no.findByName(i,e):e,a=s?s.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,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].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,s=r[i];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}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,s=r[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}let Sx=class ZS{constructor(e){this.value=e}clone(){return new ZS(this.value.clone===void 0?this.value:this.value.clone())}},s2=0;class a2 extends vr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:s2++}),this.name="",this.usage=wa,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(){return this.dispatchEvent({type:"dispose"}),this}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 s=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class Km extends Xa{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 o2{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,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 wx=new Re;class Ex{constructor(e,t,i=0,r=1/0){this.ray=new Ns(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new nl,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):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return wx.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(wx),this}intersectObject(e,t=!0,i=[]){return Zm(e,this,i,t),i.sort(Ax),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Zm(e[r],this,i,t);return i.sort(Ax),i}}function Ax(n,e){return n.distance-e.distance}function Zm(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)Zm(s[a],e,t,!0)}}class Nx{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}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=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),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(Jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class l2{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}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)}}class h0{constructor(e,t,i,r){h0.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 s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}}const Cx=new J;class c2{constructor(e=new J(1/0,1/0),t=new J(-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=Cx.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,Cx).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 Rx=new N,Ah=new N;class Ix{constructor(e=new N,t=new N){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){Rx.subVectors(e,this.start),Ah.subVectors(this.end,this.start);const i=Ah.dot(Ah);let r=Ah.dot(Rx)/i;return t&&(r=Jt(r,0,1)),r}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Lx=new N;class u2 extends _t{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new ct,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 c=a/l*Math.PI*2,u=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));const s=new Ni({fog:!1,toneMapped:!1});this.cone=new Jr(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const 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 os=new N,Nh=new Re,Qm=new Re;class h2 extends Jr{constructor(e){const t=Px(e),i=new ct,r=[],s=[],a=new xe(0,0,1),o=new xe(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));const l=new Ni({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");Qm.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(Nh.multiplyMatrices(Qm,o.matrixWorld),os.setFromMatrixPosition(Nh),r.setXYZ(a,os.x,os.y,os.z),Nh.multiplyMatrices(Qm,o.parent.matrixWorld),os.setFromMatrixPosition(Nh),r.setXYZ(a+1,os.x,os.y,os.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Px(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Px(n.children[t]));return e}class d2 extends Ft{constructor(e,t,i){const r=new Ao(t,4,2),s=new $r({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),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 p2=new N,Dx=new xe,Ux=new xe;class m2 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 Eo(t);r.rotateY(Math.PI*.5),this.material=new $r({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new wt(a,3)),this.add(new Ft(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");Dx.copy(this.light.color),Ux.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Dx:Ux;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(p2.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Ox=class extends Jr{constructor(n=10,e=10,t=4473924,i=8947848){t=new xe(t),i=new xe(i);const r=e/2,s=n/e,a=n/2,o=[],l=[];for(let h=0,d=0,p=-a;h<=e;h++,p+=s){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=h===r?t:i;m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class f2 extends Jr{constructor(e=10,t=16,i=8,r=64,s=4473924,a=8947848){s=new xe(s),a=new xe(a);const o=[],l=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,m=Math.cos(d)*e;o.push(0,0,0),o.push(p,0,m);const v=h&1?s:a;l.push(v.r,v.g,v.b),l.push(v.r,v.g,v.b)}for(let h=0;h<i;h++){const d=h&1?s:a,p=e-e/i*h;for(let m=0;m<r;m++){let v=m/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p;o.push(f,0,g),l.push(d.r,d.g,d.b),v=(m+1)/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p,o.push(f,0,g),l.push(d.r,d.g,d.b)}}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Fx=new N,Ch=new N,Vx=new N;class Bx 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 ct;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Ni({fog:!1,toneMapped:!1});this.lightPlane=new In(r,s),this.add(this.lightPlane),r=new ct,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new In(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Fx.setFromMatrixPosition(this.light.matrixWorld),Ch.setFromMatrixPosition(this.light.target.matrixWorld),Vx.subVectors(Ch,Fx),this.lightPlane.lookAt(Ch),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(Ch),this.targetLine.scale.z=Vx.length()}}const Rh=new N,Kt=new ll;class zx extends Jr{constructor(e){const t=new ct,i=new Ni({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],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,v){l(m),l(v)}function l(m){r.push(0,0,0),s.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,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 c=new xe(16755200),u=new xe(16711680),h=new xe(43775),d=new xe(16777215),p=new xe(3355443);this.setColors(c,u,h,d,p)}setColors(e,t,i,r,s){const a=this.geometry.getAttribute("color");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,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ti("c",t,e,Kt,0,0,-1),ti("t",t,e,Kt,0,0,1),ti("n1",t,e,Kt,-i,-r,-1),ti("n2",t,e,Kt,i,-r,-1),ti("n3",t,e,Kt,-i,r,-1),ti("n4",t,e,Kt,i,r,-1),ti("f1",t,e,Kt,-i,-r,1),ti("f2",t,e,Kt,i,-r,1),ti("f3",t,e,Kt,-i,r,1),ti("f4",t,e,Kt,i,r,1),ti("u1",t,e,Kt,i*.7,r*1.1,-1),ti("u2",t,e,Kt,-i*.7,r*1.1,-1),ti("u3",t,e,Kt,0,r*2,-1),ti("cf1",t,e,Kt,-i,0,1),ti("cf2",t,e,Kt,i,0,1),ti("cf3",t,e,Kt,0,-r,1),ti("cf4",t,e,Kt,0,r,1),ti("cn1",t,e,Kt,-i,0,-1),ti("cn2",t,e,Kt,i,0,-1),ti("cn3",t,e,Kt,0,-r,-1),ti("cn4",t,e,Kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ti(n,e,t,i,r,s,a){Rh.set(r,s,a).unproject(i);const o=e[n];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,u=o.length;c<u;c++)l.setXYZ(o[c],Rh.x,Rh.y,Rh.z)}}const Ih=new zi;class kx extends Jr{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),s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new wt(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Ih.setFromObject(this.object),Ih.isEmpty())return;const t=Ih.min,i=Ih.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.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 Jr{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],s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new De(r,3)),super(s,new Ni({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 g2 extends In{constructor(e,t=1,i=16776960){const r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new ct;a.setAttribute("position",new De(s,3)),a.computeBoundingSphere(),super(a,new Ni({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 ct;l.setAttribute("position",new De(o,3)),l.computeBoundingSphere(),this.add(new Ft(l,new $r({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 Gx=new N;let Lh,ef;class v2 extends _t{constructor(e=new N(0,0,1),t=new N(0,0,0),i=1,r=16776960,s=i*.2,a=s*.2){super(),this.type="ArrowHelper",Lh===void 0&&(Lh=new ct,Lh.setAttribute("position",new De([0,0,0,0,1,0],3)),ef=new da(0,.5,1,5,1),ef.translate(0,-.5,0)),this.position.copy(t),this.line=new In(Lh,new Ni({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ft(ef,new $r({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,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{Gx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Gx,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 Wx=class extends Jr{constructor(n=1){const e=[0,0,0,n,0,0,0,0,0,0,n,0,0,0,0,0,0,n],t=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new ct;i.setAttribute("position",new De(e,3)),i.setAttribute("color",new De(t,3));const r=new Ni({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(n,e,t){const i=new xe,r=this.geometry.attributes.color.array;return i.set(n),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 jx{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ml,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,s,a){return this.currentPath.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let y=0,_=g.length;y<_;y++){const I=g[y],T=new ns;T.curves=I.curves,x.push(T)}return x}function i(g,x){const y=x.length;let _=!1;for(let I=y-1,T=0;T<y;I=T++){let w=x[I],C=x[T],H=C.x-w.x,M=C.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=x[T],H=-H,C=x[I],M=-M),g.y<w.y||g.y>C.y)continue;if(g.y===w.y){if(g.x===w.x)return!0}else{const b=M*(g.x-w.x)-H*(g.y-w.y);if(b===0)return!0;if(b<0)continue;_=!_}}else{if(g.y!==w.y)continue;if(C.x<=g.x&&g.x<=w.x||w.x<=g.x&&g.x<=C.x)return!0}}return _}const r=nn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new ns,l.curves=o.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],m=0,v;d[m]=void 0,p[m]=[];for(let g=0,x=s.length;g<x;g++)o=s[g],v=o.getPoints(),a=r(v),a=e?!a:a,a?(!u&&d[m]&&m++,d[m]={s:new ns,p:v},d[m].s.curves=o.curves,u&&m++,p[m]=[]):p[m].push({h:o,p:v[0]});if(!d[0])return t(s);if(d.length>1){let g=!1,x=0;for(let y=0,_=d.length;y<_;y++)h[y]=[];for(let y=0,_=d.length;y<_;y++){const I=p[y];for(let T=0;T<I.length;T++){const w=I[T];let C=!0;for(let H=0;H<d.length;H++)i(w.p,d[H].p)&&(y!==H&&x++,C?(C=!1,h[H].push(w)):g=!0);C&&h[y].push(w)}}x>0&&g===!1&&(p=h)}let f;for(let g=0,x=d.length;g<x;g++){l=d[g].s,c.push(l),f=p[g];for(let y=0,_=f.length;y<_;y++)l.holes.push(f[y].h)}return c}}class Xx extends vr{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(){}disconnect(){}dispose(){}update(){}}class y2 extends Ir{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const x2=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class qx{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=x2,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){const t=e.material;for(const i in t)if(t[i]&&t[i].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}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){const{object:t,material:i}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;const s=r.material;for(const a in s){const o=s[a],l=i[a];if(o.equals!==void 0){if(o.equals(l)===!1)return o.copy(l),!1}else if(l.isTexture===!0){if(o.id!==l.id||o.version!==l.version)return o.id=l.id,o.version=l.version,!1}else if(o!==l)return s[a]=l,!1}if(r.morphTargetInfluences){let a=!1;for(let o=0;o<r.morphTargetInfluences.length;o++)r.morphTargetInfluences[o]!==t.morphTargetInfluences[o]&&(a=!0);if(a)return!0}return r.center&&r.center.equals(t.center)===!1?(r.center.copy(t.center),!0):(e.bundle!==null&&(r.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;const r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||s?!1:this.equals(e)!==!0}}function Cl(n,e=0){let t=3735928559^e,i=1103547991^e;if(n instanceof Array)for(let r=0,s;r<n.length;r++)s=n[r],t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);else for(let r=0,s;r<n.length;r++)s=n.charCodeAt(r),t=Math.imul(t^s,2654435761),i=Math.imul(i^s,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 Yx=n=>Cl(n),$x=n=>Cl(n),tf=(...n)=>Cl(n);function rf(n,e=!1){const t=[];n.isNode===!0&&(t.push(n.id),n=n.getSelf());for(const{property:i,childNode:r}of Rl(n))t.push(t,Cl(i.slice(0,-4)),r.getCacheKey(e));return Cl(t)}function*Rl(n,e=!1){for(const t in n){if(t.startsWith("_")===!0)continue;const i=n[t];if(Array.isArray(i)===!0)for(let r=0;r<i.length;r++){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}else if(i&&i.isNode===!0)yield{property:t,childNode:i};else if(typeof i=="object")for(const r in i){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}}}function Pn(n){if(n==null)return null;const e=typeof n;return n.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":n.isVector2===!0?"vec2":n.isVector3===!0?"vec3":n.isVector4===!0?"vec4":n.isMatrix3===!0?"mat3":n.isMatrix4===!0?"mat4":n.isColor===!0?"color":n instanceof ArrayBuffer?"ArrayBuffer":null}function nf(n,...e){const t=n?n.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]])),n==="color"?new xe(...e):t==="vec2"?new J(...e):t==="vec3"?new N(...e):t==="vec4"?new st(...e):t==="mat3"?new Ke(...e):t==="mat4"?new Re(...e):n==="bool"?e[0]||!1:n==="float"||n==="int"||n==="uint"?e[0]||0:n==="string"?e[0]||"":n==="ArrayBuffer"?af(e[0]):null}function sf(n){let e="";const t=new Uint8Array(n);for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}function af(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0)).buffer}var _2=Object.freeze({__proto__:null,arrayBufferToBase64:sf,base64ToArrayBuffer:af,getCacheKey:rf,getNodeChildren:Rl,getValueFromType:nf,getValueType:Pn,hash:tf,hashArray:$x,hashString:Yx});const of={VERTEX:"vertex",FRAGMENT:"fragment"},je={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},M2={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},lf=["fragment","vertex"],cf=["setup","analyze","generate"],uf=[...lf,"compute"],so=["x","y","z","w"];let T2=0;class qe extends vr{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=je.NONE,this.updateBeforeType=je.NONE,this.updateAfterType=je.NONE,this.uuid=cu.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:T2++})}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.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,je.FRAME)}onRenderUpdate(e){return this.onUpdate(e,je.RENDER)}onObjectUpdate(e){return this.onUpdate(e,je.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Rl(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=rf(this,e),this._cacheKeyVersion=this.version),this._cacheKey}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)}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}setup(e){const t=e.getNodeProperties(this);let i=0;for(const r of this.getChildren())t["node"+i++]=r;return null}analyze(e){if(e.increaseUsage(this)===1){const t=e.getNodeProperties(this);for(const i of Object.values(t))i&&i.isNode===!0&&i.build(e)}}generate(e,t){const{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const i=this.getShared(e);if(this!==i)return i.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){const o=e.stack.nodes.length;a.initialized=!0,a.outputNode=this.setup(e),a.outputNode!==null&&e.stack.nodes.length;for(const l of Object.values(a))l&&l.isNode===!0&&l.build(e)}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const a=this.getNodeType(e),o=e.getDataFromNode(this);r=o.snippet,r===void 0?(r=this.generate(e)||"",o.snippet=r):o.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,a,t)}else r=this.generate(e,t)||"";return e.removeChain(this),r}getSerializeChildren(){return Rl(this)}serialize(e){const t=this.getSerializeChildren(),i={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=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 s of e.inputNodes[i])r.push(t[s]);this[i]=r}else if(typeof e.inputNodes[i]=="object"){const r={};for(const s in e.inputNodes[i]){const a=e.inputNodes[i][s];r[s]=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 s=e.nodes[t];s===void 0&&(s={uuid:t,type:i,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}if(r){const o=a(e.textures),l=a(e.images),c=a(e.nodes);o.length>0&&(s.textures=o),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}class ls extends qe{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)}generate(e){const t=this.node.build(e),i=this.indexNode.build(e,"uint");return`${t}[ ${i} ]`}}class hf extends qe{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),s=i.build(e,r);return e.format(s,r,t)}}class pt extends qe{static get type(){return"TempNode"}constructor(e){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 s=super.build(e,i),a=e.getVarFromNode(this,null,i),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${s}`,this),r.snippet=s,r.propertyName=o,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class Jx extends pt{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=this.nodes,s=e.getComponentType(i),a=[];for(const l of r){let c=l.build(e);const u=e.getComponentType(l.getNodeType(e));u!==s&&(c=e.format(c,u,s)),a.push(c)}const o=`${e.getType(i)}( ${a.join(", ")} )`;return e.format(o,i,t)}}const b2=so.join("");class Ph extends qe{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(so.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))}generate(e,t){const i=this.node,r=e.getTypeLength(i.getNodeType(e));let s=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===b2.slice(0,this.components.length)?s=e.format(o,a,t):s=e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else s=i.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Kx extends pt{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,s=this.getNodeType(e),a=e.getTypeFromLength(i.length,r.getNodeType(e)),o=r.build(e,a),l=t.build(e,s),c=e.getTypeLength(s),u=[];for(let h=0;h<c;h++){const d=so[h];d===i[0]?(u.push(o),h+=i.length-1):u.push(l+"."+d)}return`${e.getType(s)}( ${u.join(", ")} )`}}class S2 extends pt{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),s=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+s,this);const l=e.getTypeLength(r),c=[];let u=0;for(let h=0;h<l;h++){const d=so[h];d===t[u]?(c.push("1.0 - "+(o+"."+d)),u++):c.push(o+"."+d)}return`${e.getType(r)}( ${c.join(", ")} )`}}class df extends qe{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?Pn(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=Pn(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=sf(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?nf(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}class Vr extends df{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.format(this.generateConst(e),i,t)}}let ao=null;const oo=new Map;function te(n,e){if(oo.has(n)){console.warn(`Redefinition of method chaining ${n}`);return}if(typeof e!="function")throw new Error(`Node element ${n} is not a function`);oo.set(n,e)}const Zx=n=>n.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Qx=n=>Zx(n).split("").sort().join(""),e_={setup(n,e){const t=e.shift();return n(Pl(t),...e)},get(n,e,t){if(typeof e=="string"&&n[e]===void 0){if(n.isStackNode!==!0&&e==="assign")return(...i)=>(ao.assign(t,...i),t);if(oo.has(e)){const i=oo.get(e);return n.isStackNode?(...r)=>t.add(i(...r)):(...r)=>i(t,...r)}else{if(e==="self")return n;if(e.endsWith("Assign")&&oo.has(e.slice(0,e.length-6))){const i=oo.get(e.slice(0,e.length-6));return n.isStackNode?(...r)=>t.assign(r[0],i(...r)):(...r)=>t.assign(i(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Zx(e),G(new Ph(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Qx(e.slice(3).toLowerCase()),i=>G(new Kx(n,e,i));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Qx(e.slice(4).toLowerCase()),()=>G(new S2(G(n),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),G(new Ph(n,e));if(/^\d+$/.test(e)===!0)return G(new ls(t,new Vr(Number(e),"uint")))}}}return Reflect.get(n,e,t)},set(n,e,t,i){return typeof e=="string"&&n[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(i[e].assign(t),!0):Reflect.set(n,e,t,i)}},pf=new WeakMap,t_=new WeakMap,w2=function(n,e=null){const t=Pn(n);if(t==="node"){let i=pf.get(n);return i===void 0&&(i=new Proxy(n,e_),pf.set(n,i),pf.set(i,i)),i}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return G(vf(n,e));if(t==="shader")return U(n)}return n},E2=function(n,e=null){for(const t in n)n[t]=G(n[t],e);return n},A2=function(n,e=null){const t=n.length;for(let i=0;i<t;i++)n[i]=G(n[i],e);return n},N2=function(n,e=null,t=null,i=null){const r=s=>G(i!==null?Object.assign(s,i):s);return e===null?(...s)=>r(new n(...qs(s))):t!==null?(t=G(t),(...s)=>r(new n(e,...qs(s),t))):(...s)=>r(new n(e,...qs(s)))},C2=function(n,...e){return G(new n(...qs(e)))};class R2 extends qe{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:i}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=t_.get(e.constructor);a===void 0&&(a=new WeakMap,t_.set(e.constructor,a));let o=a.get(t);o===void 0&&(o=G(e.buildFunctionNode(t)),a.set(t,o)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(o),s=G(o.call(i))}else{const a=t.jsFunc,o=i!==null?a(i,e):a(e);s=G(o)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class I2 extends qe{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Pl(e),G(new R2(this,e))}setup(){return this.call()}}const L2=[!1,!0],P2=[0,1,2,3],D2=[-1,-2],i_=[.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],mf=new Map;for(const n of L2)mf.set(n,new Vr(n));const ff=new Map;for(const n of P2)ff.set(n,new Vr(n,"uint"));const gf=new Map([...ff].map(n=>new Vr(n.value,"int")));for(const n of D2)gf.set(n,new Vr(n,"int"));const Dh=new Map([...gf].map(n=>new Vr(n.value)));for(const n of i_)Dh.set(n,new Vr(n));for(const n of i_)Dh.set(-n,new Vr(-n));const Uh={bool:mf,uint:ff,ints:gf,float:Dh},r_=new Map([...mf,...Dh]),vf=(n,e)=>r_.has(n)?r_.get(n):n.isNode===!0?n:new Vr(n,e),U2=n=>{try{return n.getNodeType()}catch{return}},oi=function(n,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(n)&&t.every(r=>typeof r!="object"))&&(t=[nf(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return G(e.get(t[0]));if(t.length===1){const r=vf(t[0],n);return U2(r)===n?G(r):G(new hf(r,n))}const i=t.map(r=>vf(r));return G(new Jx(i,n))}},Il=n=>typeof n=="object"&&n!==null?n.value:n,n_=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function Ll(n,e){return new Proxy(new I2(n,e),e_)}const G=(n,e=null)=>w2(n,e),Pl=(n,e=null)=>new E2(n,e),qs=(n,e=null)=>new A2(n,e),K=(...n)=>new N2(...n),ge=(...n)=>new C2(...n),U=(n,e)=>{const t=new Ll(n,e),i=(...r)=>{let s;return Pl(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return i.shaderNode=t,i.setLayout=r=>(t.setLayout(r),i),i.once=()=>(t.once=!0,i),i},O2=(...n)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...n));te("toGlobal",n=>(n.global=!0,n));const Dl=n=>{ao=n},yf=()=>ao,Le=(...n)=>ao.If(...n);function s_(n){return ao&&ao.add(n),n}te("append",s_);const a_=new oi("color"),E=new oi("float",Uh.float),P=new oi("int",Uh.ints),_e=new oi("uint",Uh.uint),cs=new oi("bool",Uh.bool),z=new oi("vec2"),dn=new oi("ivec2"),o_=new oi("uvec2"),l_=new oi("bvec2"),D=new oi("vec3"),c_=new oi("ivec3"),lo=new oi("uvec3"),xf=new oi("bvec3"),ae=new oi("vec4"),u_=new oi("ivec4"),h_=new oi("uvec4"),d_=new oi("bvec4"),Ul=new oi("mat2"),yi=new oi("mat3"),Ys=new oi("mat4"),F2=(n="")=>G(new Vr(n,"string")),V2=n=>G(new Vr(n,"ArrayBuffer"));te("toColor",a_),te("toFloat",E),te("toInt",P),te("toUint",_e),te("toBool",cs),te("toVec2",z),te("toIVec2",dn),te("toUVec2",o_),te("toBVec2",l_),te("toVec3",D),te("toIVec3",c_),te("toUVec3",lo),te("toBVec3",xf),te("toVec4",ae),te("toIVec4",u_),te("toUVec4",h_),te("toBVec4",d_),te("toMat2",Ul),te("toMat3",yi),te("toMat4",Ys);const p_=K(ls),m_=(n,e)=>G(new hf(G(n),e)),B2=(n,e)=>G(new Ph(G(n),e));te("element",p_),te("convert",m_);class _f extends qe{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=i,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}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 f_=n=>new _f(n),Mf=(n,e=0)=>new _f(n,!0,e),z2=Mf("frame"),xt=Mf("render"),g_=f_("object");class $s extends df{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=g_}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const i=this.getSelf();return e=e.bind(i),super.onUpdate(r=>{const s=e(r,i);s!==void 0&&(this.value=s)},t)}generate(e,t){const i=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),o=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,i,t)}}const fe=(n,e)=>{const t=n_(e||n),i=n&&n.isNode===!0?n.node&&n.node.value||n.value:n;return G(new $s(i,t))};class Et extends qe{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}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 ar=(n,e)=>G(new Et(n,e)),Zr=(n,e)=>G(new Et(n,e,!0)),Nt=ge(Et,"vec4","DiffuseColor"),Tf=ge(Et,"vec3","EmissiveColor"),pn=ge(Et,"float","Roughness"),Ol=ge(Et,"float","Metalness"),Oh=ge(Et,"float","Clearcoat"),Fl=ge(Et,"float","ClearcoatRoughness"),Js=ge(Et,"vec3","Sheen"),Fh=ge(Et,"float","SheenRoughness"),Vh=ge(Et,"float","Iridescence"),bf=ge(Et,"float","IridescenceIOR"),Sf=ge(Et,"float","IridescenceThickness"),Bh=ge(Et,"float","AlphaT"),us=ge(Et,"float","Anisotropy"),Vl=ge(Et,"vec3","AnisotropyT"),Ks=ge(Et,"vec3","AnisotropyB"),or=ge(Et,"color","SpecularColor"),Bl=ge(Et,"float","SpecularF90"),zh=ge(Et,"float","Shininess"),wf=ge(Et,"vec4","Output"),Zs=ge(Et,"float","dashSize"),zl=ge(Et,"float","gapSize"),k2=ge(Et,"float","pointWidth"),kl=ge(Et,"float","IOR"),kh=ge(Et,"float","Transmission"),Ef=ge(Et,"float","Thickness"),Af=ge(Et,"float","AttenuationDistance"),Nf=ge(Et,"color","AttenuationColor"),Cf=ge(Et,"float","Dispersion");class v_ extends pt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}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 so.join("").slice(0,i)!==t.components}return!1}generate(e,t){const{targetNode:i,sourceNode:r}=this,s=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.context({assign:!0}).build(e),l=r.build(e,a),c=r.getNodeType(e),u=e.getDataFromNode(this);let h;if(u.initialized===!0)t!=="void"&&(h=o);else if(s){const d=e.getVarFromNode(this,null,a),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${l}`,this);const m=i.node.context({assign:!0}).build(e);for(let v=0;v<i.components.length;v++){const f=i.components[v];e.addLineFlowCode(`${m}.${f} = ${p}[ ${v} ]`,this)}t!=="void"&&(h=o)}else h=`${o} = ${l}`,(t==="void"||c==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=o));return u.initialized=!0,e.format(h,a,t)}}const y_=K(v_);te("assign",y_);class x_ extends pt{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)}generate(e){const t=[],i=this.functionNode,r=i.getInputs(e),s=this.parameters;if(Array.isArray(s))for(let a=0;a<s.length;a++){const o=r[a],l=s[a];t.push(l.build(e,o.type))}else for(const a of r){const o=s[a.name];if(o!==void 0)t.push(o.build(e,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${i.build(e,"property")}( ${t.join(", ")} )`}}const __=(n,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?qs(e):Pl(e[0]),G(new x_(G(n),e)));te("call",__);class Gt extends pt{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let s=new Gt(e,t,i);for(let a=0;a<r.length-1;a++)s=new Gt(e,s,r[a]);t=s,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i}getNodeType(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=r.getNodeType(e),o=typeof s<"u"?s.getNodeType(e):null;if(a==="void"||o==="void")return"void";if(i==="%")return a;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return e.getIntegerType(a);if(i==="!"||i==="=="||i==="&&"||i==="||"||i==="^^")return"bool";if(i==="<"||i===">"||i==="<="||i===">="){const l=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else return a==="float"&&e.isMatrix(o)?o:e.isMatrix(a)&&e.isVector(o)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=r.getNodeType(e),l=typeof s<"u"?s.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="?e.isVector(o)?l=o:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):e.isMatrix(o)&&e.isVector(l)?l=e.getVectorFromMatrix(o):e.isVector(o)&&e.isMatrix(l)?o=e.getVectorFromMatrix(l):o=l=a):o=l=a;const c=r.build(e,o),u=typeof s<"u"?s.build(e,l):null,h=e.getTypeLength(t),d=e.getFunctionOperator(i);if(t!=="void")return i==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} < ${u} )`,a,t):i==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} <= ${u} )`,a,t):i===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} > ${u} )`,a,t):i===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} >= ${u} )`,a,t):i==="!"||i==="~"?e.format(`(${i}${c})`,o,t):d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`( ${c} ${i} ${u} )`,a,t);if(o!=="void")return d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`${c} ${i} ${u}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const zt=K(Gt,"+"),Pt=K(Gt,"-"),lt=K(Gt,"*"),Qr=K(Gt,"/"),Rf=K(Gt,"%"),M_=K(Gt,"=="),T_=K(Gt,"!="),b_=K(Gt,"<"),If=K(Gt,">"),S_=K(Gt,"<="),w_=K(Gt,">="),E_=K(Gt,"&&"),A_=K(Gt,"||"),N_=K(Gt,"!"),C_=K(Gt,"^^"),R_=K(Gt,"&"),I_=K(Gt,"~"),L_=K(Gt,"|"),P_=K(Gt,"^"),D_=K(Gt,"<<"),U_=K(Gt,">>");te("add",zt),te("sub",Pt),te("mul",lt),te("div",Qr),te("modInt",Rf),te("equal",M_),te("notEqual",T_),te("lessThan",b_),te("greaterThan",If),te("lessThanEqual",S_),te("greaterThanEqual",w_),te("and",E_),te("or",A_),te("not",N_),te("xor",C_),te("bitAnd",R_),te("bitNot",I_),te("bitOr",L_),te("bitXor",P_),te("shiftLeft",D_),te("shiftRight",U_);const O_=(...n)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Rf(...n));te("remainder",O_);class V extends pt{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=i,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>o?t:a>o?i:o>s?r:t}getNodeType(e){const t=this.method;return t===V.LENGTH||t===V.DISTANCE||t===V.DOT?"float":t===V.CROSS?"vec3":t===V.ALL?"bool":t===V.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===V.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const i=this.method,r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,o=this.bNode,l=this.cNode,c=e.renderer.isWebGLRenderer===!0;if(i===V.TRANSFORM_DIRECTION){let u=a,h=o;e.isMatrix(u.getNodeType(e))?h=ae(D(h),0):u=ae(D(u),0);const d=lt(u,h).xyz;return Mr(d).build(e,t)}else{if(i===V.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(i===V.ONE_MINUS)return Pt(1,a).build(e,t);if(i===V.RECIPROCAL)return Qr(1,a).build(e,t);if(i===V.DIFFERENCE)return It(Pt(a,o)).build(e,t);{const u=[];return i===V.CROSS||i===V.MOD?u.push(a.build(e,r),o.build(e,r)):c&&i===V.STEP?u.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),o.build(e,s)):c&&(i===V.MIN||i===V.MAX)||i===V.MOD?u.push(a.build(e,s),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":s)):i===V.REFRACT?u.push(a.build(e,s),o.build(e,s),l.build(e,"float")):i===V.MIX?u.push(a.build(e,s),o.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):(u.push(a.build(e,s)),o!==null&&u.push(o.build(e,s)),l!==null&&u.push(l.build(e,s))),e.format(`${e.getMethod(i,r)}( ${u.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}V.ALL="all",V.ANY="any",V.EQUALS="equals",V.RADIANS="radians",V.DEGREES="degrees",V.EXP="exp",V.EXP2="exp2",V.LOG="log",V.LOG2="log2",V.SQRT="sqrt",V.INVERSE_SQRT="inversesqrt",V.FLOOR="floor",V.CEIL="ceil",V.NORMALIZE="normalize",V.FRACT="fract",V.SIN="sin",V.COS="cos",V.TAN="tan",V.ASIN="asin",V.ACOS="acos",V.ATAN="atan",V.ABS="abs",V.SIGN="sign",V.LENGTH="length",V.NEGATE="negate",V.ONE_MINUS="oneMinus",V.DFDX="dFdx",V.DFDY="dFdy",V.ROUND="round",V.RECIPROCAL="reciprocal",V.TRUNC="trunc",V.FWIDTH="fwidth",V.BITCAST="bitcast",V.TRANSPOSE="transpose",V.ATAN2="atan2",V.MIN="min",V.MAX="max",V.MOD="mod",V.STEP="step",V.REFLECT="reflect",V.DISTANCE="distance",V.DIFFERENCE="difference",V.DOT="dot",V.CROSS="cross",V.POW="pow",V.TRANSFORM_DIRECTION="transformDirection",V.MIX="mix",V.CLAMP="clamp",V.REFRACT="refract",V.SMOOTHSTEP="smoothstep",V.FACEFORWARD="faceforward";const F_=E(1e-6),H2=E(1e6),Qs=E(Math.PI),G2=E(Math.PI*2),Lf=K(V,V.ALL),V_=K(V,V.ANY),B_=K(V,V.EQUALS),z_=K(V,V.RADIANS),k_=K(V,V.DEGREES),Pf=K(V,V.EXP),Hh=K(V,V.EXP2),Df=K(V,V.LOG),Hl=K(V,V.LOG2),en=K(V,V.SQRT),H_=K(V,V.INVERSE_SQRT),hs=K(V,V.FLOOR),Uf=K(V,V.CEIL),Mr=K(V,V.NORMALIZE),ds=K(V,V.FRACT),Ci=K(V,V.SIN),Tr=K(V,V.COS),G_=K(V,V.TAN),W_=K(V,V.ASIN),Gh=K(V,V.ACOS),j_=K(V,V.ATAN),It=K(V,V.ABS),Gl=K(V,V.SIGN),ea=K(V,V.LENGTH),X_=K(V,V.NEGATE),q_=K(V,V.ONE_MINUS),Y_=K(V,V.DFDX),$_=K(V,V.DFDY),J_=K(V,V.ROUND),K_=K(V,V.RECIPROCAL),Of=K(V,V.TRUNC),Z_=K(V,V.FWIDTH),W2=K(V,V.BITCAST),Q_=K(V,V.TRANSPOSE),eM=K(V,V.ATAN2),xi=K(V,V.MIN),ft=K(V,V.MAX),Wh=K(V,V.MOD),Wl=K(V,V.STEP),tM=K(V,V.REFLECT),iM=K(V,V.DISTANCE),rM=K(V,V.DIFFERENCE),qt=K(V,V.DOT),co=K(V,V.CROSS),Ji=K(V,V.POW),Ff=K(V,V.POW,2),nM=K(V,V.POW,3),sM=K(V,V.POW,4),aM=K(V,V.TRANSFORM_DIRECTION),oM=n=>lt(Gl(n),Ji(It(n),1/3)),Vf=n=>qt(n,n),rt=K(V,V.MIX),li=(n,e=0,t=1)=>G(new V(V.CLAMP,G(n),G(e),G(t))),lM=n=>li(n),Bf=K(V,V.REFRACT),Ki=K(V,V.SMOOTHSTEP),cM=K(V,V.FACEFORWARD),zf=U(([n])=>{const e=43758.5453,t=qt(n.xy,z(12.9898,78.233)),i=Wh(t,Qs);return ds(Ci(i).mul(e))}),uM=(n,e,t)=>rt(e,t,n),hM=(n,e,t)=>Ki(e,t,n);te("all",Lf),te("any",V_),te("equals",B_),te("radians",z_),te("degrees",k_),te("exp",Pf),te("exp2",Hh),te("log",Df),te("log2",Hl),te("sqrt",en),te("inverseSqrt",H_),te("floor",hs),te("ceil",Uf),te("normalize",Mr),te("fract",ds),te("sin",Ci),te("cos",Tr),te("tan",G_),te("asin",W_),te("acos",Gh),te("atan",j_),te("abs",It),te("sign",Gl),te("length",ea),te("lengthSq",Vf),te("negate",X_),te("oneMinus",q_),te("dFdx",Y_),te("dFdy",$_),te("round",J_),te("reciprocal",K_),te("trunc",Of),te("fwidth",Z_),te("atan2",eM),te("min",xi),te("max",ft),te("mod",Wh),te("step",Wl),te("reflect",tM),te("distance",iM),te("dot",qt),te("cross",co),te("pow",Ji),te("pow2",Ff),te("pow3",nM),te("pow4",sM),te("transformDirection",aM),te("mix",uM),te("clamp",li),te("refract",Bf),te("smoothstep",hM),te("faceForward",cM),te("difference",rM),te("saturate",lM),te("cbrt",oM),te("transpose",Q_),te("rand",zf);class j2 extends qe{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}getNodeType(e){const t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const i=this.elseNode.getNodeType(e);if(e.getTypeLength(i)>e.getTypeLength(t))return i}return t}setup(e){const t=this.condNode.cache(),i=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=i.context({nodeBlock:i}),a.elseNode=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:s,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=t!=="void",c=l?ar(i).build(e):"";r.nodeProperty=c;const u=s.build(e,"bool");e.addFlowCode(`
|
|
3843
|
+
}`;class WR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new Wt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Pr({vertexShader:HR,fragmentShader:GR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ft(new da(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class jR extends vr{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,m=null;const v=new WR,f=t.getContextAttributes();let g=null,x=null;const y=[],_=[],I=new J;let T=null;const w=new di;w.layers.enable(1),w.viewport=new st;const C=new di;C.layers.enable(2),C.viewport=new st;const H=[w,C],M=new em;M.layers.enable(1),M.layers.enable(2);let b=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(ie){let le=y[ie];return le===void 0&&(le=new tm,y[ie]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ie){let le=y[ie];return le===void 0&&(le=new tm,y[ie]=le),le.getGripSpace()},this.getHand=function(ie){let le=y[ie];return le===void 0&&(le=new tm,y[ie]=le),le.getHandSpace()};function j(ie){const le=_.indexOf(ie.inputSource);if(le===-1)return;const be=y[le];be!==void 0&&(be.update(ie.inputSource,ie.frame,c||a),be.dispatchEvent({type:ie.type,data:ie.inputSource}))}function Y(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",re);for(let ie=0;ie<y.length;ie++){const le=_[ie];le!==null&&(_[ie]=null,y[ie]&&y[ie].disconnect(le))}b=null,k=null,v.reset(),e.setRenderTarget(g),p=null,d=null,h=null,r=null,x=null,et.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(I.width,I.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){s=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){o=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(ie){if(r=ie,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",j),r.addEventListener("selectstart",j),r.addEventListener("selectend",j),r.addEventListener("squeeze",j),r.addEventListener("squeezestart",j),r.addEventListener("squeezeend",j),r.addEventListener("end",Y),r.addEventListener("inputsourceschange",re),f.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(I),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let le=null,be=null,Se=null;f.depth&&(Se=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,le=f.stencil?$n:Yn,be=f.stencil?qn:Nr);const Ye={colorFormat:t.RGBA8,depthFormat:Se,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(Ye),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new Ir(d.textureWidth,d.textureHeight,{format:Ei,type:jr,depthTexture:new Fs(d.textureWidth,d.textureHeight,be,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}else{const le={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,le),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),x=new Ir(p.framebufferWidth,p.framebufferHeight,{format:Ei,type:jr,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}x.isXRRenderTarget=!0,this.setFoveation(l),c=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 v.getDepthTexture()};function re(ie){for(let le=0;le<ie.removed.length;le++){const be=ie.removed[le],Se=_.indexOf(be);Se>=0&&(_[Se]=null,y[Se]&&y[Se].disconnect(be))}for(let le=0;le<ie.added.length;le++){const be=ie.added[le];let Se=_.indexOf(be);if(Se===-1){for(let We=0;We<y.length;We++)if(We>=_.length){_.push(be),Se=We;break}else if(_[We]===null){_[We]=be,Se=We;break}if(Se===-1)break}const Ye=y[Se];Ye&&Ye.connect(be)}}const $=new N,he=new N;function Q(ie,le,be){$.setFromMatrixPosition(le.matrixWorld),he.setFromMatrixPosition(be.matrixWorld);const Se=$.distanceTo(he),Ye=le.projectionMatrix.elements,We=be.projectionMatrix.elements,ot=Ye[14]/(Ye[10]-1),ce=Ye[14]/(Ye[10]+1),ue=(Ye[9]+1)/Ye[5],L=(Ye[9]-1)/Ye[5],He=(Ye[8]-1)/Ye[0],pe=(We[8]+1)/We[0],Ue=ot*He,we=ot*pe,$e=Se/(-He+pe),Be=$e*-He;if(le.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(Be),ie.translateZ($e),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert(),Ye[10]===-1)ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const R=ot+$e,S=ce+$e,W=Ue-Be,ne=we+(Se-Be),de=ue*ce/S*R,se=L*ce/S*R;ie.projectionMatrix.makePerspective(W,ne,de,se,R,S),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}}function ye(ie,le){le===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(le.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(r===null)return;let le=ie.near,be=ie.far;v.texture!==null&&(v.depthNear>0&&(le=v.depthNear),v.depthFar>0&&(be=v.depthFar)),M.near=C.near=w.near=le,M.far=C.far=w.far=be,(b!==M.near||k!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),b=M.near,k=M.far);const Se=ie.parent,Ye=M.cameras;ye(M,Se);for(let We=0;We<Ye.length;We++)ye(Ye[We],Se);Ye.length===2?Q(M,w,C):M.projectionMatrix.copy(w.projectionMatrix),Te(ie,M,Se)};function Te(ie,le,be){be===null?ie.matrix.copy(le.matrixWorld):(ie.matrix.copy(be.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(le.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=Aa*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(ie){l=ie,d!==null&&(d.fixedFoveation=ie),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ie)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let Ve=null;function at(ie,le){if(u=le.getViewerPose(c||a),m=le,u!==null){const be=u.views;p!==null&&(e.setRenderTargetFramebuffer(x,p.framebuffer),e.setRenderTarget(x));let Se=!1;be.length!==M.cameras.length&&(M.cameras.length=0,Se=!0);for(let We=0;We<be.length;We++){const ot=be[We];let ce=null;if(p!==null)ce=p.getViewport(ot);else{const L=h.getViewSubImage(d,ot);ce=L.viewport,We===0&&(e.setRenderTargetTextures(x,L.colorTexture,d.ignoreDepthValues?void 0:L.depthStencilTexture),e.setRenderTarget(x))}let ue=H[We];ue===void 0&&(ue=new di,ue.layers.enable(We),ue.viewport=new st,H[We]=ue),ue.matrix.fromArray(ot.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(ot.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(ce.x,ce.y,ce.width,ce.height),We===0&&(M.matrix.copy(ue.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Se===!0&&M.cameras.push(ue)}const Ye=r.enabledFeatures;if(Ye&&Ye.includes("depth-sensing")){const We=h.getDepthInformation(be[0]);We&&We.isValid&&We.texture&&v.init(e,We,r.renderState)}}if(i.controllerAutoUpdate)for(let be=0;be<y.length;be++){const Se=_[be],Ye=y[be];Se!==null&&Ye!==void 0&&Ye.update(Se,le,c||a)}Ve&&Ve(ie,le),le.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:le}),m=null}const et=new Bv;et.setAnimationLoop(at),this.setAnimationLoop=function(ie){Ve=ie},this.dispose=function(){}}}const Bs=new dr,XR=new Re;function qR(n,e){function t(f,g){f.matrixAutoUpdate===!0&&f.updateMatrix(),g.value.copy(f.matrix)}function i(f,g){g.color.getRGB(f.fogColor.value,Ov(n)),g.isFog?(f.fogNear.value=g.near,f.fogFar.value=g.far):g.isFogExp2&&(f.fogDensity.value=g.density)}function r(f,g,x,y,_){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(f,g):g.isMeshToonMaterial?(s(f,g),h(f,g)):g.isMeshPhongMaterial?(s(f,g),u(f,g)):g.isMeshStandardMaterial?(s(f,g),d(f,g),g.isMeshPhysicalMaterial&&p(f,g,_)):g.isMeshMatcapMaterial?(s(f,g),m(f,g)):g.isMeshDepthMaterial?s(f,g):g.isMeshDistanceMaterial?(s(f,g),v(f,g)):g.isMeshNormalMaterial?s(f,g):g.isLineBasicMaterial?(a(f,g),g.isLineDashedMaterial&&o(f,g)):g.isPointsMaterial?l(f,g,x,y):g.isSpriteMaterial?c(f,g):g.isShadowMaterial?(f.color.value.copy(g.color),f.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(f,g){f.opacity.value=g.opacity,g.color&&f.diffuse.value.copy(g.color),g.emissive&&f.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.bumpMap&&(f.bumpMap.value=g.bumpMap,t(g.bumpMap,f.bumpMapTransform),f.bumpScale.value=g.bumpScale,g.side===si&&(f.bumpScale.value*=-1)),g.normalMap&&(f.normalMap.value=g.normalMap,t(g.normalMap,f.normalMapTransform),f.normalScale.value.copy(g.normalScale),g.side===si&&f.normalScale.value.negate()),g.displacementMap&&(f.displacementMap.value=g.displacementMap,t(g.displacementMap,f.displacementMapTransform),f.displacementScale.value=g.displacementScale,f.displacementBias.value=g.displacementBias),g.emissiveMap&&(f.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,f.emissiveMapTransform)),g.specularMap&&(f.specularMap.value=g.specularMap,t(g.specularMap,f.specularMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest);const x=e.get(g),y=x.envMap,_=x.envMapRotation;y&&(f.envMap.value=y,Bs.copy(_),Bs.x*=-1,Bs.y*=-1,Bs.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Bs.y*=-1,Bs.z*=-1),f.envMapRotation.value.setFromMatrix4(XR.makeRotationFromEuler(Bs)),f.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=g.reflectivity,f.ior.value=g.ior,f.refractionRatio.value=g.refractionRatio),g.lightMap&&(f.lightMap.value=g.lightMap,f.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,f.lightMapTransform)),g.aoMap&&(f.aoMap.value=g.aoMap,f.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,f.aoMapTransform))}function a(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform))}function o(f,g){f.dashSize.value=g.dashSize,f.totalSize.value=g.dashSize+g.gapSize,f.scale.value=g.scale}function l(f,g,x,y){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.size.value=g.size*x,f.scale.value=y*.5,g.map&&(f.map.value=g.map,t(g.map,f.uvTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function c(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.rotation.value=g.rotation,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function u(f,g){f.specular.value.copy(g.specular),f.shininess.value=Math.max(g.shininess,1e-4)}function h(f,g){g.gradientMap&&(f.gradientMap.value=g.gradientMap)}function d(f,g){f.metalness.value=g.metalness,g.metalnessMap&&(f.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,f.metalnessMapTransform)),f.roughness.value=g.roughness,g.roughnessMap&&(f.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,f.roughnessMapTransform)),g.envMap&&(f.envMapIntensity.value=g.envMapIntensity)}function p(f,g,x){f.ior.value=g.ior,g.sheen>0&&(f.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),f.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(f.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,f.sheenColorMapTransform)),g.sheenRoughnessMap&&(f.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,f.sheenRoughnessMapTransform))),g.clearcoat>0&&(f.clearcoat.value=g.clearcoat,f.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(f.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,f.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(f.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===si&&f.clearcoatNormalScale.value.negate())),g.dispersion>0&&(f.dispersion.value=g.dispersion),g.iridescence>0&&(f.iridescence.value=g.iridescence,f.iridescenceIOR.value=g.iridescenceIOR,f.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(f.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,f.iridescenceMapTransform)),g.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),g.transmission>0&&(f.transmission.value=g.transmission,f.transmissionSamplerMap.value=x.texture,f.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(f.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,f.transmissionMapTransform)),f.thickness.value=g.thickness,g.thicknessMap&&(f.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=g.attenuationDistance,f.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(f.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(f.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=g.specularIntensity,f.specularColor.value.copy(g.specularColor),g.specularColorMap&&(f.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,f.specularColorMapTransform)),g.specularIntensityMap&&(f.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,f.specularIntensityMapTransform))}function m(f,g){g.matcap&&(f.matcap.value=g.matcap)}function v(f,g){const x=e.get(g).light;f.referencePosition.value.setFromMatrixPosition(x.matrixWorld),f.nearDistance.value=x.shadow.camera.near,f.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function YR(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,y){const _=y.program;i.uniformBlockBinding(x,_)}function c(x,y){let _=r[x.id];_===void 0&&(m(x),_=u(x),r[x.id]=_,x.addEventListener("dispose",f));const I=y.program;i.updateUBOMapping(x,I);const T=e.render.frame;s[x.id]!==T&&(d(x),s[x.id]=T)}function u(x){const y=h();x.__bindingPointIndex=y;const _=n.createBuffer(),I=x.__size,T=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,I,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,y,_),_}function h(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){const y=r[x.id],_=x.uniforms,I=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,y);for(let T=0,w=_.length;T<w;T++){const C=Array.isArray(_[T])?_[T]:[_[T]];for(let H=0,M=C.length;H<M;H++){const b=C[H];if(p(b,T,H,I)===!0){const k=b.__offset,j=Array.isArray(b.value)?b.value:[b.value];let Y=0;for(let re=0;re<j.length;re++){const $=j[re],he=v($);typeof $=="number"||typeof $=="boolean"?(b.__data[0]=$,n.bufferSubData(n.UNIFORM_BUFFER,k+Y,b.__data)):$.isMatrix3?(b.__data[0]=$.elements[0],b.__data[1]=$.elements[1],b.__data[2]=$.elements[2],b.__data[3]=0,b.__data[4]=$.elements[3],b.__data[5]=$.elements[4],b.__data[6]=$.elements[5],b.__data[7]=0,b.__data[8]=$.elements[6],b.__data[9]=$.elements[7],b.__data[10]=$.elements[8],b.__data[11]=0):($.toArray(b.__data,Y),Y+=he.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,k,b.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(x,y,_,I){const T=x.value,w=y+"_"+_;if(I[w]===void 0)return typeof T=="number"||typeof T=="boolean"?I[w]=T:I[w]=T.clone(),!0;{const C=I[w];if(typeof T=="number"||typeof T=="boolean"){if(C!==T)return I[w]=T,!0}else if(C.equals(T)===!1)return C.copy(T),!0}return!1}function m(x){const y=x.uniforms;let _=0;const I=16;for(let w=0,C=y.length;w<C;w++){const H=Array.isArray(y[w])?y[w]:[y[w]];for(let M=0,b=H.length;M<b;M++){const k=H[M],j=Array.isArray(k.value)?k.value:[k.value];for(let Y=0,re=j.length;Y<re;Y++){const $=j[Y],he=v($),Q=_%I,ye=Q%he.boundary,Te=Q+ye;_+=ye,Te!==0&&I-Te<he.storage&&(_+=I-Te),k.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=_,_+=he.storage}}}const T=_%I;return T>0&&(_+=I-T),x.__size=_,x.__cache={},this}function v(x){const y={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(y.boundary=4,y.storage=4):x.isVector2?(y.boundary=8,y.storage=8):x.isVector3||x.isColor?(y.boundary=16,y.storage=12):x.isVector4?(y.boundary=16,y.storage=16):x.isMatrix3?(y.boundary=48,y.storage=48):x.isMatrix4?(y.boundary=64,y.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),y}function f(x){const y=x.target;y.removeEventListener("dispose",f);const _=a.indexOf(y.__bindingPointIndex);a.splice(_,1),n.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function g(){for(const x in r)n.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:l,update:c,dispose:g}}class my{constructor(e={}){const{canvas:t=gv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=i.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let v=null,f=null;const g=[],x=[];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._outputColorSpace=Fi,this.toneMapping=mr,this.toneMappingExposure=1;const y=this;let _=!1,I=0,T=0,w=null,C=-1,H=null;const M=new st,b=new st;let k=null;const j=new xe(0);let Y=0,re=t.width,$=t.height,he=1,Q=null,ye=null;const Te=new st(0,0,re,$),Ve=new st(0,0,re,$);let at=!1;const et=new Ga;let ie=!1,le=!1;const be=new Re,Se=new Re,Ye=new N,We=new st,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ce=!1;function ue(){return w===null?he:1}let L=i;function He(A,B){return t.getContext(A,B)}try{const A={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Bn}`),t.addEventListener("webglcontextlost",oe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Ae,!1),L===null){const B="webgl2";if(L=He(B,A),L===null)throw He(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let pe,Ue,we,$e,Be,R,S,W,ne,de,se,ke,Ee,Pe,mt,ve,ze,tt,it,Oe,Mt,ut,Dt,O;function Ce(){pe=new eC(L),pe.init(),ut=new py(L,pe),Ue=new $N(L,pe,e,ut),we=new DR(L),Ue.reverseDepthBuffer&&we.buffers.depth.setReversed(!0),$e=new rC(L),Be=new MR,R=new zR(L,pe,we,Be,Ue,ut,$e),S=new KN(y),W=new QN(y),ne=new hE(L),Dt=new qN(L,ne),de=new tC(L,ne,$e,Dt),se=new sC(L,de,ne,$e),it=new nC(L,Ue,R),ve=new JN(Be),ke=new _R(y,S,W,pe,Ue,Dt,ve),Ee=new qR(y,Be),Pe=new bR,mt=new CR(pe),tt=new XN(y,S,W,we,se,d,l),ze=new LR(y,se,Ue),O=new YR(L,$e,Ue,we),Oe=new YN(L,pe,$e),Mt=new iC(L,pe,$e),$e.programs=ke.programs,y.capabilities=Ue,y.extensions=pe,y.properties=Be,y.renderLists=Pe,y.shadowMap=ze,y.state=we,y.info=$e}Ce();const ee=new jR(y,L);this.xr=ee,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const A=pe.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=pe.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return he},this.setPixelRatio=function(A){A!==void 0&&(he=A,this.setSize(re,$,!1))},this.getSize=function(A){return A.set(re,$)},this.setSize=function(A,B,X=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}re=A,$=B,t.width=Math.floor(A*he),t.height=Math.floor(B*he),X===!0&&(t.style.width=A+"px",t.style.height=B+"px"),this.setViewport(0,0,A,B)},this.getDrawingBufferSize=function(A){return A.set(re*he,$*he).floor()},this.setDrawingBufferSize=function(A,B,X){re=A,$=B,he=X,t.width=Math.floor(A*X),t.height=Math.floor(B*X),this.setViewport(0,0,A,B)},this.getCurrentViewport=function(A){return A.copy(M)},this.getViewport=function(A){return A.copy(Te)},this.setViewport=function(A,B,X,q){A.isVector4?Te.set(A.x,A.y,A.z,A.w):Te.set(A,B,X,q),we.viewport(M.copy(Te).multiplyScalar(he).round())},this.getScissor=function(A){return A.copy(Ve)},this.setScissor=function(A,B,X,q){A.isVector4?Ve.set(A.x,A.y,A.z,A.w):Ve.set(A,B,X,q),we.scissor(b.copy(Ve).multiplyScalar(he).round())},this.getScissorTest=function(){return at},this.setScissorTest=function(A){we.setScissorTest(at=A)},this.setOpaqueSort=function(A){Q=A},this.setTransparentSort=function(A){ye=A},this.getClearColor=function(A){return A.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(A=!0,B=!0,X=!0){let q=0;if(A){let F=!1;if(w!==null){const me=w.texture.format;F=me===zc||me===Bc||me===Vo}if(F){const me=w.texture.type,Ie=me===jr||me===Nr||me===va||me===qn||me===Dc||me===Uc,Fe=tt.getClearColor(),Ge=tt.getClearAlpha(),Qe=Fe.r,Ze=Fe.g,Je=Fe.b;Ie?(p[0]=Qe,p[1]=Ze,p[2]=Je,p[3]=Ge,L.clearBufferuiv(L.COLOR,0,p)):(m[0]=Qe,m[1]=Ze,m[2]=Je,m[3]=Ge,L.clearBufferiv(L.COLOR,0,m))}else q|=L.COLOR_BUFFER_BIT}B&&(q|=L.DEPTH_BUFFER_BIT,L.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),X&&(q|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(q)},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",oe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Ae,!1),Pe.dispose(),mt.dispose(),Be.dispose(),S.dispose(),W.dispose(),se.dispose(),Dt.dispose(),O.dispose(),ke.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",p0),ee.removeEventListener("sessionend",m0),_s.stop()};function oe(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const A=$e.autoReset,B=ze.enabled,X=ze.autoUpdate,q=ze.needsUpdate,F=ze.type;Ce(),$e.autoReset=A,ze.enabled=B,ze.autoUpdate=X,ze.needsUpdate=q,ze.type=F}function Ae(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ut(A){const B=A.target;B.removeEventListener("dispose",Ut),ni(B)}function ni(A){tr(A),Be.remove(A)}function tr(A){const B=Be.get(A).programs;B!==void 0&&(B.forEach(function(X){ke.releaseProgram(X)}),A.isShaderMaterial&&ke.releaseShaderCache(A))}this.renderBufferDirect=function(A,B,X,q,F,me){B===null&&(B=ot);const Ie=F.isMesh&&F.matrixWorld.determinant()<0,Fe=ew(A,B,X,q,F);we.setMaterial(q,Ie);let Ge=X.index,Qe=1;if(q.wireframe===!0){if(Ge=de.getWireframeAttribute(X),Ge===void 0)return;Qe=2}const Ze=X.drawRange,Je=X.attributes.position;let Rt=Ze.start*Qe,jt=(Ze.start+Ze.count)*Qe;me!==null&&(Rt=Math.max(Rt,me.start*Qe),jt=Math.min(jt,(me.start+me.count)*Qe)),Ge!==null?(Rt=Math.max(Rt,0),jt=Math.min(jt,Ge.count)):Je!=null&&(Rt=Math.max(Rt,0),jt=Math.min(jt,Je.count));const Qt=jt-Rt;if(Qt<0||Qt===1/0)return;Dt.setup(F,q,Fe,X,Ge);let ci,Ht=Oe;if(Ge!==null&&(ci=ne.get(Ge),Ht=Mt,Ht.setIndex(ci)),F.isMesh)q.wireframe===!0?(we.setLineWidth(q.wireframeLinewidth*ue()),Ht.setMode(L.LINES)):Ht.setMode(L.TRIANGLES);else if(F.isLine){let Xe=q.linewidth;Xe===void 0&&(Xe=1),we.setLineWidth(Xe*ue()),F.isLineSegments?Ht.setMode(L.LINES):F.isLineLoop?Ht.setMode(L.LINE_LOOP):Ht.setMode(L.LINE_STRIP)}else F.isPoints?Ht.setMode(L.POINTS):F.isSprite&&Ht.setMode(L.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)Ht.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(pe.get("WEBGL_multi_draw"))Ht.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Xe=F._multiDrawStarts,ji=F._multiDrawCounts,Ms=F._multiDrawCount,Gr=Ge?ne.get(Ge).bytesPerElement:1,ma=Be.get(q).currentProgram.getUniforms();for(let pr=0;pr<Ms;pr++)ma.setValue(L,"_gl_DrawID",pr),Ht.render(Xe[pr]/Gr,ji[pr])}else if(F.isInstancedMesh)Ht.renderInstances(Rt,Qt,F.count);else if(X.isInstancedBufferGeometry){const Xe=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,ji=Math.min(X.instanceCount,Xe);Ht.renderInstances(Rt,Qt,ji)}else Ht.render(Rt,Qt)};function At(A,B,X){A.transparent===!0&&A.side===Wr&&A.forceSinglePass===!1?(A.side=si,A.needsUpdate=!0,Sc(A,B,X),A.side=an,A.needsUpdate=!0,Sc(A,B,X),A.side=Wr):Sc(A,B,X)}this.compile=function(A,B,X=null){X===null&&(X=A),f=mt.get(X),f.init(B),x.push(f),X.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),A!==X&&A.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),f.setupLights();const q=new Set;return A.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const me=F.material;if(me)if(Array.isArray(me))for(let Ie=0;Ie<me.length;Ie++){const Fe=me[Ie];At(Fe,X,F),q.add(Fe)}else At(me,X,F),q.add(me)}),x.pop(),f=null,q},this.compileAsync=function(A,B,X=null){const q=this.compile(A,B,X);return new Promise(F=>{function me(){if(q.forEach(function(Ie){Be.get(Ie).currentProgram.isReady()&&q.delete(Ie)}),q.size===0){F(A);return}setTimeout(me,10)}pe.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let ir=null;function Mn(A){ir&&ir(A)}function p0(){_s.stop()}function m0(){_s.start()}const _s=new Bv;_s.setAnimationLoop(Mn),typeof self<"u"&&_s.setContext(self),this.setAnimationLoop=function(A){ir=A,ee.setAnimationLoop(A),A===null?_s.stop():_s.start()},ee.addEventListener("sessionstart",p0),ee.addEventListener("sessionend",m0),this.render=function(A,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(B),B=ee.getCamera()),A.isScene===!0&&A.onBeforeRender(y,A,B,w),f=mt.get(A,x.length),f.init(B),x.push(f),Se.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),et.setFromProjectionMatrix(Se),le=this.localClippingEnabled,ie=ve.init(this.clippingPlanes,le),v=Pe.get(A,g.length),v.init(),g.push(v),ee.enabled===!0&&ee.isPresenting===!0){const me=y.xr.getDepthSensingMesh();me!==null&&Wd(me,B,-1/0,y.sortObjects)}Wd(A,B,0,y.sortObjects),v.finish(),y.sortObjects===!0&&v.sort(Q,ye),ce=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,ce&&tt.addToRenderList(v,A),this.info.render.frame++,ie===!0&&ve.beginShadows();const X=f.state.shadowsArray;ze.render(X,A,B),ie===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const q=v.opaque,F=v.transmissive;if(f.setupLights(),B.isArrayCamera){const me=B.cameras;if(F.length>0)for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];g0(q,F,A,Ge)}ce&&tt.render(A);for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];f0(v,A,Ge,Ge.viewport)}}else F.length>0&&g0(q,F,A,B),ce&&tt.render(A),f0(v,A,B);w!==null&&(R.updateMultisampleRenderTarget(w),R.updateRenderTargetMipmap(w)),A.isScene===!0&&A.onAfterRender(y,A,B),Dt.resetDefaultState(),C=-1,H=null,x.pop(),x.length>0?(f=x[x.length-1],ie===!0&&ve.setGlobalState(y.clippingPlanes,f.state.camera)):f=null,g.pop(),g.length>0?v=g[g.length-1]:v=null};function Wd(A,B,X,q){if(A.visible===!1)return;if(A.layers.test(B.layers)){if(A.isGroup)X=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(B);else if(A.isLight)f.pushLight(A),A.castShadow&&f.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||et.intersectsSprite(A)){q&&We.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Se);const me=se.update(A),Ie=A.material;Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||et.intersectsObject(A))){const me=se.update(A),Ie=A.material;if(q&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),We.copy(A.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),We.copy(me.boundingSphere.center)),We.applyMatrix4(A.matrixWorld).applyMatrix4(Se)),Array.isArray(Ie)){const Fe=me.groups;for(let Ge=0,Qe=Fe.length;Ge<Qe;Ge++){const Ze=Fe[Ge],Je=Ie[Ze.materialIndex];Je&&Je.visible&&v.push(A,me,Je,X,We.z,Ze)}}else Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}const F=A.children;for(let me=0,Ie=F.length;me<Ie;me++)Wd(F[me],B,X,q)}function f0(A,B,X,q){const F=A.opaque,me=A.transmissive,Ie=A.transparent;f.setupLightsView(X),ie===!0&&ve.setGlobalState(y.clippingPlanes,X),q&&we.viewport(M.copy(q)),F.length>0&&bc(F,B,X),me.length>0&&bc(me,B,X),Ie.length>0&&bc(Ie,B,X),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function g0(A,B,X,q){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[q.id]===void 0&&(f.state.transmissionRenderTarget[q.id]=new Ir(1,1,{generateMipmaps:!0,type:pe.has("EXT_color_buffer_half_float")||pe.has("EXT_color_buffer_float")?wi:jr,minFilter:Xi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:vt.workingColorSpace}));const F=f.state.transmissionRenderTarget[q.id],me=q.viewport||M;F.setSize(me.z,me.w);const Ie=y.getRenderTarget();y.setRenderTarget(F),y.getClearColor(j),Y=y.getClearAlpha(),Y<1&&y.setClearColor(16777215,.5),y.clear(),ce&&tt.render(X);const Fe=y.toneMapping;y.toneMapping=mr;const Ge=q.viewport;if(q.viewport!==void 0&&(q.viewport=void 0),f.setupLightsView(q),ie===!0&&ve.setGlobalState(y.clippingPlanes,q),bc(A,X,q),R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F),pe.has("WEBGL_multisampled_render_to_texture")===!1){let Qe=!1;for(let Ze=0,Je=B.length;Ze<Je;Ze++){const Rt=B[Ze],jt=Rt.object,Qt=Rt.geometry,ci=Rt.material,Ht=Rt.group;if(ci.side===Wr&&jt.layers.test(q.layers)){const Xe=ci.side;ci.side=si,ci.needsUpdate=!0,v0(jt,X,q,Qt,ci,Ht),ci.side=Xe,ci.needsUpdate=!0,Qe=!0}}Qe===!0&&(R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F))}y.setRenderTarget(Ie),y.setClearColor(j,Y),Ge!==void 0&&(q.viewport=Ge),y.toneMapping=Fe}function bc(A,B,X){const q=B.isScene===!0?B.overrideMaterial:null;for(let F=0,me=A.length;F<me;F++){const Ie=A[F],Fe=Ie.object,Ge=Ie.geometry,Qe=q===null?Ie.material:q,Ze=Ie.group;Fe.layers.test(X.layers)&&v0(Fe,B,X,Ge,Qe,Ze)}}function v0(A,B,X,q,F,me){A.onBeforeRender(y,B,X,q,F,me),A.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),F.onBeforeRender(y,B,X,q,A,me),F.transparent===!0&&F.side===Wr&&F.forceSinglePass===!1?(F.side=si,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=an,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=Wr):y.renderBufferDirect(X,B,q,F,A,me),A.onAfterRender(y,B,X,q,F,me)}function Sc(A,B,X){B.isScene!==!0&&(B=ot);const q=Be.get(A),F=f.state.lights,me=f.state.shadowsArray,Ie=F.state.version,Fe=ke.getParameters(A,F.state,me,B,X),Ge=ke.getProgramCacheKey(Fe);let Qe=q.programs;q.environment=A.isMeshStandardMaterial?B.environment:null,q.fog=B.fog,q.envMap=(A.isMeshStandardMaterial?W:S).get(A.envMap||q.environment),q.envMapRotation=q.environment!==null&&A.envMap===null?B.environmentRotation:A.envMapRotation,Qe===void 0&&(A.addEventListener("dispose",Ut),Qe=new Map,q.programs=Qe);let Ze=Qe.get(Ge);if(Ze!==void 0){if(q.currentProgram===Ze&&q.lightsStateVersion===Ie)return x0(A,Fe),Ze}else Fe.uniforms=ke.getUniforms(A),A.onBuild(X,Fe,y),A.onBeforeCompile(Fe,y),Ze=ke.acquireProgram(Fe,Ge),Qe.set(Ge,Ze),q.uniforms=Fe.uniforms;const Je=q.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Je.clippingPlanes=ve.uniform),x0(A,Fe),q.needsLights=iw(A),q.lightsStateVersion=Ie,q.needsLights&&(Je.ambientLightColor.value=F.state.ambient,Je.lightProbe.value=F.state.probe,Je.directionalLights.value=F.state.directional,Je.directionalLightShadows.value=F.state.directionalShadow,Je.spotLights.value=F.state.spot,Je.spotLightShadows.value=F.state.spotShadow,Je.rectAreaLights.value=F.state.rectArea,Je.ltc_1.value=F.state.rectAreaLTC1,Je.ltc_2.value=F.state.rectAreaLTC2,Je.pointLights.value=F.state.point,Je.pointLightShadows.value=F.state.pointShadow,Je.hemisphereLights.value=F.state.hemi,Je.directionalShadowMap.value=F.state.directionalShadowMap,Je.directionalShadowMatrix.value=F.state.directionalShadowMatrix,Je.spotShadowMap.value=F.state.spotShadowMap,Je.spotLightMatrix.value=F.state.spotLightMatrix,Je.spotLightMap.value=F.state.spotLightMap,Je.pointShadowMap.value=F.state.pointShadowMap,Je.pointShadowMatrix.value=F.state.pointShadowMatrix),q.currentProgram=Ze,q.uniformsList=null,Ze}function y0(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=Bu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function x0(A,B){const X=Be.get(A);X.outputColorSpace=B.outputColorSpace,X.batching=B.batching,X.batchingColor=B.batchingColor,X.instancing=B.instancing,X.instancingColor=B.instancingColor,X.instancingMorph=B.instancingMorph,X.skinning=B.skinning,X.morphTargets=B.morphTargets,X.morphNormals=B.morphNormals,X.morphColors=B.morphColors,X.morphTargetsCount=B.morphTargetsCount,X.numClippingPlanes=B.numClippingPlanes,X.numIntersection=B.numClipIntersection,X.vertexAlphas=B.vertexAlphas,X.vertexTangents=B.vertexTangents,X.toneMapping=B.toneMapping}function ew(A,B,X,q,F){B.isScene!==!0&&(B=ot),R.resetTextureUnits();const me=B.fog,Ie=q.isMeshStandardMaterial?B.environment:null,Fe=w===null?y.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:nr,Ge=(q.isMeshStandardMaterial?W:S).get(q.envMap||Ie),Qe=q.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ze=!!X.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),Je=!!X.morphAttributes.position,Rt=!!X.morphAttributes.normal,jt=!!X.morphAttributes.color;let Qt=mr;q.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Qt=y.toneMapping);const ci=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ht=ci!==void 0?ci.length:0,Xe=Be.get(q),ji=f.state.lights;if(ie===!0&&(le===!0||A!==H)){const wr=A===H&&q.id===C;ve.setState(q,A,wr)}let Ms=!1;q.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==ji.state.version||Xe.outputColorSpace!==Fe||F.isBatchedMesh&&Xe.batching===!1||!F.isBatchedMesh&&Xe.batching===!0||F.isBatchedMesh&&Xe.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Xe.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Xe.instancing===!1||!F.isInstancedMesh&&Xe.instancing===!0||F.isSkinnedMesh&&Xe.skinning===!1||!F.isSkinnedMesh&&Xe.skinning===!0||F.isInstancedMesh&&Xe.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Xe.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Xe.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Xe.instancingMorph===!1&&F.morphTexture!==null||Xe.envMap!==Ge||q.fog===!0&&Xe.fog!==me||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==ve.numPlanes||Xe.numIntersection!==ve.numIntersection)||Xe.vertexAlphas!==Qe||Xe.vertexTangents!==Ze||Xe.morphTargets!==Je||Xe.morphNormals!==Rt||Xe.morphColors!==jt||Xe.toneMapping!==Qt||Xe.morphTargetsCount!==Ht)&&(Ms=!0):(Ms=!0,Xe.__version=q.version);let Gr=Xe.currentProgram;Ms===!0&&(Gr=Sc(q,B,F));let ma=!1,pr=!1,jd=!1;const ei=Gr.getUniforms(),Vn=Xe.uniforms;if(we.useProgram(Gr.program)&&(ma=!0,pr=!0,jd=!0),(q.id!==C||q._forceRefresh)&&(C=q.id,pr=!0,q._forceRefresh=!1),ma||H!==A){Ue.reverseDepthBuffer?(be.copy(A.projectionMatrix),Fw(be),Vw(be),ei.setValue(L,"projectionMatrix",be)):ei.setValue(L,"projectionMatrix",A.projectionMatrix),ei.setValue(L,"viewMatrix",A.matrixWorldInverse);const wr=ei.map.cameraPosition;wr!==void 0&&wr.setValue(L,Ye.setFromMatrixPosition(A.matrixWorld)),Ue.logarithmicDepthBuffer&&ei.setValue(L,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&ei.setValue(L,"isOrthographic",A.isOrthographicCamera===!0),H!==A&&(H=A,pr=!0,jd=!0)}if(F.isSkinnedMesh){ei.setOptional(L,F,"bindMatrix"),ei.setOptional(L,F,"bindMatrixInverse");const wr=F.skeleton;wr&&(wr.boneTexture===null&&wr.computeBoneTexture(),ei.setValue(L,"boneTexture",wr.boneTexture,R))}F.isBatchedMesh&&(ei.setOptional(L,F,"batchingTexture"),ei.setValue(L,"batchingTexture",F._matricesTexture,R),ei.setOptional(L,F,"batchingIdTexture"),ei.setValue(L,"batchingIdTexture",F._indirectTexture,R),ei.setOptional(L,F,"batchingColorTexture"),F._colorsTexture!==null&&ei.setValue(L,"batchingColorTexture",F._colorsTexture,R));const Xd=X.morphAttributes;if((Xd.position!==void 0||Xd.normal!==void 0||Xd.color!==void 0)&&it.update(F,X,Gr),(pr||Xe.receiveShadow!==F.receiveShadow)&&(Xe.receiveShadow=F.receiveShadow,ei.setValue(L,"receiveShadow",F.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(Vn.envMap.value=Ge,Vn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&B.environment!==null&&(Vn.envMapIntensity.value=B.environmentIntensity),pr&&(ei.setValue(L,"toneMappingExposure",y.toneMappingExposure),Xe.needsLights&&tw(Vn,jd),me&&q.fog===!0&&Ee.refreshFogUniforms(Vn,me),Ee.refreshMaterialUniforms(Vn,q,he,$,f.state.transmissionRenderTarget[A.id]),Bu.upload(L,y0(Xe),Vn,R)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Bu.upload(L,y0(Xe),Vn,R),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&ei.setValue(L,"center",F.center),ei.setValue(L,"modelViewMatrix",F.modelViewMatrix),ei.setValue(L,"normalMatrix",F.normalMatrix),ei.setValue(L,"modelMatrix",F.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const wr=q.uniformsGroups;for(let qd=0,rw=wr.length;qd<rw;qd++){const _0=wr[qd];O.update(_0,Gr),O.bind(_0,Gr)}}return Gr}function tw(A,B){A.ambientLightColor.needsUpdate=B,A.lightProbe.needsUpdate=B,A.directionalLights.needsUpdate=B,A.directionalLightShadows.needsUpdate=B,A.pointLights.needsUpdate=B,A.pointLightShadows.needsUpdate=B,A.spotLights.needsUpdate=B,A.spotLightShadows.needsUpdate=B,A.rectAreaLights.needsUpdate=B,A.hemisphereLights.needsUpdate=B}function iw(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(A,B,X){Be.get(A.texture).__webglTexture=B,Be.get(A.depthTexture).__webglTexture=X;const q=Be.get(A);q.__hasExternalTextures=!0,q.__autoAllocateDepthBuffer=X===void 0,q.__autoAllocateDepthBuffer||pe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),q.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(A,B){const X=Be.get(A);X.__webglFramebuffer=B,X.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(A,B=0,X=0){w=A,I=B,T=X;let q=!0,F=null,me=!1,Ie=!1;if(A){const Fe=Be.get(A);if(Fe.__useDefaultFramebuffer!==void 0)we.bindFramebuffer(L.FRAMEBUFFER,null),q=!1;else if(Fe.__webglFramebuffer===void 0)R.setupRenderTarget(A);else if(Fe.__hasExternalTextures)R.rebindTextures(A,Be.get(A.texture).__webglTexture,Be.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const Ze=A.depthTexture;if(Fe.__boundDepthTexture!==Ze){if(Ze!==null&&Be.has(Ze)&&(A.width!==Ze.image.width||A.height!==Ze.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(A)}}const Ge=A.texture;(Ge.isData3DTexture||Ge.isDataArrayTexture||Ge.isCompressedArrayTexture)&&(Ie=!0);const Qe=Be.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Qe[B])?F=Qe[B][X]:F=Qe[B],me=!0):A.samples>0&&R.useMultisampledRTT(A)===!1?F=Be.get(A).__webglMultisampledFramebuffer:Array.isArray(Qe)?F=Qe[X]:F=Qe,M.copy(A.viewport),b.copy(A.scissor),k=A.scissorTest}else M.copy(Te).multiplyScalar(he).floor(),b.copy(Ve).multiplyScalar(he).floor(),k=at;if(we.bindFramebuffer(L.FRAMEBUFFER,F)&&q&&we.drawBuffers(A,F),we.viewport(M),we.scissor(b),we.setScissorTest(k),me){const Fe=Be.get(A.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+B,Fe.__webglTexture,X)}else if(Ie){const Fe=Be.get(A.texture),Ge=B||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,Fe.__webglTexture,X||0,Ge)}C=-1},this.readRenderTargetPixels=function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){we.bindFramebuffer(L.FRAMEBUFFER,Fe);try{const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ue.textureTypeReadable(Ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F&&L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),me)}finally{const Ge=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ue.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F){we.bindFramebuffer(L.FRAMEBUFFER,Fe);const Je=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),0);const Rt=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Rt);const jt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Ow(L,jt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.deleteBuffer(Je),L.deleteSync(jt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(A,B=null,X=0){A.isTexture!==!0&&(hu("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,A=arguments[1]);const q=Math.pow(2,-X),F=Math.floor(A.image.width*q),me=Math.floor(A.image.height*q),Ie=B!==null?B.x:0,Fe=B!==null?B.y:0;R.setTexture2D(A,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,Ie,Fe,F,me),we.unbindTexture()},this.copyTextureToTexture=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(hu("WebGLRenderer: copyTextureToTexture function signature has changed."),q=arguments[0]||null,A=arguments[1],B=arguments[2],F=arguments[3]||0,X=null);let me,Ie,Fe,Ge,Qe,Ze;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.min.x,Ge=X.min.y):(me=A.image.width,Ie=A.image.height,Fe=0,Ge=0),q!==null?(Qe=q.x,Ze=q.y):(Qe=0,Ze=0);const Je=ut.convert(B.format),Rt=ut.convert(B.type);R.setTexture2D(B,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const jt=L.getParameter(L.UNPACK_ROW_LENGTH),Qt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),ci=L.getParameter(L.UNPACK_SKIP_PIXELS),Ht=L.getParameter(L.UNPACK_SKIP_ROWS),Xe=L.getParameter(L.UNPACK_SKIP_IMAGES),ji=A.isCompressedTexture?A.mipmaps[F]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,ji.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ji.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Fe),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ge),A.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,ji.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,F,Qe,Ze,ji.width,ji.height,Je,ji.data):L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,ji),L.pixelStorei(L.UNPACK_ROW_LENGTH,jt),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,ci),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Xe),F===0&&B.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),we.unbindTexture()},this.copyTextureToTexture3D=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(hu("WebGLRenderer: copyTextureToTexture3D function signature has changed."),X=arguments[0]||null,q=arguments[1]||null,A=arguments[2],B=arguments[3],F=arguments[4]||0);let me,Ie,Fe,Ge,Qe,Ze,Je,Rt,jt;const Qt=A.isCompressedTexture?A.mipmaps[F]:A.image;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.max.z-X.min.z,Ge=X.min.x,Qe=X.min.y,Ze=X.min.z):(me=Qt.width,Ie=Qt.height,Fe=Qt.depth,Ge=0,Qe=0,Ze=0),q!==null?(Je=q.x,Rt=q.y,jt=q.z):(Je=0,Rt=0,jt=0);const ci=ut.convert(B.format),Ht=ut.convert(B.type);let Xe;if(B.isData3DTexture)R.setTexture3D(B,0),Xe=L.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)R.setTexture2DArray(B,0),Xe=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const ji=L.getParameter(L.UNPACK_ROW_LENGTH),Ms=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Gr=L.getParameter(L.UNPACK_SKIP_PIXELS),ma=L.getParameter(L.UNPACK_SKIP_ROWS),pr=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,Qt.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Ge),L.pixelStorei(L.UNPACK_SKIP_ROWS,Qe),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Ze),A.isDataTexture||A.isData3DTexture?L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt.data):B.isCompressedArrayTexture?L.compressedTexSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Qt.data):L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt),L.pixelStorei(L.UNPACK_ROW_LENGTH,ji),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ms),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Gr),L.pixelStorei(L.UNPACK_SKIP_ROWS,ma),L.pixelStorei(L.UNPACK_SKIP_IMAGES,pr),F===0&&B.generateMipmaps&&L.generateMipmap(Xe),we.unbindTexture()},this.initRenderTarget=function(A){Be.get(A).__webglFramebuffer===void 0&&R.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?R.setTextureCube(A,0):A.isData3DTexture?R.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?R.setTexture2DArray(A,0):R.setTexture2D(A,0),we.unbindTexture()},this.resetState=function(){I=0,T=0,w=null,we.reset(),Dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===ou?"display-p3":"srgb",t.unpackColorSpace=vt.workingColorSpace===$o?"display-p3":"srgb"}}class Dd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Dd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let im=class ZS{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new ZS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Hu 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 dr,this.environmentIntensity=1,this.environmentRotation=new dr,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}}class qa{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ea,this.updateRanges=[],this.version=0,this.uuid=yr()}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,s=this.stride;r<s;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=yr()),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=yr()),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 $i=new N;class Fn{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++)$i.fromBufferAttribute(this,t),$i.applyMatrix4(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyNormalMatrix(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.transformDirection(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=qi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(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=qi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=qi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=qi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=qi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(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=ht(t,this.array),i=ht(i,this.array),r=ht(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,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,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]=s,this}clone(e){if(e===void 0){console.log("THREE.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 s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new wt(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 Fn(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.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 s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}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 hl extends hi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(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 Ya;const dl=new N,$a=new N,Ja=new N,Ka=new J,pl=new J,fy=new Re,Gu=new N,ml=new N,Wu=new N,gy=new J,rm=new J,vy=new J;class nm extends _t{constructor(e=new hl){if(super(),this.isSprite=!0,this.type="Sprite",Ya===void 0){Ya=new ct;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 qa(t,5);Ya.setIndex([0,1,2,0,2,3]),Ya.setAttribute("position",new Fn(i,3,0,!1)),Ya.setAttribute("uv",new Fn(i,2,3,!1))}this.geometry=Ya,this.material=e,this.center=new J(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),$a.setFromMatrixScale(this.matrixWorld),fy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ja.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&$a.multiplyScalar(-Ja.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const a=this.center;ju(Gu.set(-.5,-.5,0),Ja,a,$a,r,s),ju(ml.set(.5,-.5,0),Ja,a,$a,r,s),ju(Wu.set(.5,.5,0),Ja,a,$a,r,s),gy.set(0,0),rm.set(1,0),vy.set(1,1);let o=e.ray.intersectTriangle(Gu,ml,Wu,!1,dl);if(o===null&&(ju(ml.set(-.5,.5,0),Ja,a,$a,r,s),rm.set(0,1),o=e.ray.intersectTriangle(Gu,Wu,ml,!1,dl),o===null))return;const l=e.ray.origin.distanceTo(dl);l<e.near||l>e.far||t.push({distance:l,point:dl.clone(),uv:er.getInterpolation(dl,Gu,ml,Wu,gy,rm,vy,new J),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 ju(n,e,t,i,r,s){Ka.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(pl.x=s*Ka.x-r*Ka.y,pl.y=r*Ka.x+s*Ka.y):pl.copy(Ka),n.copy(e),n.x+=pl.x,n.y+=pl.y,n.applyMatrix4(fy)}const Xu=new N,yy=new N;class sm extends _t{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,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 s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Xu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Xu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Xu.setFromMatrixPosition(e.matrixWorld),yy.setFromMatrixPosition(this.matrixWorld);const i=Xu.distanceTo(yy)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;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<s;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,s=i.length;r<s;r++){const a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const xy=new N,_y=new st,My=new st,$R=new N,Ty=new Re,qu=new N,am=new Ai,by=new Re,om=new Cs;class lm extends Ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=np,this.bindMatrix=new Re,this.bindMatrixInverse=new Re,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new zi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,qu),this.boundingBox.expandByPoint(qu)}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,qu),this.boundingSphere.expandByPoint(qu)}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(),am.copy(this.boundingSphere),am.applyMatrix4(r),e.ray.intersectsSphere(am)!==!1&&(by.copy(r).invert(),om.copy(e.ray).applyMatrix4(by),!(this.boundingBox!==null&&om.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,om)))}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 st,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===np?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===H0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;_y.fromBufferAttribute(r.attributes.skinIndex,e),My.fromBufferAttribute(r.attributes.skinWeight,e),xy.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=My.getComponent(s);if(a!==0){const o=_y.getComponent(s);Ty.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector($R.copy(xy).applyMatrix4(Ty),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Yu extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ur extends Wt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=$t,u=$t,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Sy=new Re,JR=new Re;class vc{constructor(e=[],t=[]){this.uuid=yr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=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){console.warn("THREE.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 Re)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Re;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 s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:JR;Sy.multiplyMatrices(o,t[s]),Sy.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new vc(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 Ur(t,e,e,Ei,Oi);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 s=e.bones[i];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Yu),this.bones.push(a),this.boneInverses.push(new Re().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}class Rn extends wt{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}}const Za=new Re,wy=new Re,$u=[],Ey=new zi,KR=new Re,fl=new Ft,gl=new Ai;class cm extends Ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Rn(new Float32Array(i*16),16),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,KR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new zi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Za),Ey.copy(e.boundingBox).applyMatrix4(Za),this.boundingBox.union(Ey)}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,Za),gl.copy(e.boundingSphere).applyMatrix4(Za),this.boundingSphere.union(gl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),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,s=i.length+1,a=e*s+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(fl.geometry=this.geometry,fl.material=this.material,fl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),gl.copy(this.boundingSphere),gl.applyMatrix4(i),e.ray.intersectsSphere(gl)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Za),wy.multiplyMatrices(i,Za),fl.matrixWorld=wy,fl.raycast(e,$u);for(let a=0,o=$u.length;a<o;a++){const l=$u[a];l.instanceId=s,l.object=this,t.push(l)}$u.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 Ur(new Float32Array(r*this.count),r,this.count,Fo,Oi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function ZR(n,e){return n.z-e.z}function QR(n,e){return e.z-n.z}class eI{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=t,a.index=i}reset(){this.list.length=0,this.index=0}}const ns=new Re,um=new Re,tI=new Re,iI=new xe(1,1,1),Ay=new Re,hm=new Ga,Ju=new zi,zs=new Ai,vl=new N,Ny=new N,rI=new N,dm=new eI,Hi=new Ft,Ku=[];function nI(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s<r;s++)for(let a=0;a<i;a++)e.setComponent(s+t,a,n.getComponent(s,a))}else e.array.set(n.array,t*i);e.needsUpdate=!0}class pm extends Ft{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,i=t*2,r){super(new ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_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 Ur(t,e,e,Ei,Oi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new Ur(t,e,e,Vo,Nr);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 Ur(t,e,e,Ei,Oi);i.colorSpace=vt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,u=new o.constructor(i*l),h=new wt(u,l,c);t.setAttribute(s,h)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new wt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zi);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,ns),this.getBoundingBoxAt(s,Ju).applyMatrix4(ns),e.union(Ju)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,ns),this.getBoundingSphereAt(s,zs).applyMatrix4(ns),e.union(zs)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(i=this._availableInstanceIds.pop(),this._drawInfo[i]=t):(i=this._drawInfo.length,this._drawInfo.push(t));const r=this._matricesTexture,s=r.image.data;tI.toArray(s,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(iI.toArray(a.image.data,i*4),a.needsUpdate=!0),i}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,a.push(r),o.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new zi,sphereInitialized:!1,sphere:new Ai}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in i.attributes){const m=t.getAttribute(p),v=i.getAttribute(p);nI(m,v,l);const f=m.itemSize;for(let g=m.count,x=c;g<x;g++){const y=l+g;for(let _=0;_<f;_++)v.setComponent(y,_,0)}v.needsUpdate=!0,v.addUpdateRange(l*f,c*f)}if(r){const p=o.indexStart;for(let m=0;m<a.count;m++)s.setX(p+m,l+a.getX(m));for(let m=a.count,v=o.indexCount;m<v;m++)s.setX(p+m,l);s.needsUpdate=!0,s.addUpdateRange(p,o.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=r?a.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.box,s=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const a=s.index,o=s.attributes.position,l=this._drawRanges[e];for(let c=l.start,u=l.start+l.count;c<u;c++){let h=c;a&&(h=a.getX(h)),r.expandByPoint(vl.fromBufferAttribute(o,h))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Ju),Ju.getCenter(r.center);const a=s.index,o=s.attributes.position,l=this._drawRanges[e];let c=0;for(let u=l.start,h=l.start+l.count;u<h;u++){let d=u;a&&(d=a.getX(d)),vl.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(vl))}r.radius=Math.sqrt(c),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture,s=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const i=this._colorsTexture,r=this._colorsTexture.image.data,s=this._drawInfo;return e>=s.length||s[e].active===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||i[e].visible===t?this:(i[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||t<0||t>=this._geometryCount?null:(i[e].geometryIndex=t,this)}getGeometryIdAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;const i=this._drawRanges[e];return t.start=i.start,t.count=i.count,t}raycast(e,t){const i=this._drawInfo,r=this._drawRanges,s=this.matrixWorld,a=this.geometry;Hi.material=this.material,Hi.geometry.index=a.index,Hi.geometry.attributes=a.attributes,Hi.geometry.boundingBox===null&&(Hi.geometry.boundingBox=new zi),Hi.geometry.boundingSphere===null&&(Hi.geometry.boundingSphere=new Ai);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const c=i[o].geometryIndex,u=r[c];Hi.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,Hi.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,Hi.geometry.boundingBox),this.getBoundingSphereAt(c,Hi.geometry.boundingSphere),Hi.raycast(e,Ku);for(let h=0,d=Ku.length;h<d;h++){const p=Ku[h];p.object=this,p.batchId=o,t.push(p)}Ku.length=0}Hi.material=null,Hi.geometry.index=null,Hi.geometry.attributes={},Hi.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._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.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(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data;d&&(Ay.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),hm.setFromProjectionMatrix(Ay,e.coordinateSystem));let v=0;if(this.sortObjects){um.copy(this.matrixWorld).invert(),vl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(um),Ny.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(um);for(let x=0,y=l.length;x<y;x++)if(l[x].visible&&l[x].active){const _=l[x].geometryIndex;this.getMatrixAt(x,ns),this.getBoundingSphereAt(_,zs).applyMatrix4(ns);let I=!1;if(d&&(I=!hm.intersectsSphere(zs)),!I){const T=rI.subVectors(zs.center,vl).dot(Ny);dm.push(h[_],T,x)}}const f=dm.list,g=this.customSort;g===null?f.sort(s.transparent?QR:ZR):g.call(this,f,i);for(let x=0,y=f.length;x<y;x++){const _=f[x];c[v]=_.start*o,u[v]=_.count,m[v]=_.index,v++}dm.reset()}else for(let f=0,g=l.length;f<g;f++)if(l[f].visible&&l[f].active){const x=l[f].geometryIndex;let y=!1;if(d&&(this.getMatrixAt(f,ns),this.getBoundingSphereAt(x,zs).applyMatrix4(ns),y=!hm.intersectsSphere(zs)),!y){const _=h[x];c[v]=_.start*o,u[v]=_.count,m[v]=f,v++}}p.needsUpdate=!0,this._multiDrawCount=v,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class Ni extends hi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(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 Zu=new N,Qu=new N,Cy=new Re,yl=new Cs,eh=new Ai,mm=new N,Ry=new N;class In extends _t{constructor(e=new ct,t=new Ni){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,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,s=t.count;r<s;r++)Zu.fromBufferAttribute(t,r-1),Qu.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Zu.distanceTo(Qu);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),eh.copy(i.boundingSphere),eh.applyMatrix4(r),eh.radius+=s,e.ray.intersectsSphere(eh)===!1)return;Cy.copy(r).invert(),yl.copy(e.ray).applyMatrix4(Cy);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=u.getX(m),g=u.getX(m+1),x=th(this,e,yl,l,f,g);x&&t.push(x)}if(this.isLineLoop){const m=u.getX(p-1),v=u.getX(d),f=th(this,e,yl,l,m,v);f&&t.push(f)}}else{const d=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=th(this,e,yl,l,m,m+1);f&&t.push(f)}if(this.isLineLoop){const m=th(this,e,yl,l,p-1,d);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,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function th(n,e,t,i,r,s){const a=n.geometry.attributes.position;if(Zu.fromBufferAttribute(a,r),Qu.fromBufferAttribute(a,s),t.distanceSqToSegment(Zu,Qu,mm,Ry)>i)return;mm.applyMatrix4(n.matrixWorld);const o=e.ray.origin.distanceTo(mm);if(!(o<e.near||o>e.far))return{distance:o,point:Ry.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const Iy=new N,Ly=new N;class Jr extends In{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,s=t.count;r<s;r+=2)Iy.fromBufferAttribute(t,r),Ly.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Iy.distanceTo(Ly);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class fm extends In{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Qa extends hi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(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 Py=new Re,gm=new Cs,ih=new Ai,rh=new N;class vm extends _t{constructor(e=new ct,t=new Qa){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,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,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),ih.copy(i.boundingSphere),ih.applyMatrix4(r),ih.radius+=s,e.ray.intersectsSphere(ih)===!1)return;Py.copy(r).invert(),gm.copy(e.ray).applyMatrix4(Py);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,u=i.attributes.position;if(c!==null){const h=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=h,m=d;p<m;p++){const v=c.getX(p);rh.fromBufferAttribute(u,v),Dy(rh,v,l,r,e,t,this)}}else{const h=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=h,m=d;p<m;p++)rh.fromBufferAttribute(u,p),Dy(rh,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,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Dy(n,e,t,i,r,s,a){const o=gm.distanceSqToPoint(n);if(o<t){const l=new N;gm.closestPointToPoint(n,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Uy extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Lt,this.magFilter=s!==void 0?s:Lt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class ym extends Wt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=$t,this.minFilter=$t,this.generateMipmaps=!1,this.needsUpdate=!0}}class xl extends Wt{constructor(e,t,i,r,s,a,o,l,c,u,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Oy extends xl{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=gr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Fy extends xl{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,fr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Vy extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Or{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}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),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(s-1);const u=i[r],h=i[r+1]-u,d=(a-u)/h;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new J:new N);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new N,r=[],s=[],a=[],o=new N,l=new Re;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new N)}s[0]=new N,a[0]=new N;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[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(Jt(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(Jt(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class nh extends Or{constructor(e=0,t=0,i=1,r=1,s=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=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new J){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*u-p*h+this.aX,c=d*h+p*u+this.aY}return i.set(l,c)}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 By extends nh{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function xm(){let n=0,e=0,t=0,i=0;function r(s,a,o,l){n=s,e=o,t=-3*s+3*a-2*o-l,i=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,u,h){let d=(a-s)/c-(o-s)/(c+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+h)+(l-o)/h;d*=u,p*=u,r(a,o,d,p)},calc:function(s){const a=s*s,o=a*s;return n+e*s+t*a+i*o}}}const sh=new N,_m=new xm,Mm=new xm,Tm=new xm;class bm extends Or{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 N){const i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,u;this.closed||o>0?c=r[(o-1)%s]:(sh.subVectors(r[0],r[1]).add(r[0]),c=sh);const h=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(sh.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=sh),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(d),p),f=Math.pow(d.distanceToSquared(u),p);v<1e-4&&(v=1),m<1e-4&&(m=v),f<1e-4&&(f=v),_m.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,v,f),Mm.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,v,f),Tm.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,v,f)}else this.curveType==="catmullrom"&&(_m.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),Mm.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),Tm.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(_m.calc(l),Mm.calc(l),Tm.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 N().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function zy(n,e,t,i,r){const s=(i-e)*.5,a=(r-t)*.5,o=n*n,l=n*o;return(2*t-2*i+s+a)*l+(-3*t+3*i-2*s-a)*o+s*n+t}function sI(n,e){const t=1-n;return t*t*e}function aI(n,e){return 2*(1-n)*n*e}function oI(n,e){return n*n*e}function _l(n,e,t,i){return sI(n,e)+aI(n,t)+oI(n,i)}function lI(n,e){const t=1-n;return t*t*t*e}function cI(n,e){const t=1-n;return 3*t*t*n*e}function uI(n,e){return 3*(1-n)*n*n*e}function hI(n,e){return n*n*n*e}function Ml(n,e,t,i,r){return lI(n,e)+cI(n,t)+uI(n,i)+hI(n,r)}class Sm extends Or{constructor(e=new J,t=new J,i=new J,r=new J){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(Ml(e,r.x,s.x,a.x,o.x),Ml(e,r.y,s.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 ky extends Or{constructor(e=new N,t=new N,i=new N,r=new N){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(Ml(e,r.x,s.x,a.x,o.x),Ml(e,r.y,s.y,a.y,o.y),Ml(e,r.z,s.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 wm extends Or{constructor(e=new J,t=new J){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new J){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 J){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 Hy extends Or{constructor(e=new N,t=new N){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new N){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 N){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 Em extends Or{constructor(e=new J,t=new J,i=new J){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(_l(e,r.x,s.x,a.x),_l(e,r.y,s.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 Am extends Or{constructor(e=new N,t=new N,i=new N){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(_l(e,r.x,s.x,a.x),_l(e,r.y,s.y,a.y),_l(e,r.z,s.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 Nm extends Or{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new J){const i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],u=r[a>r.length-2?r.length-1:a+1],h=r[a>r.length-3?r.length-1:a+2];return i.set(zy(o,l.x,c.x,u.x,h.x),zy(o,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;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 J().fromArray(r))}return this}}var ah=Object.freeze({__proto__:null,ArcCurve:By,CatmullRomCurve3:bm,CubicBezierCurve:Sm,CubicBezierCurve3:ky,EllipseCurve:nh,LineCurve:wm,LineCurve3:Hy,QuadraticBezierCurve:Em,QuadraticBezierCurve3:Am,SplineCurve:Nm});class Gy extends Or{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 ah[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const a=r[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}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,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}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 ah[r.type]().fromJSON(r))}return this}}class Tl extends Gy{constructor(e){super(),this.type="Path",this.currentPoint=new J,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 wm(this.currentPoint.clone(),new J(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new Em(this.currentPoint.clone(),new J(e,t),new J(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){const o=new Sm(this.currentPoint.clone(),new J(e,t),new J(i,r),new J(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Nm(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,o,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,a,o,l),this}absellipse(e,t,i,r,s,a,o,l){const c=new nh(e,t,i,r,s,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),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 yc extends ct{constructor(e=[new J(0,-.5),new J(.5,0),new J(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=Jt(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],u=1/t,h=new N,d=new J,p=new N,m=new N,v=new N;let f=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let x=0;x<=t;x++){const y=i+x*u*r,_=Math.sin(y),I=Math.cos(y);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*_,h.y=e[T].y,h.z=e[T].x*I,a.push(h.x,h.y,h.z),d.x=x/t,d.y=T/(e.length-1),o.push(d.x,d.y);const w=l[3*T+0]*_,C=l[3*T+1],H=l[3*T+0]*I;c.push(w,C,H)}}for(let x=0;x<t;x++)for(let y=0;y<e.length-1;y++){const _=y+x*e.length,I=_,T=_+e.length,w=_+e.length+1,C=_+1;s.push(I,T,C),s.push(w,C,T)}this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("uv",new De(o,2)),this.setAttribute("normal",new De(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yc(e.points,e.segments,e.phiStart,e.phiLength)}}class Ud extends yc{constructor(e=1,t=1,i=4,r=8){const s=new Tl;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new Ud(e.radius,e.length,e.capSegments,e.radialSegments)}}class Od extends ct{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 s=[],a=[],o=[],l=[],c=new N,u=new J;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=i+h/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[d]/e+1)/2,u.y=(a[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Od(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class pa extends ct{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let m=0;const v=[],f=i/2;let g=0;x(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function x(){const _=new N,I=new N;let T=0;const w=(t-e)/i;for(let C=0;C<=s;C++){const H=[],M=C/s,b=M*(t-e)+e;for(let k=0;k<=r;k++){const j=k/r,Y=j*l+o,re=Math.sin(Y),$=Math.cos(Y);I.x=b*re,I.y=-M*i+f,I.z=b*$,h.push(I.x,I.y,I.z),_.set(re,w,$).normalize(),d.push(_.x,_.y,_.z),p.push(j,1-M),H.push(m++)}v.push(H)}for(let C=0;C<r;C++)for(let H=0;H<s;H++){const M=v[H][C],b=v[H+1][C],k=v[H+1][C+1],j=v[H][C+1];e>0&&(u.push(M,b,j),T+=3),t>0&&(u.push(b,k,j),T+=3)}c.addGroup(g,T,0),g+=T}function y(_){const I=m,T=new J,w=new N;let C=0;const H=_===!0?e:t,M=_===!0?1:-1;for(let k=1;k<=r;k++)h.push(0,f*M,0),d.push(0,M,0),p.push(.5,.5),m++;const b=m;for(let k=0;k<=r;k++){const j=k/r*l+o,Y=Math.cos(j),re=Math.sin(j);w.x=H*re,w.y=f*M,w.z=H*Y,h.push(w.x,w.y,w.z),d.push(0,M,0),T.x=Y*.5+.5,T.y=re*.5*M+.5,p.push(T.x,T.y),m++}for(let k=0;k<r;k++){const j=I+k,Y=b+k;_===!0?u.push(Y,Y+1,j):u.push(Y+1,Y,j),C+=3}c.addGroup(g,C,_===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pa(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fd extends pa{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Fd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ys extends ct{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],a=[];o(r),c(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){const y=new N,_=new N,I=new N;for(let T=0;T<t.length;T+=3)p(t[T+0],y),p(t[T+1],_),p(t[T+2],I),l(y,_,I,x)}function l(x,y,_,I){const T=I+1,w=[];for(let C=0;C<=T;C++){w[C]=[];const H=x.clone().lerp(_,C/T),M=y.clone().lerp(_,C/T),b=T-C;for(let k=0;k<=b;k++)k===0&&C===T?w[C][k]=H:w[C][k]=H.clone().lerp(M,k/b)}for(let C=0;C<T;C++)for(let H=0;H<2*(T-C)-1;H++){const M=Math.floor(H/2);H%2===0?(d(w[C][M+1]),d(w[C+1][M]),d(w[C][M])):(d(w[C][M+1]),d(w[C+1][M+1]),d(w[C+1][M]))}}function c(x){const y=new N;for(let _=0;_<s.length;_+=3)y.x=s[_+0],y.y=s[_+1],y.z=s[_+2],y.normalize().multiplyScalar(x),s[_+0]=y.x,s[_+1]=y.y,s[_+2]=y.z}function u(){const x=new N;for(let y=0;y<s.length;y+=3){x.x=s[y+0],x.y=s[y+1],x.z=s[y+2];const _=f(x)/2/Math.PI+.5,I=g(x)/Math.PI+.5;a.push(_,1-I)}m(),h()}function h(){for(let x=0;x<a.length;x+=6){const y=a[x+0],_=a[x+2],I=a[x+4],T=Math.max(y,_,I),w=Math.min(y,_,I);T>.9&&w<.1&&(y<.2&&(a[x+0]+=1),_<.2&&(a[x+2]+=1),I<.2&&(a[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function p(x,y){const _=x*3;y.x=e[_+0],y.y=e[_+1],y.z=e[_+2]}function m(){const x=new N,y=new N,_=new N,I=new N,T=new J,w=new J,C=new J;for(let H=0,M=0;H<s.length;H+=9,M+=6){x.set(s[H+0],s[H+1],s[H+2]),y.set(s[H+3],s[H+4],s[H+5]),_.set(s[H+6],s[H+7],s[H+8]),T.set(a[M+0],a[M+1]),w.set(a[M+2],a[M+3]),C.set(a[M+4],a[M+5]),I.copy(x).add(y).add(_).divideScalar(3);const b=f(I);v(T,M+0,x,b),v(w,M+2,y,b),v(C,M+4,_,b)}}function v(x,y,_,I){I<0&&x.x===1&&(a[y]=x.x-1),_.x===0&&_.z===0&&(a[y]=I/2/Math.PI+.5)}function f(x){return Math.atan2(x.z,-x.x)}function g(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 ys(e.vertices,e.indices,e.radius,e.details)}}class Vd extends ys{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-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(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Vd(e.radius,e.detail)}}const oh=new N,lh=new N,Cm=new N,ch=new er;class Rm extends ct{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(Es*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let p=0;p<o;p+=3){s?(l[0]=s.getX(p),l[1]=s.getX(p+1),l[2]=s.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:m,b:v,c:f}=ch;if(m.fromBufferAttribute(a,l[0]),v.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),ch.getNormal(Cm),u[0]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,u[1]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,u[2]=`${Math.round(f.x*i)},${Math.round(f.y*i)},${Math.round(f.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let g=0;g<3;g++){const x=(g+1)%3,y=u[g],_=u[x],I=ch[c[g]],T=ch[c[x]],w=`${y}_${_}`,C=`${_}_${y}`;C in h&&h[C]?(Cm.dot(h[C].normal)<=r&&(d.push(I.x,I.y,I.z),d.push(T.x,T.y,T.z)),h[C]=null):w in h||(h[w]={index0:l[g],index1:l[x],normal:Cm.clone()})}}for(const p in h)if(h[p]){const{index0:m,index1:v}=h[p];oh.fromBufferAttribute(a,m),lh.fromBufferAttribute(a,v),d.push(oh.x,oh.y,oh.z),d.push(lh.x,lh.y,lh.z)}this.setAttribute("position",new De(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class ss extends Tl{constructor(e){super(e),this.uuid=yr(),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 Tl().fromJSON(r))}return this}}const dI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=Wy(n,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,u,h,d,p;if(i&&(s=vI(n,e,s,t)),n.length>80*t){o=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)h=n[m],d=n[m+1],h<o&&(o=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-o,u-l),p=p!==0?32767/p:0}return bl(s,a,t,o,l,p,0),a}};function Wy(n,e,t,i,r){let s,a;if(r===NI(n,e,t,i)>0)for(s=e;s<t;s+=i)a=qy(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=qy(s,n[s],n[s+1],a);return a&&uh(a,a.next)&&(wl(a),a=a.next),a}function ks(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(uh(t,t.next)||Xt(t.prev,t,t.next)===0)){if(wl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function bl(n,e,t,i,r,s,a){if(!n)return;!a&&s&&TI(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?mI(n,i,r,s):pI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),wl(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=fI(ks(n),e,t),bl(n,e,t,i,r,s,2)):a===2&&gI(n,e,t,i,r,s):bl(ks(n),e,t,i,r,s,1);break}}}function pI(n){const e=n.prev,t=n,i=n.next;if(Xt(e,t,i)>=0)return!1;const r=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=r<s?r<a?r:a:s<a?s:a,h=o<l?o<c?o:c:l<c?l:c,d=r>s?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=p&&eo(r,o,s,l,a,c,m.x,m.y)&&Xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function mI(n,e,t,i){const r=n.prev,s=n,a=n.next;if(Xt(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,u=r.y,h=s.y,d=a.y,p=o<l?o<c?o:c:l<c?l:c,m=u<h?u<d?u:d:h<d?h:d,v=o>l?o>c?o:c:l>c?l:c,f=u>h?u>d?u:d:h>d?h:d,g=Im(p,m,e,t,i),x=Im(v,f,e,t,i);let y=n.prevZ,_=n.nextZ;for(;y&&y.z>=g&&_&&_.z<=x;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&eo(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&eo(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&eo(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&eo(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function fI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!uh(r,s)&&jy(r,i,i.next,s)&&Sl(r,s)&&Sl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),wl(i),wl(i.next),i=n=s),i=i.next}while(i!==n);return ks(i)}function gI(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&wI(a,o)){let l=Xy(a,o);a=ks(a,a.next),l=ks(l,l.next),bl(a,e,t,i,r,s,0),bl(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function vI(n,e,t,i){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*i,l=s<a-1?e[s+1]*i:n.length,c=Wy(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(SI(c));for(r.sort(yI),s=0;s<r.length;s++)t=xI(r[s],t);return t}function yI(n,e){return n.x-e.x}function xI(n,e){const t=_I(n,e);if(!t)return e;const i=Xy(t,n);return ks(i,i.next),ks(t,t.next)}function _I(n,e){let t=e,i=-1/0,r;const s=n.x,a=n.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>i&&(i=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;const o=r,l=r.x,c=r.y;let u=1/0,h;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&eo(a<c?s:i,a,l,c,a<c?i:s,a,t.x,t.y)&&(h=Math.abs(a-t.y)/(s-t.x),Sl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&MI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function MI(n,e){return Xt(n.prev,n,e.prev)<0&&Xt(e.next,n,n.next)<0}function TI(n,e,t,i){let r=n;do r.z===0&&(r.z=Im(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,bI(r)}function bI(n){let e,t,i,r,s,a,o,l,c=1;do{for(t=n,n=null,s=null,a=0;t;){for(a++,i=t,o=0,e=0;e<c&&(o++,i=i.nextZ,!!i);e++);for(l=c;o>0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(a>1);return n}function Im(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function SI(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function eo(n,e,t,i,r,s,a,o){return(r-a)*(e-o)>=(n-a)*(s-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(i-o)}function wI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!EI(n,e)&&(Sl(n,e)&&Sl(e,n)&&AI(n,e)&&(Xt(n.prev,n,e.prev)||Xt(n,e.prev,e))||uh(n,e)&&Xt(n.prev,n,n.next)>0&&Xt(e.prev,e,e.next)>0)}function Xt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function uh(n,e){return n.x===e.x&&n.y===e.y}function jy(n,e,t,i){const r=dh(Xt(n,e,t)),s=dh(Xt(n,e,i)),a=dh(Xt(t,i,n)),o=dh(Xt(t,i,e));return!!(r!==s&&a!==o||r===0&&hh(n,t,e)||s===0&&hh(n,i,e)||a===0&&hh(t,n,i)||o===0&&hh(t,e,i))}function hh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function dh(n){return n>0?1:n<0?-1:0}function EI(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&jy(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Sl(n,e){return Xt(n.prev,n,n.next)<0?Xt(n,e,n.next)>=0&&Xt(n,n.prev,e)>=0:Xt(n,e,n.prev)<0||Xt(n,n.next,e)<0}function AI(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function Xy(n,e){const t=new Lm(n.i,n.x,n.y),i=new Lm(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function qy(n,e,t,i){const r=new Lm(n,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 wl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Lm(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function NI(n,e,t,i){let r=0;for(let s=e,a=t-i;s<t;s+=i)r+=(n[a]-n[s])*(n[s+1]+n[a+1]),a=s;return r}class nn{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return nn.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];Yy(e),$y(i,e);let a=e.length;t.forEach(Yy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,$y(i,t[l]);const o=dI.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Yy(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function $y(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class xc extends ct{constructor(e=new ss([new J(.5,.5),new J(-.5,.5),new J(-.5,-.5),new J(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,f=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:CI;let y,_=!1,I,T,w,C;g&&(y=g.getSpacedPoints(u),_=!0,d=!1,I=g.computeFrenetFrames(u,!1),T=new N,w=new N,C=new N),d||(f=0,p=0,m=0,v=0);const H=o.extractPoints(c);let M=H.shape;const b=H.holes;if(!nn.isClockWise(M)){M=M.reverse();for(let ce=0,ue=b.length;ce<ue;ce++){const L=b[ce];nn.isClockWise(L)&&(b[ce]=L.reverse())}}const k=nn.triangulateShape(M,b),j=M;for(let ce=0,ue=b.length;ce<ue;ce++){const L=b[ce];M=M.concat(L)}function Y(ce,ue,L){return ue||console.error("THREE.ExtrudeGeometry: vec does not exist"),ce.clone().addScaledVector(ue,L)}const re=M.length,$=k.length;function he(ce,ue,L){let He,pe,Ue;const we=ce.x-ue.x,$e=ce.y-ue.y,Be=L.x-ce.x,R=L.y-ce.y,S=we*we+$e*$e,W=we*R-$e*Be;if(Math.abs(W)>Number.EPSILON){const ne=Math.sqrt(S),de=Math.sqrt(Be*Be+R*R),se=ue.x-$e/ne,ke=ue.y+we/ne,Ee=L.x-R/de,Pe=L.y+Be/de,mt=((Ee-se)*R-(Pe-ke)*Be)/(we*R-$e*Be);He=se+we*mt-ce.x,pe=ke+$e*mt-ce.y;const ve=He*He+pe*pe;if(ve<=2)return new J(He,pe);Ue=Math.sqrt(ve/2)}else{let ne=!1;we>Number.EPSILON?Be>Number.EPSILON&&(ne=!0):we<-Number.EPSILON?Be<-Number.EPSILON&&(ne=!0):Math.sign($e)===Math.sign(R)&&(ne=!0),ne?(He=-$e,pe=we,Ue=Math.sqrt(S)):(He=we,pe=$e,Ue=Math.sqrt(S/2))}return new J(He/Ue,pe/Ue)}const Q=[];for(let ce=0,ue=j.length,L=ue-1,He=ce+1;ce<ue;ce++,L++,He++)L===ue&&(L=0),He===ue&&(He=0),Q[ce]=he(j[ce],j[L],j[He]);const ye=[];let Te,Ve=Q.concat();for(let ce=0,ue=b.length;ce<ue;ce++){const L=b[ce];Te=[];for(let He=0,pe=L.length,Ue=pe-1,we=He+1;He<pe;He++,Ue++,we++)Ue===pe&&(Ue=0),we===pe&&(we=0),Te[He]=he(L[He],L[Ue],L[we]);ye.push(Te),Ve=Ve.concat(Te)}for(let ce=0;ce<f;ce++){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);be(we.x,we.y,-L)}for(let pe=0,Ue=b.length;pe<Ue;pe++){const we=b[pe];Te=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],Te[$e],He);be(R.x,R.y,-L)}}}const at=m+v;for(let ce=0;ce<re;ce++){const ue=d?Y(M[ce],Ve[ce],at):M[ce];_?(w.copy(I.normals[0]).multiplyScalar(ue.x),T.copy(I.binormals[0]).multiplyScalar(ue.y),C.copy(y[0]).add(w).add(T),be(C.x,C.y,C.z)):be(ue.x,ue.y,0)}for(let ce=1;ce<=u;ce++)for(let ue=0;ue<re;ue++){const L=d?Y(M[ue],Ve[ue],at):M[ue];_?(w.copy(I.normals[ce]).multiplyScalar(L.x),T.copy(I.binormals[ce]).multiplyScalar(L.y),C.copy(y[ce]).add(w).add(T),be(C.x,C.y,C.z)):be(L.x,L.y,h/u*ce)}for(let ce=f-1;ce>=0;ce--){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);be(we.x,we.y,h+L)}for(let pe=0,Ue=b.length;pe<Ue;pe++){const we=b[pe];Te=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],Te[$e],He);_?be(R.x,R.y+y[u-1].y,y[u-1].x+L):be(R.x,R.y,h+L)}}}et(),ie();function et(){const ce=r.length/3;if(d){let ue=0,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[2]+L,pe[1]+L,pe[0]+L)}ue=u+f*2,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[0]+L,pe[1]+L,pe[2]+L)}}else{for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[2],L[1],L[0])}for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[0]+re*u,L[1]+re*u,L[2]+re*u)}}i.addGroup(ce,r.length/3-ce,0)}function ie(){const ce=r.length/3;let ue=0;le(j,ue),ue+=j.length;for(let L=0,He=b.length;L<He;L++){const pe=b[L];le(pe,ue),ue+=pe.length}i.addGroup(ce,r.length/3-ce,1)}function le(ce,ue){let L=ce.length;for(;--L>=0;){const He=L;let pe=L-1;pe<0&&(pe=ce.length-1);for(let Ue=0,we=u+f*2;Ue<we;Ue++){const $e=re*Ue,Be=re*(Ue+1),R=ue+He+$e,S=ue+pe+$e,W=ue+pe+Be,ne=ue+He+Be;Ye(R,S,W,ne)}}}function be(ce,ue,L){l.push(ce),l.push(ue),l.push(L)}function Se(ce,ue,L){We(ce),We(ue),We(L);const He=r.length/3,pe=x.generateTopUV(i,r,He-3,He-2,He-1);ot(pe[0]),ot(pe[1]),ot(pe[2])}function Ye(ce,ue,L,He){We(ce),We(ue),We(He),We(ue),We(L),We(He);const pe=r.length/3,Ue=x.generateSideWallUV(i,r,pe-6,pe-3,pe-2,pe-1);ot(Ue[0]),ot(Ue[1]),ot(Ue[3]),ot(Ue[1]),ot(Ue[2]),ot(Ue[3])}function We(ce){r.push(l[ce*3+0]),r.push(l[ce*3+1]),r.push(l[ce*3+2])}function ot(ce){s.push(ce.x),s.push(ce.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 RI(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new ah[r.type]().fromJSON(r)),new xc(i,e.options)}}const CI={generateTopUV:function(n,e,t,i,r){const s=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new J(s,a),new J(o,l),new J(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],h=e[i*3+2],d=e[r*3],p=e[r*3+1],m=e[r*3+2],v=e[s*3],f=e[s*3+1],g=e[s*3+2];return Math.abs(o-u)<Math.abs(a-c)?[new J(a,1-l),new J(c,1-h),new J(d,1-m),new J(v,1-g)]:[new J(o,1-l),new J(u,1-h),new J(p,1-m),new J(f,1-g)]}};function RI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Bd extends ys{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],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Bd(e.radius,e.detail)}}class Ao extends ys{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 Ao(e.radius,e.detail)}}class _c extends ct{constructor(e=.5,t=1,i=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],c=[],u=[];let h=e;const d=(t-e)/r,p=new N,m=new J;for(let v=0;v<=r;v++){for(let f=0;f<=i;f++){const g=s+f/i*a;p.x=h*Math.cos(g),p.y=h*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}h+=d}for(let v=0;v<r;v++){const f=v*(i+1);for(let g=0;g<i;g++){const x=g+f,y=x,_=x+i+1,I=x+i+2,T=x+1;o.push(y,_,T),o.push(_,I,T)}}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _c(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class zd extends ct{constructor(e=new ss([new J(0,.5),new J(-.5,-.5),new J(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(a,2));function c(u){const h=r.length/3,d=u.extractPoints(t);let p=d.shape;const m=d.holes;nn.isClockWise(p)===!1&&(p=p.reverse());for(let f=0,g=m.length;f<g;f++){const x=m[f];nn.isClockWise(x)===!0&&(m[f]=x.reverse())}const v=nn.triangulateShape(p,m);for(let f=0,g=m.length;f<g;f++){const x=m[f];p=p.concat(x)}for(let f=0,g=p.length;f<g;f++){const x=p[f];r.push(x.x,x.y,0),s.push(0,0,1),a.push(x.x,x.y)}for(let f=0,g=v.length;f<g;f++){const x=v[f],y=x[0]+h,_=x[1]+h,I=x[2]+h;i.push(y,_,I),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 II(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];i.push(a)}return new zd(i,e.curveSegments)}}function II(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class No extends ct{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,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 c=0;const u=[],h=new N,d=new N,p=[],m=[],v=[],f=[];for(let g=0;g<=i;g++){const x=[],y=g/i;let _=0;g===0&&a===0?_=.5/t:g===i&&l===Math.PI&&(_=-.5/t);for(let I=0;I<=t;I++){const T=I/t;h.x=-e*Math.cos(r+T*s)*Math.sin(a+y*o),h.y=e*Math.cos(a+y*o),h.z=e*Math.sin(r+T*s)*Math.sin(a+y*o),m.push(h.x,h.y,h.z),d.copy(h).normalize(),v.push(d.x,d.y,d.z),f.push(T+_,1-y),x.push(c++)}u.push(x)}for(let g=0;g<i;g++)for(let x=0;x<t;x++){const y=u[g][x+1],_=u[g][x],I=u[g+1][x],T=u[g+1][x+1];(g!==0||a>0)&&p.push(y,_,T),(g!==i-1||l<Math.PI)&&p.push(_,I,T)}this.setIndex(p),this.setAttribute("position",new De(m,3)),this.setAttribute("normal",new De(v,3)),this.setAttribute("uv",new De(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new No(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class kd extends ys{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 kd(e.radius,e.detail)}}class Mc extends ct{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const a=[],o=[],l=[],c=[],u=new N,h=new N,d=new N;for(let p=0;p<=i;p++)for(let m=0;m<=r;m++){const v=m/r*s,f=p/i*Math.PI*2;h.x=(e+t*Math.cos(f))*Math.cos(v),h.y=(e+t*Math.cos(f))*Math.sin(v),h.z=t*Math.sin(f),o.push(h.x,h.y,h.z),u.x=e*Math.cos(v),u.y=e*Math.sin(v),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=r;m++){const v=(r+1)*p+m-1,f=(r+1)*(p-1)+m-1,g=(r+1)*(p-1)+m,x=(r+1)*p+m;a.push(v,f,x),a.push(f,g,x)}this.setIndex(a),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mc(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Hd extends ct{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],c=[],u=[],h=new N,d=new N,p=new N,m=new N,v=new N,f=new N,g=new N;for(let y=0;y<=i;++y){const _=y/i*s*Math.PI*2;x(_,s,a,e,p),x(_+.01,s,a,e,m),f.subVectors(m,p),g.addVectors(m,p),v.crossVectors(f,g),g.crossVectors(v,f),v.normalize(),g.normalize();for(let I=0;I<=r;++I){const T=I/r*Math.PI*2,w=-t*Math.cos(T),C=t*Math.sin(T);h.x=p.x+(w*g.x+C*v.x),h.y=p.y+(w*g.y+C*v.y),h.z=p.z+(w*g.z+C*v.z),l.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),c.push(d.x,d.y,d.z),u.push(y/i),u.push(I/r)}}for(let y=1;y<=i;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),T=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;o.push(I,T,C),o.push(T,w,C)}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function x(y,_,I,T,w){const C=Math.cos(y),H=Math.sin(y),M=I/_*y,b=Math.cos(M);w.x=T*(2+b)*.5*C,w.y=T*(2+b)*H*.5,w.z=T*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Gd extends ct{constructor(e=new Am(new N(-1,-1,0),new N(-1,1,0),new N(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new N,l=new N,c=new J;let u=new N;const h=[],d=[],p=[],m=[];v(),this.setIndex(m),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function v(){for(let y=0;y<t;y++)f(y);f(s===!1?t:0),x(),g()}function f(y){u=e.getPointAt(y/t,u);const _=a.normals[y],I=a.binormals[y];for(let T=0;T<=r;T++){const w=T/r*Math.PI*2,C=Math.sin(w),H=-Math.cos(w);l.x=H*_.x+C*I.x,l.y=H*_.y+C*I.y,l.z=H*_.z+C*I.z,l.normalize(),d.push(l.x,l.y,l.z),o.x=u.x+i*l.x,o.y=u.y+i*l.y,o.z=u.z+i*l.z,h.push(o.x,o.y,o.z)}}function g(){for(let y=1;y<=t;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),T=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;m.push(I,T,C),m.push(T,w,C)}}function x(){for(let y=0;y<=t;y++)for(let _=0;_<=r;_++)c.x=y/t,c.y=_/r,p.push(c.x,c.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 Gd(new ah[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Pm extends ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new N,s=new N;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 c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,p=h.count;for(let m=d,v=d+p;m<v;m+=3)for(let f=0;f<3;f++){const g=o.getX(m+f),x=o.getX(m+(f+1)%3);r.fromBufferAttribute(a,g),s.fromBufferAttribute(a,x),Jy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;r.fromBufferAttribute(a,u),s.fromBufferAttribute(a,h),Jy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Jy(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var Ky=Object.freeze({__proto__:null,BoxGeometry:_n,CapsuleGeometry:Ud,CircleGeometry:Od,ConeGeometry:Fd,CylinderGeometry:pa,DodecahedronGeometry:Vd,EdgesGeometry:Rm,ExtrudeGeometry:xc,IcosahedronGeometry:Bd,LatheGeometry:yc,OctahedronGeometry:Ao,PlaneGeometry:da,PolyhedronGeometry:ys,RingGeometry:_c,ShapeGeometry:zd,SphereGeometry:No,TetrahedronGeometry:kd,TorusGeometry:Mc,TorusKnotGeometry:Hd,TubeGeometry:Gd,WireframeGeometry:Pm});class ph extends hi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new xe(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}}class Dm extends Pr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class El extends hi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xe(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 xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(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 dr,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 mh extends El{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 J(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(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 xe(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 xe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xe(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 fh extends hi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=fa,this.reflectivity=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.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 Um extends hi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(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 gh extends hi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(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 vh extends hi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=fa,this.reflectivity=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.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 Om extends hi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.flatShading=e.flatShading,this.fog=e.fog,this}}class yh extends Ni{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 Hs(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Zy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Qy(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Fm(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=n[o+l]}return r}function Vm(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=n[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=n[r++];while(s!==void 0)}function LI(n,e,t,i,r=30){const s=n.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),h=[],d=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*r;if(!(m<t||m>=i)){h.push(c.times[p]);for(let v=0;v<u;++v)d.push(c.values[p*u+v])}}h.length!==0&&(c.times=Hs(h,c.times.constructor),c.values=Hs(d,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function PI(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=n.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const m=o.times.length-1;let v;if(s<=o.times[0]){const g=u,x=h-u;v=o.values.slice(g,x)}else if(s>=o.times[m]){const g=m*h+u,x=g+h-u;v=o.values.slice(g,x)}else{const g=o.createInterpolant(),x=u,y=h-u;g.evaluate(s),v=g.resultBuffer.slice(x,y)}l==="quaternion"&&new Bi().fromArray(v).normalize().conjugate().toArray(v);const f=c.times.length;for(let g=0;g<f;++g){const x=g*p+d;if(l==="quaternion")Bi.multiplyQuaternionsFlat(c.values,x,v,0,c.values,x);else{const y=p-d*2;for(let _=0;_<y;++_)c.values[x+_]-=v[_]}}}return n.blendMode=mp,n}const DI={convertArray:Hs,isTypedArray:Zy,getKeyframeOrder:Qy,sortedArray:Fm,flattenJSON:Vm,subclip:LI,makeClipAdditive:PI};class to{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],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)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],s=t[i-1],s===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,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ex extends to{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:Ts,endingEnd:Ts}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case bs:s=e,o=2*t-i;break;case Yo:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case bs:a=e,l=2*i-t;break;case Yo:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=a*u}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),v=m*m,f=v*m,g=-d*f+2*d*v-d*m,x=(1+d)*f+(-1.5-2*d)*v+(-.5+d)*m+1,y=(-1-p)*f+(1.5+p)*v+.5*m,_=p*f-p*v;for(let I=0;I!==o;++I)s[I]=g*a[u+I]+x*a[c+I]+y*a[l+I]+_*a[h+I];return s}}class Bm extends to{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(i-t)/(r-t),h=1-u;for(let d=0;d!==o;++d)s[d]=a[c+d]*h+a[l+d]*u;return s}}class tx extends to{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Fr{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=Hs(t,this.TimeBufferType),this.values=Hs(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:Hs(e.times,Array),values:Hs(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new tx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Bm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ex(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case wa:t=this.InterpolantFactoryMethodDiscrete;break;case qo:t=this.InterpolantFactoryMethodLinear;break;case su:t=this.InterpolantFactoryMethodSmooth;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 console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return wa;case this.InterpolantFactoryMethodLinear:return qo;case this.InterpolantFactoryMethodSmooth:return su}}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 s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Zy(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===su,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(r)l=!0;else{const h=o*i,d=h-i,p=h+i;for(let m=0;m!==i;++m){const v=t[h+m];if(v!==t[d+m]||v!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*i,d=a*i;for(let p=0;p!==i;++p)t[d+p]=t[h+p]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++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}}Fr.prototype.TimeBufferType=Float32Array,Fr.prototype.ValueBufferType=Float32Array,Fr.prototype.DefaultInterpolation=qo;class as extends Fr{constructor(e,t,i){super(e,t,i)}}as.prototype.ValueTypeName="bool",as.prototype.ValueBufferType=Array,as.prototype.DefaultInterpolation=wa,as.prototype.InterpolantFactoryMethodLinear=void 0,as.prototype.InterpolantFactoryMethodSmooth=void 0;class xh extends Fr{}xh.prototype.ValueTypeName="color";class io extends Fr{}io.prototype.ValueTypeName="number";class ix extends to{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let c=e*o;for(let u=c+o;c!==u;c+=4)Bi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class ro extends Fr{InterpolantFactoryMethodLinear(e){return new ix(this.times,this.values,this.getValueSize(),e)}}ro.prototype.ValueTypeName="quaternion",ro.prototype.InterpolantFactoryMethodSmooth=void 0;class Gs extends Fr{constructor(e,t,i){super(e,t,i)}}Gs.prototype.ValueTypeName="string",Gs.prototype.ValueBufferType=Array,Gs.prototype.DefaultInterpolation=wa,Gs.prototype.InterpolantFactoryMethodLinear=void 0,Gs.prototype.InterpolantFactoryMethodSmooth=void 0;class no extends Fr{}no.prototype.ValueTypeName="vector";class so{constructor(e="",t=-1,i=[],r=au){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=yr(),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(OI(i[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Fr.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const u=Qy(l);l=Fm(l,1,u),c=Fm(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new io(".morphTargetInfluences["+t[o].name+"]",l,c).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={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(s);if(u&&u.length>1){const h=u[1];let d=r[h];d||(r[h]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,h,d,p,m){if(d.length!==0){const v=[],f=[];Vm(d,v,f,p),v.length!==0&&m.push(new u(h,v,f))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const h=c[u].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const d={};let p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let m=0;m<h[p].morphTargets.length;m++)d[h[p].morphTargets[m]]=-1;for(const m in d){const v=[],f=[];for(let g=0;g!==h[p].morphTargets.length;++g){const x=h[p];v.push(x.time),f.push(x.morphTarget===m?1:0)}r.push(new io(".morphTargetInfluence["+m+"]",v,f))}l=d.length*a}else{const d=".bones["+t[u].name+"]";i(no,d+".position",h,"pos",r),i(ro,d+".quaternion",h,"rot",r),i(no,d+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.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 t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function UI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return io;case"vector":case"vector2":case"vector3":case"vector4":return no;case"color":return xh;case"quaternion":return ro;case"bool":case"boolean":return as;case"string":return Gs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function OI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=UI(n.type);if(n.times===void 0){const t=[],i=[];Vm(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const un={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class _h{constructor(e,t,i){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){o++,s===!1&&r.onStart!==void 0&&r.onStart(u,a,o),s=!0},this.itemEnd=function(u){a++,r.onProgress!==void 0&&r.onProgress(u,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const p=c[h],m=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const zm=new _h;class Gi{constructor(e){this.manager=e!==void 0?e:zm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}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}}Gi.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ln={};class FI extends Error{constructor(e,t){super(e),this.response=t}}class Kr extends Gi{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=un.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ln[e]!==void 0){Ln[e].push({onLoad:t,onProgress:i,onError:r});return}Ln[e]=[],Ln[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Ln[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let v=0;const f=new ReadableStream({start(g){x();function x(){h.read().then(({done:y,value:_})=>{if(y)g.close();else{v+=_.byteLength;const I=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let T=0,w=u.length;T<w;T++){const C=u[T];C.onProgress&&C.onProgress(I)}g.enqueue(_),x()}},y=>{g.error(y)})}}});return new Response(f)}else throw new FI(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{un.add(e,c);const u=Ln[e];delete Ln[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=Ln[e];if(u===void 0)throw this.manager.itemError(e),c;delete Ln[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.onError(c)}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}}class VI extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=so.parse(e[i]);t.push(r)}return t}}class BI extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=[],o=new xl,l=new Kr(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(h){l.load(e[h],function(d){const p=s.parse(d,!0);a[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(o.minFilter=Lt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else l.load(e,function(h){const d=s.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<d.mipmapCount;v++)a[m].mipmaps.push(d.mipmaps[m*d.mipmapCount+v]),a[m].format=d.format,a[m].width=d.width,a[m].height=d.height}o.image=a}else o.image.width=d.width,o.image.height=d.height,o.mipmaps=d.mipmaps;d.mipmapCount===1&&(o.minFilter=Lt),o.format=d.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}class Al extends Gi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=un.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=el("img");function l(){u(),un.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class zI extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=new Is;s.colorSpace=Fi;const a=new Al(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(u){s.images[c]=u,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class rx extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Ur,o=new Kr(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:gr,a.wrapT=c.wrapT!==void 0?c.wrapT:gr,a.magFilter=c.magFilter!==void 0?c.magFilter:Lt,a.minFilter=c.minFilter!==void 0?c.minFilter:Lt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Xi),c.mipmapCount===1&&(a.minFilter=Lt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,r),a}}class nx extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=new Wt,a=new Al(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class os extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}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,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Mh extends os{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const km=new Re,sx=new N,ax=new N;class Hm{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new Re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ga,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;sx.setFromMatrixPosition(e.matrixWorld),t.position.copy(sx),ax.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ax),t.updateMatrixWorld(),km.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(km),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(km)}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.mapSize.copy(e.mapSize),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 kI extends Hm{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Aa*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Nl extends os{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new kI}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}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.shadow=e.shadow.clone(),this}}const ox=new Re,Cl=new N,Gm=new N;class HI extends Hm{constructor(){super(new di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new N(1,0,0),new N(-1,0,0),new N(0,0,1),new N(0,0,-1),new N(0,1,0),new N(0,-1,0)],this._cubeUps=[new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,0,1),new N(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Cl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Cl),Gm.copy(i.position),Gm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Gm),i.updateMatrixWorld(),r.makeTranslation(-Cl.x,-Cl.y,-Cl.z),ox.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ox)}}class Th extends os{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 HI}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}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}}class GI extends Hm{constructor(){super(new Ds(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class bh extends os{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new GI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Sh extends os{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Wm extends os{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 lx{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new N)}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,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(i*s)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=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*s),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*i*s),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,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}class jm extends os{constructor(e=new lx,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Tc extends Gi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}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 xe().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.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 s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=i(a.value);break;case"c":r.uniforms[s].value=new xe().setHex(a.value);break;case"v2":r.uniforms[s].value=new J().fromArray(a.value);break;case"v3":r.uniforms[s].value=new N().fromArray(a.value);break;case"v4":r.uniforms[s].value=new st().fromArray(a.value);break;case"m3":r.uniforms[s].value=new Ke().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Re().fromArray(a.value);break;default:r.uniforms[s].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 s in e.extensions)r.extensions[s]=e.extensions[s];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 s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new J().fromArray(s)}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 J().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 Tc.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ph,SpriteMaterial:hl,RawShaderMaterial:Dm,ShaderMaterial:Pr,PointsMaterial:Qa,MeshPhysicalMaterial:mh,MeshStandardMaterial:El,MeshPhongMaterial:fh,MeshToonMaterial:Um,MeshNormalMaterial:gh,MeshLambertMaterial:vh,MeshDepthMaterial:ku,MeshDistanceMaterial:Zp,MeshBasicMaterial:$r,MeshMatcapMaterial:Om,LineDashedMaterial:yh,LineBasicMaterial:Ni,Material:hi};return new t[e]}}class wh{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}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 Xm extends ct{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 cx extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(d,p){if(t[p]!==void 0)return t[p];const m=d.interleavedBuffers[p],v=s(d,m.buffer),f=Na(m.type,v),g=new qa(f,m.stride);return g.uuid=m.uuid,t[p]=g,g}function s(d,p){if(i[p]!==void 0)return i[p];const m=d.arrayBuffers[p],v=new Uint32Array(m).buffer;return i[p]=v,v}const a=e.isInstancedBufferGeometry?new Xm:new ct,o=e.data.index;if(o!==void 0){const d=Na(o.type,o.array);a.setIndex(new wt(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let m;if(p.isInterleavedBufferAttribute){const v=r(e.data,p.data);m=new Fn(v,p.itemSize,p.offset,p.normalized)}else{const v=Na(p.type,p.array),f=p.isInstancedBufferAttribute?Rn:wt;m=new f(v,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),a.setAttribute(d,m)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],m=[];for(let v=0,f=p.length;v<f;v++){const g=p[v];let x;if(g.isInterleavedBufferAttribute){const y=r(e.data,g.data);x=new Fn(y,g.itemSize,g.offset,g.normalized)}else{const y=Na(g.type,g.array);x=new wt(y,g.itemSize,g.normalized)}g.name!==void 0&&(x.name=g.name),m.push(x)}a.morphAttributes[d]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const m=u[d];a.addGroup(m.start,m.count,m.materialIndex)}const h=e.data.boundingSphere;if(h!==void 0){const d=new N;h.center!==void 0&&d.fromArray(h.center),a.boundingSphere=new Ai(d,h.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class ux extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=this.path===""?wh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new Kr(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?wh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),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),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),this.bindLightTargets(c),t!==void 0){let h=!1;for(const d in a)if(a[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new ss().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new vc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new cx;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in Ky?o=Ky[l.type].fromJSON(l,t):console.warn(`THREE.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 s=new Tc;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=s.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],s=so.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function a(l){return i.manager.itemStart(l),s.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 c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return a(u)}else return l.data?{data:Na(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new _h(t);s=new Al(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],d=h.url;if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m],g=o(f);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Ur(g.data,g.width,g.height)))}r[h.uuid]=new Kn(p)}else{const p=o(h.url);r[h.uuid]=new Kn(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(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:Na(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Al(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=await s(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Ur(m.data,m.width,m.height)))}i[l.uuid]=new Kn(u)}else{const u=await s(l.url);i[l.uuid]=new Kn(u)}}}return i}parseTextures(e,t){function i(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let u;Array.isArray(c)?(u=new Is,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Ur:u=new Wt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=o.uuid,o.name!==void 0&&(u.name=o.name),o.mapping!==void 0&&(u.mapping=i(o.mapping,WI)),o.channel!==void 0&&(u.channel=o.channel),o.offset!==void 0&&u.offset.fromArray(o.offset),o.repeat!==void 0&&u.repeat.fromArray(o.repeat),o.center!==void 0&&u.center.fromArray(o.center),o.rotation!==void 0&&(u.rotation=o.rotation),o.wrap!==void 0&&(u.wrapS=i(o.wrap[0],hx),u.wrapT=i(o.wrap[1],hx)),o.format!==void 0&&(u.format=o.format),o.internalFormat!==void 0&&(u.internalFormat=o.internalFormat),o.type!==void 0&&(u.type=o.type),o.colorSpace!==void 0&&(u.colorSpace=o.colorSpace),o.minFilter!==void 0&&(u.minFilter=i(o.minFilter,dx)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,dx)),o.anisotropy!==void 0&&(u.anisotropy=o.anisotropy),o.flipY!==void 0&&(u.flipY=o.flipY),o.generateMipmaps!==void 0&&(u.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(u.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(u.compareFunction=o.compareFunction),o.userData!==void 0&&(u.userData=o.userData),r[o.uuid]=u}return r}parseObject(e,t,i,r,s){let a;function o(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m];i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),p.push(i[f])}return p}return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),i[d]}}function c(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":a=new Hu,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new xe(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new im(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Dd(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 di(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 Ds(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 Sh(e.color,e.intensity);break;case"DirectionalLight":a=new bh(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Th(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Wm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Nl(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new Mh(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new jm().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),h=l(e.material),a=new lm(u,h),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":u=o(e.geometry),h=l(e.material),a=new Ft(u,h);break;case"InstancedMesh":u=o(e.geometry),h=l(e.material);const d=e.count,p=e.instanceMatrix,m=e.instanceColor;a=new cm(u,h,d),a.instanceMatrix=new Rn(new Float32Array(p.array),16),m!==void 0&&(a.instanceColor=new Rn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),h=l(e.material),a=new pm(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),a.geometry=u,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(v=>{const f=new zi;f.min.fromArray(v.boxMin),f.max.fromArray(v.boxMax);const g=new Ai;return g.radius=v.sphereRadius,g.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:f,sphereInitialized:v.sphereInitialized,sphere:g}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new sm;break;case"Line":a=new In(o(e.geometry),l(e.material));break;case"LineLoop":a=new fm(o(e.geometry),l(e.material));break;case"LineSegments":a=new Jr(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new vm(o(e.geometry),l(e.material));break;case"Sprite":a=new nm(l(e.material));break;case"Group":a=new Vs;break;case"Bone":a=new Yu;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.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.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)a.add(this.parseObject(d[p],t,i,r,s))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const m=d[p];a.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const m=d[p],v=a.getObjectByProperty("uuid",m.object);v!==void 0&&a.addLevel(v,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?console.warn("THREE.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 WI={UVMapping:Lc,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,EquirectangularReflectionMapping:Hn,EquirectangularRefractionMapping:Gn,CubeUVReflectionMapping:Wn},hx={RepeatWrapping:jn,ClampToEdgeWrapping:gr,MirroredRepeatWrapping:ga},dx={NearestFilter:$t,NearestMipmapNearestFilter:Pc,NearestMipmapLinearFilter:bn,LinearFilter:Lt,LinearMipmapNearestFilter:Xn,LinearMipmapLinearFilter:Xi};class px extends Gi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=un.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return un.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),un.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});un.add(e,l),s.manager.itemStart(e)}}let Eh;class Ah{static getContext(){return Eh===void 0&&(Eh=new(window.AudioContext||window.webkitAudioContext)),Eh}static setContext(e){Eh=e}}class mx extends Gi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Ah.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},i,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const fx=new Re,gx=new Re,Ws=new Re;class qm{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new di,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new di,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,Ws.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,s=t.near*Math.tan(Es*t.fov*.5)/t.zoom;let a,o;gx.elements[12]=-i,fx.elements[12]=i,a=-s*t.aspect+r,o=s*t.aspect+r,Ws.elements[0]=2*t.near/(o-a),Ws.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Ws),a=-s*t.aspect-r,o=s*t.aspect-r,Ws.elements[0]=2*t.near/(o-a),Ws.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Ws)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(gx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(fx)}}class Ym{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=vx(),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=vx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function vx(){return performance.now()}const hn=new N,yx=new Bi,jI=new N,js=new N;let xx=class extends _t{constructor(){super(),this.type="AudioListener",this.context=Ah.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Ym}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(n){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=n,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(n){return this.gain.gain.setTargetAtTime(n,this.context.currentTime,.01),this}updateMatrixWorld(n){super.updateMatrixWorld(n);const e=this.context.listener,t=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(hn,yx,jI),!(!Number.isFinite(hn.x)||!Number.isFinite(hn.y)||!Number.isFinite(hn.z)))if(js.set(0,0,-1).applyQuaternion(yx),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(hn.x,i),e.positionY.linearRampToValueAtTime(hn.y,i),e.positionZ.linearRampToValueAtTime(hn.z,i),e.forwardX.linearRampToValueAtTime(js.x,i),e.forwardY.linearRampToValueAtTime(js.y,i),e.forwardZ.linearRampToValueAtTime(js.z,i),e.upX.linearRampToValueAtTime(t.x,i),e.upY.linearRampToValueAtTime(t.y,i),e.upZ.linearRampToValueAtTime(t.z,i)}else e.setPosition(hn.x,hn.y,hn.z),e.setOrientation(js.x,js.y,js.z,t.x,t.y,t.z)}};class $m 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){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;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){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.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){console.warn("THREE.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}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.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}}const Xs=new N,_x=new Bi,XI=new N,qs=new N;class Mx extends $m{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}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(Xs,_x,XI),qs.set(0,0,1).applyQuaternion(_x);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Xs.x,i),t.positionY.linearRampToValueAtTime(Xs.y,i),t.positionZ.linearRampToValueAtTime(Xs.z,i),t.orientationX.linearRampToValueAtTime(qs.x,i),t.orientationY.linearRampToValueAtTime(qs.y,i),t.orientationZ.linearRampToValueAtTime(qs.z,i)}else t.setPosition(Xs.x,Xs.y,Xs.z),t.setOrientation(qs.x,qs.y,qs.z)}}class qI{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 Tx{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,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,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[s+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,s,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,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++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 s=i,a=r;s!==a;++s)t[s]=t[r+s%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,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){Bi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;Bi.multiplyQuaternionsFlat(e,a,e,t,e,i),Bi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const Jm="\\[\\]\\.:\\/",YI=new RegExp("["+Jm+"]","g"),Km="[^"+Jm+"]",$I="[^"+Jm.replace("\\.","")+"]",JI=/((?:WC+[\/:])*)/.source.replace("WC",Km),KI=/(WCOD+)?/.source.replace("WCOD",$I),ZI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Km),QI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Km),e2=new RegExp("^"+JI+KI+ZI+QI+"$"),t2=["material","materials","bones","map"];class i2{constructor(e,t,i){const r=i||bt.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_,s=i.length;r!==s;++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 bt{constructor(e,t,i){this.path=t,this.parsedPath=i||bt.parseTrackName(t),this.node=bt.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 bt.Composite(e,t,i):new bt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(YI,"")}static parseTrackName(e){const t=e2.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 s=i.nodeName.substring(r+1);t2.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===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(s,a){for(let o=0;o<s.length;o++){const l=s[o];if(!a&&(l.name===t||l.uuid===t)||a&&l.userData&&l.userData.name===t)return l;const c=i(l.children,a);if(c)return c}return null},r=i(e.children);if(r)return r;{const s=i(e.children,!0);if(s)return s}}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,s=i.length;r!==s;++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,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++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 s=t.propertyIndex;if(e||(e=bt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}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}}bt.Composite=i2,bt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},bt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},bt.prototype.GetterByBindingType=[bt.prototype._getValue_direct,bt.prototype._getValue_array,bt.prototype._getValue_arrayElement,bt.prototype._getValue_toArray],bt.prototype.SetterByBindingTypeAndVersioning=[[bt.prototype._setValue_direct,bt.prototype._setValue_direct_setNeedsUpdate,bt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_array,bt.prototype._setValue_array_setNeedsUpdate,bt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_arrayElement,bt.prototype._setValue_arrayElement_setNeedsUpdate,bt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[bt.prototype._setValue_fromArray,bt.prototype._setValue_fromArray_setNeedsUpdate,bt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class r2{constructor(){this.isAnimationObjectGroup=!0,this.uuid=yr(),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,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(d);for(let v=0,f=a;v!==f;++v)s[v].push(new bt(d,i[v],r[v]))}else if(m<c){o=e[m];const v=--c,f=e[v];t[f.uuid]=m,e[m]=f,t[p]=v,e[v]=d;for(let g=0,x=a;g!==x;++g){const y=s[g],_=y[v];let I=y[m];y[m]=_,I===void 0&&(I=new bt(d,i[g],r[g])),y[v]=I}}else e[m]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=r;p!==m;++p){const v=i[p],f=v[h],g=v[u];v[u]=f,v[h]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const d=--s,p=e[d],m=--a,v=e[m];t[p.uuid]=h,e[h]=p,t[v.uuid]=d,e[d]=v,e.pop();for(let f=0,g=r;f!==g;++f){const x=i[f],y=x[d],_=x[m];x[h]=y,x[d]=_,x.pop()}}else{const d=--a,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,v=r;m!==v;++m){const f=i[m];f[h]=f[d],f.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);r=s.length,i[e]=r,a.push(e),o.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){const m=l[d];h[d]=new bt(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),r[i]=r[o],r.pop()}}}class bx{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:Ts,endingEnd:Ts};for(let c=0;c!==a;++c){const u=s[c].createInterpolant(null);o[c]=u,u.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=pp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){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,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[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 s=this._startTime;if(s!==null){const l=(e-s)*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,c=this._propertyBindings;switch(this.blendMode){case mp:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case au:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].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,s=this._loopCount;const a=i===W0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===dp){s===-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(s===-1&&(e>=0?(s=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,s+=Math.abs(o);const l=this.repetitions-s;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 c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=bs,r.endingEnd=bs):(e?r.endingStart=this.zeroSlopeAtStart?bs:Ts:r.endingStart=Yo,t?r.endingEnd=this.zeroSlopeAtEnd?bs:Ts:r.endingEnd=Yo)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}}const n2=new Float32Array(1);class Sx extends vr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const d=r[h],p=d.name;let m=u[p];if(m!==void 0)++m.referenceCount,a[h]=m;else{if(m=a[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[h].binding.parsedPath;m=new Tx(bt.create(i,p,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[h]=m}o[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.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 s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;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,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[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 s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Bm(new Float32Array(2),new Float32Array(2),1,n2),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?so.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(i===void 0&&(a!==null?i=a.blendMode:i=au),l!==void 0){const h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const u=new bx(this,a,t,i);return this._bindAction(u,c),this._addInactiveAction(u,o,s),u}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?so.findByName(i,e):e,a=s?s.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,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].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,s=r[i];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}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,s=r[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}let wx=class QS{constructor(e){this.value=e}clone(){return new QS(this.value.clone===void 0?this.value:this.value.clone())}},s2=0;class a2 extends vr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:s2++}),this.name="",this.usage=Ea,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(){return this.dispatchEvent({type:"dispose"}),this}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 s=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class Zm extends qa{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 o2{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,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 Re;class Ax{constructor(e,t,i=0,r=1/0){this.ray=new Cs(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new sl,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):console.error("THREE.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 Qm(e,this,i,t),i.sort(Nx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Qm(e[r],this,i,t);return i.sort(Nx),i}}function Nx(n,e){return n.distance-e.distance}function Qm(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)Qm(s[a],e,t,!0)}}class Cx{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}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=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),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(Jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class l2{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}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)}}class d0{constructor(e,t,i,r){d0.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 s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}}const Rx=new J;class c2{constructor(e=new J(1/0,1/0),t=new J(-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 N,Nh=new N;class Lx{constructor(e=new N,t=new N){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),Nh.subVectors(this.end,this.start);const i=Nh.dot(Nh);let r=Nh.dot(Ix)/i;return t&&(r=Jt(r,0,1)),r}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Px=new N;class u2 extends _t{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new ct,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 c=a/l*Math.PI*2,u=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));const s=new Ni({fog:!1,toneMapped:!1});this.cone=new Jr(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Px.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Px),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const ls=new N,Ch=new Re,ef=new Re;class h2 extends Jr{constructor(e){const t=Dx(e),i=new ct,r=[],s=[],a=new xe(0,0,1),o=new xe(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));const l=new Ni({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");ef.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(Ch.multiplyMatrices(ef,o.matrixWorld),ls.setFromMatrixPosition(Ch),r.setXYZ(a,ls.x,ls.y,ls.z),Ch.multiplyMatrices(ef,o.parent.matrixWorld),ls.setFromMatrixPosition(Ch),r.setXYZ(a+1,ls.x,ls.y,ls.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Dx(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Dx(n.children[t]));return e}class d2 extends Ft{constructor(e,t,i){const r=new No(t,4,2),s=new $r({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),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 p2=new N,Ux=new xe,Ox=new xe;class m2 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 Ao(t);r.rotateY(Math.PI*.5),this.material=new $r({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new wt(a,3)),this.add(new Ft(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");Ux.copy(this.light.color),Ox.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Ux:Ox;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(p2.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Fx=class extends Jr{constructor(n=10,e=10,t=4473924,i=8947848){t=new xe(t),i=new xe(i);const r=e/2,s=n/e,a=n/2,o=[],l=[];for(let h=0,d=0,p=-a;h<=e;h++,p+=s){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=h===r?t:i;m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class f2 extends Jr{constructor(e=10,t=16,i=8,r=64,s=4473924,a=8947848){s=new xe(s),a=new xe(a);const o=[],l=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,m=Math.cos(d)*e;o.push(0,0,0),o.push(p,0,m);const v=h&1?s:a;l.push(v.r,v.g,v.b),l.push(v.r,v.g,v.b)}for(let h=0;h<i;h++){const d=h&1?s:a,p=e-e/i*h;for(let m=0;m<r;m++){let v=m/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p;o.push(f,0,g),l.push(d.r,d.g,d.b),v=(m+1)/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p,o.push(f,0,g),l.push(d.r,d.g,d.b)}}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Vx=new N,Rh=new N,Bx=new N;class zx 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 ct;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Ni({fog:!1,toneMapped:!1});this.lightPlane=new In(r,s),this.add(this.lightPlane),r=new ct,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new In(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Vx.setFromMatrixPosition(this.light.matrixWorld),Rh.setFromMatrixPosition(this.light.target.matrixWorld),Bx.subVectors(Rh,Vx),this.lightPlane.lookAt(Rh),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(Rh),this.targetLine.scale.z=Bx.length()}}const Ih=new N,Kt=new cl;class kx extends Jr{constructor(e){const t=new ct,i=new Ni({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],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,v){l(m),l(v)}function l(m){r.push(0,0,0),s.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,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 c=new xe(16755200),u=new xe(16711680),h=new xe(43775),d=new xe(16777215),p=new xe(3355443);this.setColors(c,u,h,d,p)}setColors(e,t,i,r,s){const a=this.geometry.getAttribute("color");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,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ti("c",t,e,Kt,0,0,-1),ti("t",t,e,Kt,0,0,1),ti("n1",t,e,Kt,-i,-r,-1),ti("n2",t,e,Kt,i,-r,-1),ti("n3",t,e,Kt,-i,r,-1),ti("n4",t,e,Kt,i,r,-1),ti("f1",t,e,Kt,-i,-r,1),ti("f2",t,e,Kt,i,-r,1),ti("f3",t,e,Kt,-i,r,1),ti("f4",t,e,Kt,i,r,1),ti("u1",t,e,Kt,i*.7,r*1.1,-1),ti("u2",t,e,Kt,-i*.7,r*1.1,-1),ti("u3",t,e,Kt,0,r*2,-1),ti("cf1",t,e,Kt,-i,0,1),ti("cf2",t,e,Kt,i,0,1),ti("cf3",t,e,Kt,0,-r,1),ti("cf4",t,e,Kt,0,r,1),ti("cn1",t,e,Kt,-i,0,-1),ti("cn2",t,e,Kt,i,0,-1),ti("cn3",t,e,Kt,0,-r,-1),ti("cn4",t,e,Kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ti(n,e,t,i,r,s,a){Ih.set(r,s,a).unproject(i);const o=e[n];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,u=o.length;c<u;c++)l.setXYZ(o[c],Ih.x,Ih.y,Ih.z)}}const Lh=new zi;class Hx extends Jr{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),s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new wt(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Lh.setFromObject(this.object),Lh.isEmpty())return;const t=Lh.min,i=Lh.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.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 Gx extends Jr{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],s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new De(r,3)),super(s,new Ni({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 g2 extends In{constructor(e,t=1,i=16776960){const r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new ct;a.setAttribute("position",new De(s,3)),a.computeBoundingSphere(),super(a,new Ni({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 ct;l.setAttribute("position",new De(o,3)),l.computeBoundingSphere(),this.add(new Ft(l,new $r({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 N;let Ph,tf;class v2 extends _t{constructor(e=new N(0,0,1),t=new N(0,0,0),i=1,r=16776960,s=i*.2,a=s*.2){super(),this.type="ArrowHelper",Ph===void 0&&(Ph=new ct,Ph.setAttribute("position",new De([0,0,0,0,1,0],3)),tf=new pa(0,.5,1,5,1),tf.translate(0,-.5,0)),this.position.copy(t),this.line=new In(Ph,new Ni({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ft(tf,new $r({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,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 Jr{constructor(n=1){const e=[0,0,0,n,0,0,0,0,0,0,n,0,0,0,0,0,0,n],t=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new ct;i.setAttribute("position",new De(e,3)),i.setAttribute("color",new De(t,3));const r=new Ni({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(n,e,t){const i=new xe,r=this.geometry.attributes.color.array;return i.set(n),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 xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Tl,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,s,a){return this.currentPath.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let y=0,_=g.length;y<_;y++){const I=g[y],T=new ss;T.curves=I.curves,x.push(T)}return x}function i(g,x){const y=x.length;let _=!1;for(let I=y-1,T=0;T<y;I=T++){let w=x[I],C=x[T],H=C.x-w.x,M=C.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=x[T],H=-H,C=x[I],M=-M),g.y<w.y||g.y>C.y)continue;if(g.y===w.y){if(g.x===w.x)return!0}else{const b=M*(g.x-w.x)-H*(g.y-w.y);if(b===0)return!0;if(b<0)continue;_=!_}}else{if(g.y!==w.y)continue;if(C.x<=g.x&&g.x<=w.x||w.x<=g.x&&g.x<=C.x)return!0}}return _}const r=nn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new ss,l.curves=o.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],m=0,v;d[m]=void 0,p[m]=[];for(let g=0,x=s.length;g<x;g++)o=s[g],v=o.getPoints(),a=r(v),a=e?!a:a,a?(!u&&d[m]&&m++,d[m]={s:new ss,p:v},d[m].s.curves=o.curves,u&&m++,p[m]=[]):p[m].push({h:o,p:v[0]});if(!d[0])return t(s);if(d.length>1){let g=!1,x=0;for(let y=0,_=d.length;y<_;y++)h[y]=[];for(let y=0,_=d.length;y<_;y++){const I=p[y];for(let T=0;T<I.length;T++){const w=I[T];let C=!0;for(let H=0;H<d.length;H++)i(w.p,d[H].p)&&(y!==H&&x++,C?(C=!1,h[H].push(w)):g=!0);C&&h[y].push(w)}}x>0&&g===!1&&(p=h)}let f;for(let g=0,x=d.length;g<x;g++){l=d[g].s,c.push(l),f=p[g];for(let y=0,_=f.length;y<_;y++)l.holes.push(f[y].h)}return c}}class qx extends vr{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(){}disconnect(){}dispose(){}update(){}}class y2 extends Ir{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const x2=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class Yx{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=x2,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){const t=e.material;for(const i in t)if(t[i]&&t[i].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}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){const{object:t,material:i}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;const s=r.material;for(const a in s){const o=s[a],l=i[a];if(o.equals!==void 0){if(o.equals(l)===!1)return o.copy(l),!1}else if(l.isTexture===!0){if(o.id!==l.id||o.version!==l.version)return o.id=l.id,o.version=l.version,!1}else if(o!==l)return s[a]=l,!1}if(r.morphTargetInfluences){let a=!1;for(let o=0;o<r.morphTargetInfluences.length;o++)r.morphTargetInfluences[o]!==t.morphTargetInfluences[o]&&(a=!0);if(a)return!0}return r.center&&r.center.equals(t.center)===!1?(r.center.copy(t.center),!0):(e.bundle!==null&&(r.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;const r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||s?!1:this.equals(e)!==!0}}function Rl(n,e=0){let t=3735928559^e,i=1103547991^e;if(n instanceof Array)for(let r=0,s;r<n.length;r++)s=n[r],t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);else for(let r=0,s;r<n.length;r++)s=n.charCodeAt(r),t=Math.imul(t^s,2654435761),i=Math.imul(i^s,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 $x=n=>Rl(n),Jx=n=>Rl(n),rf=(...n)=>Rl(n);function nf(n,e=!1){const t=[];n.isNode===!0&&(t.push(n.id),n=n.getSelf());for(const{property:i,childNode:r}of Il(n))t.push(t,Rl(i.slice(0,-4)),r.getCacheKey(e));return Rl(t)}function*Il(n,e=!1){for(const t in n){if(t.startsWith("_")===!0)continue;const i=n[t];if(Array.isArray(i)===!0)for(let r=0;r<i.length;r++){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}else if(i&&i.isNode===!0)yield{property:t,childNode:i};else if(typeof i=="object")for(const r in i){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}}}function Pn(n){if(n==null)return null;const e=typeof n;return n.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":n.isVector2===!0?"vec2":n.isVector3===!0?"vec3":n.isVector4===!0?"vec4":n.isMatrix3===!0?"mat3":n.isMatrix4===!0?"mat4":n.isColor===!0?"color":n instanceof ArrayBuffer?"ArrayBuffer":null}function sf(n,...e){const t=n?n.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]])),n==="color"?new xe(...e):t==="vec2"?new J(...e):t==="vec3"?new N(...e):t==="vec4"?new st(...e):t==="mat3"?new Ke(...e):t==="mat4"?new Re(...e):n==="bool"?e[0]||!1:n==="float"||n==="int"||n==="uint"?e[0]||0:n==="string"?e[0]||"":n==="ArrayBuffer"?of(e[0]):null}function af(n){let e="";const t=new Uint8Array(n);for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}function of(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0)).buffer}var _2=Object.freeze({__proto__:null,arrayBufferToBase64:af,base64ToArrayBuffer:of,getCacheKey:nf,getNodeChildren:Il,getValueFromType:sf,getValueType:Pn,hash:rf,hashArray:Jx,hashString:$x});const lf={VERTEX:"vertex",FRAGMENT:"fragment"},je={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},M2={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},cf=["fragment","vertex"],uf=["setup","analyze","generate"],hf=[...cf,"compute"],ao=["x","y","z","w"];let T2=0;class qe extends vr{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=je.NONE,this.updateBeforeType=je.NONE,this.updateAfterType=je.NONE,this.uuid=uu.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:T2++})}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.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,je.FRAME)}onRenderUpdate(e){return this.onUpdate(e,je.RENDER)}onObjectUpdate(e){return this.onUpdate(e,je.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Il(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=nf(this,e),this._cacheKeyVersion=this.version),this._cacheKey}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)}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}setup(e){const t=e.getNodeProperties(this);let i=0;for(const r of this.getChildren())t["node"+i++]=r;return null}analyze(e){if(e.increaseUsage(this)===1){const t=e.getNodeProperties(this);for(const i of Object.values(t))i&&i.isNode===!0&&i.build(e)}}generate(e,t){const{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const i=this.getShared(e);if(this!==i)return i.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){const o=e.stack.nodes.length;a.initialized=!0,a.outputNode=this.setup(e),a.outputNode!==null&&e.stack.nodes.length;for(const l of Object.values(a))l&&l.isNode===!0&&l.build(e)}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const a=this.getNodeType(e),o=e.getDataFromNode(this);r=o.snippet,r===void 0?(r=this.generate(e)||"",o.snippet=r):o.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,a,t)}else r=this.generate(e,t)||"";return e.removeChain(this),r}getSerializeChildren(){return Il(this)}serialize(e){const t=this.getSerializeChildren(),i={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=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 s of e.inputNodes[i])r.push(t[s]);this[i]=r}else if(typeof e.inputNodes[i]=="object"){const r={};for(const s in e.inputNodes[i]){const a=e.inputNodes[i][s];r[s]=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 s=e.nodes[t];s===void 0&&(s={uuid:t,type:i,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}if(r){const o=a(e.textures),l=a(e.images),c=a(e.nodes);o.length>0&&(s.textures=o),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}class cs extends qe{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)}generate(e){const t=this.node.build(e),i=this.indexNode.build(e,"uint");return`${t}[ ${i} ]`}}class df extends qe{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),s=i.build(e,r);return e.format(s,r,t)}}class pt extends qe{static get type(){return"TempNode"}constructor(e){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 s=super.build(e,i),a=e.getVarFromNode(this,null,i),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${s}`,this),r.snippet=s,r.propertyName=o,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class Kx extends pt{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=this.nodes,s=e.getComponentType(i),a=[];for(const l of r){let c=l.build(e);const u=e.getComponentType(l.getNodeType(e));u!==s&&(c=e.format(c,u,s)),a.push(c)}const o=`${e.getType(i)}( ${a.join(", ")} )`;return e.format(o,i,t)}}const b2=ao.join("");class Dh extends qe{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(ao.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))}generate(e,t){const i=this.node,r=e.getTypeLength(i.getNodeType(e));let s=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===b2.slice(0,this.components.length)?s=e.format(o,a,t):s=e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else s=i.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Zx extends pt{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,s=this.getNodeType(e),a=e.getTypeFromLength(i.length,r.getNodeType(e)),o=r.build(e,a),l=t.build(e,s),c=e.getTypeLength(s),u=[];for(let h=0;h<c;h++){const d=ao[h];d===i[0]?(u.push(o),h+=i.length-1):u.push(l+"."+d)}return`${e.getType(s)}( ${u.join(", ")} )`}}class S2 extends pt{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),s=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+s,this);const l=e.getTypeLength(r),c=[];let u=0;for(let h=0;h<l;h++){const d=ao[h];d===t[u]?(c.push("1.0 - "+(o+"."+d)),u++):c.push(o+"."+d)}return`${e.getType(r)}( ${c.join(", ")} )`}}class pf extends qe{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?Pn(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=Pn(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=af(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?sf(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}class Vr extends pf{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.format(this.generateConst(e),i,t)}}let oo=null;const lo=new Map;function te(n,e){if(lo.has(n)){console.warn(`Redefinition of method chaining ${n}`);return}if(typeof e!="function")throw new Error(`Node element ${n} is not a function`);lo.set(n,e)}const Qx=n=>n.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),e_=n=>Qx(n).split("").sort().join(""),t_={setup(n,e){const t=e.shift();return n(Dl(t),...e)},get(n,e,t){if(typeof e=="string"&&n[e]===void 0){if(n.isStackNode!==!0&&e==="assign")return(...i)=>(oo.assign(t,...i),t);if(lo.has(e)){const i=lo.get(e);return n.isStackNode?(...r)=>t.add(i(...r)):(...r)=>i(t,...r)}else{if(e==="self")return n;if(e.endsWith("Assign")&&lo.has(e.slice(0,e.length-6))){const i=lo.get(e.slice(0,e.length-6));return n.isStackNode?(...r)=>t.assign(r[0],i(...r)):(...r)=>t.assign(i(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Qx(e),G(new Dh(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=e_(e.slice(3).toLowerCase()),i=>G(new Zx(n,e,i));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=e_(e.slice(4).toLowerCase()),()=>G(new S2(G(n),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),G(new Dh(n,e));if(/^\d+$/.test(e)===!0)return G(new cs(t,new Vr(Number(e),"uint")))}}}return Reflect.get(n,e,t)},set(n,e,t,i){return typeof e=="string"&&n[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(i[e].assign(t),!0):Reflect.set(n,e,t,i)}},mf=new WeakMap,i_=new WeakMap,w2=function(n,e=null){const t=Pn(n);if(t==="node"){let i=mf.get(n);return i===void 0&&(i=new Proxy(n,t_),mf.set(n,i),mf.set(i,i)),i}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return G(yf(n,e));if(t==="shader")return U(n)}return n},E2=function(n,e=null){for(const t in n)n[t]=G(n[t],e);return n},A2=function(n,e=null){const t=n.length;for(let i=0;i<t;i++)n[i]=G(n[i],e);return n},N2=function(n,e=null,t=null,i=null){const r=s=>G(i!==null?Object.assign(s,i):s);return e===null?(...s)=>r(new n(...Ys(s))):t!==null?(t=G(t),(...s)=>r(new n(e,...Ys(s),t))):(...s)=>r(new n(e,...Ys(s)))},C2=function(n,...e){return G(new n(...Ys(e)))};class R2 extends qe{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:i}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=i_.get(e.constructor);a===void 0&&(a=new WeakMap,i_.set(e.constructor,a));let o=a.get(t);o===void 0&&(o=G(e.buildFunctionNode(t)),a.set(t,o)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(o),s=G(o.call(i))}else{const a=t.jsFunc,o=i!==null?a(i,e):a(e);s=G(o)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class I2 extends qe{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Dl(e),G(new R2(this,e))}setup(){return this.call()}}const L2=[!1,!0],P2=[0,1,2,3],D2=[-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],ff=new Map;for(const n of L2)ff.set(n,new Vr(n));const gf=new Map;for(const n of P2)gf.set(n,new Vr(n,"uint"));const vf=new Map([...gf].map(n=>new Vr(n.value,"int")));for(const n of D2)vf.set(n,new Vr(n,"int"));const Uh=new Map([...vf].map(n=>new Vr(n.value)));for(const n of r_)Uh.set(n,new Vr(n));for(const n of r_)Uh.set(-n,new Vr(-n));const Oh={bool:ff,uint:gf,ints:vf,float:Uh},n_=new Map([...ff,...Uh]),yf=(n,e)=>n_.has(n)?n_.get(n):n.isNode===!0?n:new Vr(n,e),U2=n=>{try{return n.getNodeType()}catch{return}},oi=function(n,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(n)&&t.every(r=>typeof r!="object"))&&(t=[sf(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return G(e.get(t[0]));if(t.length===1){const r=yf(t[0],n);return U2(r)===n?G(r):G(new df(r,n))}const i=t.map(r=>yf(r));return G(new Kx(i,n))}},Ll=n=>typeof n=="object"&&n!==null?n.value:n,s_=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function Pl(n,e){return new Proxy(new I2(n,e),t_)}const G=(n,e=null)=>w2(n,e),Dl=(n,e=null)=>new E2(n,e),Ys=(n,e=null)=>new A2(n,e),K=(...n)=>new N2(...n),ge=(...n)=>new C2(...n),U=(n,e)=>{const t=new Pl(n,e),i=(...r)=>{let s;return Dl(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return i.shaderNode=t,i.setLayout=r=>(t.setLayout(r),i),i.once=()=>(t.once=!0,i),i},O2=(...n)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...n));te("toGlobal",n=>(n.global=!0,n));const Ul=n=>{oo=n},xf=()=>oo,Le=(...n)=>oo.If(...n);function a_(n){return oo&&oo.add(n),n}te("append",a_);const o_=new oi("color"),E=new oi("float",Oh.float),P=new oi("int",Oh.ints),_e=new oi("uint",Oh.uint),us=new oi("bool",Oh.bool),z=new oi("vec2"),dn=new oi("ivec2"),l_=new oi("uvec2"),c_=new oi("bvec2"),D=new oi("vec3"),u_=new oi("ivec3"),co=new oi("uvec3"),_f=new oi("bvec3"),ae=new oi("vec4"),h_=new oi("ivec4"),d_=new oi("uvec4"),p_=new oi("bvec4"),Ol=new oi("mat2"),yi=new oi("mat3"),$s=new oi("mat4"),F2=(n="")=>G(new Vr(n,"string")),V2=n=>G(new Vr(n,"ArrayBuffer"));te("toColor",o_),te("toFloat",E),te("toInt",P),te("toUint",_e),te("toBool",us),te("toVec2",z),te("toIVec2",dn),te("toUVec2",l_),te("toBVec2",c_),te("toVec3",D),te("toIVec3",u_),te("toUVec3",co),te("toBVec3",_f),te("toVec4",ae),te("toIVec4",h_),te("toUVec4",d_),te("toBVec4",p_),te("toMat2",Ol),te("toMat3",yi),te("toMat4",$s);const m_=K(cs),f_=(n,e)=>G(new df(G(n),e)),B2=(n,e)=>G(new Dh(G(n),e));te("element",m_),te("convert",f_);class Mf extends qe{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=i,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}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 g_=n=>new Mf(n),Tf=(n,e=0)=>new Mf(n,!0,e),z2=Tf("frame"),xt=Tf("render"),v_=g_("object");class Js extends pf{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=v_}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const i=this.getSelf();return e=e.bind(i),super.onUpdate(r=>{const s=e(r,i);s!==void 0&&(this.value=s)},t)}generate(e,t){const i=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),o=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,i,t)}}const fe=(n,e)=>{const t=s_(e||n),i=n&&n.isNode===!0?n.node&&n.node.value||n.value:n;return G(new Js(i,t))};class Et extends qe{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}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 ar=(n,e)=>G(new Et(n,e)),Zr=(n,e)=>G(new Et(n,e,!0)),Nt=ge(Et,"vec4","DiffuseColor"),bf=ge(Et,"vec3","EmissiveColor"),pn=ge(Et,"float","Roughness"),Fl=ge(Et,"float","Metalness"),Fh=ge(Et,"float","Clearcoat"),Vl=ge(Et,"float","ClearcoatRoughness"),Ks=ge(Et,"vec3","Sheen"),Vh=ge(Et,"float","SheenRoughness"),Bh=ge(Et,"float","Iridescence"),Sf=ge(Et,"float","IridescenceIOR"),wf=ge(Et,"float","IridescenceThickness"),zh=ge(Et,"float","AlphaT"),hs=ge(Et,"float","Anisotropy"),Bl=ge(Et,"vec3","AnisotropyT"),Zs=ge(Et,"vec3","AnisotropyB"),or=ge(Et,"color","SpecularColor"),zl=ge(Et,"float","SpecularF90"),kh=ge(Et,"float","Shininess"),Ef=ge(Et,"vec4","Output"),Qs=ge(Et,"float","dashSize"),kl=ge(Et,"float","gapSize"),k2=ge(Et,"float","pointWidth"),Hl=ge(Et,"float","IOR"),Hh=ge(Et,"float","Transmission"),Af=ge(Et,"float","Thickness"),Nf=ge(Et,"float","AttenuationDistance"),Cf=ge(Et,"color","AttenuationColor"),Rf=ge(Et,"float","Dispersion");class y_ extends pt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}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 ao.join("").slice(0,i)!==t.components}return!1}generate(e,t){const{targetNode:i,sourceNode:r}=this,s=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.context({assign:!0}).build(e),l=r.build(e,a),c=r.getNodeType(e),u=e.getDataFromNode(this);let h;if(u.initialized===!0)t!=="void"&&(h=o);else if(s){const d=e.getVarFromNode(this,null,a),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${l}`,this);const m=i.node.context({assign:!0}).build(e);for(let v=0;v<i.components.length;v++){const f=i.components[v];e.addLineFlowCode(`${m}.${f} = ${p}[ ${v} ]`,this)}t!=="void"&&(h=o)}else h=`${o} = ${l}`,(t==="void"||c==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=o));return u.initialized=!0,e.format(h,a,t)}}const x_=K(y_);te("assign",x_);class __ extends pt{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)}generate(e){const t=[],i=this.functionNode,r=i.getInputs(e),s=this.parameters;if(Array.isArray(s))for(let a=0;a<s.length;a++){const o=r[a],l=s[a];t.push(l.build(e,o.type))}else for(const a of r){const o=s[a.name];if(o!==void 0)t.push(o.build(e,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${i.build(e,"property")}( ${t.join(", ")} )`}}const M_=(n,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Ys(e):Dl(e[0]),G(new __(G(n),e)));te("call",M_);class Gt extends pt{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let s=new Gt(e,t,i);for(let a=0;a<r.length-1;a++)s=new Gt(e,s,r[a]);t=s,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i}getNodeType(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=r.getNodeType(e),o=typeof s<"u"?s.getNodeType(e):null;if(a==="void"||o==="void")return"void";if(i==="%")return a;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return e.getIntegerType(a);if(i==="!"||i==="=="||i==="&&"||i==="||"||i==="^^")return"bool";if(i==="<"||i===">"||i==="<="||i===">="){const l=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else return a==="float"&&e.isMatrix(o)?o:e.isMatrix(a)&&e.isVector(o)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=r.getNodeType(e),l=typeof s<"u"?s.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="?e.isVector(o)?l=o:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):e.isMatrix(o)&&e.isVector(l)?l=e.getVectorFromMatrix(o):e.isVector(o)&&e.isMatrix(l)?o=e.getVectorFromMatrix(l):o=l=a):o=l=a;const c=r.build(e,o),u=typeof s<"u"?s.build(e,l):null,h=e.getTypeLength(t),d=e.getFunctionOperator(i);if(t!=="void")return i==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} < ${u} )`,a,t):i==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} <= ${u} )`,a,t):i===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} > ${u} )`,a,t):i===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} >= ${u} )`,a,t):i==="!"||i==="~"?e.format(`(${i}${c})`,o,t):d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`( ${c} ${i} ${u} )`,a,t);if(o!=="void")return d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`${c} ${i} ${u}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const zt=K(Gt,"+"),Pt=K(Gt,"-"),lt=K(Gt,"*"),Qr=K(Gt,"/"),If=K(Gt,"%"),T_=K(Gt,"=="),b_=K(Gt,"!="),S_=K(Gt,"<"),Lf=K(Gt,">"),w_=K(Gt,"<="),E_=K(Gt,">="),A_=K(Gt,"&&"),N_=K(Gt,"||"),C_=K(Gt,"!"),R_=K(Gt,"^^"),I_=K(Gt,"&"),L_=K(Gt,"~"),P_=K(Gt,"|"),D_=K(Gt,"^"),U_=K(Gt,"<<"),O_=K(Gt,">>");te("add",zt),te("sub",Pt),te("mul",lt),te("div",Qr),te("modInt",If),te("equal",T_),te("notEqual",b_),te("lessThan",S_),te("greaterThan",Lf),te("lessThanEqual",w_),te("greaterThanEqual",E_),te("and",A_),te("or",N_),te("not",C_),te("xor",R_),te("bitAnd",I_),te("bitNot",L_),te("bitOr",P_),te("bitXor",D_),te("shiftLeft",U_),te("shiftRight",O_);const F_=(...n)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),If(...n));te("remainder",F_);class V extends pt{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=i,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>o?t:a>o?i:o>s?r:t}getNodeType(e){const t=this.method;return t===V.LENGTH||t===V.DISTANCE||t===V.DOT?"float":t===V.CROSS?"vec3":t===V.ALL?"bool":t===V.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===V.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const i=this.method,r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,o=this.bNode,l=this.cNode,c=e.renderer.isWebGLRenderer===!0;if(i===V.TRANSFORM_DIRECTION){let u=a,h=o;e.isMatrix(u.getNodeType(e))?h=ae(D(h),0):u=ae(D(u),0);const d=lt(u,h).xyz;return Mr(d).build(e,t)}else{if(i===V.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(i===V.ONE_MINUS)return Pt(1,a).build(e,t);if(i===V.RECIPROCAL)return Qr(1,a).build(e,t);if(i===V.DIFFERENCE)return It(Pt(a,o)).build(e,t);{const u=[];return i===V.CROSS||i===V.MOD?u.push(a.build(e,r),o.build(e,r)):c&&i===V.STEP?u.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),o.build(e,s)):c&&(i===V.MIN||i===V.MAX)||i===V.MOD?u.push(a.build(e,s),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":s)):i===V.REFRACT?u.push(a.build(e,s),o.build(e,s),l.build(e,"float")):i===V.MIX?u.push(a.build(e,s),o.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):(u.push(a.build(e,s)),o!==null&&u.push(o.build(e,s)),l!==null&&u.push(l.build(e,s))),e.format(`${e.getMethod(i,r)}( ${u.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}V.ALL="all",V.ANY="any",V.EQUALS="equals",V.RADIANS="radians",V.DEGREES="degrees",V.EXP="exp",V.EXP2="exp2",V.LOG="log",V.LOG2="log2",V.SQRT="sqrt",V.INVERSE_SQRT="inversesqrt",V.FLOOR="floor",V.CEIL="ceil",V.NORMALIZE="normalize",V.FRACT="fract",V.SIN="sin",V.COS="cos",V.TAN="tan",V.ASIN="asin",V.ACOS="acos",V.ATAN="atan",V.ABS="abs",V.SIGN="sign",V.LENGTH="length",V.NEGATE="negate",V.ONE_MINUS="oneMinus",V.DFDX="dFdx",V.DFDY="dFdy",V.ROUND="round",V.RECIPROCAL="reciprocal",V.TRUNC="trunc",V.FWIDTH="fwidth",V.BITCAST="bitcast",V.TRANSPOSE="transpose",V.ATAN2="atan2",V.MIN="min",V.MAX="max",V.MOD="mod",V.STEP="step",V.REFLECT="reflect",V.DISTANCE="distance",V.DIFFERENCE="difference",V.DOT="dot",V.CROSS="cross",V.POW="pow",V.TRANSFORM_DIRECTION="transformDirection",V.MIX="mix",V.CLAMP="clamp",V.REFRACT="refract",V.SMOOTHSTEP="smoothstep",V.FACEFORWARD="faceforward";const V_=E(1e-6),H2=E(1e6),ea=E(Math.PI),G2=E(Math.PI*2),Pf=K(V,V.ALL),B_=K(V,V.ANY),z_=K(V,V.EQUALS),k_=K(V,V.RADIANS),H_=K(V,V.DEGREES),Df=K(V,V.EXP),Gh=K(V,V.EXP2),Uf=K(V,V.LOG),Gl=K(V,V.LOG2),en=K(V,V.SQRT),G_=K(V,V.INVERSE_SQRT),ds=K(V,V.FLOOR),Of=K(V,V.CEIL),Mr=K(V,V.NORMALIZE),ps=K(V,V.FRACT),Ci=K(V,V.SIN),Tr=K(V,V.COS),W_=K(V,V.TAN),j_=K(V,V.ASIN),Wh=K(V,V.ACOS),X_=K(V,V.ATAN),It=K(V,V.ABS),Wl=K(V,V.SIGN),ta=K(V,V.LENGTH),q_=K(V,V.NEGATE),Y_=K(V,V.ONE_MINUS),$_=K(V,V.DFDX),J_=K(V,V.DFDY),K_=K(V,V.ROUND),Z_=K(V,V.RECIPROCAL),Ff=K(V,V.TRUNC),Q_=K(V,V.FWIDTH),W2=K(V,V.BITCAST),eM=K(V,V.TRANSPOSE),tM=K(V,V.ATAN2),xi=K(V,V.MIN),ft=K(V,V.MAX),jh=K(V,V.MOD),jl=K(V,V.STEP),iM=K(V,V.REFLECT),rM=K(V,V.DISTANCE),nM=K(V,V.DIFFERENCE),qt=K(V,V.DOT),uo=K(V,V.CROSS),Ji=K(V,V.POW),Vf=K(V,V.POW,2),sM=K(V,V.POW,3),aM=K(V,V.POW,4),oM=K(V,V.TRANSFORM_DIRECTION),lM=n=>lt(Wl(n),Ji(It(n),1/3)),Bf=n=>qt(n,n),rt=K(V,V.MIX),li=(n,e=0,t=1)=>G(new V(V.CLAMP,G(n),G(e),G(t))),cM=n=>li(n),zf=K(V,V.REFRACT),Ki=K(V,V.SMOOTHSTEP),uM=K(V,V.FACEFORWARD),kf=U(([n])=>{const e=43758.5453,t=qt(n.xy,z(12.9898,78.233)),i=jh(t,ea);return ps(Ci(i).mul(e))}),hM=(n,e,t)=>rt(e,t,n),dM=(n,e,t)=>Ki(e,t,n);te("all",Pf),te("any",B_),te("equals",z_),te("radians",k_),te("degrees",H_),te("exp",Df),te("exp2",Gh),te("log",Uf),te("log2",Gl),te("sqrt",en),te("inverseSqrt",G_),te("floor",ds),te("ceil",Of),te("normalize",Mr),te("fract",ps),te("sin",Ci),te("cos",Tr),te("tan",W_),te("asin",j_),te("acos",Wh),te("atan",X_),te("abs",It),te("sign",Wl),te("length",ta),te("lengthSq",Bf),te("negate",q_),te("oneMinus",Y_),te("dFdx",$_),te("dFdy",J_),te("round",K_),te("reciprocal",Z_),te("trunc",Ff),te("fwidth",Q_),te("atan2",tM),te("min",xi),te("max",ft),te("mod",jh),te("step",jl),te("reflect",iM),te("distance",rM),te("dot",qt),te("cross",uo),te("pow",Ji),te("pow2",Vf),te("pow3",sM),te("pow4",aM),te("transformDirection",oM),te("mix",hM),te("clamp",li),te("refract",zf),te("smoothstep",dM),te("faceForward",uM),te("difference",nM),te("saturate",cM),te("cbrt",lM),te("transpose",eM),te("rand",kf);class j2 extends qe{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}getNodeType(e){const t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const i=this.elseNode.getNodeType(e);if(e.getTypeLength(i)>e.getTypeLength(t))return i}return t}setup(e){const t=this.condNode.cache(),i=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=i.context({nodeBlock:i}),a.elseNode=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:s,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=t!=="void",c=l?ar(i).build(e):"";r.nodeProperty=c;const u=s.build(e,"bool");e.addFlowCode(`
|
|
3844
3844
|
${e.tab}if ( ${u} ) {
|
|
3845
3845
|
|
|
3846
3846
|
`).addFlowTab();let h=a.build(e,i);if(h&&(l?h=c+" = "+h+";":h="return "+h+";"),e.removeFlowTab().addFlowCode(e.tab+" "+h+`
|
|
@@ -3853,18 +3853,18 @@ ${e.tab}if ( ${u} ) {
|
|
|
3853
3853
|
|
|
3854
3854
|
`)}else e.addFlowCode(`
|
|
3855
3855
|
|
|
3856
|
-
`);return e.format(c,i,t)}}const Ri=K(j2);te("select",Ri);const dM=(...n)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ri(...n));te("cond",dM);class kf extends qe{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e);return e.setContext(t),i}generate(e,t){const i=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(i),r}}const Hf=K(kf),pM=(n,e)=>Hf(n,{label:e});te("context",Hf),te("label",pM);class mM extends qe{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:i}=this,r=e.getVarFromNode(this,i,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const Gf=K(mM);te("temp",Gf),te("toVar",(...n)=>Gf(...n).append());class fM extends qe{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}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,s=this.getNodeType(e);t.varying=i=e.getVaryingFromNode(this,r,s),t.node=this.node}return i.needsInterpolation||(i.needsInterpolation=e.shaderStage==="fragment"),i}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),i=this.setupVarying(e);if(t.propertyName===void 0){const r=this.getNodeType(e),s=e.getPropertyName(i,of.VERTEX);e.flowNodeFromShaderStage(of.VERTEX,this.node,r,s),t.propertyName=s}return e.getPropertyName(i)}}const Ii=K(fM);te("varying",Ii);const jl="WorkingColorSpace",Wf="OutputColorSpace";function gM(n){let e=null;return n===nr?e="Linear":n===Fi&&(e="sRGB"),e}function jh(n,e){return gM(n)+"To"+gM(e)}class Xl extends pt{static get type(){return"ColorSpaceNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.source=t,this.target=i}getColorSpace(e,t){return t===jl?vt.workingColorSpace:t===Wf?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{renderer:t}=e,{colorNode:i}=this,r=this.getColorSpace(e,this.source),s=this.getColorSpace(e,this.target);if(r===s)return i;const a=jh(r,s);let o=null;const l=t.nodes.library.getColorSpaceFunction(a);return l!==null?o=ae(l(i.rgb),i.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",a),o=i),o}}const vM=n=>G(new Xl(G(n),jl,Wf)),yM=n=>G(new Xl(G(n),Wf,jl)),xM=(n,e)=>G(new Xl(G(n),jl,e)),jf=(n,e)=>G(new Xl(G(n),e,jl));te("toOutputColorSpace",vM),te("toWorkingColorSpace",yM),te("workingToColorSpace",xM),te("colorSpaceToWorking",jf);let X2=class extends ls{static get type(){return"ReferenceElementNode"}constructor(n,e){super(n,e),this.referenceNode=n,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(n){const e=super.generate(n),t=this.referenceNode.getNodeType(),i=this.getNodeType();return n.format(e,t,i)}};class _M extends qe{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=je.OBJECT}setGroup(e){return this.group=e,this}element(e){return G(new X2(this,G(e)))}setNodeType(e){const t=fe(null,e).getSelf();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}}const q2=(n,e,t)=>G(new _M(n,e,t));class MM extends _M{static get type(){return"RendererReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.renderer=i,this.setGroup(xt)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const TM=(n,e,t)=>G(new MM(n,e,t));class bM extends pt{static get type(){return"ToneMappingNode"}constructor(e,t=wM,i=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=i}getCacheKey(){return tf(super.getCacheKey(),this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,i=this.toneMapping;if(i===mr)return t;let r=null;const s=e.renderer.nodes.library.getToneMappingFunction(i);return s!==null?r=ae(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",i),r=t),r}}const SM=(n,e,t)=>G(new bM(n,G(e),G(t))),wM=TM("toneMappingExposure","float");te("toneMapping",(n,e,t)=>SM(e,t,n));class EM extends df{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=wa,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(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=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,o=i.isInterleavedBuffer===!0?i:new Xa(i,s),l=new Fn(o,r,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 s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=Ii(this).build(e,t),s}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}}const ql=(n,e,t,i)=>G(new EM(n,e,t,i)),AM=(n,e,t,i)=>ql(n,e,t,i).setUsage(bs),Xh=(n,e,t,i)=>ql(n,e,t,i).setInstanced(!0),Xf=(n,e,t,i)=>AM(n,e,t,i).setInstanced(!0);te("toAttribute",n=>ql(n.value));class NM extends qe{static get type(){return"ComputeNode"}constructor(e,t,i=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=i,this.dispatchCount=0,this.version=1,this.updateBeforeType=je.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let i=t[0];for(let r=1;r<t.length;r++)i*=t[r];this.dispatchCount=Math.ceil(e/i)}onInit(){}updateBefore({renderer:e}){e.compute(this)}generate(e){const{shaderStage:t}=e;if(t==="compute"){const i=this.computeNode.build(e,"void");i!==""&&e.addLineFlowCode(i,this)}}}const CM=(n,e,t)=>G(new NM(G(n),e,t));te("compute",CM);class RM extends qe{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const i=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(i),s}}const Yl=(n,...e)=>G(new RM(G(n),...e));te("cache",Yl);class IM extends qe{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 LM=K(IM);te("bypass",LM);class qf extends qe{static get type(){return"RemapNode"}constructor(e,t,i,r=E(0),s=E(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=i,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:i,outLowNode:r,outHighNode:s,doClamp:a}=this;let o=e.sub(t).div(i.sub(t));return a===!0&&(o=o.clamp()),o.mul(s.sub(r)).add(r)}}const PM=K(qf,null,null,{doClamp:!1}),DM=K(qf);te("remap",PM),te("remapClamp",DM);class UM extends qe{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 ps=K(UM),OM=n=>(n?Ri(n,ps("discard")):ps("discard")).append(),Y2=()=>ps("return").append();te("discard",OM);class FM extends pt{static get type(){return"RenderOutputNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=i,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const i=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||mr,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Cr;return i!==mr&&(t=t.toneMapping(i)),r!==Cr&&r!==vt.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const VM=(n,e=null,t=null)=>G(new FM(G(n),e,t));te("renderOutput",VM);function $2(n){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",n)}class Yf extends qe{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),s=e.getTypeFromAttribute(r),a=e.getAttribute(t,s);return e.shaderStage==="vertex"?e.format(a.name,s,i):Ii(this).build(e,i)}else return console.warn(`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 _i=(n,e)=>G(new Yf(n,e)),nt=n=>_i("uv"+(n>0?n:""),"vec2");class BM extends qe{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 ms=K(BM);class zM extends $s{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=je.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:s}=i;this.value=Math.log2(Math.max(r,s))}}}const kM=K(zM);class mn extends $s{static get type(){return"TextureNode"}constructor(e,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.sampler=!0,this.updateMatrix=!1,this.updateType=je.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=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===Nr?"uvec4":this.value.type===va?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return nt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=fe(this.value.matrix)),this._matrixUniform.mul(D(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?je.FRAME:je.NONE,this}setupUV(e,t){const i=this.value;return e.isFlipY()&&(i.isRenderTargetTexture===!0||i.isFramebufferTexture===!0||i.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(P(ms(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let i=this.uvNode;(i===null||e.context.forceUVContext===!0)&&e.context.getUV&&(i=e.context.getUV(this)),i||(i=this.getDefaultUV()),this.updateMatrix===!0&&(i=this.getTransformedUV(i)),i=this.setupUV(e,i);let r=this.levelNode;r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),t.uvNode=i,t.levelNode=r,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,i,r,s,a,o,l){const c=this.value;let u;return r?u=e.generateTextureLevel(c,t,i,r,a):s?u=e.generateTextureBias(c,t,i,s,a):l?u=e.generateTextureGrad(c,t,i,l,a):o?u=e.generateTextureCompare(c,t,i,o,a):this.sampler===!1?u=e.generateTextureLoad(c,t,i,a):u=e.generateTexture(c,t,i,a),u}generate(e,t){const i=e.getNodeProperties(this),r=this.value;if(!r||r.isTexture!==!0)throw new Error("TextureNode: Need a three.js texture.");const s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let o=a.propertyName;if(o===void 0){const{uvNode:u,levelNode:h,biasNode:d,compareNode:p,depthNode:m,gradNode:v}=i,f=this.generateUV(e,u),g=h?h.build(e,"float"):null,x=d?d.build(e,"float"):null,y=m?m.build(e,"int"):null,_=p?p.build(e,"float"):null,I=v?[v[0].build(e,"vec2"),v[1].build(e,"vec2")]:null,T=e.getVarFromNode(this);o=e.getPropertyName(T);const w=this.generateSnippet(e,s,f,g,x,y,_,I);e.addLineFlowCode(`${o} = ${w}`,this),a.snippet=w,a.propertyName=o}let l=o;const c=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(l=jf(ps(l,c),r.colorSpace).setup(e).build(e,c)),e.format(l,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=G(e),t.referenceNode=this.getSelf(),G(t)}blur(e){const t=this.clone();return t.biasNode=G(e).mul(kM(t)),t.referenceNode=this.getSelf(),G(t)}level(e){const t=this.clone();return t.levelNode=G(e),t.referenceNode=this.getSelf(),G(t)}size(e){return ms(this,e)}bias(e){const t=this.clone();return t.biasNode=G(e),t.referenceNode=this.getSelf(),G(t)}compare(e){const t=this.clone();return t.compareNode=G(e),t.referenceNode=this.getSelf(),G(t)}grad(e,t){const i=this.clone();return i.gradNode=[G(e),G(t)],i.referenceNode=this.getSelf(),G(i)}depth(e){const t=this.clone();return t.depthNode=G(e),t.referenceNode=this.getSelf(),G(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()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const yt=K(mn),Br=(...n)=>yt(...n).setSampler(!1),J2=n=>(n.isNode===!0?n:yt(n)).convert("sampler"),uo=fe("float").label("cameraNear").setGroup(xt).onRenderUpdate(({camera:n})=>n.near),ho=fe("float").label("cameraFar").setGroup(xt).onRenderUpdate(({camera:n})=>n.far),HM=fe("float").label("cameraLogDepth").setGroup(xt).onRenderUpdate(({camera:n})=>2/(Math.log(n.far+1)/Math.LN2)),lr=fe("mat4").label("cameraProjectionMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrix),K2=fe("mat4").label("cameraProjectionMatrixInverse").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrixInverse),cr=fe("mat4").label("cameraViewMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorldInverse),Z2=fe("mat4").label("cameraWorldMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorld),Q2=fe("mat3").label("cameraNormalMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.normalMatrix),$f=fe(new N).label("cameraPosition").setGroup(xt).onRenderUpdate(({camera:n},e)=>e.value.setFromMatrixPosition(n.matrixWorld));class St extends qe{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=je.OBJECT,this._uniformNode=new $s(null)}getNodeType(){const e=this.scope;if(e===St.WORLD_MATRIX)return"mat4";if(e===St.POSITION||e===St.VIEW_POSITION||e===St.DIRECTION||e===St.SCALE)return"vec3"}update(e){const t=this.object3d,i=this._uniformNode,r=this.scope;if(r===St.WORLD_MATRIX)i.value=t.matrixWorld;else if(r===St.POSITION)i.value=i.value||new N,i.value.setFromMatrixPosition(t.matrixWorld);else if(r===St.SCALE)i.value=i.value||new N,i.value.setFromMatrixScale(t.matrixWorld);else if(r===St.DIRECTION)i.value=i.value||new N,t.getWorldDirection(i.value);else if(r===St.VIEW_POSITION){const s=e.camera;i.value=i.value||new N,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===St.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===St.POSITION||t===St.VIEW_POSITION||t===St.DIRECTION||t===St.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}St.WORLD_MATRIX="worldMatrix",St.POSITION="position",St.SCALE="scale",St.VIEW_POSITION="viewPosition",St.DIRECTION="direction";const eL=K(St,St.DIRECTION),tL=K(St,St.WORLD_MATRIX),iL=K(St,St.POSITION),rL=K(St,St.SCALE),nL=K(St,St.VIEW_POSITION);class tn extends St{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const sL=ge(tn,tn.DIRECTION),zr=ge(tn,tn.WORLD_MATRIX),aL=ge(tn,tn.POSITION),oL=ge(tn,tn.SCALE),lL=ge(tn,tn.VIEW_POSITION),GM=fe(new Ke).onObjectUpdate(({object:n},e)=>e.value.getNormalMatrix(n.matrixWorld)),WM=fe(new Re).onObjectUpdate(({object:n},e)=>e.value.copy(n.matrixWorld).invert()),fn=cr.mul(zr).toVar("modelViewMatrix_2"),cL=U(n=>(n.context.isHighPrecisionModelViewMatrix=!0,fe("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),uL=U(n=>{const e=n.context.isHighPrecisionModelViewMatrix;return fe("mat3").onObjectUpdate(({object:t,camera:i})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highPrecisionModelNormalMatrix"),Li=_i("position","vec3"),Zt=Li.varying("positionLocal"),qh=Li.varying("positionPrevious"),Yh=zr.mul(Zt).xyz.varying("v_positionWorld"),Jf=Zt.transformDirection(zr).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),Pi=fn.mul(Zt).xyz.varying("v_positionView"),Vt=Pi.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class jM extends qe{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:i}=e;return t.coordinateSystem===Rr&&i.side===si?"false":e.getFrontFacing()}}const XM=ge(jM),$l=E(XM).mul(2).sub(1),$h=_i("normal","vec3"),ur=U(n=>n.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),D(0,1,0)):$h,"vec3").once()().toVar("normalLocal"),qM=Pi.dFdx().cross(Pi.dFdy()).normalize().toVar("normalFlat"),hr=U(n=>{let e;return n.material.flatShading===!0?e=qM:e=Ii(Zf(ur),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Jh=Ii(hr.transformDirection(cr),"v_normalWorld").normalize().toVar("normalWorld"),Yt=U(n=>n.context.setupNormal(),"vec3").once()().mul($l).toVar("transformedNormalView"),Kf=Yt.transformDirection(cr).toVar("transformedNormalWorld"),po=U(n=>n.context.setupClearcoatNormal(),"vec3").once()().mul($l).toVar("transformedClearcoatNormalView"),YM=U(([n,e=zr])=>{const t=yi(e),i=n.div(D(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(i).xyz}),Zf=U(([n],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(n);const i=GM.mul(n);return cr.transformDirection(i)}),$M=fe(0).onReference(({material:n})=>n).onRenderUpdate(({material:n})=>n.refractionRatio),JM=Vt.negate().reflect(Yt),KM=Vt.negate().refract(Yt,$M),ZM=JM.transformDirection(cr).toVar("reflectVector"),QM=KM.transformDirection(cr).toVar("reflectVector");class e1 extends mn{static get type(){return"CubeTextureNode"}constructor(e,t=null,i=null,r=null){super(e,t,i,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===fr?ZM:e.mapping===Ar?QM:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),D(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const i=this.value;return e.renderer.coordinateSystem===Ss||!i.isRenderTargetTexture?D(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const Kh=K(e1);class Zh extends $s{static get type(){return"BufferNode"}constructor(e,t,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=i}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const Jl=(n,e,t)=>G(new Zh(n,e,t));class hL extends ls{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),i=this.getNodeType();return e.format(t,"vec4",i)}}class Qf extends Zh{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=je.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,i=this.getElementLength(),r=this.getElementType();if(i===1)for(let s=0;s<e.length;s++){const a=s*4;t[a]=e[s]}else if(r==="color")for(let s=0;s<e.length;s++){const a=s*4,o=e[s];t[a]=o.r,t[a+1]=o.g,t[a+2]=o.b||0}else for(let s=0;s<e.length;s++){const a=s*4,o=e[s];t[a]=o.x,t[a+1]=o.y,t[a+2]=o.z||0,t[a+3]=o.w||0}}setup(e){const t=this.array.length;this._elementType=this.elementType===null?Pn(this.array[0]):this.elementType,this._elementLength=e.getTypeLength(this._elementType);let i=Float32Array;return this._elementType.charAt(0)==="i"?i=Int32Array:this._elementType.charAt(0)==="u"&&(i=Uint32Array),this.value=new i(t*4),this.bufferCount=t,this.bufferType=e.changeComponentType("vec4",e.getComponentType(this._elementType)),super.setup(e)}element(e){return G(new hL(this,G(e)))}}const gn=(n,e)=>G(new Qf(n,e)),dL=(n,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),G(new Qf(n,e)));class pL extends ls{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 Kl extends qe{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=je.OBJECT}element(e){return G(new pL(this,G(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=Jl(null,e,this.count):Array.isArray(this.getValueFromReference())?t=gn(null,e):e==="texture"?t=yt(null):e==="cubeTexture"?t=Kh(null):t=fe(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}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 fi=(n,e,t)=>G(new Kl(n,e,t)),eg=(n,e,t,i)=>G(new Kl(n,e,i,t));class t1 extends Kl{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 rn=(n,e,t)=>G(new t1(n,e,t)),Qh=U(n=>(n.geometry.hasAttribute("tangent")===!1&&n.geometry.computeTangents(),_i("tangent","vec4")))(),Zl=Qh.xyz.toVar("tangentLocal"),Ql=fn.mul(ae(Zl,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),i1=Ql.transformDirection(cr).varying("v_tangentWorld").normalize().toVar("tangentWorld"),tg=Ql.toVar("transformedTangentView"),mL=tg.transformDirection(cr).normalize().toVar("transformedTangentWorld"),ec=n=>n.mul(Qh.w).xyz,fL=Ii(ec($h.cross(Qh)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),gL=Ii(ec(ur.cross(Zl)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),r1=Ii(ec(hr.cross(Ql)),"v_bitangentView").normalize().toVar("bitangentView"),vL=Ii(ec(Jh.cross(i1)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),n1=ec(Yt.cross(tg)).normalize().toVar("transformedBitangentView"),yL=n1.transformDirection(cr).normalize().toVar("transformedBitangentWorld"),ta=yi(Ql,r1,hr),s1=Vt.mul(ta),xL=(n,e)=>n.sub(s1.mul(e)),a1=(()=>{let n=Ks.cross(Vt);return n=n.cross(Ks).normalize(),n=rt(n,Yt,us.mul(pn.oneMinus()).oneMinus().pow2().pow2()).normalize(),n})(),_L=U(n=>{const{eye_pos:e,surf_norm:t,mapN:i,uv:r}=n,s=e.dFdx(),a=e.dFdy(),o=r.dFdx(),l=r.dFdy(),c=t,u=a.cross(c),h=c.cross(s),d=u.mul(o.x).add(h.mul(l.x)),p=u.mul(o.y).add(h.mul(l.y)),m=d.dot(d).max(p.dot(p)),v=$l.mul(m.inverseSqrt());return zt(d.mul(i.x,v),p.mul(i.y,v),c.mul(i.z)).normalize()});class o1 extends pt{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=on}setup(e){const{normalMapType:t,scaleNode:i}=this;let r=this.node.mul(2).sub(1);i!==null&&(r=D(r.xy.mul(i),r.z));let s=null;return t===gp?s=Zf(r):t===on&&(e.hasGeometryAttribute("tangent")===!0?s=ta.mul(r).normalize():s=_L({eye_pos:Pi,surf_norm:hr,mapN:r,uv:nt()})),s}}const ig=K(o1),ML=U(({textureNode:n,bumpScale:e})=>{const t=r=>n.cache().context({getUV:s=>r(s.uvNode||nt()),forceUVContext:!0}),i=E(t(r=>r));return z(E(t(r=>r.add(r.dFdx()))).sub(i),E(t(r=>r.add(r.dFdy()))).sub(i)).mul(e)}),TL=U(n=>{const{surf_pos:e,surf_norm:t,dHdxy:i}=n,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,o=s.cross(a),l=a.cross(r),c=r.dot(o).mul($l),u=c.sign().mul(i.x.mul(o).add(i.y.mul(l)));return c.abs().mul(t).sub(u).normalize()});class l1 extends pt{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=ML({textureNode:this.textureNode,bumpScale:e});return TL({surf_pos:Pi,surf_norm:hr,dHdxy:t})}}const c1=K(l1),u1=new Map;class Z extends qe{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=u1.get(e);return i===void 0&&(i=rn(e,t),u1.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===Z.COLOR){const s=t.color!==void 0?this.getColor(i):D();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(i===Z.OPACITY){const s=this.getFloat(i);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(i===Z.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=E(1);else if(i===Z.SPECULAR_INTENSITY){const s=this.getFloat(i);t.specularMap?r=s.mul(this.getTexture(i).a):r=s}else if(i===Z.SPECULAR_COLOR){const s=this.getColor(i);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(i).rgb):r=s}else if(i===Z.ROUGHNESS){const s=this.getFloat(i);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).g):r=s}else if(i===Z.METALNESS){const s=this.getFloat(i);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(i).b):r=s}else if(i===Z.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(i).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(i)):r=a}else if(i===Z.NORMAL)t.normalMap?(r=ig(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=c1(this.getTexture("bump").r,this.getFloat("bumpScale")):r=hr;else if(i===Z.CLEARCOAT){const s=this.getFloat(i);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.CLEARCOAT_ROUGHNESS){const s=this.getFloat(i);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=ig(this.getTexture(i),this.getCache(i+"Scale","vec2")):r=hr;else if(i===Z.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(i===Z.SHEEN_ROUGHNESS){const s=this.getFloat(i);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).a):r=s,r=r.clamp(.07,1)}else if(i===Z.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(i);r=Ul(fo.x,fo.y,fo.y.negate(),fo.x).mul(s.rg.mul(2).sub(z(1)).normalize().mul(s.b))}else r=fo;else if(i===Z.IRIDESCENCE_THICKNESS){const s=fi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=fi("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(i).g).add(a)}else r=s}else if(i===Z.TRANSMISSION){const s=this.getFloat(i);t.transmissionMap?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.THICKNESS){const s=this.getFloat(i);t.thicknessMap?r=s.mul(this.getTexture(i).g):r=s}else if(i===Z.IOR)r=this.getFloat(i);else if(i===Z.LIGHT_MAP)r=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===Z.AO_MAP)r=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(i,s)}return r}}Z.ALPHA_TEST="alphaTest",Z.COLOR="color",Z.OPACITY="opacity",Z.SHININESS="shininess",Z.SPECULAR="specular",Z.SPECULAR_STRENGTH="specularStrength",Z.SPECULAR_INTENSITY="specularIntensity",Z.SPECULAR_COLOR="specularColor",Z.REFLECTIVITY="reflectivity",Z.ROUGHNESS="roughness",Z.METALNESS="metalness",Z.NORMAL="normal",Z.CLEARCOAT="clearcoat",Z.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Z.CLEARCOAT_NORMAL="clearcoatNormal",Z.EMISSIVE="emissive",Z.ROTATION="rotation",Z.SHEEN="sheen",Z.SHEEN_ROUGHNESS="sheenRoughness",Z.ANISOTROPY="anisotropy",Z.IRIDESCENCE="iridescence",Z.IRIDESCENCE_IOR="iridescenceIOR",Z.IRIDESCENCE_THICKNESS="iridescenceThickness",Z.IOR="ior",Z.TRANSMISSION="transmission",Z.THICKNESS="thickness",Z.ATTENUATION_DISTANCE="attenuationDistance",Z.ATTENUATION_COLOR="attenuationColor",Z.LINE_SCALE="scale",Z.LINE_DASH_SIZE="dashSize",Z.LINE_GAP_SIZE="gapSize",Z.LINE_WIDTH="linewidth",Z.LINE_DASH_OFFSET="dashOffset",Z.POINT_WIDTH="pointWidth",Z.DISPERSION="dispersion",Z.LIGHT_MAP="light",Z.AO_MAP="ao";const h1=ge(Z,Z.ALPHA_TEST),mo=ge(Z,Z.COLOR),d1=ge(Z,Z.SHININESS),p1=ge(Z,Z.EMISSIVE),ed=ge(Z,Z.OPACITY),m1=ge(Z,Z.SPECULAR),rg=ge(Z,Z.SPECULAR_INTENSITY),f1=ge(Z,Z.SPECULAR_COLOR),tc=ge(Z,Z.SPECULAR_STRENGTH),td=ge(Z,Z.REFLECTIVITY),g1=ge(Z,Z.ROUGHNESS),v1=ge(Z,Z.METALNESS),y1=ge(Z,Z.NORMAL).context({getUV:null}),x1=ge(Z,Z.CLEARCOAT),_1=ge(Z,Z.CLEARCOAT_ROUGHNESS),M1=ge(Z,Z.CLEARCOAT_NORMAL).context({getUV:null}),T1=ge(Z,Z.ROTATION),b1=ge(Z,Z.SHEEN),S1=ge(Z,Z.SHEEN_ROUGHNESS),w1=ge(Z,Z.ANISOTROPY),E1=ge(Z,Z.IRIDESCENCE),A1=ge(Z,Z.IRIDESCENCE_IOR),N1=ge(Z,Z.IRIDESCENCE_THICKNESS),C1=ge(Z,Z.TRANSMISSION),R1=ge(Z,Z.THICKNESS),I1=ge(Z,Z.IOR),L1=ge(Z,Z.ATTENUATION_DISTANCE),P1=ge(Z,Z.ATTENUATION_COLOR),id=ge(Z,Z.LINE_SCALE),ng=ge(Z,Z.LINE_DASH_SIZE),sg=ge(Z,Z.LINE_GAP_SIZE),rd=ge(Z,Z.LINE_WIDTH),ag=ge(Z,Z.LINE_DASH_OFFSET),D1=ge(Z,Z.POINT_WIDTH),U1=ge(Z,Z.DISPERSION),og=ge(Z,Z.LIGHT_MAP),O1=ge(Z,Z.AO_MAP),fo=fe(new J).onReference(function(n){return n.material}).onRenderUpdate(function({material:n}){this.value.set(n.anisotropy*Math.cos(n.anisotropyRotation),n.anisotropy*Math.sin(n.anisotropyRotation))});class F1 extends pt{static get type(){return"ModelViewProjectionNode"}constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if(e.shaderStage==="fragment")return Ii(e.context.mvp);const t=this.positionNode||Zt,i=e.renderer.nodes.modelViewMatrix||fn;return lr.mul(i).mul(t)}}const lg=K(F1);class Bt extends qe{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),i=this.scope;let r;if(i===Bt.VERTEX)r=e.getVertexIndex();else if(i===Bt.INSTANCE)r=e.getInstanceIndex();else if(i===Bt.DRAW)r=e.getDrawIndex();else if(i===Bt.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(i===Bt.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(i===Bt.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+i);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=Ii(this).build(e,t),s}}Bt.VERTEX="vertex",Bt.INSTANCE="instance",Bt.SUBGROUP="subgroup",Bt.INVOCATION_LOCAL="invocationLocal",Bt.INVOCATION_SUBGROUP="invocationSubgroup",Bt.DRAW="draw";const V1=ge(Bt,Bt.VERTEX),ic=ge(Bt,Bt.INSTANCE),bL=ge(Bt,Bt.SUBGROUP),SL=ge(Bt,Bt.INVOCATION_SUBGROUP),wL=ge(Bt,Bt.INVOCATION_LOCAL),B1=ge(Bt,Bt.DRAW);class z1 extends qe{static get type(){return"InstanceNode"}constructor(e){super("void"),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=je.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,i=this.instanceColorNode;const r=this.instanceMesh;if(t===null){const o=r.instanceMatrix;if(r.count<=1e3)t=Jl(o.array,"mat4",Math.max(r.count,1)).element(ic);else{const l=new Km(o.array,16,1);this.buffer=l;const c=o.usage===bs?Xf:Xh,u=[c(l,"vec4",16,0),c(l,"vec4",16,4),c(l,"vec4",16,8),c(l,"vec4",16,12)];t=Ys(...u)}this.instanceMatrixNode=t}const s=r.instanceColor;if(s&&i===null){const o=new Rn(s.array,3),l=s.usage===bs?Xf:Xh;this.bufferColor=o,i=D(l(o,"vec3",3,0)),this.instanceColorNode=i}const a=t.mul(Zt).xyz;if(Zt.assign(a),e.hasGeometryAttribute("normal")){const o=YM(ur,t);ur.assign(o)}this.instanceColorNode!==null&&Zr("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==bs&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==bs&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const k1=K(z1);class H1 extends qe{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=ic:this.batchingIdNode=B1);const t=U(([p])=>{const m=ms(Br(this.batchMesh._indirectTexture),0),v=P(p).modInt(P(m)),f=P(p).div(P(m));return Br(this.batchMesh._indirectTexture,dn(v,f)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(P(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=ms(Br(i),0),s=E(t).mul(4).toInt().toVar(),a=s.modInt(r),o=s.div(P(r)),l=Ys(Br(i,dn(a,o)),Br(i,dn(a.add(1),o)),Br(i,dn(a.add(2),o)),Br(i,dn(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){const p=U(([m])=>{const v=ms(Br(c),0).x,f=m,g=f.modInt(v),x=f.div(v);return Br(c,dn(g,x)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);Zr("vec3","vBatchColor").assign(p)}const u=yi(l);Zt.assign(l.mul(Zt));const h=ur.div(D(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),d=u.mul(h).xyz;ur.assign(d),e.hasGeometryAttribute("tangent")&&Zl.mulAssign(u)}}const G1=K(H1),W1=new WeakMap;class cg extends qe{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=je.OBJECT,this.skinIndexNode=_i("skinIndex","uvec4"),this.skinWeightNode=_i("skinWeight","vec4");let i,r,s;t?(i=fi("bindMatrix","mat4"),r=fi("bindMatrixInverse","mat4"),s=eg("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(i=fe(e.bindMatrix,"mat4"),r=fe(e.bindMatrixInverse,"mat4"),s=Jl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=i,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=Zt){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),c=e.element(i.z),u=e.element(i.w),h=s.mul(t),d=zt(o.mul(r.x).mul(h),l.mul(r.y).mul(h),c.mul(r.z).mul(h),u.mul(r.w).mul(h));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ur){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),c=e.element(i.z),u=e.element(i.w);let h=zt(r.x.mul(o),r.y.mul(l),r.z.mul(c),r.w.mul(u));return h=a.mul(h).mul(s),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=eg("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,qh)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&qh.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(Zt.assign(t),e.hasGeometryAttribute("normal")){const i=this.getSkinnedNormal();ur.assign(i),e.hasGeometryAttribute("tangent")&&Zl.assign(i)}}generate(e,t){if(t!=="void")return Zt.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;W1.get(t)!==e.frameId&&(W1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const EL=n=>G(new cg(n)),j1=n=>G(new cg(n,!0));class X1 extends qe{static get type(){return"LoopNode"}constructor(e=[]){super(),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 s=0,a=this.params.length-1;s<a;s++){const o=this.params[s],l=o.isNode!==!0&&o.name||this.getVarName(s),c=o.isNode!==!0&&o.type||"int";i[l]=ps(l,c)}const r=e.addStack();return t.returnsNode=this.params[this.params.length-1](i,r,e),t.stackNode=r,e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),i=this.params,r=t.stackNode;for(let o=0,l=i.length-1;o<l;o++){const c=i[o];let u=null,h=null,d=null,p=null,m=null,v=null;c.isNode?(p="int",d=this.getVarName(o),u="0",h=c.build(e,p),m="<"):(p=c.type||"int",d=c.name||this.getVarName(o),u=c.start,h=c.end,m=c.condition,v=c.update,typeof u=="number"?u=u.toString():u&&u.isNode&&(u=u.build(e,p)),typeof h=="number"?h=h.toString():h&&h.isNode&&(h=h.build(e,p)),u!==void 0&&h===void 0?(u=u+" - 1",h="0",m=">="):h!==void 0&&u===void 0&&(u="0",m="<"),m===void 0&&(Number(u)>Number(h)?m=">=":m="<"));const f={start:u,end:h},g=f.start,x=f.end;let y="",_="",I="";v||(p==="int"||p==="uint"?m.includes("<")?v="++":v="--":m.includes("<")?v="+= 1.":v="-= 1."),y+=e.getVar(p,d)+" = "+g,_+=d+" "+m+" "+x,I+=d+" "+v;const T=`for ( ${y}; ${_}; ${I} )`;e.addFlowCode((o===0?`
|
|
3856
|
+
`);return e.format(c,i,t)}}const Ri=K(j2);te("select",Ri);const pM=(...n)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ri(...n));te("cond",pM);class Hf extends qe{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e);return e.setContext(t),i}generate(e,t){const i=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(i),r}}const Gf=K(Hf),mM=(n,e)=>Gf(n,{label:e});te("context",Gf),te("label",mM);class fM extends qe{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:i}=this,r=e.getVarFromNode(this,i,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const Wf=K(fM);te("temp",Wf),te("toVar",(...n)=>Wf(...n).append());class gM extends qe{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}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,s=this.getNodeType(e);t.varying=i=e.getVaryingFromNode(this,r,s),t.node=this.node}return i.needsInterpolation||(i.needsInterpolation=e.shaderStage==="fragment"),i}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),i=this.setupVarying(e);if(t.propertyName===void 0){const r=this.getNodeType(e),s=e.getPropertyName(i,lf.VERTEX);e.flowNodeFromShaderStage(lf.VERTEX,this.node,r,s),t.propertyName=s}return e.getPropertyName(i)}}const Ii=K(gM);te("varying",Ii);const Xl="WorkingColorSpace",jf="OutputColorSpace";function vM(n){let e=null;return n===nr?e="Linear":n===Fi&&(e="sRGB"),e}function Xh(n,e){return vM(n)+"To"+vM(e)}class ql extends pt{static get type(){return"ColorSpaceNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.source=t,this.target=i}getColorSpace(e,t){return t===Xl?vt.workingColorSpace:t===jf?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{renderer:t}=e,{colorNode:i}=this,r=this.getColorSpace(e,this.source),s=this.getColorSpace(e,this.target);if(r===s)return i;const a=Xh(r,s);let o=null;const l=t.nodes.library.getColorSpaceFunction(a);return l!==null?o=ae(l(i.rgb),i.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",a),o=i),o}}const yM=n=>G(new ql(G(n),Xl,jf)),xM=n=>G(new ql(G(n),jf,Xl)),_M=(n,e)=>G(new ql(G(n),Xl,e)),Xf=(n,e)=>G(new ql(G(n),e,Xl));te("toOutputColorSpace",yM),te("toWorkingColorSpace",xM),te("workingToColorSpace",_M),te("colorSpaceToWorking",Xf);let X2=class extends cs{static get type(){return"ReferenceElementNode"}constructor(n,e){super(n,e),this.referenceNode=n,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(n){const e=super.generate(n),t=this.referenceNode.getNodeType(),i=this.getNodeType();return n.format(e,t,i)}};class MM extends qe{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=je.OBJECT}setGroup(e){return this.group=e,this}element(e){return G(new X2(this,G(e)))}setNodeType(e){const t=fe(null,e).getSelf();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}}const q2=(n,e,t)=>G(new MM(n,e,t));class TM extends MM{static get type(){return"RendererReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.renderer=i,this.setGroup(xt)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const bM=(n,e,t)=>G(new TM(n,e,t));class SM extends pt{static get type(){return"ToneMappingNode"}constructor(e,t=EM,i=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=i}getCacheKey(){return rf(super.getCacheKey(),this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,i=this.toneMapping;if(i===mr)return t;let r=null;const s=e.renderer.nodes.library.getToneMappingFunction(i);return s!==null?r=ae(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",i),r=t),r}}const wM=(n,e,t)=>G(new SM(n,G(e),G(t))),EM=bM("toneMappingExposure","float");te("toneMapping",(n,e,t)=>wM(e,t,n));class AM extends pf{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=Ea,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(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=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,o=i.isInterleavedBuffer===!0?i:new qa(i,s),l=new Fn(o,r,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 s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=Ii(this).build(e,t),s}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}}const Yl=(n,e,t,i)=>G(new AM(n,e,t,i)),NM=(n,e,t,i)=>Yl(n,e,t,i).setUsage(Ss),qh=(n,e,t,i)=>Yl(n,e,t,i).setInstanced(!0),qf=(n,e,t,i)=>NM(n,e,t,i).setInstanced(!0);te("toAttribute",n=>Yl(n.value));class CM extends qe{static get type(){return"ComputeNode"}constructor(e,t,i=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=i,this.dispatchCount=0,this.version=1,this.updateBeforeType=je.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let i=t[0];for(let r=1;r<t.length;r++)i*=t[r];this.dispatchCount=Math.ceil(e/i)}onInit(){}updateBefore({renderer:e}){e.compute(this)}generate(e){const{shaderStage:t}=e;if(t==="compute"){const i=this.computeNode.build(e,"void");i!==""&&e.addLineFlowCode(i,this)}}}const RM=(n,e,t)=>G(new CM(G(n),e,t));te("compute",RM);class IM extends qe{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const i=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(i),s}}const $l=(n,...e)=>G(new IM(G(n),...e));te("cache",$l);class LM extends qe{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 PM=K(LM);te("bypass",PM);class Yf extends qe{static get type(){return"RemapNode"}constructor(e,t,i,r=E(0),s=E(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=i,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:i,outLowNode:r,outHighNode:s,doClamp:a}=this;let o=e.sub(t).div(i.sub(t));return a===!0&&(o=o.clamp()),o.mul(s.sub(r)).add(r)}}const DM=K(Yf,null,null,{doClamp:!1}),UM=K(Yf);te("remap",DM),te("remapClamp",UM);class OM extends qe{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 ms=K(OM),FM=n=>(n?Ri(n,ms("discard")):ms("discard")).append(),Y2=()=>ms("return").append();te("discard",FM);class VM extends pt{static get type(){return"RenderOutputNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=i,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const i=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||mr,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Cr;return i!==mr&&(t=t.toneMapping(i)),r!==Cr&&r!==vt.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const BM=(n,e=null,t=null)=>G(new VM(G(n),e,t));te("renderOutput",BM);function $2(n){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",n)}class $f extends qe{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),s=e.getTypeFromAttribute(r),a=e.getAttribute(t,s);return e.shaderStage==="vertex"?e.format(a.name,s,i):Ii(this).build(e,i)}else return console.warn(`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 _i=(n,e)=>G(new $f(n,e)),nt=n=>_i("uv"+(n>0?n:""),"vec2");class zM extends qe{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 fs=K(zM);class kM extends Js{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=je.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:s}=i;this.value=Math.log2(Math.max(r,s))}}}const HM=K(kM);class mn extends Js{static get type(){return"TextureNode"}constructor(e,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.sampler=!0,this.updateMatrix=!1,this.updateType=je.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=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===Nr?"uvec4":this.value.type===ya?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return nt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=fe(this.value.matrix)),this._matrixUniform.mul(D(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?je.FRAME:je.NONE,this}setupUV(e,t){const i=this.value;return e.isFlipY()&&(i.isRenderTargetTexture===!0||i.isFramebufferTexture===!0||i.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(P(fs(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let i=this.uvNode;(i===null||e.context.forceUVContext===!0)&&e.context.getUV&&(i=e.context.getUV(this)),i||(i=this.getDefaultUV()),this.updateMatrix===!0&&(i=this.getTransformedUV(i)),i=this.setupUV(e,i);let r=this.levelNode;r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),t.uvNode=i,t.levelNode=r,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,i,r,s,a,o,l){const c=this.value;let u;return r?u=e.generateTextureLevel(c,t,i,r,a):s?u=e.generateTextureBias(c,t,i,s,a):l?u=e.generateTextureGrad(c,t,i,l,a):o?u=e.generateTextureCompare(c,t,i,o,a):this.sampler===!1?u=e.generateTextureLoad(c,t,i,a):u=e.generateTexture(c,t,i,a),u}generate(e,t){const i=e.getNodeProperties(this),r=this.value;if(!r||r.isTexture!==!0)throw new Error("TextureNode: Need a three.js texture.");const s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let o=a.propertyName;if(o===void 0){const{uvNode:u,levelNode:h,biasNode:d,compareNode:p,depthNode:m,gradNode:v}=i,f=this.generateUV(e,u),g=h?h.build(e,"float"):null,x=d?d.build(e,"float"):null,y=m?m.build(e,"int"):null,_=p?p.build(e,"float"):null,I=v?[v[0].build(e,"vec2"),v[1].build(e,"vec2")]:null,T=e.getVarFromNode(this);o=e.getPropertyName(T);const w=this.generateSnippet(e,s,f,g,x,y,_,I);e.addLineFlowCode(`${o} = ${w}`,this),a.snippet=w,a.propertyName=o}let l=o;const c=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(l=Xf(ms(l,c),r.colorSpace).setup(e).build(e,c)),e.format(l,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=G(e),t.referenceNode=this.getSelf(),G(t)}blur(e){const t=this.clone();return t.biasNode=G(e).mul(HM(t)),t.referenceNode=this.getSelf(),G(t)}level(e){const t=this.clone();return t.levelNode=G(e),t.referenceNode=this.getSelf(),G(t)}size(e){return fs(this,e)}bias(e){const t=this.clone();return t.biasNode=G(e),t.referenceNode=this.getSelf(),G(t)}compare(e){const t=this.clone();return t.compareNode=G(e),t.referenceNode=this.getSelf(),G(t)}grad(e,t){const i=this.clone();return i.gradNode=[G(e),G(t)],i.referenceNode=this.getSelf(),G(i)}depth(e){const t=this.clone();return t.depthNode=G(e),t.referenceNode=this.getSelf(),G(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()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const yt=K(mn),Br=(...n)=>yt(...n).setSampler(!1),J2=n=>(n.isNode===!0?n:yt(n)).convert("sampler"),ho=fe("float").label("cameraNear").setGroup(xt).onRenderUpdate(({camera:n})=>n.near),po=fe("float").label("cameraFar").setGroup(xt).onRenderUpdate(({camera:n})=>n.far),GM=fe("float").label("cameraLogDepth").setGroup(xt).onRenderUpdate(({camera:n})=>2/(Math.log(n.far+1)/Math.LN2)),lr=fe("mat4").label("cameraProjectionMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrix),K2=fe("mat4").label("cameraProjectionMatrixInverse").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrixInverse),cr=fe("mat4").label("cameraViewMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorldInverse),Z2=fe("mat4").label("cameraWorldMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorld),Q2=fe("mat3").label("cameraNormalMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.normalMatrix),Jf=fe(new N).label("cameraPosition").setGroup(xt).onRenderUpdate(({camera:n},e)=>e.value.setFromMatrixPosition(n.matrixWorld));class St extends qe{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=je.OBJECT,this._uniformNode=new Js(null)}getNodeType(){const e=this.scope;if(e===St.WORLD_MATRIX)return"mat4";if(e===St.POSITION||e===St.VIEW_POSITION||e===St.DIRECTION||e===St.SCALE)return"vec3"}update(e){const t=this.object3d,i=this._uniformNode,r=this.scope;if(r===St.WORLD_MATRIX)i.value=t.matrixWorld;else if(r===St.POSITION)i.value=i.value||new N,i.value.setFromMatrixPosition(t.matrixWorld);else if(r===St.SCALE)i.value=i.value||new N,i.value.setFromMatrixScale(t.matrixWorld);else if(r===St.DIRECTION)i.value=i.value||new N,t.getWorldDirection(i.value);else if(r===St.VIEW_POSITION){const s=e.camera;i.value=i.value||new N,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===St.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===St.POSITION||t===St.VIEW_POSITION||t===St.DIRECTION||t===St.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}St.WORLD_MATRIX="worldMatrix",St.POSITION="position",St.SCALE="scale",St.VIEW_POSITION="viewPosition",St.DIRECTION="direction";const eL=K(St,St.DIRECTION),tL=K(St,St.WORLD_MATRIX),iL=K(St,St.POSITION),rL=K(St,St.SCALE),nL=K(St,St.VIEW_POSITION);class tn extends St{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const sL=ge(tn,tn.DIRECTION),zr=ge(tn,tn.WORLD_MATRIX),aL=ge(tn,tn.POSITION),oL=ge(tn,tn.SCALE),lL=ge(tn,tn.VIEW_POSITION),WM=fe(new Ke).onObjectUpdate(({object:n},e)=>e.value.getNormalMatrix(n.matrixWorld)),jM=fe(new Re).onObjectUpdate(({object:n},e)=>e.value.copy(n.matrixWorld).invert()),fn=cr.mul(zr).toVar("modelViewMatrix_2"),cL=U(n=>(n.context.isHighPrecisionModelViewMatrix=!0,fe("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),uL=U(n=>{const e=n.context.isHighPrecisionModelViewMatrix;return fe("mat3").onObjectUpdate(({object:t,camera:i})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highPrecisionModelNormalMatrix"),Li=_i("position","vec3"),Zt=Li.varying("positionLocal"),Yh=Li.varying("positionPrevious"),$h=zr.mul(Zt).xyz.varying("v_positionWorld"),Kf=Zt.transformDirection(zr).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),Pi=fn.mul(Zt).xyz.varying("v_positionView"),Vt=Pi.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class XM extends qe{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:i}=e;return t.coordinateSystem===Rr&&i.side===si?"false":e.getFrontFacing()}}const qM=ge(XM),Jl=E(qM).mul(2).sub(1),Jh=_i("normal","vec3"),ur=U(n=>n.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),D(0,1,0)):Jh,"vec3").once()().toVar("normalLocal"),YM=Pi.dFdx().cross(Pi.dFdy()).normalize().toVar("normalFlat"),hr=U(n=>{let e;return n.material.flatShading===!0?e=YM:e=Ii(Qf(ur),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Kh=Ii(hr.transformDirection(cr),"v_normalWorld").normalize().toVar("normalWorld"),Yt=U(n=>n.context.setupNormal(),"vec3").once()().mul(Jl).toVar("transformedNormalView"),Zf=Yt.transformDirection(cr).toVar("transformedNormalWorld"),mo=U(n=>n.context.setupClearcoatNormal(),"vec3").once()().mul(Jl).toVar("transformedClearcoatNormalView"),$M=U(([n,e=zr])=>{const t=yi(e),i=n.div(D(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(i).xyz}),Qf=U(([n],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(n);const i=WM.mul(n);return cr.transformDirection(i)}),JM=fe(0).onReference(({material:n})=>n).onRenderUpdate(({material:n})=>n.refractionRatio),KM=Vt.negate().reflect(Yt),ZM=Vt.negate().refract(Yt,JM),QM=KM.transformDirection(cr).toVar("reflectVector"),e1=ZM.transformDirection(cr).toVar("reflectVector");class t1 extends mn{static get type(){return"CubeTextureNode"}constructor(e,t=null,i=null,r=null){super(e,t,i,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===fr?QM:e.mapping===Ar?e1:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),D(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const i=this.value;return e.renderer.coordinateSystem===ws||!i.isRenderTargetTexture?D(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const Zh=K(t1);class Qh extends Js{static get type(){return"BufferNode"}constructor(e,t,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=i}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const Kl=(n,e,t)=>G(new Qh(n,e,t));class hL extends cs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),i=this.getNodeType();return e.format(t,"vec4",i)}}class eg extends Qh{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=je.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,i=this.getElementLength(),r=this.getElementType();if(i===1)for(let s=0;s<e.length;s++){const a=s*4;t[a]=e[s]}else if(r==="color")for(let s=0;s<e.length;s++){const a=s*4,o=e[s];t[a]=o.r,t[a+1]=o.g,t[a+2]=o.b||0}else for(let s=0;s<e.length;s++){const a=s*4,o=e[s];t[a]=o.x,t[a+1]=o.y,t[a+2]=o.z||0,t[a+3]=o.w||0}}setup(e){const t=this.array.length;this._elementType=this.elementType===null?Pn(this.array[0]):this.elementType,this._elementLength=e.getTypeLength(this._elementType);let i=Float32Array;return this._elementType.charAt(0)==="i"?i=Int32Array:this._elementType.charAt(0)==="u"&&(i=Uint32Array),this.value=new i(t*4),this.bufferCount=t,this.bufferType=e.changeComponentType("vec4",e.getComponentType(this._elementType)),super.setup(e)}element(e){return G(new hL(this,G(e)))}}const gn=(n,e)=>G(new eg(n,e)),dL=(n,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),G(new eg(n,e)));class pL extends cs{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 Zl extends qe{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=je.OBJECT}element(e){return G(new pL(this,G(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=Kl(null,e,this.count):Array.isArray(this.getValueFromReference())?t=gn(null,e):e==="texture"?t=yt(null):e==="cubeTexture"?t=Zh(null):t=fe(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}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 fi=(n,e,t)=>G(new Zl(n,e,t)),tg=(n,e,t,i)=>G(new Zl(n,e,i,t));class i1 extends Zl{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 rn=(n,e,t)=>G(new i1(n,e,t)),ed=U(n=>(n.geometry.hasAttribute("tangent")===!1&&n.geometry.computeTangents(),_i("tangent","vec4")))(),Ql=ed.xyz.toVar("tangentLocal"),ec=fn.mul(ae(Ql,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),r1=ec.transformDirection(cr).varying("v_tangentWorld").normalize().toVar("tangentWorld"),ig=ec.toVar("transformedTangentView"),mL=ig.transformDirection(cr).normalize().toVar("transformedTangentWorld"),tc=n=>n.mul(ed.w).xyz,fL=Ii(tc(Jh.cross(ed)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),gL=Ii(tc(ur.cross(Ql)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),n1=Ii(tc(hr.cross(ec)),"v_bitangentView").normalize().toVar("bitangentView"),vL=Ii(tc(Kh.cross(r1)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),s1=tc(Yt.cross(ig)).normalize().toVar("transformedBitangentView"),yL=s1.transformDirection(cr).normalize().toVar("transformedBitangentWorld"),ia=yi(ec,n1,hr),a1=Vt.mul(ia),xL=(n,e)=>n.sub(a1.mul(e)),o1=(()=>{let n=Zs.cross(Vt);return n=n.cross(Zs).normalize(),n=rt(n,Yt,hs.mul(pn.oneMinus()).oneMinus().pow2().pow2()).normalize(),n})(),_L=U(n=>{const{eye_pos:e,surf_norm:t,mapN:i,uv:r}=n,s=e.dFdx(),a=e.dFdy(),o=r.dFdx(),l=r.dFdy(),c=t,u=a.cross(c),h=c.cross(s),d=u.mul(o.x).add(h.mul(l.x)),p=u.mul(o.y).add(h.mul(l.y)),m=d.dot(d).max(p.dot(p)),v=Jl.mul(m.inverseSqrt());return zt(d.mul(i.x,v),p.mul(i.y,v),c.mul(i.z)).normalize()});class l1 extends pt{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=on}setup(e){const{normalMapType:t,scaleNode:i}=this;let r=this.node.mul(2).sub(1);i!==null&&(r=D(r.xy.mul(i),r.z));let s=null;return t===vp?s=Qf(r):t===on&&(e.hasGeometryAttribute("tangent")===!0?s=ia.mul(r).normalize():s=_L({eye_pos:Pi,surf_norm:hr,mapN:r,uv:nt()})),s}}const rg=K(l1),ML=U(({textureNode:n,bumpScale:e})=>{const t=r=>n.cache().context({getUV:s=>r(s.uvNode||nt()),forceUVContext:!0}),i=E(t(r=>r));return z(E(t(r=>r.add(r.dFdx()))).sub(i),E(t(r=>r.add(r.dFdy()))).sub(i)).mul(e)}),TL=U(n=>{const{surf_pos:e,surf_norm:t,dHdxy:i}=n,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,o=s.cross(a),l=a.cross(r),c=r.dot(o).mul(Jl),u=c.sign().mul(i.x.mul(o).add(i.y.mul(l)));return c.abs().mul(t).sub(u).normalize()});class c1 extends pt{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=ML({textureNode:this.textureNode,bumpScale:e});return TL({surf_pos:Pi,surf_norm:hr,dHdxy:t})}}const u1=K(c1),h1=new Map;class Z extends qe{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=h1.get(e);return i===void 0&&(i=rn(e,t),h1.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===Z.COLOR){const s=t.color!==void 0?this.getColor(i):D();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(i===Z.OPACITY){const s=this.getFloat(i);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(i===Z.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=E(1);else if(i===Z.SPECULAR_INTENSITY){const s=this.getFloat(i);t.specularMap?r=s.mul(this.getTexture(i).a):r=s}else if(i===Z.SPECULAR_COLOR){const s=this.getColor(i);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(i).rgb):r=s}else if(i===Z.ROUGHNESS){const s=this.getFloat(i);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).g):r=s}else if(i===Z.METALNESS){const s=this.getFloat(i);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(i).b):r=s}else if(i===Z.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(i).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(i)):r=a}else if(i===Z.NORMAL)t.normalMap?(r=rg(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=u1(this.getTexture("bump").r,this.getFloat("bumpScale")):r=hr;else if(i===Z.CLEARCOAT){const s=this.getFloat(i);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.CLEARCOAT_ROUGHNESS){const s=this.getFloat(i);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=rg(this.getTexture(i),this.getCache(i+"Scale","vec2")):r=hr;else if(i===Z.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(i===Z.SHEEN_ROUGHNESS){const s=this.getFloat(i);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).a):r=s,r=r.clamp(.07,1)}else if(i===Z.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(i);r=Ol(go.x,go.y,go.y.negate(),go.x).mul(s.rg.mul(2).sub(z(1)).normalize().mul(s.b))}else r=go;else if(i===Z.IRIDESCENCE_THICKNESS){const s=fi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=fi("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(i).g).add(a)}else r=s}else if(i===Z.TRANSMISSION){const s=this.getFloat(i);t.transmissionMap?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.THICKNESS){const s=this.getFloat(i);t.thicknessMap?r=s.mul(this.getTexture(i).g):r=s}else if(i===Z.IOR)r=this.getFloat(i);else if(i===Z.LIGHT_MAP)r=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===Z.AO_MAP)r=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(i,s)}return r}}Z.ALPHA_TEST="alphaTest",Z.COLOR="color",Z.OPACITY="opacity",Z.SHININESS="shininess",Z.SPECULAR="specular",Z.SPECULAR_STRENGTH="specularStrength",Z.SPECULAR_INTENSITY="specularIntensity",Z.SPECULAR_COLOR="specularColor",Z.REFLECTIVITY="reflectivity",Z.ROUGHNESS="roughness",Z.METALNESS="metalness",Z.NORMAL="normal",Z.CLEARCOAT="clearcoat",Z.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Z.CLEARCOAT_NORMAL="clearcoatNormal",Z.EMISSIVE="emissive",Z.ROTATION="rotation",Z.SHEEN="sheen",Z.SHEEN_ROUGHNESS="sheenRoughness",Z.ANISOTROPY="anisotropy",Z.IRIDESCENCE="iridescence",Z.IRIDESCENCE_IOR="iridescenceIOR",Z.IRIDESCENCE_THICKNESS="iridescenceThickness",Z.IOR="ior",Z.TRANSMISSION="transmission",Z.THICKNESS="thickness",Z.ATTENUATION_DISTANCE="attenuationDistance",Z.ATTENUATION_COLOR="attenuationColor",Z.LINE_SCALE="scale",Z.LINE_DASH_SIZE="dashSize",Z.LINE_GAP_SIZE="gapSize",Z.LINE_WIDTH="linewidth",Z.LINE_DASH_OFFSET="dashOffset",Z.POINT_WIDTH="pointWidth",Z.DISPERSION="dispersion",Z.LIGHT_MAP="light",Z.AO_MAP="ao";const d1=ge(Z,Z.ALPHA_TEST),fo=ge(Z,Z.COLOR),p1=ge(Z,Z.SHININESS),m1=ge(Z,Z.EMISSIVE),td=ge(Z,Z.OPACITY),f1=ge(Z,Z.SPECULAR),ng=ge(Z,Z.SPECULAR_INTENSITY),g1=ge(Z,Z.SPECULAR_COLOR),ic=ge(Z,Z.SPECULAR_STRENGTH),id=ge(Z,Z.REFLECTIVITY),v1=ge(Z,Z.ROUGHNESS),y1=ge(Z,Z.METALNESS),x1=ge(Z,Z.NORMAL).context({getUV:null}),_1=ge(Z,Z.CLEARCOAT),M1=ge(Z,Z.CLEARCOAT_ROUGHNESS),T1=ge(Z,Z.CLEARCOAT_NORMAL).context({getUV:null}),b1=ge(Z,Z.ROTATION),S1=ge(Z,Z.SHEEN),w1=ge(Z,Z.SHEEN_ROUGHNESS),E1=ge(Z,Z.ANISOTROPY),A1=ge(Z,Z.IRIDESCENCE),N1=ge(Z,Z.IRIDESCENCE_IOR),C1=ge(Z,Z.IRIDESCENCE_THICKNESS),R1=ge(Z,Z.TRANSMISSION),I1=ge(Z,Z.THICKNESS),L1=ge(Z,Z.IOR),P1=ge(Z,Z.ATTENUATION_DISTANCE),D1=ge(Z,Z.ATTENUATION_COLOR),rd=ge(Z,Z.LINE_SCALE),sg=ge(Z,Z.LINE_DASH_SIZE),ag=ge(Z,Z.LINE_GAP_SIZE),nd=ge(Z,Z.LINE_WIDTH),og=ge(Z,Z.LINE_DASH_OFFSET),U1=ge(Z,Z.POINT_WIDTH),O1=ge(Z,Z.DISPERSION),lg=ge(Z,Z.LIGHT_MAP),F1=ge(Z,Z.AO_MAP),go=fe(new J).onReference(function(n){return n.material}).onRenderUpdate(function({material:n}){this.value.set(n.anisotropy*Math.cos(n.anisotropyRotation),n.anisotropy*Math.sin(n.anisotropyRotation))});class V1 extends pt{static get type(){return"ModelViewProjectionNode"}constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if(e.shaderStage==="fragment")return Ii(e.context.mvp);const t=this.positionNode||Zt,i=e.renderer.nodes.modelViewMatrix||fn;return lr.mul(i).mul(t)}}const cg=K(V1);class Bt extends qe{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),i=this.scope;let r;if(i===Bt.VERTEX)r=e.getVertexIndex();else if(i===Bt.INSTANCE)r=e.getInstanceIndex();else if(i===Bt.DRAW)r=e.getDrawIndex();else if(i===Bt.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(i===Bt.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(i===Bt.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+i);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=Ii(this).build(e,t),s}}Bt.VERTEX="vertex",Bt.INSTANCE="instance",Bt.SUBGROUP="subgroup",Bt.INVOCATION_LOCAL="invocationLocal",Bt.INVOCATION_SUBGROUP="invocationSubgroup",Bt.DRAW="draw";const B1=ge(Bt,Bt.VERTEX),rc=ge(Bt,Bt.INSTANCE),bL=ge(Bt,Bt.SUBGROUP),SL=ge(Bt,Bt.INVOCATION_SUBGROUP),wL=ge(Bt,Bt.INVOCATION_LOCAL),z1=ge(Bt,Bt.DRAW);class k1 extends qe{static get type(){return"InstanceNode"}constructor(e){super("void"),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=je.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,i=this.instanceColorNode;const r=this.instanceMesh;if(t===null){const o=r.instanceMatrix;if(r.count<=1e3)t=Kl(o.array,"mat4",Math.max(r.count,1)).element(rc);else{const l=new Zm(o.array,16,1);this.buffer=l;const c=o.usage===Ss?qf:qh,u=[c(l,"vec4",16,0),c(l,"vec4",16,4),c(l,"vec4",16,8),c(l,"vec4",16,12)];t=$s(...u)}this.instanceMatrixNode=t}const s=r.instanceColor;if(s&&i===null){const o=new Rn(s.array,3),l=s.usage===Ss?qf:qh;this.bufferColor=o,i=D(l(o,"vec3",3,0)),this.instanceColorNode=i}const a=t.mul(Zt).xyz;if(Zt.assign(a),e.hasGeometryAttribute("normal")){const o=$M(ur,t);ur.assign(o)}this.instanceColorNode!==null&&Zr("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==Ss&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==Ss&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const H1=K(k1);class G1 extends qe{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=rc:this.batchingIdNode=z1);const t=U(([p])=>{const m=fs(Br(this.batchMesh._indirectTexture),0),v=P(p).modInt(P(m)),f=P(p).div(P(m));return Br(this.batchMesh._indirectTexture,dn(v,f)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(P(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=fs(Br(i),0),s=E(t).mul(4).toInt().toVar(),a=s.modInt(r),o=s.div(P(r)),l=$s(Br(i,dn(a,o)),Br(i,dn(a.add(1),o)),Br(i,dn(a.add(2),o)),Br(i,dn(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){const p=U(([m])=>{const v=fs(Br(c),0).x,f=m,g=f.modInt(v),x=f.div(v);return Br(c,dn(g,x)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);Zr("vec3","vBatchColor").assign(p)}const u=yi(l);Zt.assign(l.mul(Zt));const h=ur.div(D(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),d=u.mul(h).xyz;ur.assign(d),e.hasGeometryAttribute("tangent")&&Ql.mulAssign(u)}}const W1=K(G1),j1=new WeakMap;class ug extends qe{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=je.OBJECT,this.skinIndexNode=_i("skinIndex","uvec4"),this.skinWeightNode=_i("skinWeight","vec4");let i,r,s;t?(i=fi("bindMatrix","mat4"),r=fi("bindMatrixInverse","mat4"),s=tg("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(i=fe(e.bindMatrix,"mat4"),r=fe(e.bindMatrixInverse,"mat4"),s=Kl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=i,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=Zt){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),c=e.element(i.z),u=e.element(i.w),h=s.mul(t),d=zt(o.mul(r.x).mul(h),l.mul(r.y).mul(h),c.mul(r.z).mul(h),u.mul(r.w).mul(h));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ur){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),c=e.element(i.z),u=e.element(i.w);let h=zt(r.x.mul(o),r.y.mul(l),r.z.mul(c),r.w.mul(u));return h=a.mul(h).mul(s),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=tg("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Yh)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&Yh.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(Zt.assign(t),e.hasGeometryAttribute("normal")){const i=this.getSkinnedNormal();ur.assign(i),e.hasGeometryAttribute("tangent")&&Ql.assign(i)}}generate(e,t){if(t!=="void")return Zt.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;j1.get(t)!==e.frameId&&(j1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const EL=n=>G(new ug(n)),X1=n=>G(new ug(n,!0));class q1 extends qe{static get type(){return"LoopNode"}constructor(e=[]){super(),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 s=0,a=this.params.length-1;s<a;s++){const o=this.params[s],l=o.isNode!==!0&&o.name||this.getVarName(s),c=o.isNode!==!0&&o.type||"int";i[l]=ms(l,c)}const r=e.addStack();return t.returnsNode=this.params[this.params.length-1](i,r,e),t.stackNode=r,e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),i=this.params,r=t.stackNode;for(let o=0,l=i.length-1;o<l;o++){const c=i[o];let u=null,h=null,d=null,p=null,m=null,v=null;c.isNode?(p="int",d=this.getVarName(o),u="0",h=c.build(e,p),m="<"):(p=c.type||"int",d=c.name||this.getVarName(o),u=c.start,h=c.end,m=c.condition,v=c.update,typeof u=="number"?u=u.toString():u&&u.isNode&&(u=u.build(e,p)),typeof h=="number"?h=h.toString():h&&h.isNode&&(h=h.build(e,p)),u!==void 0&&h===void 0?(u=u+" - 1",h="0",m=">="):h!==void 0&&u===void 0&&(u="0",m="<"),m===void 0&&(Number(u)>Number(h)?m=">=":m="<"));const f={start:u,end:h},g=f.start,x=f.end;let y="",_="",I="";v||(p==="int"||p==="uint"?m.includes("<")?v="++":v="--":m.includes("<")?v="+= 1.":v="-= 1."),y+=e.getVar(p,d)+" = "+g,_+=d+" "+m+" "+x,I+=d+" "+v;const T=`for ( ${y}; ${_}; ${I} )`;e.addFlowCode((o===0?`
|
|
3857
3857
|
`:"")+e.tab+T+` {
|
|
3858
3858
|
|
|
3859
3859
|
`).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
|
|
3860
3860
|
`+e.tab+s);for(let o=0,l=this.params.length-1;o<l;o++)e.addFlowCode((o===0?"":e.tab)+`}
|
|
3861
3861
|
|
|
3862
|
-
`).removeFlowTab();return e.addFlowTab(),a}}const gt=(...n)=>G(new X1(qs(n,"int"))).append(),AL=()=>ps("continue").append(),nd=()=>ps("break").append(),NL=(...n)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),gt(...n)),ug=new WeakMap,br=new st,q1=U(({bufferMap:n,influence:e,stride:t,width:i,depth:r,offset:s})=>{const a=P(V1).mul(t).add(s),o=a.div(i),l=a.sub(o.mul(i));return Br(n,dn(l,o)).depth(r).mul(e)});function CL(n){const e=n.morphAttributes.position!==void 0,t=n.morphAttributes.normal!==void 0,i=n.morphAttributes.color!==void 0,r=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,s=r!==void 0?r.length:0;let a=ug.get(n);if(a===void 0||a.count!==s){let o=function(){f.dispose(),ug.delete(n),n.removeEventListener("dispose",o)};a!==void 0&&a.texture.dispose();const l=n.morphAttributes.position||[],c=n.morphAttributes.normal||[],u=n.morphAttributes.color||[];let h=0;e===!0&&(h=1),t===!0&&(h=2),i===!0&&(h=3);let d=n.attributes.position.count*h,p=1;const m=4096;d>m&&(p=Math.ceil(d/m),d=m);const v=new Float32Array(d*p*4*s),f=new tl(v,d,p,s);f.type=Oi,f.needsUpdate=!0;const g=h*4;for(let x=0;x<s;x++){const y=l[x],_=c[x],I=u[x],T=d*p*4*x;for(let w=0;w<y.count;w++){const C=w*g;e===!0&&(br.fromBufferAttribute(y,w),v[T+C+0]=br.x,v[T+C+1]=br.y,v[T+C+2]=br.z,v[T+C+3]=0),t===!0&&(br.fromBufferAttribute(_,w),v[T+C+4]=br.x,v[T+C+5]=br.y,v[T+C+6]=br.z,v[T+C+7]=0),i===!0&&(br.fromBufferAttribute(I,w),v[T+C+8]=br.x,v[T+C+9]=br.y,v[T+C+10]=br.z,v[T+C+11]=I.itemSize===4?br.w:1)}}a={count:s,texture:f,stride:h,size:new J(d,p)},ug.set(n,a),n.addEventListener("dispose",o)}return a}class Y1 extends qe{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=fe(1),this.updateType=je.OBJECT}setup(e){const{geometry:t}=e,i=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=s!==void 0?s.length:0,{texture:o,stride:l,size:c}=CL(t);i===!0&&Zt.mulAssign(this.morphBaseInfluence),r===!0&&ur.mulAssign(this.morphBaseInfluence);const u=P(c.width);gt(a,({i:h})=>{const d=E(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(Br(this.mesh.morphTexture,dn(P(h).add(1),P(ic))).r):d.assign(fi("morphTargetInfluences","float").element(h).toVar()),i===!0&&Zt.addAssign(q1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(0)})),r===!0&&ur.addAssign(q1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(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 $1=K(Y1),RL=n=>n.sort((e,t)=>e.id-t.id),IL=(n,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===n)return t;return null},hg=new WeakMap;class J1 extends qe{static get type(){return"LightsNode"}constructor(e=[]){super("vec3"),this.totalDiffuseNode=D().toVar("totalDiffuse"),this.totalSpecularNode=D().toVar("totalSpecular"),this.outgoingLightNode=D().toVar("outgoingLight"),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const i of this._lightNodes)t.push(i.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const i of t.nodes)i.build(e)}setupLightsNode(e){const t=[],i=this._lightNodes,r=RL(this._lights),s=e.renderer.nodes.library;for(const a of r)if(a.isNode)t.push(G(a));else{let o=null;if(i!==null&&(o=IL(a.id,i)),o===null){const l=s.getLightNodeClass(a.constructor);if(l===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let c=null;hg.has(a)?c=hg.get(a):(c=new l(a),hg.set(a,c)),t.push(c)}}this._lightNodes=t}setup(e){this._lightNodes===null&&this.setupLightsNode(e);const t=e.context,i=t.lightingModel;let r=this.outgoingLightNode;if(i){const{_lightNodes:s,totalDiffuseNode:a,totalSpecularNode:o}=this;t.outgoingLight=r;const l=e.addStack(),c=e.getDataFromNode(this);c.nodes=l.nodes,i.start(t,l,e);for(const g of s)g.build(e);i.indirect(t,l,e);const{backdrop:u,backdropAlpha:h}=t,{directDiffuse:d,directSpecular:p,indirectDiffuse:m,indirectSpecular:v}=t.reflectedLight;let f=d.add(m);u!==null&&(h!==null?f=D(h.mix(f,u)):f=D(u),t.material.transparent=!0),a.assign(f),o.assign(p.add(v)),r.assign(a.add(o)),i.finish(t,l,e),r=r.bypass(e.removeStack())}return r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}const K1=K(J1);class ia extends qe{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class Z1 extends ia{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Q1 extends kf{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=D().toVar("directDiffuse"),r=D().toVar("directSpecular"),s=D().toVar("indirectDiffuse"),a=D().toVar("indirectSpecular"),o={directDiffuse:i,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:D().toVar("radiance"),irradiance:D().toVar("irradiance"),iblIrradiance:D().toVar("iblIrradiance"),ambientOcclusion:E(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 eT=K(Q1);class tT extends ia{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let rc,nc;class ri extends qe{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ri.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=je.NONE;return(this.scope===ri.SIZE||this.scope===ri.VIEWPORT)&&(e=je.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ri.VIEWPORT?t!==null?nc.copy(t.viewport):(e.getViewport(nc),nc.multiplyScalar(e.getPixelRatio())):t!==null?(rc.width=t.width,rc.height=t.height):e.getDrawingBufferSize(rc)}setup(){const e=this.scope;let t=null;return e===ri.SIZE?t=fe(rc||(rc=new J)):e===ri.VIEWPORT?t=fe(nc||(nc=new st)):t=z(vo.div(go)),t}generate(e){if(this.scope===ri.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(go).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${i}.y - ${t}.y )`}return t}return super.generate(e)}}ri.COORDINATE="coordinate",ri.VIEWPORT="viewport",ri.SIZE="size",ri.UV="uv";const fs=ge(ri,ri.UV),go=ge(ri,ri.SIZE),vo=ge(ri,ri.COORDINATE),Dn=ge(ri,ri.VIEWPORT),iT=Dn.zw,rT=vo.sub(Dn.xy),LL=rT.div(iT),PL=U(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),go),"vec2").once()(),DL=U(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),fs),"vec2").once()(),UL=U(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),fs.flipY()),"vec2").once()(),sc=new J;class ac extends mn{static get type(){return"ViewportTextureNode"}constructor(e=fs,t=null,i=null){i===null&&(i=new vm,i.minFilter=Xi),super(i,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=je.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(sc);const i=this.value;(i.image.width!==sc.width||i.image.height!==sc.height)&&(i.image.width=sc.width,i.image.height=sc.height,i.needsUpdate=!0);const r=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const OL=K(ac),nT=K(ac,null,null,{generateMipmaps:!0});let dg=null;class sT extends ac{static get type(){return"ViewportDepthTextureNode"}constructor(e=fs,t=null){dg===null&&(dg=new Os),super(e,t,dg)}}const pg=K(sT);class Qi extends qe{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===Qi.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,i=this.valueNode;let r=null;if(t===Qi.DEPTH_BASE)i!==null&&(r=oT().assign(i));else if(t===Qi.DEPTH)e.isPerspectiveCamera?r=aT(Pi.z,uo,ho):r=oc(Pi.z,uo,ho);else if(t===Qi.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const s=mg(i,uo,ho);r=oc(s,uo,ho)}else r=i;else r=oc(Pi.z,uo,ho);return r}}Qi.DEPTH_BASE="depthBase",Qi.DEPTH="depth",Qi.LINEAR_DEPTH="linearDepth";const oc=(n,e,t)=>n.add(e).div(e.sub(t)),FL=(n,e,t)=>e.sub(t).mul(n).sub(e),aT=(n,e,t)=>e.add(n).mul(t).div(t.sub(e).mul(n)),mg=(n,e,t)=>e.mul(t).div(t.sub(e).mul(n).sub(t)),oT=K(Qi,Qi.DEPTH_BASE),fg=ge(Qi,Qi.DEPTH),sd=K(Qi,Qi.LINEAR_DEPTH),VL=sd(pg());fg.assign=n=>oT(n);class ys extends qe{static get type(){return"ClippingNode"}constructor(e=ys.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{localClipIntersection:i,localClippingCount:r,globalClippingCount:s}=t,a=s+r,o=i?a-r:a;return this.scope===ys.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,a,o):this.setupDefault(t.planes,a,o)}setupAlphaToCoverage(e,t,i){return U(()=>{const r=gn(e),s=ar("float","distanceToPlane"),a=ar("float","distanceToGradient"),o=ar("float","clipOpacity");o.assign(1);let l;if(gt(i,({i:c})=>{l=r.element(c),s.assign(Pi.dot(l.xyz).negate().add(l.w)),a.assign(s.fwidth().div(2)),o.mulAssign(Ki(a.negate(),a,s)),o.equal(0).discard()}),i<t){const c=ar("float","unionclipOpacity");c.assign(1),gt({start:i,end:t},({i:u})=>{l=r.element(u),s.assign(Pi.dot(l.xyz).negate().add(l.w)),a.assign(s.fwidth().div(2)),c.mulAssign(Ki(a.negate(),a,s).oneMinus())}),o.mulAssign(c.oneMinus())}Nt.a.mulAssign(o),Nt.a.equal(0).discard()})()}setupDefault(e,t,i){return U(()=>{const r=gn(e);let s;if(gt(i,({i:a})=>{s=r.element(a),Pi.dot(s.xyz).greaterThan(s.w).discard()}),i<t){const a=ar("bool","clipped");a.assign(!0),gt({start:i,end:t},({i:o})=>{s=r.element(o),a.assign(Pi.dot(s.xyz).greaterThan(s.w).and(a))}),a.discard()}})()}}ys.ALPHA_TO_COVERAGE="alphaToCoverage",ys.DEFAULT="default";const BL=()=>G(new ys),zL=()=>G(new ys(ys.ALPHA_TO_COVERAGE));class Tt extends hi{static get type(){return"NodeMaterial"}constructor(){super(),this.isNodeMaterial=!0,this.type=this.constructor.type,this.forceSinglePass=!1,this.fog=!0,this.lights=!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.positionNode=null,this.depthNode=null,this.shadowNode=null,this.shadowPositionNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+rf(this)}build(e){this.setup(e)}setupObserver(e){return new qx(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow("vertex",e.removeStack()),e.addStack();let t;const i=this.setupClipping(e);if(this.depthWrite===!0&&this.setupDepth(e),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const r=this.setupLighting(e);i!==null&&e.stack.add(i);const s=ae(r,Nt.a).max(0);if(t=this.setupOutput(e,s),wf.assign(t),this.outputNode!==null&&(t=this.outputNode),e.renderer.getRenderTarget()!==null){const a=e.renderer.getMRT(),o=this.mrtNode;a!==null?(t=a,o!==null&&(t=a.merge(o))):o!==null&&(t=o)}}else{let r=this.fragmentNode;r.isOutputStructNode!==!0&&(r=ae(r)),t=this.setupOutput(e,r)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{globalClippingCount:t,localClippingCount:i}=e.clippingContext;let r=null;if(t||i){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=zL():e.stack.add(BL())}return r}setupDepth(e){const{renderer:t}=e;let i=this.depthNode;if(i===null){const r="getMRT"in t&&t.getMRT();r&&r.has("depth")?i=r.get("depth"):t.logarithmicDepthBuffer===!0&&(i=lg().w.add(1).log2().mul(HM).mul(.5))}i!==null&&fg.assign(i).append()}setupPosition(e){const{object:t}=e,i=t.geometry;if(e.addStack(),(i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&$1(t).append(),t.isSkinnedMesh===!0&&j1(t).append(),this.displacementMap){const s=rn("displacementMap","texture"),a=rn("displacementScale","float"),o=rn("displacementBias","float");Zt.addAssign(ur.normalize().mul(s.x.mul(a).add(o)))}t.isBatchedMesh&&G1(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&k1(t).append(),this.positionNode!==null&&Zt.assign(this.positionNode);const r=lg();return e.context.vertex=e.removeStack(),e.context.mvp=r,r}setupDiffuseColor({object:e,geometry:t}){let i=this.colorNode?ae(this.colorNode):mo;this.vertexColors===!0&&t.hasAttribute("color")&&(i=ae(i.xyz.mul(_i("color","vec3")),i.a)),e.instanceColor&&(i=Zr("vec3","vInstanceColor").mul(i)),e.isBatchedMesh&&e._colorsTexture&&(i=Zr("vec3","vBatchColor").mul(i)),Nt.assign(i);const r=this.opacityNode?E(this.opacityNode):ed;if(Nt.a.assign(Nt.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?E(this.alphaTestNode):h1;Nt.a.lessThanEqual(s).discard()}this.transparent===!1&&this.blending===Tn&&this.alphaToCoverage===!1&&Nt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?D(0):Nt.rgb}setupNormal(){return this.normalNode?D(this.normalNode):y1}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?rn("envMap","cubeTexture"):rn("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new tT(og)),t}setupLights(e){const t=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&t.push(i);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:O1;t.push(new Z1(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=K1([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:i,backdropAlphaNode:r,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let o=this.setupOutgoingLight(e);if(a&&a.getScope().getLights().length>0){const l=this.setupLightingModel(e);o=eT(a,l,i,r)}else i!==null&&(o=D(r!==null?rt(o,i,r):i));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Tf.assign(D(s||p1)),o=o.add(Tf)),o}setupOutput(e,t){if(this.fog===!0){const i=e.fogNode;i&&(t=ae(i.mix(t.rgb,i.colorNode),t.a))}return 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=hi.prototype.toJSON.call(this,e),r=Rl(this);i.inputNodes={};for(const{property:a,childNode:o}of r)i.inputNodes[a]=o.toJSON(e).uuid;function s(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(t){const a=s(e.textures),o=s(e.images),l=s(e.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,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.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const kL=new Za;class HL extends Tt{static get type(){return"InstancedPointsNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(kL),this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,i=this.useColor;this.vertexNode=U(()=>{const r=_i("instancePosition").xyz,s=ae(fn.mul(ae(r,1))),a=Dn.z.div(Dn.w),o=lr.mul(s),l=Li.xy.toVar();return l.mulAssign(this.pointWidthNode?this.pointWidthNode:D1),l.assign(l.div(Dn.z)),l.y.assign(l.y.mul(a)),l.assign(l.mul(o.w)),o.addAssign(ae(l,0,0)),o})(),this.fragmentNode=U(()=>{const r=E(1).toVar(),s=Vf(nt().mul(2).sub(1));if(t&&e.samples>1){const o=E(s.fwidth()).toVar();r.assign(Ki(o.oneMinus(),o.add(1),s).oneMinus())}else s.greaterThan(1).discard();let a;return this.pointColorNode?a=this.pointColorNode:i?a=_i("instanceColor").mul(mo):a=mo,r.mulAssign(ed),ae(a,r)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const GL=new Ni;class WL extends Tt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(GL),this.setValues(e)}}const jL=new vh;class XL extends Tt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(jL),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode,t=this.dashScaleNode?E(this.dashScaleNode):id,i=this.dashSizeNode?E(this.dashSizeNode):ng,r=this.dashSizeNode?E(this.dashGapNode):sg;Zs.assign(i),zl.assign(r);const s=Ii(_i("lineDistance").mul(t));(e?s.add(e):s).mod(Zs.add(zl)).greaterThan(Zs).discard()}}const qL=new vh;class YL extends Tt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(qL),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,i=this.useColor,r=this.dashed,s=this.worldUnits,a=U(({start:l,end:c})=>{const u=lr.element(2).element(2),h=lr.element(3).element(2).mul(-.5).div(u).sub(l.z).div(c.z.sub(l.z));return ae(rt(l.xyz,c.xyz,h),c.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=U(()=>{const l=_i("instanceStart"),c=_i("instanceEnd"),u=ae(fn.mul(ae(l,1))).toVar("start"),h=ae(fn.mul(ae(c,1))).toVar("end");s&&(Zr("vec3","worldStart").assign(u.xyz),Zr("vec3","worldEnd").assign(h.xyz));const d=Dn.z.div(Dn.w),p=lr.element(2).element(3).equal(-1);Le(p,()=>{Le(u.z.lessThan(0).and(h.z.greaterThan(0)),()=>{h.assign(a({start:u,end:h}))}).ElseIf(h.z.lessThan(0).and(u.z.greaterThanEqual(0)),()=>{u.assign(a({start:h,end:u}))})});const m=lr.mul(u),v=lr.mul(h),f=m.xyz.div(m.w),g=v.xyz.div(v.w),x=g.xy.sub(f.xy).toVar();x.x.assign(x.x.mul(d)),x.assign(x.normalize());const y=ae().toVar();if(s){const _=h.xyz.sub(u.xyz).normalize(),I=rt(u.xyz,h.xyz,.5).normalize(),T=_.cross(I).normalize(),w=_.cross(T),C=Zr("vec4","worldPos");C.assign(Li.y.lessThan(.5).select(u,h));const H=rd.mul(.5);C.addAssign(ae(Li.x.lessThan(0).select(T.mul(H),T.mul(H).negate()),0)),r||(C.addAssign(ae(Li.y.lessThan(.5).select(_.mul(H).negate(),_.mul(H)),0)),C.addAssign(ae(w.mul(H),0)),Le(Li.y.greaterThan(1).or(Li.y.lessThan(0)),()=>{C.subAssign(ae(w.mul(2).mul(H),0))})),y.assign(lr.mul(C));const M=D().toVar();M.assign(Li.y.lessThan(.5).select(f,g)),y.z.assign(M.z.mul(y.w))}else{const _=z(x.y,x.x.negate()).toVar("offset");x.x.assign(x.x.div(d)),_.x.assign(_.x.div(d)),_.assign(Li.x.lessThan(0).select(_.negate(),_)),Le(Li.y.lessThan(0),()=>{_.assign(_.sub(x))}).ElseIf(Li.y.greaterThan(1),()=>{_.assign(_.add(x))}),_.assign(_.mul(rd)),_.assign(_.div(Dn.w)),y.assign(Li.y.lessThan(.5).select(m,v)),_.assign(_.mul(y.w)),y.assign(y.add(ae(_,0,0)))}return y})();const o=U(({p1:l,p2:c,p3:u,p4:h})=>{const d=l.sub(u),p=h.sub(u),m=c.sub(l),v=d.dot(p),f=p.dot(m),g=d.dot(m),x=p.dot(p),y=m.dot(m).mul(x).sub(f.mul(f)),_=v.mul(f).sub(g.mul(x)).div(y).clamp(),I=v.add(f.mul(_)).div(x).clamp();return z(_,I)});this.fragmentNode=U(()=>{const l=nt();if(r){const h=this.offsetNode?E(this.offsetNodeNode):ag,d=this.dashScaleNode?E(this.dashScaleNode):id,p=this.dashSizeNode?E(this.dashSizeNode):ng,m=this.dashSizeNode?E(this.dashGapNode):sg;Zs.assign(p),zl.assign(m);const v=_i("instanceDistanceStart"),f=_i("instanceDistanceEnd"),g=Li.y.lessThan(.5).select(d.mul(v),id.mul(f)),x=Ii(g.add(ag)),y=h?x.add(h):x;l.y.lessThan(-1).or(l.y.greaterThan(1)).discard(),y.mod(Zs.add(zl)).greaterThan(Zs).discard()}const c=E(1).toVar("alpha");if(s){const h=Zr("vec3","worldStart"),d=Zr("vec3","worldEnd"),p=Zr("vec4","worldPos").xyz.normalize().mul(1e5),m=d.sub(h),v=o({p1:h,p2:d,p3:D(0,0,0),p4:p}),f=h.add(m.mul(v.x)),g=p.mul(v.y),x=f.sub(g).length().div(rd);if(!r)if(t&&e.samples>1){const y=x.fwidth();c.assign(Ki(y.negate().add(.5),y.add(.5),x).oneMinus())}else x.greaterThan(.5).discard()}else if(t&&e.samples>1){const h=l.x,d=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1)),p=h.mul(h).add(d.mul(d)),m=E(p.fwidth()).toVar("dlen");Le(l.y.abs().greaterThan(1),()=>{c.assign(Ki(m.oneMinus(),m.add(1),p).oneMinus())})}else Le(l.y.abs().greaterThan(1),()=>{const h=l.x,d=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1));h.mul(h).add(d.mul(d)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(i){const h=_i("instanceColorStart"),d=_i("instanceColorEnd");u=Li.y.lessThan(.5).select(h,d).mul(mo)}else u=mo;return ae(u,c)})()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const lT=n=>G(n).mul(.5).add(.5),$L=n=>G(n).mul(2).sub(1),JL=new fh;class KL extends Tt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(JL),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?E(this.opacityNode):ed;Nt.assign(ae(lT(Yt),e))}}class cT extends pt{static get type(){return"EquirectUVNode"}constructor(e=Jf){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(Math.PI*2)).add(.5),i=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return z(t,i)}}const gg=K(cT);class uT extends Lu{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const i=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,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 s=new _n(5,5,5),a=gg(Jf),o=new Tt;o.colorNode=yt(t,a,0),o.side=si,o.blending=Er;const l=new Ft(s,o),c=new ku;c.add(l),t.minFilter===Xi&&(t.minFilter=Lt);const u=new Iu(1,10,this),h=e.getMRT();return e.setMRT(null),u.update(e,c),e.setMRT(h),t.minFilter=i,t.currentGenerateMipmaps=r,l.geometry.dispose(),l.material.dispose(),this}}const lc=new WeakMap;class ZL extends pt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Kh();const t=new Rs;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=je.RENDER}updateBefore(e){const{renderer:t,material:i}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:i[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===kn||a===Hn){if(lc.has(s)){const o=lc.get(s);dT(o,s.mapping),this._cubeTexture=o}else{const o=s.image;if(QL(o)){const l=new uT(o.height);l.fromEquirectangularTexture(t,s),dT(l.texture,s.mapping),this._cubeTexture=l.texture,lc.set(s,l.texture),s.addEventListener("dispose",hT)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function QL(n){return n==null?!1:n.height>0}function hT(n){const e=n.target;e.removeEventListener("dispose",hT);const t=lc.get(e);t!==void 0&&(lc.delete(e),t.dispose())}function dT(n,e){e===kn?n.mapping=fr:e===Hn&&(n.mapping=Ar)}const eP=K(ZL);class ad extends ia{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=eP(this.envNode)}}class tP extends ia{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=E(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class cc{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class pT extends cc{constructor(){super()}indirect(e,t,i){const r=e.ambientOcclusion,s=e.reflectedLight,a=i.context.irradianceLightMap;s.indirectDiffuse.assign(ae(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(ae(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Nt.rgb)}finish(e,t,i){const r=i.material,s=e.outgoingLight,a=i.context.environment;if(a)switch(r.combine){case ma:s.rgb.assign(rt(s.rgb,s.rgb.mul(a.rgb),tc.mul(td)));break;case ep:s.rgb.assign(rt(s.rgb,a.rgb,tc.mul(td)));break;case tp:s.rgb.addAssign(a.rgb.mul(tc.mul(td)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const iP=new $r;class rP extends Tt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(iP),this.setValues(e)}setupNormal(){return hr}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new ad(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new tP(og)),t}setupOutgoingLight(){return Nt.rgb}setupLightingModel(){return new pT}}const yo=U(({f0:n,f90:e,dotVH:t})=>{const i=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return n.mul(i.oneMinus()).add(e.mul(i))}),ra=U(n=>n.diffuseColor.mul(1/Math.PI)),nP=()=>E(.25),sP=U(({dotNH:n})=>zh.mul(E(.5)).add(1).mul(E(1/Math.PI)).mul(n.pow(zh))),aP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(e).clamp(),i=Vt.dot(e).clamp(),r=yo({f0:or,f90:1,dotVH:i}),s=nP(),a=sP({dotNH:t});return r.mul(s).mul(a)});class vg extends pT{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:i}){const r=Yt.dot(e).clamp().mul(t);i.directDiffuse.addAssign(r.mul(ra({diffuseColor:Nt.rgb}))),this.specular===!0&&i.directSpecular.addAssign(r.mul(aP({lightDirection:e})).mul(tc))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ra({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const oP=new gh;class lP extends Tt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(oP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new ad(t):null}setupLightingModel(){return new vg(!1)}}const cP=new mh;class uP extends Tt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(cP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new ad(t):null}setupLightingModel(){return new vg}setupVariants(){const e=(this.shininessNode?E(this.shininessNode):d1).max(1e-4);zh.assign(e);const t=this.specularNode||m1;or.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const mT=U(()=>{const n=hr.dFdx().abs().max(hr.dFdy().abs());return n.x.max(n.y).max(n.z)}),yg=U(n=>{const{roughness:e}=n,t=mT();let i=e.max(.0525);return i=i.add(t),i=i.min(1),i}),fT=U(({alpha:n,dotNL:e,dotNV:t})=>{const i=n.pow2(),r=e.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(i.add(i.oneMinus().mul(e.pow2())).sqrt());return Qr(.5,r.add(s).max(F_))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),hP=U(({alphaT:n,alphaB:e,dotTV:t,dotBV:i,dotTL:r,dotBL:s,dotNV:a,dotNL:o})=>{const l=o.mul(D(n.mul(t),e.mul(i),a).length()),c=a.mul(D(n.mul(r),e.mul(s),o).length());return Qr(.5,l.add(c)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),gT=U(({alpha:n,dotNH:e})=>{const t=n.pow2(),i=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),dP=E(1/Math.PI),pP=U(({alphaT:n,alphaB:e,dotNH:t,dotTH:i,dotBH:r})=>{const s=n.mul(e),a=D(e.mul(i),n.mul(r),s.mul(t)),o=a.dot(a),l=s.div(o);return dP.mul(s.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),xg=U(n=>{const{lightDirection:e,f0:t,f90:i,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=n,l=n.normalView||Yt,c=r.pow2(),u=e.add(Vt).normalize(),h=l.dot(e).clamp(),d=l.dot(Vt).clamp(),p=l.dot(u).clamp(),m=Vt.dot(u).clamp();let v=yo({f0:t,f90:i,dotVH:m}),f,g;if(Il(a)&&(v=Vh.mix(v,s)),Il(o)){const x=Vl.dot(e),y=Vl.dot(Vt),_=Vl.dot(u),I=Ks.dot(e),T=Ks.dot(Vt),w=Ks.dot(u);f=hP({alphaT:Bh,alphaB:c,dotTV:y,dotBV:T,dotTL:x,dotBL:I,dotNV:d,dotNL:h}),g=pP({alphaT:Bh,alphaB:c,dotNH:p,dotTH:_,dotBH:w})}else f=fT({alpha:c,dotNL:h,dotNV:d}),g=gT({alpha:c,dotNH:p});return v.mul(f).mul(g)}),_g=U(({roughness:n,dotNV:e})=>{const t=ae(-1,-.0275,-.572,.022),i=ae(1,.0425,1.04,-.04),r=n.mul(t).add(i),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return z(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),vT=U(n=>{const{dotNV:e,specularColor:t,specularF90:i,roughness:r}=n,s=_g({dotNV:e,roughness:r});return t.mul(s.x).add(i.mul(s.y))}),yT=U(({f:n,f90:e,dotVH:t})=>{const i=t.oneMinus().saturate(),r=i.mul(i),s=i.mul(r,r).clamp(0,.9999);return n.sub(D(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),mP=U(({roughness:n,dotNH:e})=>{const t=n.pow2(),i=E(1).div(t),r=e.pow2().oneMinus().max(.0078125);return E(2).add(i).mul(r.pow(i.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),fP=U(({dotNV:n,dotNL:e})=>E(1).div(E(4).mul(e.add(n).sub(e.mul(n))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),gP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(n).clamp(),i=Yt.dot(Vt).clamp(),r=Yt.dot(e).clamp(),s=mP({roughness:Fh,dotNH:r}),a=fP({dotNV:i,dotNL:t});return Js.mul(s).mul(a)}),vP=U(({N:n,V:e,roughness:t})=>{const i=.0078125,r=n.dot(e).saturate(),s=z(t,r.oneMinus().sqrt());return s.assign(s.mul(.984375).add(i)),s}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),yP=U(({f:n})=>{const e=n.length();return ft(e.mul(e).add(n.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),od=U(({v1:n,v2:e})=>{const t=n.dot(e),i=t.abs().toVar(),r=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),s=i.add(4.1616724).mul(i).add(3.417594).toVar(),a=r.div(s),o=t.greaterThan(0).select(a,ft(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return n.cross(e).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),xT=U(({N:n,V:e,P:t,mInv:i,p0:r,p1:s,p2:a,p3:o})=>{const l=s.sub(r).toVar(),c=o.sub(r).toVar(),u=l.cross(c),h=D().toVar();return Le(u.dot(t.sub(r)).greaterThanEqual(0),()=>{const d=e.sub(n.mul(e.dot(n))).normalize(),p=n.cross(d).negate(),m=i.mul(yi(d,p,n).transpose()).toVar(),v=m.mul(r.sub(t)).normalize().toVar(),f=m.mul(s.sub(t)).normalize().toVar(),g=m.mul(a.sub(t)).normalize().toVar(),x=m.mul(o.sub(t)).normalize().toVar(),y=D(0).toVar();y.addAssign(od({v1:v,v2:f})),y.addAssign(od({v1:f,v2:g})),y.addAssign(od({v1:g,v2:x})),y.addAssign(od({v1:x,v2:v})),h.assign(D(yP({f:y})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),ld=1/6,_T=n=>lt(ld,lt(n,lt(n,n.negate().add(3)).sub(3)).add(1)),Mg=n=>lt(ld,lt(n,lt(n,lt(3,n).sub(6))).add(4)),MT=n=>lt(ld,lt(n,lt(n,lt(-3,n).add(3)).add(3)).add(1)),Tg=n=>lt(ld,Ji(n,3)),TT=n=>_T(n).add(Mg(n)),bT=n=>MT(n).add(Tg(n)),ST=n=>zt(-1,Mg(n).div(_T(n).add(Mg(n)))),wT=n=>zt(1,Tg(n).div(MT(n).add(Tg(n)))),ET=(n,e,t)=>{const i=n.uvNode,r=lt(i,e.zw).add(.5),s=hs(r),a=ds(r),o=TT(a.x),l=bT(a.x),c=ST(a.x),u=wT(a.x),h=ST(a.y),d=wT(a.y),p=z(s.x.add(c),s.y.add(h)).sub(.5).mul(e.xy),m=z(s.x.add(u),s.y.add(h)).sub(.5).mul(e.xy),v=z(s.x.add(c),s.y.add(d)).sub(.5).mul(e.xy),f=z(s.x.add(u),s.y.add(d)).sub(.5).mul(e.xy),g=TT(a.y).mul(zt(o.mul(n.uv(p).level(t)),l.mul(n.uv(m).level(t)))),x=bT(a.y).mul(zt(o.mul(n.uv(v).level(t)),l.mul(n.uv(f).level(t))));return g.add(x)},AT=U(([n,e=E(3)])=>{const t=z(n.size(P(e))),i=z(n.size(P(e.add(1)))),r=Qr(1,t),s=Qr(1,i),a=ET(n,ae(r,t),hs(e)),o=ET(n,ae(s,i),Uf(e));return ds(e).mix(a,o)}),NT=U(([n,e,t,i,r])=>{const s=D(Bf(e.negate(),Mr(n),Qr(1,i))),a=D(ea(r[0].xyz),ea(r[1].xyz),ea(r[2].xyz));return Mr(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),xP=U(([n,e])=>n.mul(li(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),_P=nT(),CT=U(([n,e,t])=>{const i=_P.uv(n),r=Hl(E(go.x)).mul(xP(e,t));return AT(i,r)}),RT=U(([n,e,t])=>(Le(t.notEqual(0),()=>{const i=Df(e).negate().div(t);return Pf(i.negate().mul(n))}),D(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),MP=U(([n,e,t,i,r,s,a,o,l,c,u,h,d,p,m])=>{let v,f;if(m){v=ae().toVar(),f=D().toVar();const I=u.sub(1).mul(m.mul(.025)),T=D(u.sub(I),u,u.add(I));gt({start:0,end:3},({i:w})=>{const C=T.element(w),H=NT(n,e,h,C,o),M=a.add(H),b=c.mul(l.mul(ae(M,1))),k=z(b.xy.div(b.w)).toVar();k.addAssign(1),k.divAssign(2),k.assign(z(k.x,k.y.oneMinus()));const j=CT(k,t,C);v.element(w).assign(j.element(w)),v.a.addAssign(j.a),f.element(w).assign(i.element(w).mul(RT(ea(H),d,p).element(w)))}),v.a.divAssign(3)}else{const I=NT(n,e,h,u,o),T=a.add(I),w=c.mul(l.mul(ae(T,1))),C=z(w.xy.div(w.w)).toVar();C.addAssign(1),C.divAssign(2),C.assign(z(C.x,C.y.oneMinus())),v=CT(C,t,u),f=i.mul(RT(ea(I),d,p))}const g=f.rgb.mul(v.rgb),x=n.dot(e).clamp(),y=D(vT({dotNV:x,specularColor:r,specularF90:s,roughness:t})),_=f.r.add(f.g,f.b).div(3);return ae(y.oneMinus().mul(g),v.a.oneMinus().mul(_).oneMinus())}),TP=yi(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),bP=n=>{const e=n.sqrt();return D(1).add(e).div(D(1).sub(e))},IT=(n,e)=>n.sub(e).div(n.add(e)).pow2(),SP=(n,e)=>{const t=n.mul(2*Math.PI*1e-9),i=D(54856e-17,44201e-17,52481e-17),r=D(1681e3,1795300,2208400),s=D(43278e5,93046e5,66121e5),a=E(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let o=i.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return o=D(o.x.add(a),o.y,o.z).div(10685e-11),TP.mul(o)},wP=U(({outsideIOR:n,eta2:e,cosTheta1:t,thinFilmThickness:i,baseF0:r})=>{const s=rt(n,e,Ki(0,.03,i)),a=n.div(s).pow2().mul(E(1).sub(t.pow2())),o=E(1).sub(a).sqrt(),l=IT(s,n),c=yo({f0:l,f90:1,dotVH:t}),u=c.oneMinus(),h=s.lessThan(n).select(Math.PI,0),d=E(Math.PI).sub(h),p=bP(r.clamp(0,.9999)),m=IT(p,s.toVec3()),v=yo({f0:m,f90:1,dotVH:o}),f=D(p.x.lessThan(s).select(Math.PI,0),p.y.lessThan(s).select(Math.PI,0),p.z.lessThan(s).select(Math.PI,0)),g=s.mul(i,o,2),x=D(d).add(f),y=c.mul(v).clamp(1e-5,.9999),_=y.sqrt(),I=u.pow2().mul(v).div(D(1).sub(y));let T=c.add(I),w=I.sub(u);for(let C=1;C<=2;++C){w=w.mul(_);const H=SP(E(C).mul(g),E(C).mul(x)).mul(2);T=T.add(w.mul(H))}return T.max(D(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),EP=U(({normal:n,viewDir:e,roughness:t})=>{const i=n.dot(e).saturate(),r=t.pow2(),s=Ri(t.lessThan(.25),E(-339.2).mul(r).add(E(161.4).mul(t)).sub(25.9),E(-8.48).mul(r).add(E(14.3).mul(t)).sub(9.95)),a=Ri(t.lessThan(.25),E(44).mul(r).sub(E(23.7).mul(t)).add(3.26),E(1.97).mul(r).sub(E(3.27).mul(t)).add(.72));return Ri(t.lessThan(.25),0,E(.1).mul(t).sub(.025)).add(s.mul(i).add(a).exp()).mul(1/Math.PI).saturate()}),bg=D(.04),Sg=E(1);class cd extends cc{constructor(e=!1,t=!1,i=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=i,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=D().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=D().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=D().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=D().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=D().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Yt.dot(Vt).clamp();this.iridescenceFresnel=wP({outsideIOR:E(1),eta2:bf,cosTheta1:t,thinFilmThickness:Sf,baseF0:or}),this.iridescenceF0=yT({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Yh,i=$f.sub(Yh).normalize(),r=Kf;e.backdrop=MP(r,i,pn,Nt,or,Bl,t,zr,cr,lr,kl,Ef,Nf,Af,this.dispersion?Cf:null),e.backdropAlpha=kh,Nt.a.mulAssign(rt(1,e.backdrop.a,kh))}}computeMultiscattering(e,t,i){const r=Yt.dot(Vt).clamp(),s=_g({roughness:pn,dotNV:r}),a=(this.iridescenceF0?Vh.mix(or,this.iridescenceF0):or).mul(s.x).add(i.mul(s.y)),o=s.x.add(s.y).oneMinus(),l=or.add(or.oneMinus().mul(.047619)),c=a.mul(l).div(o.mul(l).oneMinus());e.addAssign(a),t.addAssign(c.mul(o))}direct({lightDirection:e,lightColor:t,reflectedLight:i}){const r=Yt.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(gP({lightDirection:e}))),this.clearcoat===!0){const s=po.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(xg({lightDirection:e,f0:bg,f90:Sg,roughness:Fl,normalView:po})))}i.directDiffuse.addAssign(r.mul(ra({diffuseColor:Nt.rgb}))),i.directSpecular.addAssign(r.mul(xg({lightDirection:e,f0:or,f90:1,roughness:pn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:i,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:o}){const l=t.add(i).sub(r),c=t.sub(i).sub(r),u=t.sub(i).add(r),h=t.add(i).add(r),d=Yt,p=Vt,m=Pi.toVar(),v=vP({N:d,V:p,roughness:pn}),f=a.uv(v).toVar(),g=o.uv(v).toVar(),x=yi(D(f.x,0,f.y),D(0,1,0),D(f.z,0,f.w)).toVar(),y=or.mul(g.x).add(or.oneMinus().mul(g.y)).toVar();s.directSpecular.addAssign(e.mul(y).mul(xT({N:d,V:p,P:m,mInv:x,p0:l,p1:c,p2:u,p3:h}))),s.directDiffuse.addAssign(e.mul(Nt).mul(xT({N:d,V:p,P:m,mInv:yi(1,0,0,0,1,0,0,0,1),p0:l,p1:c,p2:u,p3:h})))}indirect(e,t,i){this.indirectDiffuse(e,t,i),this.indirectSpecular(e,t,i),this.ambientOcclusion(e,t,i)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(ra({diffuseColor:Nt})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:i}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Js,EP({normal:Yt,viewDir:Vt,roughness:Fh}))),this.clearcoat===!0){const c=po.dot(Vt).clamp(),u=vT({dotNV:c,specularColor:bg,specularF90:Sg,roughness:Fl});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(u))}const r=D().toVar("singleScattering"),s=D().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,Bl);const o=r.add(s),l=Nt.mul(o.r.max(o.g).max(o.b).oneMinus());i.indirectSpecular.addAssign(e.mul(r)),i.indirectSpecular.addAssign(s.mul(a)),i.indirectDiffuse.addAssign(l.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const i=Yt.dot(Vt).clamp().add(e),r=pn.mul(-16).oneMinus().negate().exp2(),s=e.sub(i.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(s)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const i=po.dot(Vt).clamp(),r=yo({dotVH:i,f0:bg,f90:Sg}),s=t.mul(Oh.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Oh));t.assign(s)}if(this.sheen===!0){const i=Js.r.max(Js.g).max(Js.b).mul(.157).oneMinus(),r=t.mul(i).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const LT=E(1),wg=E(-2),ud=E(.8),Eg=E(-1),hd=E(.4),Ag=E(2),dd=E(.305),Ng=E(3),PT=E(.21),AP=E(4),DT=E(4),NP=E(16),CP=U(([n])=>{const e=D(It(n)).toVar(),t=E(-1).toVar();return Le(e.x.greaterThan(e.z),()=>{Le(e.x.greaterThan(e.y),()=>{t.assign(Ri(n.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ri(n.y.greaterThan(0),1,4))})}).Else(()=>{Le(e.z.greaterThan(e.y),()=>{t.assign(Ri(n.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ri(n.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),RP=U(([n,e])=>{const t=z().toVar();return Le(e.equal(0),()=>{t.assign(z(n.z,n.y).div(It(n.x)))}).ElseIf(e.equal(1),()=>{t.assign(z(n.x.negate(),n.z.negate()).div(It(n.y)))}).ElseIf(e.equal(2),()=>{t.assign(z(n.x.negate(),n.y).div(It(n.z)))}).ElseIf(e.equal(3),()=>{t.assign(z(n.z.negate(),n.y).div(It(n.x)))}).ElseIf(e.equal(4),()=>{t.assign(z(n.x.negate(),n.z).div(It(n.y)))}).Else(()=>{t.assign(z(n.x,n.y).div(It(n.z)))}),lt(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),IP=U(([n])=>{const e=E(0).toVar();return Le(n.greaterThanEqual(ud),()=>{e.assign(LT.sub(n).mul(Eg.sub(wg)).div(LT.sub(ud)).add(wg))}).ElseIf(n.greaterThanEqual(hd),()=>{e.assign(ud.sub(n).mul(Ag.sub(Eg)).div(ud.sub(hd)).add(Eg))}).ElseIf(n.greaterThanEqual(dd),()=>{e.assign(hd.sub(n).mul(Ng.sub(Ag)).div(hd.sub(dd)).add(Ag))}).ElseIf(n.greaterThanEqual(PT),()=>{e.assign(dd.sub(n).mul(AP.sub(Ng)).div(dd.sub(PT)).add(Ng))}).Else(()=>{e.assign(E(-2).mul(Hl(lt(1.16,n))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),UT=U(([n,e])=>{const t=n.toVar();t.assign(lt(2,t).sub(1));const i=D(t,1).toVar();return Le(e.equal(0),()=>{i.assign(i.zyx)}).ElseIf(e.equal(1),()=>{i.assign(i.xzy),i.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{i.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{i.assign(i.zyx),i.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{i.assign(i.xzy),i.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{i.z.mulAssign(-1)}),i}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),OT=U(([n,e,t,i,r,s])=>{const a=E(t),o=D(e),l=li(IP(a),wg,s),c=ds(l),u=hs(l),h=D(Cg(n,o,u,i,r,s)).toVar();return Le(c.notEqual(0),()=>{const d=D(Cg(n,o,u.add(1),i,r,s)).toVar();h.assign(rt(h,d,c))}),h}),Cg=U(([n,e,t,i,r,s])=>{const a=E(t).toVar(),o=D(e),l=E(CP(o)).toVar(),c=E(ft(DT.sub(a),0)).toVar();a.assign(ft(a,DT));const u=E(Hh(a)).toVar(),h=z(RP(o,l).mul(u.sub(2)).add(1)).toVar();return Le(l.greaterThan(2),()=>{h.y.addAssign(u),l.subAssign(3)}),h.x.addAssign(l.mul(u)),h.x.addAssign(c.mul(lt(3,NP))),h.y.addAssign(lt(4,Hh(s).sub(u))),h.x.mulAssign(i),h.y.mulAssign(r),n.uv(h).grad(z(),z())}),Rg=U(({envMap:n,mipInt:e,outputDirection:t,theta:i,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=Tr(i),c=t.mul(l).add(r.cross(t).mul(Ci(i))).add(r.mul(r.dot(t).mul(l.oneMinus())));return Cg(n,c,e,s,a,o)}),FT=U(({n,latitudinal:e,poleAxis:t,outputDirection:i,weights:r,samples:s,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{const d=D(Ri(e,t,co(t,i))).toVar();Le(Lf(d.equals(D(0))),()=>{d.assign(D(i.z,0,i.x.negate()))}),d.assign(Mr(d));const p=D().toVar();return p.addAssign(r.element(P(0)).mul(Rg({theta:0,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),gt({start:P(1),end:n},({i:m})=>{Le(m.greaterThanEqual(s),()=>{nd()});const v=E(a.mul(E(m))).toVar();p.addAssign(r.element(m).mul(Rg({theta:v.mul(-1),axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),p.addAssign(r.element(m).mul(Rg({theta:v,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),ae(p,1)});let pd=null;const VT=new WeakMap;function LP(n){const e=Math.log2(n)-2,t=1/n;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function PP(n){let e=VT.get(n);if((e!==void 0?e.pmremVersion:-1)!==n.pmremVersion){const t=n.image;if(n.isCubeTexture)if(DP(t))e=pd.fromCubemap(n,e);else return null;else if(UP(t))e=pd.fromEquirectangular(n,e);else return null;e.pmremVersion=n.pmremVersion,VT.set(n,e)}return e.texture}class BT extends pt{static get type(){return"PMREMNode"}constructor(e,t=null,i=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=i,this._generator=null;const r=new Wt;r.isRenderTargetTexture=!0,this._texture=yt(r),this._width=fe(0),this._height=fe(0),this._maxMip=fe(0),this.updateBeforeType=je.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=LP(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,i=this._value;t!==i.pmremVersion&&(i.isPMREMTexture===!0?e=i:e=PP(i),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){pd===null&&(pd=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const i=this.value;e.renderer.coordinateSystem===Rr&&i.isPMREMTexture!==!0&&i.isRenderTargetTexture===!0&&(t=D(t.x.negate(),t.yz));let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),OT(this._texture,t,r,this._width,this._height,this._maxMip)}}function DP(n){if(n==null)return!1;let e=0;const t=6;for(let i=0;i<t;i++)n[i]!==void 0&&e++;return e===t}function UP(n){return n==null?!1:n.height>0}const zT=K(BT),kT=new WeakMap;class HT extends ia{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const h=i.isTextureNode?i.value:t[i.property];let d=kT.get(h);d===void 0&&(d=zT(h),kT.set(h,d)),i=d}const r=t.envMap?fi("envMapIntensity","float",e.material):fi("environmentIntensity","float",e.scene),s=t.useAnisotropy===!0||t.anisotropy>0?a1:Yt,a=i.context(GT(pn,s)).mul(r),o=i.context(OP(Kf)).mul(Math.PI).mul(r),l=Yl(a),c=Yl(o);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(c);const u=e.context.lightingModel.clearcoatRadiance;if(u){const h=i.context(GT(Fl,po)).mul(r),d=Yl(h);u.addAssign(d)}}}const GT=(n,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Vt.negate().reflect(e),t=n.mul(n).mix(t,e).normalize(),t=t.transformDirection(cr)),t),getTextureLevel:()=>n}},OP=n=>({getUV:()=>n,getTextureLevel:()=>E(1)}),FP=new wl;class WT extends Tt{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(FP),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new HT(t):null}setupLightingModel(){return new cd}setupSpecular(){const e=rt(D(.04),Nt.rgb,Ol);or.assign(e),Bl.assign(1)}setupVariants(){const e=this.metalnessNode?E(this.metalnessNode):v1;Ol.assign(e);let t=this.roughnessNode?E(this.roughnessNode):g1;t=yg({roughness:t}),pn.assign(t),this.setupSpecular(),Nt.assign(ae(Nt.rgb.mul(e.oneMinus()),Nt.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const VP=new ph;class jT extends WT{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(VP),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?E(this.iorNode):I1;kl.assign(e),or.assign(rt(xi(Ff(kl.sub(1).div(kl.add(1))).mul(f1),D(1)).mul(rg),Nt.rgb,Ol)),Bl.assign(rt(rg,1,Ol))}setupLightingModel(){return new cd(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?E(this.clearcoatNode):x1,i=this.clearcoatRoughnessNode?E(this.clearcoatRoughnessNode):_1;Oh.assign(t),Fl.assign(yg({roughness:i}))}if(this.useSheen){const t=this.sheenNode?D(this.sheenNode):b1,i=this.sheenRoughnessNode?E(this.sheenRoughnessNode):S1;Js.assign(t),Fh.assign(i)}if(this.useIridescence){const t=this.iridescenceNode?E(this.iridescenceNode):E1,i=this.iridescenceIORNode?E(this.iridescenceIORNode):A1,r=this.iridescenceThicknessNode?E(this.iridescenceThicknessNode):N1;Vh.assign(t),bf.assign(i),Sf.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?z(this.anisotropyNode):w1).toVar();us.assign(t.length()),Le(us.equal(0),()=>{t.assign(z(1,0))}).Else(()=>{t.divAssign(z(us)),us.assign(us.saturate())}),Bh.assign(us.pow2().mix(pn.pow2(),1)),Vl.assign(ta[0].mul(t.x).add(ta[1].mul(t.y))),Ks.assign(ta[1].mul(t.x).sub(ta[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?E(this.transmissionNode):C1,i=this.thicknessNode?E(this.thicknessNode):R1,r=this.attenuationDistanceNode?E(this.attenuationDistanceNode):L1,s=this.attenuationColorNode?D(this.attenuationColorNode):P1;if(kh.assign(t),Ef.assign(i),Af.assign(r),Nf.assign(s),this.useDispersion){const a=this.dispersionNode?E(this.dispersionNode):U1;Cf.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?D(this.clearcoatNormalNode):M1}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class BP extends cd{constructor(e,t,i,r){super(e,t,i),this.useSSS=r}direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){if(this.useSSS===!0){const a=s.material,{thicknessColorNode:o,thicknessDistortionNode:l,thicknessAmbientNode:c,thicknessAttenuationNode:u,thicknessPowerNode:h,thicknessScaleNode:d}=a,p=e.add(Yt.mul(l)).normalize(),m=E(Vt.dot(p.negate()).saturate().pow(h).mul(d)),v=D(m.add(c).mul(o));i.directDiffuse.addAssign(v.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s)}}class zP extends jT{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=E(.1),this.thicknessAmbientNode=E(0),this.thicknessAttenuationNode=E(.1),this.thicknessPowerNode=E(2),this.thicknessScaleNode=E(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new BP(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const kP=U(({normal:n,lightDirection:e,builder:t})=>{const i=n.dot(e),r=z(i.mul(.5).add(.5),0);if(t.material.gradientMap){const s=rn("gradientMap","texture").context({getUV:()=>r});return D(s.r)}else{const s=r.fwidth().mul(.5);return rt(D(.7),D(1),Ki(E(.7).sub(s.x),E(.7).add(s.x),r.x))}});class HP extends cc{direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){const a=kP({normal:$h,lightDirection:e,builder:s}).mul(t);i.directDiffuse.addAssign(a.mul(ra({diffuseColor:Nt.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ra({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const GP=new Dm;class WP extends Tt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(GP),this.setValues(e)}setupLightingModel(){return new HP}}class XT extends pt{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=D(Vt.z,0,Vt.x.negate()).normalize(),t=Vt.cross(e);return z(e.dot(Yt),t.dot(Yt)).mul(.495).add(.5)}}const qT=ge(XT),jP=new Um;class XP extends Tt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(jP),this.setValues(e)}setupVariants(e){const t=qT;let i;e.material.matcap?i=rn("matcap","texture").context({getUV:()=>t}):i=D(rt(.2,.8,t.y)),Nt.rgb.mulAssign(i.rgb)}}const qP=new Za;class YP extends Tt{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(qP),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class YT extends pt{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:i}=this;if(this.getNodeType(e)==="vec2"){const r=t.cos(),s=t.sin();return Ul(r,s,s.negate(),r).mul(i)}else{const r=t,s=Ys(ae(1,0,0,0),ae(0,Tr(r.x),Ci(r.x).negate(),0),ae(0,Ci(r.x),Tr(r.x),0),ae(0,0,0,1)),a=Ys(ae(Tr(r.y),0,Ci(r.y),0),ae(0,1,0,0),ae(Ci(r.y).negate(),0,Tr(r.y),0),ae(0,0,0,1)),o=Ys(ae(Tr(r.z),Ci(r.z).negate(),0,0),ae(Ci(r.z),Tr(r.z),0,0),ae(0,0,1,0),ae(0,0,0,1));return s.mul(a).mul(o).mul(ae(i,1)).xyz}}}const Ig=K(YT),$P=new ul;class JP extends Tt{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues($P),this.setValues(e)}setupPosition({object:e,camera:t,context:i}){const r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:o}=this,l=Zt;let c=fn.mul(D(s||0)),u=z(zr[0].xyz.length(),zr[1].xyz.length());o!==null&&(u=u.mul(o)),!r&&t.isPerspectiveCamera&&(u=u.mul(c.z.negate()));let h=l.xy;if(e.center&&e.center.isVector2===!0){const v=q2("center","vec2");h=h.sub(v.sub(.5))}h=h.mul(u);const d=E(a||T1),p=Ig(h,d);c=ae(c.xy.add(p),c.zw);const m=lr.mul(c);return i.vertex=l,m}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class KP extends cc{constructor(){super(),this.shadowNode=E(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Nt.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Nt.rgb)}}const ZP=new dh;class QP extends Tt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ZP),this.setValues(e)}setupLightingModel(){return new KP}}const e3=U(({texture:n,uv:e})=>{const t=D().toVar();return Le(e.x.lessThan(1e-4),()=>{t.assign(D(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{t.assign(D(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{t.assign(D(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{t.assign(D(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{t.assign(D(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{t.assign(D(0,0,-1))}).Else(()=>{const i=n.uv(e.add(D(-.01,0,0))).r.sub(n.uv(e.add(D(.01,0,0))).r),r=n.uv(e.add(D(0,-.01,0))).r.sub(n.uv(e.add(D(0,.01,0))).r),s=n.uv(e.add(D(0,0,-.01))).r.sub(n.uv(e.add(D(0,0,.01))).r);t.assign(D(i,r,s))}),t.normalize()});class $T extends mn{static get type(){return"Texture3DNode"}constructor(e,t=null,i=null){super(e,t,i),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return D(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return e3({texture:this,uv:e})}}const JT=K($T);class t3 extends Tt{static get type(){return"VolumeNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){const t=JT(this.map,null,0),i=U(({orig:r,dir:s})=>{const a=D(-.5),o=D(.5),l=s.reciprocal(),c=a.sub(r).mul(l),u=o.sub(r).mul(l),h=xi(c,u),d=ft(c,u),p=ft(h.x,ft(h.y,h.z)),m=xi(d.x,xi(d.y,d.z));return z(p,m)});this.fragmentNode=U(()=>{const r=Ii(D(WM.mul(ae($f,1)))),s=Ii(Li.sub(r)).normalize(),a=z(i({orig:r,dir:s})).toVar();a.x.greaterThan(a.y).discard(),a.assign(z(ft(a.x,0),a.y));const o=D(r.add(a.x.mul(s))).toVar(),l=D(s.abs().reciprocal()).toVar(),c=E(xi(l.x,xi(l.y,l.z))).toVar("delta");c.divAssign(rn("steps","float"));const u=ae(rn("base","color"),0).toVar();return gt({type:"float",start:a.x,end:a.y,update:"+= delta"},()=>{const h=ar("float","d").assign(t.uv(o.add(.5)).r);this.testNode!==null?this.testNode({map:t,mapValue:h,probe:o,finalColor:u}).append():(u.a.assign(1),nd()),o.addAssign(s.mul(c))}),u.a.equal(0).discard(),ae(u)})(),super.setup(e)}}class KT extends Gi{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,i,r){const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{try{t(this.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),this.manager.itemError(e)}},i,r)}parseNodes(e){const t={};if(e!==void 0){for(const r of e){const{uuid:s,type:a}=r;t[s]=this.createNodeFromType(a),t[s].uuid=s}const i={nodes:t,textures:this.textures};for(const r of e)r.meta=i,t[r.uuid].deserialize(r),delete r.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const i={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=i,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),E()):G(new this.nodes[e])}}class ZT extends Mc{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),i=this.nodes,r=e.inputNodes;for(const s in r){const a=r[s];t[s]=i[a]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class i3 extends cx{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const i=super.parse(e,t);return this._nodesJSON=null,i}parseNodes(e,t){if(e!==void 0){const i=new KT;return i.setNodes(this.nodes),i.setTextures(t),i.parseNodes(e)}return{}}parseMaterials(e,t){const i={};if(e!==void 0){const r=this.parseNodes(this._nodesJSON,t),s=new ZT;s.setTextures(t),s.setNodes(r),s.setNodeMaterials(this.nodeMaterials);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]=s.parse(l)}}return i}}class Lg{constructor(e,t,i=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=i}}class QT{constructor(e,t,i){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=i.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class Pg{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class eb extends Pg{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class tb{constructor(e,t,i=""){this.name=e,this.type=t,this.code=i,Object.defineProperty(this,"isNodeCode",{value:!0})}}let r3=0;class md{constructor(e=null){this.id=r3++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Dg extends Et{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const n3=(n,e)=>G(new Dg(n,e));class Ug extends qe{static get type(){return"CodeNode"}constructor(e="",t=[],i=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=i,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const i=e.getCodeFromNode(this,this.getNodeType(e));return i.code=this.code,i.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const fd=K(Ug),s3=(n,e)=>fd(n,e,"js"),a3=(n,e)=>fd(n,e,"wgsl"),o3=(n,e)=>fd(n,e,"glsl");class Og extends Ug{static get type(){return"FunctionNode"}constructor(e="",t=[],i=""){super(e,t,i)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let i=t.nodeFunction;return i===void 0&&(i=e.parser.parseFunction(this.code),t.nodeFunction=i),i}generate(e,t){super.generate(e);const i=this.getNodeFunction(e),r=i.name,s=i.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const o=e.getPropertyName(a),l=this.getNodeFunction(e).getCode(o);return a.code=l+`
|
|
3863
|
-
`,t==="property"?o:e.format(`${o}()`,s,t)}}const ib=(n,e=[],t="")=>{for(let s=0;s<e.length;s++){const a=e[s];typeof a=="function"&&(e[s]=a.functionNode)}const i=G(new Og(n,e,t)),r=(...s)=>i.call(...s);return r.functionNode=i,r},l3=(n,e)=>ib(n,e,"glsl"),c3=(n,e)=>ib(n,e,"wgsl");class na{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class u3 extends na{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class h3 extends na{constructor(e,t=new J){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class d3 extends na{constructor(e,t=new N){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class p3 extends na{constructor(e,t=new st){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class m3 extends na{constructor(e,t=new xe){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class f3 extends na{constructor(e,t=new Ke){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class g3 extends na{constructor(e,t=new Re){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class v3 extends u3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class y3 extends h3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class x3 extends d3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class _3 extends p3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class M3 extends m3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class T3 extends f3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class b3 extends g3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class rb extends qe{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const i=new Ll(t);return this._currentCond=Ri(e,i),this.add(this._currentCond)}ElseIf(e,t){const i=new Ll(t),r=Ri(e,i);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Ll(e),this}build(e,...t){const i=yf();Dl(this);for(const r of this.nodes)r.build(e,"void");return Dl(i),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const gd=K(rb);class S3{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let i=0;i<e.length;i++)if(t=t.get(e[i]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let i=this.weakMap;for(let r=0;r<e.length;r++){const s=e[r];i.has(s)===!1&&i.set(s,new WeakMap),i=i.get(s)}return i.set(e[e.length-1],t)}delete(e){let t=this.weakMap;for(let i=0;i<e.length;i++)if(t=t.get(e[i]),t===void 0)return!1;return t.delete(e[e.length-1])}}const xo=4,nb=[.125,.215,.35,.446,.526,.582],sa=20,Fg=new Ps(-1,1,1,-1,0,1),w3=new di(90,1),sb=new xe;let Vg=null,Bg=0,zg=0;const aa=(1+Math.sqrt(5))/2,_o=1/aa,ab=[new N(-aa,_o,0),new N(aa,_o,0),new N(-_o,0,aa),new N(_o,0,aa),new N(0,aa,-_o),new N(0,aa,_o),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],E3=[3,1,5,0,4,2],kg=UT(nt(),_i("faceIndex")).normalize(),Hg=D(kg.x,kg.y.negate(),kg.z);class A3{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,i=.1,r=100){Vg=this._renderer.getRenderTarget(),Bg=this._renderer.getActiveCubeFace(),zg=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=lb(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=cb(),await 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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Vg,Bg,zg),e.scissorTest=!1,vd(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===fr||e.mapping===Ar?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Vg=this._renderer.getRenderTarget(),Bg=this._renderer.getActiveCubeFace(),zg=this._renderer.getActiveMipmapLevel();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:Lt,minFilter:Lt,generateMipmaps:!1,type:wi,format:Ei,colorSpace:nr},r=ob(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=ob(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=N3(s)),this._blurMaterial=C3(s,e,t)}return r}async _compileMaterial(e){const t=new Ft(this._lodPlanes[0],e);await this._renderer.compile(t,Fg)}_sceneToCubeUV(e,t,i,r){const s=w3;s.near=t,s.far=i;const a=[-1,1,-1,-1,-1,-1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear;l.getClearColor(sb),l.autoClear=!1;let u=this._backgroundBox;if(u===null){const p=new $r({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1});u=new Ft(new _n,p)}let h=!1;const d=e.background;d?d.isColor&&(u.material.color.copy(d),e.background=null,h=!0):(u.material.color.copy(sb),h=!0),l.setRenderTarget(r),l.clear(),h&&l.render(u,s);for(let p=0;p<6;p++){const m=p%3;m===0?(s.up.set(0,a[p],0),s.lookAt(o[p],0,0)):m===1?(s.up.set(0,0,a[p]),s.lookAt(0,o[p],0)):(s.up.set(0,a[p],0),s.lookAt(0,0,o[p]));const v=this._cubeSize;vd(r,m*v,p>2?v:0,v,v),l.render(e,s)}l.autoClear=c,e.background=d}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===fr||e.mapping===Ar;r?this._cubemapMaterial===null&&(this._cubemapMaterial=lb(e)):this._equirectMaterial===null&&(this._equirectMaterial=cb(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const o=this._cubeSize;vd(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Fg)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=ab[(r-s-1)%ab.length];this._blur(e,s-1,s,a,o)}t.autoClear=i}_blur(e,t,i,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[r];h.material=c;const d=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*sa-1),v=s/m,f=isFinite(s)?1+Math.floor(u*v):sa;f>sa&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${sa}`);const g=[];let x=0;for(let w=0;w<sa;++w){const C=w/v,H=Math.exp(-C*C/2);g.push(H),w===0?x+=H:w<f&&(x+=2*H)}for(let w=0;w<g.length;w++)g[w]=g[w]/x;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=f,d.weights.array=g,d.latitudinal.value=a==="latitudinal"?1:0,o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=m,d.mipInt.value=y-i;const _=this._sizeLods[r],I=3*_*(r>y-xo?r-y+xo:0),T=4*(this._cubeSize-_);vd(t,I,T,3*_,2*_),l.setRenderTarget(t),l.render(h,Fg)}}function N3(n){const e=[],t=[],i=[],r=[];let s=n;const a=n-xo+1+nb.length;for(let o=0;o<a;o++){const l=Math.pow(2,s);t.push(l);let c=1/l;o>n-xo?c=nb[o-n+xo-1]:o===0&&(c=0),i.push(c);const u=1/(l-2),h=-u,d=1+u,p=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,v=6,f=3,g=2,x=1,y=new Float32Array(f*v*m),_=new Float32Array(g*v*m),I=new Float32Array(x*v*m);for(let w=0;w<m;w++){const C=w%3*2/3-1,H=w>2?0:-1,M=[C,H,0,C+2/3,H,0,C+2/3,H+1,0,C,H,0,C+2/3,H+1,0,C,H+1,0],b=E3[w];y.set(M,f*v*b),_.set(p,g*v*b);const k=[b,b,b,b,b,b];I.set(k,x*v*b)}const T=new ct;T.setAttribute("position",new wt(y,f)),T.setAttribute("uv",new wt(_,g)),T.setAttribute("faceIndex",new wt(I,x)),e.push(T),r.push(new Ft(T,null)),s>xo&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i,lodMeshes:r}}function ob(n,e,t){const i=new ui(n,e,t);return i.texture.mapping=Gn,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function vd(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Gg(n){const e=new Tt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Er,e.name=`PMREM_${n}`,e}function C3(n,e,t){const i=gn(new Array(sa).fill(0)),r=fe(new N(0,1,0)),s=fe(0),a=E(sa),o=fe(0),l=fe(1),c=yt(null),u=fe(0),h=E(1/e),d=E(1/t),p=E(n),m={n:a,latitudinal:o,weights:i,poleAxis:r,outputDirection:Hg,dTheta:s,samples:l,envMap:c,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},v=Gg("blur");return v.uniforms=m,v.fragmentNode=FT({...m,latitudinal:o.equal(1)}),v}function lb(n){const e=Gg("cubemap");return e.fragmentNode=Kh(n,Hg),e}function cb(n){const e=Gg("equirect");return e.fragmentNode=yt(n,gg(Hg),0),e}let R3=0;class ub{constructor(e="",t=[],i=0,r=[]){this.name=e,this.bindings=t,this.index=i,this.bindingsReference=r,this.id=R3++}}const hb=new WeakMap,I3=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),L3=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),yd=n=>(n=Number(n),n+(n%1?"":".0"));class db{constructor(e,t,i){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=i,this.scene=null,this.camera=null,this.nodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=gd(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new md,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=hb.get(this.renderer);return e===void 0&&(e=new S3,hb.set(this.renderer,e)),e}createRenderTarget(e,t,i){return new ui(e,t,i)}createCubeRenderTarget(e,t){return new uT(e,t)}createPMREMGenerator(){return new A3(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const i=this.getBindGroupsCache(),r=[];let s=!0;for(const o of t)r.push(o),s=s&&o.groupNode.shared!==!0;let a;return s?(a=i.get(r),a===void 0&&(a=new ub(e,r,this.bindingsIndexes[e].group,r),i.set(r,a))):a=new ub(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const i=this.bindings[t];let r=i[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),i[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},i=this.bindings;for(const r of uf)for(const s in i[r]){const a=i[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,i)=>t.bindings[0].groupNode.order-i.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const i=e[t];this.bindingsIndexes[i.name].group=t,i.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType(),i=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==je.NONE&&this.updateNodes.push(e.getSelf()),i!==je.NONE&&this.updateBeforeNodes.push(e.getSelf()),r!==je.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Lt||e.magFilter===jn||e.magFilter===bn||e.magFilter===Xi||e.minFilter===Lt||e.minFilter===jn||e.minFilter===bn||e.minFilter===Xi}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const i=this.getDataFromNode(e);return i.cache===void 0&&(i.cache=new md(t?this.getCache():null)),i.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new xe:e==="vec2"?t=new J:e==="vec3"?t=new N:e==="vec4"&&(t=new st)),e==="float")return yd(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${yd(t.r)}, ${yd(t.g)}, ${yd(t.b)} )`;const i=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(i===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(i===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(i===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(i>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(i>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const i=this.attributes;for(const s of i)if(s.name===e)return s;const r=new Lg(e,t);return i.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===va)return"int";if(t===Nr)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const i=I3.get(e);return(t==="float"?"":t[0])+i}getTypeFromArray(e){return L3.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const i=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof Iv)&&s!==!0&&(a=this.getTypeFromArray(i)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),i=/vec([2-4])/.exec(t);return i!==null?Number(i[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=gd(this.stack),this.stacks.push(yf()||this.stack),Dl(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Dl(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,i=null){i=i===null?e.isGlobal(this)?this.globalCache:this.cache:i;let r=i.getData(e);return r===void 0&&(r={},i.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const i=this.getDataFromNode(e,t);return i.properties||(i.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const i=this.getDataFromNode(e);let r=i.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new Lg("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),i.bufferAttribute=r}return r}getStructTypeFromNode(e,t=this.shaderStage){const i=this.getDataFromNode(e,t);if(i.structType===void 0){const r=this.structs.index++;e.name=`StructType${r}`,this.structs[t].push(e),i.structType=e}return e}getUniformFromNode(e,t,i=this.shaderStage,r=null){r==="in"&&(console.warn('NodeBuilder: "in" is a reserved word, using "inValue" instead.',e,r),e.name="inValue",r=e.name);const s=this.getDataFromNode(e,i,this.globalCache);let a=s.uniform;if(a===void 0){const o=this.uniforms.index++;a=new QT(r||"nodeUniform"+o,t,e),this.uniforms[i].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,i=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const o=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+o.length),a=new Pg(t,i),o.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,i=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,o=a.length;t===null&&(t="nodeVarying"+o),s=new eb(t,i),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,i=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[i]||(this.codes[i]=[]),o=a.length;s=new tb("nodeCode"+o,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:i,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const o of i)this.addLineFlowCode(o)}addLineFlowCodeBlock(e,t,i){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(i,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
|
|
3864
|
-
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),i=this.flowChildNode(e,t);return this.flowsData.set(e,i),i}buildFunctionNode(e){const t=new
|
|
3862
|
+
`).removeFlowTab();return e.addFlowTab(),a}}const gt=(...n)=>G(new q1(Ys(n,"int"))).append(),AL=()=>ms("continue").append(),sd=()=>ms("break").append(),NL=(...n)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),gt(...n)),hg=new WeakMap,br=new st,Y1=U(({bufferMap:n,influence:e,stride:t,width:i,depth:r,offset:s})=>{const a=P(B1).mul(t).add(s),o=a.div(i),l=a.sub(o.mul(i));return Br(n,dn(l,o)).depth(r).mul(e)});function CL(n){const e=n.morphAttributes.position!==void 0,t=n.morphAttributes.normal!==void 0,i=n.morphAttributes.color!==void 0,r=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,s=r!==void 0?r.length:0;let a=hg.get(n);if(a===void 0||a.count!==s){let o=function(){f.dispose(),hg.delete(n),n.removeEventListener("dispose",o)};a!==void 0&&a.texture.dispose();const l=n.morphAttributes.position||[],c=n.morphAttributes.normal||[],u=n.morphAttributes.color||[];let h=0;e===!0&&(h=1),t===!0&&(h=2),i===!0&&(h=3);let d=n.attributes.position.count*h,p=1;const m=4096;d>m&&(p=Math.ceil(d/m),d=m);const v=new Float32Array(d*p*4*s),f=new il(v,d,p,s);f.type=Oi,f.needsUpdate=!0;const g=h*4;for(let x=0;x<s;x++){const y=l[x],_=c[x],I=u[x],T=d*p*4*x;for(let w=0;w<y.count;w++){const C=w*g;e===!0&&(br.fromBufferAttribute(y,w),v[T+C+0]=br.x,v[T+C+1]=br.y,v[T+C+2]=br.z,v[T+C+3]=0),t===!0&&(br.fromBufferAttribute(_,w),v[T+C+4]=br.x,v[T+C+5]=br.y,v[T+C+6]=br.z,v[T+C+7]=0),i===!0&&(br.fromBufferAttribute(I,w),v[T+C+8]=br.x,v[T+C+9]=br.y,v[T+C+10]=br.z,v[T+C+11]=I.itemSize===4?br.w:1)}}a={count:s,texture:f,stride:h,size:new J(d,p)},hg.set(n,a),n.addEventListener("dispose",o)}return a}class $1 extends qe{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=fe(1),this.updateType=je.OBJECT}setup(e){const{geometry:t}=e,i=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=s!==void 0?s.length:0,{texture:o,stride:l,size:c}=CL(t);i===!0&&Zt.mulAssign(this.morphBaseInfluence),r===!0&&ur.mulAssign(this.morphBaseInfluence);const u=P(c.width);gt(a,({i:h})=>{const d=E(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(Br(this.mesh.morphTexture,dn(P(h).add(1),P(rc))).r):d.assign(fi("morphTargetInfluences","float").element(h).toVar()),i===!0&&Zt.addAssign(Y1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(0)})),r===!0&&ur.addAssign(Y1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(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 J1=K($1),RL=n=>n.sort((e,t)=>e.id-t.id),IL=(n,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===n)return t;return null},dg=new WeakMap;class K1 extends qe{static get type(){return"LightsNode"}constructor(e=[]){super("vec3"),this.totalDiffuseNode=D().toVar("totalDiffuse"),this.totalSpecularNode=D().toVar("totalSpecular"),this.outgoingLightNode=D().toVar("outgoingLight"),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const i of this._lightNodes)t.push(i.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const i of t.nodes)i.build(e)}setupLightsNode(e){const t=[],i=this._lightNodes,r=RL(this._lights),s=e.renderer.nodes.library;for(const a of r)if(a.isNode)t.push(G(a));else{let o=null;if(i!==null&&(o=IL(a.id,i)),o===null){const l=s.getLightNodeClass(a.constructor);if(l===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let c=null;dg.has(a)?c=dg.get(a):(c=new l(a),dg.set(a,c)),t.push(c)}}this._lightNodes=t}setup(e){this._lightNodes===null&&this.setupLightsNode(e);const t=e.context,i=t.lightingModel;let r=this.outgoingLightNode;if(i){const{_lightNodes:s,totalDiffuseNode:a,totalSpecularNode:o}=this;t.outgoingLight=r;const l=e.addStack(),c=e.getDataFromNode(this);c.nodes=l.nodes,i.start(t,l,e);for(const g of s)g.build(e);i.indirect(t,l,e);const{backdrop:u,backdropAlpha:h}=t,{directDiffuse:d,directSpecular:p,indirectDiffuse:m,indirectSpecular:v}=t.reflectedLight;let f=d.add(m);u!==null&&(h!==null?f=D(h.mix(f,u)):f=D(u),t.material.transparent=!0),a.assign(f),o.assign(p.add(v)),r.assign(a.add(o)),i.finish(t,l,e),r=r.bypass(e.removeStack())}return r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}const Z1=K(K1);class ra extends qe{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class Q1 extends ra{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class eT extends Hf{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=D().toVar("directDiffuse"),r=D().toVar("directSpecular"),s=D().toVar("indirectDiffuse"),a=D().toVar("indirectSpecular"),o={directDiffuse:i,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:D().toVar("radiance"),irradiance:D().toVar("irradiance"),iblIrradiance:D().toVar("iblIrradiance"),ambientOcclusion:E(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 tT=K(eT);class iT extends ra{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let nc,sc;class ri extends qe{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ri.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=je.NONE;return(this.scope===ri.SIZE||this.scope===ri.VIEWPORT)&&(e=je.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ri.VIEWPORT?t!==null?sc.copy(t.viewport):(e.getViewport(sc),sc.multiplyScalar(e.getPixelRatio())):t!==null?(nc.width=t.width,nc.height=t.height):e.getDrawingBufferSize(nc)}setup(){const e=this.scope;let t=null;return e===ri.SIZE?t=fe(nc||(nc=new J)):e===ri.VIEWPORT?t=fe(sc||(sc=new st)):t=z(yo.div(vo)),t}generate(e){if(this.scope===ri.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(vo).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${i}.y - ${t}.y )`}return t}return super.generate(e)}}ri.COORDINATE="coordinate",ri.VIEWPORT="viewport",ri.SIZE="size",ri.UV="uv";const gs=ge(ri,ri.UV),vo=ge(ri,ri.SIZE),yo=ge(ri,ri.COORDINATE),Dn=ge(ri,ri.VIEWPORT),rT=Dn.zw,nT=yo.sub(Dn.xy),LL=nT.div(rT),PL=U(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),vo),"vec2").once()(),DL=U(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),gs),"vec2").once()(),UL=U(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),gs.flipY()),"vec2").once()(),ac=new J;class oc extends mn{static get type(){return"ViewportTextureNode"}constructor(e=gs,t=null,i=null){i===null&&(i=new ym,i.minFilter=Xi),super(i,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=je.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(ac);const i=this.value;(i.image.width!==ac.width||i.image.height!==ac.height)&&(i.image.width=ac.width,i.image.height=ac.height,i.needsUpdate=!0);const r=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const OL=K(oc),sT=K(oc,null,null,{generateMipmaps:!0});let pg=null;class aT extends oc{static get type(){return"ViewportDepthTextureNode"}constructor(e=gs,t=null){pg===null&&(pg=new Fs),super(e,t,pg)}}const mg=K(aT);class Qi extends qe{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===Qi.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,i=this.valueNode;let r=null;if(t===Qi.DEPTH_BASE)i!==null&&(r=lT().assign(i));else if(t===Qi.DEPTH)e.isPerspectiveCamera?r=oT(Pi.z,ho,po):r=lc(Pi.z,ho,po);else if(t===Qi.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const s=fg(i,ho,po);r=lc(s,ho,po)}else r=i;else r=lc(Pi.z,ho,po);return r}}Qi.DEPTH_BASE="depthBase",Qi.DEPTH="depth",Qi.LINEAR_DEPTH="linearDepth";const lc=(n,e,t)=>n.add(e).div(e.sub(t)),FL=(n,e,t)=>e.sub(t).mul(n).sub(e),oT=(n,e,t)=>e.add(n).mul(t).div(t.sub(e).mul(n)),fg=(n,e,t)=>e.mul(t).div(t.sub(e).mul(n).sub(t)),lT=K(Qi,Qi.DEPTH_BASE),gg=ge(Qi,Qi.DEPTH),ad=K(Qi,Qi.LINEAR_DEPTH),VL=ad(mg());gg.assign=n=>lT(n);class xs extends qe{static get type(){return"ClippingNode"}constructor(e=xs.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{localClipIntersection:i,localClippingCount:r,globalClippingCount:s}=t,a=s+r,o=i?a-r:a;return this.scope===xs.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,a,o):this.setupDefault(t.planes,a,o)}setupAlphaToCoverage(e,t,i){return U(()=>{const r=gn(e),s=ar("float","distanceToPlane"),a=ar("float","distanceToGradient"),o=ar("float","clipOpacity");o.assign(1);let l;if(gt(i,({i:c})=>{l=r.element(c),s.assign(Pi.dot(l.xyz).negate().add(l.w)),a.assign(s.fwidth().div(2)),o.mulAssign(Ki(a.negate(),a,s)),o.equal(0).discard()}),i<t){const c=ar("float","unionclipOpacity");c.assign(1),gt({start:i,end:t},({i:u})=>{l=r.element(u),s.assign(Pi.dot(l.xyz).negate().add(l.w)),a.assign(s.fwidth().div(2)),c.mulAssign(Ki(a.negate(),a,s).oneMinus())}),o.mulAssign(c.oneMinus())}Nt.a.mulAssign(o),Nt.a.equal(0).discard()})()}setupDefault(e,t,i){return U(()=>{const r=gn(e);let s;if(gt(i,({i:a})=>{s=r.element(a),Pi.dot(s.xyz).greaterThan(s.w).discard()}),i<t){const a=ar("bool","clipped");a.assign(!0),gt({start:i,end:t},({i:o})=>{s=r.element(o),a.assign(Pi.dot(s.xyz).greaterThan(s.w).and(a))}),a.discard()}})()}}xs.ALPHA_TO_COVERAGE="alphaToCoverage",xs.DEFAULT="default";const BL=()=>G(new xs),zL=()=>G(new xs(xs.ALPHA_TO_COVERAGE));class Tt extends hi{static get type(){return"NodeMaterial"}constructor(){super(),this.isNodeMaterial=!0,this.type=this.constructor.type,this.forceSinglePass=!1,this.fog=!0,this.lights=!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.positionNode=null,this.depthNode=null,this.shadowNode=null,this.shadowPositionNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+nf(this)}build(e){this.setup(e)}setupObserver(e){return new Yx(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow("vertex",e.removeStack()),e.addStack();let t;const i=this.setupClipping(e);if(this.depthWrite===!0&&this.setupDepth(e),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const r=this.setupLighting(e);i!==null&&e.stack.add(i);const s=ae(r,Nt.a).max(0);if(t=this.setupOutput(e,s),Ef.assign(t),this.outputNode!==null&&(t=this.outputNode),e.renderer.getRenderTarget()!==null){const a=e.renderer.getMRT(),o=this.mrtNode;a!==null?(t=a,o!==null&&(t=a.merge(o))):o!==null&&(t=o)}}else{let r=this.fragmentNode;r.isOutputStructNode!==!0&&(r=ae(r)),t=this.setupOutput(e,r)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{globalClippingCount:t,localClippingCount:i}=e.clippingContext;let r=null;if(t||i){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=zL():e.stack.add(BL())}return r}setupDepth(e){const{renderer:t}=e;let i=this.depthNode;if(i===null){const r="getMRT"in t&&t.getMRT();r&&r.has("depth")?i=r.get("depth"):t.logarithmicDepthBuffer===!0&&(i=cg().w.add(1).log2().mul(GM).mul(.5))}i!==null&&gg.assign(i).append()}setupPosition(e){const{object:t}=e,i=t.geometry;if(e.addStack(),(i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&J1(t).append(),t.isSkinnedMesh===!0&&X1(t).append(),this.displacementMap){const s=rn("displacementMap","texture"),a=rn("displacementScale","float"),o=rn("displacementBias","float");Zt.addAssign(ur.normalize().mul(s.x.mul(a).add(o)))}t.isBatchedMesh&&W1(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&H1(t).append(),this.positionNode!==null&&Zt.assign(this.positionNode);const r=cg();return e.context.vertex=e.removeStack(),e.context.mvp=r,r}setupDiffuseColor({object:e,geometry:t}){let i=this.colorNode?ae(this.colorNode):fo;this.vertexColors===!0&&t.hasAttribute("color")&&(i=ae(i.xyz.mul(_i("color","vec3")),i.a)),e.instanceColor&&(i=Zr("vec3","vInstanceColor").mul(i)),e.isBatchedMesh&&e._colorsTexture&&(i=Zr("vec3","vBatchColor").mul(i)),Nt.assign(i);const r=this.opacityNode?E(this.opacityNode):td;if(Nt.a.assign(Nt.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?E(this.alphaTestNode):d1;Nt.a.lessThanEqual(s).discard()}this.transparent===!1&&this.blending===Tn&&this.alphaToCoverage===!1&&Nt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?D(0):Nt.rgb}setupNormal(){return this.normalNode?D(this.normalNode):x1}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?rn("envMap","cubeTexture"):rn("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new iT(lg)),t}setupLights(e){const t=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&t.push(i);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:F1;t.push(new Q1(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=Z1([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:i,backdropAlphaNode:r,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let o=this.setupOutgoingLight(e);if(a&&a.getScope().getLights().length>0){const l=this.setupLightingModel(e);o=tT(a,l,i,r)}else i!==null&&(o=D(r!==null?rt(o,i,r):i));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(bf.assign(D(s||m1)),o=o.add(bf)),o}setupOutput(e,t){if(this.fog===!0){const i=e.fogNode;i&&(t=ae(i.mix(t.rgb,i.colorNode),t.a))}return 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=hi.prototype.toJSON.call(this,e),r=Il(this);i.inputNodes={};for(const{property:a,childNode:o}of r)i.inputNodes[a]=o.toJSON(e).uuid;function s(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(t){const a=s(e.textures),o=s(e.images),l=s(e.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,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.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const kL=new Qa;class HL extends Tt{static get type(){return"InstancedPointsNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(kL),this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,i=this.useColor;this.vertexNode=U(()=>{const r=_i("instancePosition").xyz,s=ae(fn.mul(ae(r,1))),a=Dn.z.div(Dn.w),o=lr.mul(s),l=Li.xy.toVar();return l.mulAssign(this.pointWidthNode?this.pointWidthNode:U1),l.assign(l.div(Dn.z)),l.y.assign(l.y.mul(a)),l.assign(l.mul(o.w)),o.addAssign(ae(l,0,0)),o})(),this.fragmentNode=U(()=>{const r=E(1).toVar(),s=Bf(nt().mul(2).sub(1));if(t&&e.samples>1){const o=E(s.fwidth()).toVar();r.assign(Ki(o.oneMinus(),o.add(1),s).oneMinus())}else s.greaterThan(1).discard();let a;return this.pointColorNode?a=this.pointColorNode:i?a=_i("instanceColor").mul(fo):a=fo,r.mulAssign(td),ae(a,r)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const GL=new Ni;class WL extends Tt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(GL),this.setValues(e)}}const jL=new yh;class XL extends Tt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(jL),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode,t=this.dashScaleNode?E(this.dashScaleNode):rd,i=this.dashSizeNode?E(this.dashSizeNode):sg,r=this.dashSizeNode?E(this.dashGapNode):ag;Qs.assign(i),kl.assign(r);const s=Ii(_i("lineDistance").mul(t));(e?s.add(e):s).mod(Qs.add(kl)).greaterThan(Qs).discard()}}const qL=new yh;class YL extends Tt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(qL),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,i=this.useColor,r=this.dashed,s=this.worldUnits,a=U(({start:l,end:c})=>{const u=lr.element(2).element(2),h=lr.element(3).element(2).mul(-.5).div(u).sub(l.z).div(c.z.sub(l.z));return ae(rt(l.xyz,c.xyz,h),c.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=U(()=>{const l=_i("instanceStart"),c=_i("instanceEnd"),u=ae(fn.mul(ae(l,1))).toVar("start"),h=ae(fn.mul(ae(c,1))).toVar("end");s&&(Zr("vec3","worldStart").assign(u.xyz),Zr("vec3","worldEnd").assign(h.xyz));const d=Dn.z.div(Dn.w),p=lr.element(2).element(3).equal(-1);Le(p,()=>{Le(u.z.lessThan(0).and(h.z.greaterThan(0)),()=>{h.assign(a({start:u,end:h}))}).ElseIf(h.z.lessThan(0).and(u.z.greaterThanEqual(0)),()=>{u.assign(a({start:h,end:u}))})});const m=lr.mul(u),v=lr.mul(h),f=m.xyz.div(m.w),g=v.xyz.div(v.w),x=g.xy.sub(f.xy).toVar();x.x.assign(x.x.mul(d)),x.assign(x.normalize());const y=ae().toVar();if(s){const _=h.xyz.sub(u.xyz).normalize(),I=rt(u.xyz,h.xyz,.5).normalize(),T=_.cross(I).normalize(),w=_.cross(T),C=Zr("vec4","worldPos");C.assign(Li.y.lessThan(.5).select(u,h));const H=nd.mul(.5);C.addAssign(ae(Li.x.lessThan(0).select(T.mul(H),T.mul(H).negate()),0)),r||(C.addAssign(ae(Li.y.lessThan(.5).select(_.mul(H).negate(),_.mul(H)),0)),C.addAssign(ae(w.mul(H),0)),Le(Li.y.greaterThan(1).or(Li.y.lessThan(0)),()=>{C.subAssign(ae(w.mul(2).mul(H),0))})),y.assign(lr.mul(C));const M=D().toVar();M.assign(Li.y.lessThan(.5).select(f,g)),y.z.assign(M.z.mul(y.w))}else{const _=z(x.y,x.x.negate()).toVar("offset");x.x.assign(x.x.div(d)),_.x.assign(_.x.div(d)),_.assign(Li.x.lessThan(0).select(_.negate(),_)),Le(Li.y.lessThan(0),()=>{_.assign(_.sub(x))}).ElseIf(Li.y.greaterThan(1),()=>{_.assign(_.add(x))}),_.assign(_.mul(nd)),_.assign(_.div(Dn.w)),y.assign(Li.y.lessThan(.5).select(m,v)),_.assign(_.mul(y.w)),y.assign(y.add(ae(_,0,0)))}return y})();const o=U(({p1:l,p2:c,p3:u,p4:h})=>{const d=l.sub(u),p=h.sub(u),m=c.sub(l),v=d.dot(p),f=p.dot(m),g=d.dot(m),x=p.dot(p),y=m.dot(m).mul(x).sub(f.mul(f)),_=v.mul(f).sub(g.mul(x)).div(y).clamp(),I=v.add(f.mul(_)).div(x).clamp();return z(_,I)});this.fragmentNode=U(()=>{const l=nt();if(r){const h=this.offsetNode?E(this.offsetNodeNode):og,d=this.dashScaleNode?E(this.dashScaleNode):rd,p=this.dashSizeNode?E(this.dashSizeNode):sg,m=this.dashSizeNode?E(this.dashGapNode):ag;Qs.assign(p),kl.assign(m);const v=_i("instanceDistanceStart"),f=_i("instanceDistanceEnd"),g=Li.y.lessThan(.5).select(d.mul(v),rd.mul(f)),x=Ii(g.add(og)),y=h?x.add(h):x;l.y.lessThan(-1).or(l.y.greaterThan(1)).discard(),y.mod(Qs.add(kl)).greaterThan(Qs).discard()}const c=E(1).toVar("alpha");if(s){const h=Zr("vec3","worldStart"),d=Zr("vec3","worldEnd"),p=Zr("vec4","worldPos").xyz.normalize().mul(1e5),m=d.sub(h),v=o({p1:h,p2:d,p3:D(0,0,0),p4:p}),f=h.add(m.mul(v.x)),g=p.mul(v.y),x=f.sub(g).length().div(nd);if(!r)if(t&&e.samples>1){const y=x.fwidth();c.assign(Ki(y.negate().add(.5),y.add(.5),x).oneMinus())}else x.greaterThan(.5).discard()}else if(t&&e.samples>1){const h=l.x,d=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1)),p=h.mul(h).add(d.mul(d)),m=E(p.fwidth()).toVar("dlen");Le(l.y.abs().greaterThan(1),()=>{c.assign(Ki(m.oneMinus(),m.add(1),p).oneMinus())})}else Le(l.y.abs().greaterThan(1),()=>{const h=l.x,d=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1));h.mul(h).add(d.mul(d)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(i){const h=_i("instanceColorStart"),d=_i("instanceColorEnd");u=Li.y.lessThan(.5).select(h,d).mul(fo)}else u=fo;return ae(u,c)})()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const cT=n=>G(n).mul(.5).add(.5),$L=n=>G(n).mul(2).sub(1),JL=new gh;class KL extends Tt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(JL),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?E(this.opacityNode):td;Nt.assign(ae(cT(Yt),e))}}class uT extends pt{static get type(){return"EquirectUVNode"}constructor(e=Kf){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(Math.PI*2)).add(.5),i=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return z(t,i)}}const vg=K(uT);class hT extends Pu{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const i=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,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 s=new _n(5,5,5),a=vg(Kf),o=new Tt;o.colorNode=yt(t,a,0),o.side=si,o.blending=Er;const l=new Ft(s,o),c=new Hu;c.add(l),t.minFilter===Xi&&(t.minFilter=Lt);const u=new Lu(1,10,this),h=e.getMRT();return e.setMRT(null),u.update(e,c),e.setMRT(h),t.minFilter=i,t.currentGenerateMipmaps=r,l.geometry.dispose(),l.material.dispose(),this}}const cc=new WeakMap;class ZL extends pt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Zh();const t=new Is;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=je.RENDER}updateBefore(e){const{renderer:t,material:i}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:i[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===Hn||a===Gn){if(cc.has(s)){const o=cc.get(s);pT(o,s.mapping),this._cubeTexture=o}else{const o=s.image;if(QL(o)){const l=new hT(o.height);l.fromEquirectangularTexture(t,s),pT(l.texture,s.mapping),this._cubeTexture=l.texture,cc.set(s,l.texture),s.addEventListener("dispose",dT)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function QL(n){return n==null?!1:n.height>0}function dT(n){const e=n.target;e.removeEventListener("dispose",dT);const t=cc.get(e);t!==void 0&&(cc.delete(e),t.dispose())}function pT(n,e){e===Hn?n.mapping=fr:e===Gn&&(n.mapping=Ar)}const eP=K(ZL);class od extends ra{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=eP(this.envNode)}}class tP extends ra{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=E(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class uc{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mT extends uc{constructor(){super()}indirect(e,t,i){const r=e.ambientOcclusion,s=e.reflectedLight,a=i.context.irradianceLightMap;s.indirectDiffuse.assign(ae(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(ae(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Nt.rgb)}finish(e,t,i){const r=i.material,s=e.outgoingLight,a=i.context.environment;if(a)switch(r.combine){case fa:s.rgb.assign(rt(s.rgb,s.rgb.mul(a.rgb),ic.mul(id)));break;case tp:s.rgb.assign(rt(s.rgb,a.rgb,ic.mul(id)));break;case ip:s.rgb.addAssign(a.rgb.mul(ic.mul(id)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const iP=new $r;class rP extends Tt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(iP),this.setValues(e)}setupNormal(){return hr}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new od(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new tP(lg)),t}setupOutgoingLight(){return Nt.rgb}setupLightingModel(){return new mT}}const xo=U(({f0:n,f90:e,dotVH:t})=>{const i=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return n.mul(i.oneMinus()).add(e.mul(i))}),na=U(n=>n.diffuseColor.mul(1/Math.PI)),nP=()=>E(.25),sP=U(({dotNH:n})=>kh.mul(E(.5)).add(1).mul(E(1/Math.PI)).mul(n.pow(kh))),aP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(e).clamp(),i=Vt.dot(e).clamp(),r=xo({f0:or,f90:1,dotVH:i}),s=nP(),a=sP({dotNH:t});return r.mul(s).mul(a)});class yg extends mT{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:i}){const r=Yt.dot(e).clamp().mul(t);i.directDiffuse.addAssign(r.mul(na({diffuseColor:Nt.rgb}))),this.specular===!0&&i.directSpecular.addAssign(r.mul(aP({lightDirection:e})).mul(ic))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(na({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const oP=new vh;class lP extends Tt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(oP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new od(t):null}setupLightingModel(){return new yg(!1)}}const cP=new fh;class uP extends Tt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(cP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new od(t):null}setupLightingModel(){return new yg}setupVariants(){const e=(this.shininessNode?E(this.shininessNode):p1).max(1e-4);kh.assign(e);const t=this.specularNode||f1;or.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const fT=U(()=>{const n=hr.dFdx().abs().max(hr.dFdy().abs());return n.x.max(n.y).max(n.z)}),xg=U(n=>{const{roughness:e}=n,t=fT();let i=e.max(.0525);return i=i.add(t),i=i.min(1),i}),gT=U(({alpha:n,dotNL:e,dotNV:t})=>{const i=n.pow2(),r=e.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(i.add(i.oneMinus().mul(e.pow2())).sqrt());return Qr(.5,r.add(s).max(V_))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),hP=U(({alphaT:n,alphaB:e,dotTV:t,dotBV:i,dotTL:r,dotBL:s,dotNV:a,dotNL:o})=>{const l=o.mul(D(n.mul(t),e.mul(i),a).length()),c=a.mul(D(n.mul(r),e.mul(s),o).length());return Qr(.5,l.add(c)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),vT=U(({alpha:n,dotNH:e})=>{const t=n.pow2(),i=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),dP=E(1/Math.PI),pP=U(({alphaT:n,alphaB:e,dotNH:t,dotTH:i,dotBH:r})=>{const s=n.mul(e),a=D(e.mul(i),n.mul(r),s.mul(t)),o=a.dot(a),l=s.div(o);return dP.mul(s.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),_g=U(n=>{const{lightDirection:e,f0:t,f90:i,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=n,l=n.normalView||Yt,c=r.pow2(),u=e.add(Vt).normalize(),h=l.dot(e).clamp(),d=l.dot(Vt).clamp(),p=l.dot(u).clamp(),m=Vt.dot(u).clamp();let v=xo({f0:t,f90:i,dotVH:m}),f,g;if(Ll(a)&&(v=Bh.mix(v,s)),Ll(o)){const x=Bl.dot(e),y=Bl.dot(Vt),_=Bl.dot(u),I=Zs.dot(e),T=Zs.dot(Vt),w=Zs.dot(u);f=hP({alphaT:zh,alphaB:c,dotTV:y,dotBV:T,dotTL:x,dotBL:I,dotNV:d,dotNL:h}),g=pP({alphaT:zh,alphaB:c,dotNH:p,dotTH:_,dotBH:w})}else f=gT({alpha:c,dotNL:h,dotNV:d}),g=vT({alpha:c,dotNH:p});return v.mul(f).mul(g)}),Mg=U(({roughness:n,dotNV:e})=>{const t=ae(-1,-.0275,-.572,.022),i=ae(1,.0425,1.04,-.04),r=n.mul(t).add(i),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return z(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),yT=U(n=>{const{dotNV:e,specularColor:t,specularF90:i,roughness:r}=n,s=Mg({dotNV:e,roughness:r});return t.mul(s.x).add(i.mul(s.y))}),xT=U(({f:n,f90:e,dotVH:t})=>{const i=t.oneMinus().saturate(),r=i.mul(i),s=i.mul(r,r).clamp(0,.9999);return n.sub(D(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),mP=U(({roughness:n,dotNH:e})=>{const t=n.pow2(),i=E(1).div(t),r=e.pow2().oneMinus().max(.0078125);return E(2).add(i).mul(r.pow(i.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),fP=U(({dotNV:n,dotNL:e})=>E(1).div(E(4).mul(e.add(n).sub(e.mul(n))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),gP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(n).clamp(),i=Yt.dot(Vt).clamp(),r=Yt.dot(e).clamp(),s=mP({roughness:Vh,dotNH:r}),a=fP({dotNV:i,dotNL:t});return Ks.mul(s).mul(a)}),vP=U(({N:n,V:e,roughness:t})=>{const i=.0078125,r=n.dot(e).saturate(),s=z(t,r.oneMinus().sqrt());return s.assign(s.mul(.984375).add(i)),s}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),yP=U(({f:n})=>{const e=n.length();return ft(e.mul(e).add(n.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),ld=U(({v1:n,v2:e})=>{const t=n.dot(e),i=t.abs().toVar(),r=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),s=i.add(4.1616724).mul(i).add(3.417594).toVar(),a=r.div(s),o=t.greaterThan(0).select(a,ft(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return n.cross(e).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),_T=U(({N:n,V:e,P:t,mInv:i,p0:r,p1:s,p2:a,p3:o})=>{const l=s.sub(r).toVar(),c=o.sub(r).toVar(),u=l.cross(c),h=D().toVar();return Le(u.dot(t.sub(r)).greaterThanEqual(0),()=>{const d=e.sub(n.mul(e.dot(n))).normalize(),p=n.cross(d).negate(),m=i.mul(yi(d,p,n).transpose()).toVar(),v=m.mul(r.sub(t)).normalize().toVar(),f=m.mul(s.sub(t)).normalize().toVar(),g=m.mul(a.sub(t)).normalize().toVar(),x=m.mul(o.sub(t)).normalize().toVar(),y=D(0).toVar();y.addAssign(ld({v1:v,v2:f})),y.addAssign(ld({v1:f,v2:g})),y.addAssign(ld({v1:g,v2:x})),y.addAssign(ld({v1:x,v2:v})),h.assign(D(yP({f:y})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),cd=1/6,MT=n=>lt(cd,lt(n,lt(n,n.negate().add(3)).sub(3)).add(1)),Tg=n=>lt(cd,lt(n,lt(n,lt(3,n).sub(6))).add(4)),TT=n=>lt(cd,lt(n,lt(n,lt(-3,n).add(3)).add(3)).add(1)),bg=n=>lt(cd,Ji(n,3)),bT=n=>MT(n).add(Tg(n)),ST=n=>TT(n).add(bg(n)),wT=n=>zt(-1,Tg(n).div(MT(n).add(Tg(n)))),ET=n=>zt(1,bg(n).div(TT(n).add(bg(n)))),AT=(n,e,t)=>{const i=n.uvNode,r=lt(i,e.zw).add(.5),s=ds(r),a=ps(r),o=bT(a.x),l=ST(a.x),c=wT(a.x),u=ET(a.x),h=wT(a.y),d=ET(a.y),p=z(s.x.add(c),s.y.add(h)).sub(.5).mul(e.xy),m=z(s.x.add(u),s.y.add(h)).sub(.5).mul(e.xy),v=z(s.x.add(c),s.y.add(d)).sub(.5).mul(e.xy),f=z(s.x.add(u),s.y.add(d)).sub(.5).mul(e.xy),g=bT(a.y).mul(zt(o.mul(n.uv(p).level(t)),l.mul(n.uv(m).level(t)))),x=ST(a.y).mul(zt(o.mul(n.uv(v).level(t)),l.mul(n.uv(f).level(t))));return g.add(x)},NT=U(([n,e=E(3)])=>{const t=z(n.size(P(e))),i=z(n.size(P(e.add(1)))),r=Qr(1,t),s=Qr(1,i),a=AT(n,ae(r,t),ds(e)),o=AT(n,ae(s,i),Of(e));return ps(e).mix(a,o)}),CT=U(([n,e,t,i,r])=>{const s=D(zf(e.negate(),Mr(n),Qr(1,i))),a=D(ta(r[0].xyz),ta(r[1].xyz),ta(r[2].xyz));return Mr(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),xP=U(([n,e])=>n.mul(li(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),_P=sT(),RT=U(([n,e,t])=>{const i=_P.uv(n),r=Gl(E(vo.x)).mul(xP(e,t));return NT(i,r)}),IT=U(([n,e,t])=>(Le(t.notEqual(0),()=>{const i=Uf(e).negate().div(t);return Df(i.negate().mul(n))}),D(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),MP=U(([n,e,t,i,r,s,a,o,l,c,u,h,d,p,m])=>{let v,f;if(m){v=ae().toVar(),f=D().toVar();const I=u.sub(1).mul(m.mul(.025)),T=D(u.sub(I),u,u.add(I));gt({start:0,end:3},({i:w})=>{const C=T.element(w),H=CT(n,e,h,C,o),M=a.add(H),b=c.mul(l.mul(ae(M,1))),k=z(b.xy.div(b.w)).toVar();k.addAssign(1),k.divAssign(2),k.assign(z(k.x,k.y.oneMinus()));const j=RT(k,t,C);v.element(w).assign(j.element(w)),v.a.addAssign(j.a),f.element(w).assign(i.element(w).mul(IT(ta(H),d,p).element(w)))}),v.a.divAssign(3)}else{const I=CT(n,e,h,u,o),T=a.add(I),w=c.mul(l.mul(ae(T,1))),C=z(w.xy.div(w.w)).toVar();C.addAssign(1),C.divAssign(2),C.assign(z(C.x,C.y.oneMinus())),v=RT(C,t,u),f=i.mul(IT(ta(I),d,p))}const g=f.rgb.mul(v.rgb),x=n.dot(e).clamp(),y=D(yT({dotNV:x,specularColor:r,specularF90:s,roughness:t})),_=f.r.add(f.g,f.b).div(3);return ae(y.oneMinus().mul(g),v.a.oneMinus().mul(_).oneMinus())}),TP=yi(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),bP=n=>{const e=n.sqrt();return D(1).add(e).div(D(1).sub(e))},LT=(n,e)=>n.sub(e).div(n.add(e)).pow2(),SP=(n,e)=>{const t=n.mul(2*Math.PI*1e-9),i=D(54856e-17,44201e-17,52481e-17),r=D(1681e3,1795300,2208400),s=D(43278e5,93046e5,66121e5),a=E(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let o=i.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return o=D(o.x.add(a),o.y,o.z).div(10685e-11),TP.mul(o)},wP=U(({outsideIOR:n,eta2:e,cosTheta1:t,thinFilmThickness:i,baseF0:r})=>{const s=rt(n,e,Ki(0,.03,i)),a=n.div(s).pow2().mul(E(1).sub(t.pow2())),o=E(1).sub(a).sqrt(),l=LT(s,n),c=xo({f0:l,f90:1,dotVH:t}),u=c.oneMinus(),h=s.lessThan(n).select(Math.PI,0),d=E(Math.PI).sub(h),p=bP(r.clamp(0,.9999)),m=LT(p,s.toVec3()),v=xo({f0:m,f90:1,dotVH:o}),f=D(p.x.lessThan(s).select(Math.PI,0),p.y.lessThan(s).select(Math.PI,0),p.z.lessThan(s).select(Math.PI,0)),g=s.mul(i,o,2),x=D(d).add(f),y=c.mul(v).clamp(1e-5,.9999),_=y.sqrt(),I=u.pow2().mul(v).div(D(1).sub(y));let T=c.add(I),w=I.sub(u);for(let C=1;C<=2;++C){w=w.mul(_);const H=SP(E(C).mul(g),E(C).mul(x)).mul(2);T=T.add(w.mul(H))}return T.max(D(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),EP=U(({normal:n,viewDir:e,roughness:t})=>{const i=n.dot(e).saturate(),r=t.pow2(),s=Ri(t.lessThan(.25),E(-339.2).mul(r).add(E(161.4).mul(t)).sub(25.9),E(-8.48).mul(r).add(E(14.3).mul(t)).sub(9.95)),a=Ri(t.lessThan(.25),E(44).mul(r).sub(E(23.7).mul(t)).add(3.26),E(1.97).mul(r).sub(E(3.27).mul(t)).add(.72));return Ri(t.lessThan(.25),0,E(.1).mul(t).sub(.025)).add(s.mul(i).add(a).exp()).mul(1/Math.PI).saturate()}),Sg=D(.04),wg=E(1);class ud extends uc{constructor(e=!1,t=!1,i=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=i,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=D().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=D().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=D().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=D().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=D().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Yt.dot(Vt).clamp();this.iridescenceFresnel=wP({outsideIOR:E(1),eta2:Sf,cosTheta1:t,thinFilmThickness:wf,baseF0:or}),this.iridescenceF0=xT({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=$h,i=Jf.sub($h).normalize(),r=Zf;e.backdrop=MP(r,i,pn,Nt,or,zl,t,zr,cr,lr,Hl,Af,Cf,Nf,this.dispersion?Rf:null),e.backdropAlpha=Hh,Nt.a.mulAssign(rt(1,e.backdrop.a,Hh))}}computeMultiscattering(e,t,i){const r=Yt.dot(Vt).clamp(),s=Mg({roughness:pn,dotNV:r}),a=(this.iridescenceF0?Bh.mix(or,this.iridescenceF0):or).mul(s.x).add(i.mul(s.y)),o=s.x.add(s.y).oneMinus(),l=or.add(or.oneMinus().mul(.047619)),c=a.mul(l).div(o.mul(l).oneMinus());e.addAssign(a),t.addAssign(c.mul(o))}direct({lightDirection:e,lightColor:t,reflectedLight:i}){const r=Yt.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(gP({lightDirection:e}))),this.clearcoat===!0){const s=mo.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(_g({lightDirection:e,f0:Sg,f90:wg,roughness:Vl,normalView:mo})))}i.directDiffuse.addAssign(r.mul(na({diffuseColor:Nt.rgb}))),i.directSpecular.addAssign(r.mul(_g({lightDirection:e,f0:or,f90:1,roughness:pn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:i,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:o}){const l=t.add(i).sub(r),c=t.sub(i).sub(r),u=t.sub(i).add(r),h=t.add(i).add(r),d=Yt,p=Vt,m=Pi.toVar(),v=vP({N:d,V:p,roughness:pn}),f=a.uv(v).toVar(),g=o.uv(v).toVar(),x=yi(D(f.x,0,f.y),D(0,1,0),D(f.z,0,f.w)).toVar(),y=or.mul(g.x).add(or.oneMinus().mul(g.y)).toVar();s.directSpecular.addAssign(e.mul(y).mul(_T({N:d,V:p,P:m,mInv:x,p0:l,p1:c,p2:u,p3:h}))),s.directDiffuse.addAssign(e.mul(Nt).mul(_T({N:d,V:p,P:m,mInv:yi(1,0,0,0,1,0,0,0,1),p0:l,p1:c,p2:u,p3:h})))}indirect(e,t,i){this.indirectDiffuse(e,t,i),this.indirectSpecular(e,t,i),this.ambientOcclusion(e,t,i)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(na({diffuseColor:Nt})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:i}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Ks,EP({normal:Yt,viewDir:Vt,roughness:Vh}))),this.clearcoat===!0){const c=mo.dot(Vt).clamp(),u=yT({dotNV:c,specularColor:Sg,specularF90:wg,roughness:Vl});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(u))}const r=D().toVar("singleScattering"),s=D().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,zl);const o=r.add(s),l=Nt.mul(o.r.max(o.g).max(o.b).oneMinus());i.indirectSpecular.addAssign(e.mul(r)),i.indirectSpecular.addAssign(s.mul(a)),i.indirectDiffuse.addAssign(l.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const i=Yt.dot(Vt).clamp().add(e),r=pn.mul(-16).oneMinus().negate().exp2(),s=e.sub(i.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(s)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const i=mo.dot(Vt).clamp(),r=xo({dotVH:i,f0:Sg,f90:wg}),s=t.mul(Fh.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Fh));t.assign(s)}if(this.sheen===!0){const i=Ks.r.max(Ks.g).max(Ks.b).mul(.157).oneMinus(),r=t.mul(i).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const PT=E(1),Eg=E(-2),hd=E(.8),Ag=E(-1),dd=E(.4),Ng=E(2),pd=E(.305),Cg=E(3),DT=E(.21),AP=E(4),UT=E(4),NP=E(16),CP=U(([n])=>{const e=D(It(n)).toVar(),t=E(-1).toVar();return Le(e.x.greaterThan(e.z),()=>{Le(e.x.greaterThan(e.y),()=>{t.assign(Ri(n.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ri(n.y.greaterThan(0),1,4))})}).Else(()=>{Le(e.z.greaterThan(e.y),()=>{t.assign(Ri(n.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ri(n.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),RP=U(([n,e])=>{const t=z().toVar();return Le(e.equal(0),()=>{t.assign(z(n.z,n.y).div(It(n.x)))}).ElseIf(e.equal(1),()=>{t.assign(z(n.x.negate(),n.z.negate()).div(It(n.y)))}).ElseIf(e.equal(2),()=>{t.assign(z(n.x.negate(),n.y).div(It(n.z)))}).ElseIf(e.equal(3),()=>{t.assign(z(n.z.negate(),n.y).div(It(n.x)))}).ElseIf(e.equal(4),()=>{t.assign(z(n.x.negate(),n.z).div(It(n.y)))}).Else(()=>{t.assign(z(n.x,n.y).div(It(n.z)))}),lt(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),IP=U(([n])=>{const e=E(0).toVar();return Le(n.greaterThanEqual(hd),()=>{e.assign(PT.sub(n).mul(Ag.sub(Eg)).div(PT.sub(hd)).add(Eg))}).ElseIf(n.greaterThanEqual(dd),()=>{e.assign(hd.sub(n).mul(Ng.sub(Ag)).div(hd.sub(dd)).add(Ag))}).ElseIf(n.greaterThanEqual(pd),()=>{e.assign(dd.sub(n).mul(Cg.sub(Ng)).div(dd.sub(pd)).add(Ng))}).ElseIf(n.greaterThanEqual(DT),()=>{e.assign(pd.sub(n).mul(AP.sub(Cg)).div(pd.sub(DT)).add(Cg))}).Else(()=>{e.assign(E(-2).mul(Gl(lt(1.16,n))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),OT=U(([n,e])=>{const t=n.toVar();t.assign(lt(2,t).sub(1));const i=D(t,1).toVar();return Le(e.equal(0),()=>{i.assign(i.zyx)}).ElseIf(e.equal(1),()=>{i.assign(i.xzy),i.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{i.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{i.assign(i.zyx),i.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{i.assign(i.xzy),i.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{i.z.mulAssign(-1)}),i}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),FT=U(([n,e,t,i,r,s])=>{const a=E(t),o=D(e),l=li(IP(a),Eg,s),c=ps(l),u=ds(l),h=D(Rg(n,o,u,i,r,s)).toVar();return Le(c.notEqual(0),()=>{const d=D(Rg(n,o,u.add(1),i,r,s)).toVar();h.assign(rt(h,d,c))}),h}),Rg=U(([n,e,t,i,r,s])=>{const a=E(t).toVar(),o=D(e),l=E(CP(o)).toVar(),c=E(ft(UT.sub(a),0)).toVar();a.assign(ft(a,UT));const u=E(Gh(a)).toVar(),h=z(RP(o,l).mul(u.sub(2)).add(1)).toVar();return Le(l.greaterThan(2),()=>{h.y.addAssign(u),l.subAssign(3)}),h.x.addAssign(l.mul(u)),h.x.addAssign(c.mul(lt(3,NP))),h.y.addAssign(lt(4,Gh(s).sub(u))),h.x.mulAssign(i),h.y.mulAssign(r),n.uv(h).grad(z(),z())}),Ig=U(({envMap:n,mipInt:e,outputDirection:t,theta:i,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=Tr(i),c=t.mul(l).add(r.cross(t).mul(Ci(i))).add(r.mul(r.dot(t).mul(l.oneMinus())));return Rg(n,c,e,s,a,o)}),VT=U(({n,latitudinal:e,poleAxis:t,outputDirection:i,weights:r,samples:s,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{const d=D(Ri(e,t,uo(t,i))).toVar();Le(Pf(d.equals(D(0))),()=>{d.assign(D(i.z,0,i.x.negate()))}),d.assign(Mr(d));const p=D().toVar();return p.addAssign(r.element(P(0)).mul(Ig({theta:0,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),gt({start:P(1),end:n},({i:m})=>{Le(m.greaterThanEqual(s),()=>{sd()});const v=E(a.mul(E(m))).toVar();p.addAssign(r.element(m).mul(Ig({theta:v.mul(-1),axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),p.addAssign(r.element(m).mul(Ig({theta:v,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),ae(p,1)});let md=null;const BT=new WeakMap;function LP(n){const e=Math.log2(n)-2,t=1/n;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function PP(n){let e=BT.get(n);if((e!==void 0?e.pmremVersion:-1)!==n.pmremVersion){const t=n.image;if(n.isCubeTexture)if(DP(t))e=md.fromCubemap(n,e);else return null;else if(UP(t))e=md.fromEquirectangular(n,e);else return null;e.pmremVersion=n.pmremVersion,BT.set(n,e)}return e.texture}class zT extends pt{static get type(){return"PMREMNode"}constructor(e,t=null,i=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=i,this._generator=null;const r=new Wt;r.isRenderTargetTexture=!0,this._texture=yt(r),this._width=fe(0),this._height=fe(0),this._maxMip=fe(0),this.updateBeforeType=je.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=LP(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,i=this._value;t!==i.pmremVersion&&(i.isPMREMTexture===!0?e=i:e=PP(i),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){md===null&&(md=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const i=this.value;e.renderer.coordinateSystem===Rr&&i.isPMREMTexture!==!0&&i.isRenderTargetTexture===!0&&(t=D(t.x.negate(),t.yz));let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),FT(this._texture,t,r,this._width,this._height,this._maxMip)}}function DP(n){if(n==null)return!1;let e=0;const t=6;for(let i=0;i<t;i++)n[i]!==void 0&&e++;return e===t}function UP(n){return n==null?!1:n.height>0}const kT=K(zT),HT=new WeakMap;class GT extends ra{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const h=i.isTextureNode?i.value:t[i.property];let d=HT.get(h);d===void 0&&(d=kT(h),HT.set(h,d)),i=d}const r=t.envMap?fi("envMapIntensity","float",e.material):fi("environmentIntensity","float",e.scene),s=t.useAnisotropy===!0||t.anisotropy>0?o1:Yt,a=i.context(WT(pn,s)).mul(r),o=i.context(OP(Zf)).mul(Math.PI).mul(r),l=$l(a),c=$l(o);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(c);const u=e.context.lightingModel.clearcoatRadiance;if(u){const h=i.context(WT(Vl,mo)).mul(r),d=$l(h);u.addAssign(d)}}}const WT=(n,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Vt.negate().reflect(e),t=n.mul(n).mix(t,e).normalize(),t=t.transformDirection(cr)),t),getTextureLevel:()=>n}},OP=n=>({getUV:()=>n,getTextureLevel:()=>E(1)}),FP=new El;class jT extends Tt{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(FP),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new GT(t):null}setupLightingModel(){return new ud}setupSpecular(){const e=rt(D(.04),Nt.rgb,Fl);or.assign(e),zl.assign(1)}setupVariants(){const e=this.metalnessNode?E(this.metalnessNode):y1;Fl.assign(e);let t=this.roughnessNode?E(this.roughnessNode):v1;t=xg({roughness:t}),pn.assign(t),this.setupSpecular(),Nt.assign(ae(Nt.rgb.mul(e.oneMinus()),Nt.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const VP=new mh;class XT extends jT{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(VP),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?E(this.iorNode):L1;Hl.assign(e),or.assign(rt(xi(Vf(Hl.sub(1).div(Hl.add(1))).mul(g1),D(1)).mul(ng),Nt.rgb,Fl)),zl.assign(rt(ng,1,Fl))}setupLightingModel(){return new ud(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?E(this.clearcoatNode):_1,i=this.clearcoatRoughnessNode?E(this.clearcoatRoughnessNode):M1;Fh.assign(t),Vl.assign(xg({roughness:i}))}if(this.useSheen){const t=this.sheenNode?D(this.sheenNode):S1,i=this.sheenRoughnessNode?E(this.sheenRoughnessNode):w1;Ks.assign(t),Vh.assign(i)}if(this.useIridescence){const t=this.iridescenceNode?E(this.iridescenceNode):A1,i=this.iridescenceIORNode?E(this.iridescenceIORNode):N1,r=this.iridescenceThicknessNode?E(this.iridescenceThicknessNode):C1;Bh.assign(t),Sf.assign(i),wf.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?z(this.anisotropyNode):E1).toVar();hs.assign(t.length()),Le(hs.equal(0),()=>{t.assign(z(1,0))}).Else(()=>{t.divAssign(z(hs)),hs.assign(hs.saturate())}),zh.assign(hs.pow2().mix(pn.pow2(),1)),Bl.assign(ia[0].mul(t.x).add(ia[1].mul(t.y))),Zs.assign(ia[1].mul(t.x).sub(ia[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?E(this.transmissionNode):R1,i=this.thicknessNode?E(this.thicknessNode):I1,r=this.attenuationDistanceNode?E(this.attenuationDistanceNode):P1,s=this.attenuationColorNode?D(this.attenuationColorNode):D1;if(Hh.assign(t),Af.assign(i),Nf.assign(r),Cf.assign(s),this.useDispersion){const a=this.dispersionNode?E(this.dispersionNode):O1;Rf.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?D(this.clearcoatNormalNode):T1}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class BP extends ud{constructor(e,t,i,r){super(e,t,i),this.useSSS=r}direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){if(this.useSSS===!0){const a=s.material,{thicknessColorNode:o,thicknessDistortionNode:l,thicknessAmbientNode:c,thicknessAttenuationNode:u,thicknessPowerNode:h,thicknessScaleNode:d}=a,p=e.add(Yt.mul(l)).normalize(),m=E(Vt.dot(p.negate()).saturate().pow(h).mul(d)),v=D(m.add(c).mul(o));i.directDiffuse.addAssign(v.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s)}}class zP extends XT{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=E(.1),this.thicknessAmbientNode=E(0),this.thicknessAttenuationNode=E(.1),this.thicknessPowerNode=E(2),this.thicknessScaleNode=E(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new BP(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const kP=U(({normal:n,lightDirection:e,builder:t})=>{const i=n.dot(e),r=z(i.mul(.5).add(.5),0);if(t.material.gradientMap){const s=rn("gradientMap","texture").context({getUV:()=>r});return D(s.r)}else{const s=r.fwidth().mul(.5);return rt(D(.7),D(1),Ki(E(.7).sub(s.x),E(.7).add(s.x),r.x))}});class HP extends uc{direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){const a=kP({normal:Jh,lightDirection:e,builder:s}).mul(t);i.directDiffuse.addAssign(a.mul(na({diffuseColor:Nt.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(na({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const GP=new Um;class WP extends Tt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(GP),this.setValues(e)}setupLightingModel(){return new HP}}class qT extends pt{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=D(Vt.z,0,Vt.x.negate()).normalize(),t=Vt.cross(e);return z(e.dot(Yt),t.dot(Yt)).mul(.495).add(.5)}}const YT=ge(qT),jP=new Om;class XP extends Tt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(jP),this.setValues(e)}setupVariants(e){const t=YT;let i;e.material.matcap?i=rn("matcap","texture").context({getUV:()=>t}):i=D(rt(.2,.8,t.y)),Nt.rgb.mulAssign(i.rgb)}}const qP=new Qa;class YP extends Tt{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(qP),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class $T extends pt{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:i}=this;if(this.getNodeType(e)==="vec2"){const r=t.cos(),s=t.sin();return Ol(r,s,s.negate(),r).mul(i)}else{const r=t,s=$s(ae(1,0,0,0),ae(0,Tr(r.x),Ci(r.x).negate(),0),ae(0,Ci(r.x),Tr(r.x),0),ae(0,0,0,1)),a=$s(ae(Tr(r.y),0,Ci(r.y),0),ae(0,1,0,0),ae(Ci(r.y).negate(),0,Tr(r.y),0),ae(0,0,0,1)),o=$s(ae(Tr(r.z),Ci(r.z).negate(),0,0),ae(Ci(r.z),Tr(r.z),0,0),ae(0,0,1,0),ae(0,0,0,1));return s.mul(a).mul(o).mul(ae(i,1)).xyz}}}const Lg=K($T),$P=new hl;class JP extends Tt{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues($P),this.setValues(e)}setupPosition({object:e,camera:t,context:i}){const r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:o}=this,l=Zt;let c=fn.mul(D(s||0)),u=z(zr[0].xyz.length(),zr[1].xyz.length());o!==null&&(u=u.mul(o)),!r&&t.isPerspectiveCamera&&(u=u.mul(c.z.negate()));let h=l.xy;if(e.center&&e.center.isVector2===!0){const v=q2("center","vec2");h=h.sub(v.sub(.5))}h=h.mul(u);const d=E(a||b1),p=Lg(h,d);c=ae(c.xy.add(p),c.zw);const m=lr.mul(c);return i.vertex=l,m}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class KP extends uc{constructor(){super(),this.shadowNode=E(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Nt.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Nt.rgb)}}const ZP=new ph;class QP extends Tt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ZP),this.setValues(e)}setupLightingModel(){return new KP}}const e3=U(({texture:n,uv:e})=>{const t=D().toVar();return Le(e.x.lessThan(1e-4),()=>{t.assign(D(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{t.assign(D(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{t.assign(D(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{t.assign(D(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{t.assign(D(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{t.assign(D(0,0,-1))}).Else(()=>{const i=n.uv(e.add(D(-.01,0,0))).r.sub(n.uv(e.add(D(.01,0,0))).r),r=n.uv(e.add(D(0,-.01,0))).r.sub(n.uv(e.add(D(0,.01,0))).r),s=n.uv(e.add(D(0,0,-.01))).r.sub(n.uv(e.add(D(0,0,.01))).r);t.assign(D(i,r,s))}),t.normalize()});class JT extends mn{static get type(){return"Texture3DNode"}constructor(e,t=null,i=null){super(e,t,i),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return D(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return e3({texture:this,uv:e})}}const KT=K(JT);class t3 extends Tt{static get type(){return"VolumeNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){const t=KT(this.map,null,0),i=U(({orig:r,dir:s})=>{const a=D(-.5),o=D(.5),l=s.reciprocal(),c=a.sub(r).mul(l),u=o.sub(r).mul(l),h=xi(c,u),d=ft(c,u),p=ft(h.x,ft(h.y,h.z)),m=xi(d.x,xi(d.y,d.z));return z(p,m)});this.fragmentNode=U(()=>{const r=Ii(D(jM.mul(ae(Jf,1)))),s=Ii(Li.sub(r)).normalize(),a=z(i({orig:r,dir:s})).toVar();a.x.greaterThan(a.y).discard(),a.assign(z(ft(a.x,0),a.y));const o=D(r.add(a.x.mul(s))).toVar(),l=D(s.abs().reciprocal()).toVar(),c=E(xi(l.x,xi(l.y,l.z))).toVar("delta");c.divAssign(rn("steps","float"));const u=ae(rn("base","color"),0).toVar();return gt({type:"float",start:a.x,end:a.y,update:"+= delta"},()=>{const h=ar("float","d").assign(t.uv(o.add(.5)).r);this.testNode!==null?this.testNode({map:t,mapValue:h,probe:o,finalColor:u}).append():(u.a.assign(1),sd()),o.addAssign(s.mul(c))}),u.a.equal(0).discard(),ae(u)})(),super.setup(e)}}class ZT extends Gi{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,i,r){const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{try{t(this.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),this.manager.itemError(e)}},i,r)}parseNodes(e){const t={};if(e!==void 0){for(const r of e){const{uuid:s,type:a}=r;t[s]=this.createNodeFromType(a),t[s].uuid=s}const i={nodes:t,textures:this.textures};for(const r of e)r.meta=i,t[r.uuid].deserialize(r),delete r.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const i={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=i,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),E()):G(new this.nodes[e])}}class QT extends Tc{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),i=this.nodes,r=e.inputNodes;for(const s in r){const a=r[s];t[s]=i[a]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class i3 extends ux{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const i=super.parse(e,t);return this._nodesJSON=null,i}parseNodes(e,t){if(e!==void 0){const i=new ZT;return i.setNodes(this.nodes),i.setTextures(t),i.parseNodes(e)}return{}}parseMaterials(e,t){const i={};if(e!==void 0){const r=this.parseNodes(this._nodesJSON,t),s=new QT;s.setTextures(t),s.setNodes(r),s.setNodeMaterials(this.nodeMaterials);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]=s.parse(l)}}return i}}class Pg{constructor(e,t,i=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=i}}class eb{constructor(e,t,i){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=i.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class Dg{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class tb extends Dg{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class ib{constructor(e,t,i=""){this.name=e,this.type=t,this.code=i,Object.defineProperty(this,"isNodeCode",{value:!0})}}let r3=0;class fd{constructor(e=null){this.id=r3++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Ug extends Et{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const n3=(n,e)=>G(new Ug(n,e));class Og extends qe{static get type(){return"CodeNode"}constructor(e="",t=[],i=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=i,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const i=e.getCodeFromNode(this,this.getNodeType(e));return i.code=this.code,i.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const gd=K(Og),s3=(n,e)=>gd(n,e,"js"),a3=(n,e)=>gd(n,e,"wgsl"),o3=(n,e)=>gd(n,e,"glsl");class Fg extends Og{static get type(){return"FunctionNode"}constructor(e="",t=[],i=""){super(e,t,i)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let i=t.nodeFunction;return i===void 0&&(i=e.parser.parseFunction(this.code),t.nodeFunction=i),i}generate(e,t){super.generate(e);const i=this.getNodeFunction(e),r=i.name,s=i.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const o=e.getPropertyName(a),l=this.getNodeFunction(e).getCode(o);return a.code=l+`
|
|
3863
|
+
`,t==="property"?o:e.format(`${o}()`,s,t)}}const rb=(n,e=[],t="")=>{for(let s=0;s<e.length;s++){const a=e[s];typeof a=="function"&&(e[s]=a.functionNode)}const i=G(new Fg(n,e,t)),r=(...s)=>i.call(...s);return r.functionNode=i,r},l3=(n,e)=>rb(n,e,"glsl"),c3=(n,e)=>rb(n,e,"wgsl");class sa{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class u3 extends sa{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class h3 extends sa{constructor(e,t=new J){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class d3 extends sa{constructor(e,t=new N){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class p3 extends sa{constructor(e,t=new st){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class m3 extends sa{constructor(e,t=new xe){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class f3 extends sa{constructor(e,t=new Ke){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class g3 extends sa{constructor(e,t=new Re){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class v3 extends u3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class y3 extends h3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class x3 extends d3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class _3 extends p3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class M3 extends m3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class T3 extends f3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class b3 extends g3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class nb extends qe{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const i=new Pl(t);return this._currentCond=Ri(e,i),this.add(this._currentCond)}ElseIf(e,t){const i=new Pl(t),r=Ri(e,i);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Pl(e),this}build(e,...t){const i=xf();Ul(this);for(const r of this.nodes)r.build(e,"void");return Ul(i),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const vd=K(nb);class S3{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let i=0;i<e.length;i++)if(t=t.get(e[i]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let i=this.weakMap;for(let r=0;r<e.length;r++){const s=e[r];i.has(s)===!1&&i.set(s,new WeakMap),i=i.get(s)}return i.set(e[e.length-1],t)}delete(e){let t=this.weakMap;for(let i=0;i<e.length;i++)if(t=t.get(e[i]),t===void 0)return!1;return t.delete(e[e.length-1])}}const _o=4,sb=[.125,.215,.35,.446,.526,.582],aa=20,Vg=new Ds(-1,1,1,-1,0,1),w3=new di(90,1),ab=new xe;let Bg=null,zg=0,kg=0;const oa=(1+Math.sqrt(5))/2,Mo=1/oa,ob=[new N(-oa,Mo,0),new N(oa,Mo,0),new N(-Mo,0,oa),new N(Mo,0,oa),new N(0,oa,-Mo),new N(0,oa,Mo),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],E3=[3,1,5,0,4,2],Hg=OT(nt(),_i("faceIndex")).normalize(),Gg=D(Hg.x,Hg.y.negate(),Hg.z);class A3{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,i=.1,r=100){Bg=this._renderer.getRenderTarget(),zg=this._renderer.getActiveCubeFace(),kg=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=cb(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ub(),await 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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Bg,zg,kg),e.scissorTest=!1,yd(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===fr||e.mapping===Ar?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Bg=this._renderer.getRenderTarget(),zg=this._renderer.getActiveCubeFace(),kg=this._renderer.getActiveMipmapLevel();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:Lt,minFilter:Lt,generateMipmaps:!1,type:wi,format:Ei,colorSpace:nr},r=lb(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=lb(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=N3(s)),this._blurMaterial=C3(s,e,t)}return r}async _compileMaterial(e){const t=new Ft(this._lodPlanes[0],e);await this._renderer.compile(t,Vg)}_sceneToCubeUV(e,t,i,r){const s=w3;s.near=t,s.far=i;const a=[-1,1,-1,-1,-1,-1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear;l.getClearColor(ab),l.autoClear=!1;let u=this._backgroundBox;if(u===null){const p=new $r({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1});u=new Ft(new _n,p)}let h=!1;const d=e.background;d?d.isColor&&(u.material.color.copy(d),e.background=null,h=!0):(u.material.color.copy(ab),h=!0),l.setRenderTarget(r),l.clear(),h&&l.render(u,s);for(let p=0;p<6;p++){const m=p%3;m===0?(s.up.set(0,a[p],0),s.lookAt(o[p],0,0)):m===1?(s.up.set(0,0,a[p]),s.lookAt(0,o[p],0)):(s.up.set(0,a[p],0),s.lookAt(0,0,o[p]));const v=this._cubeSize;yd(r,m*v,p>2?v:0,v,v),l.render(e,s)}l.autoClear=c,e.background=d}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===fr||e.mapping===Ar;r?this._cubemapMaterial===null&&(this._cubemapMaterial=cb(e)):this._equirectMaterial===null&&(this._equirectMaterial=ub(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const o=this._cubeSize;yd(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Vg)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=ob[(r-s-1)%ob.length];this._blur(e,s-1,s,a,o)}t.autoClear=i}_blur(e,t,i,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[r];h.material=c;const d=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*aa-1),v=s/m,f=isFinite(s)?1+Math.floor(u*v):aa;f>aa&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${aa}`);const g=[];let x=0;for(let w=0;w<aa;++w){const C=w/v,H=Math.exp(-C*C/2);g.push(H),w===0?x+=H:w<f&&(x+=2*H)}for(let w=0;w<g.length;w++)g[w]=g[w]/x;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=f,d.weights.array=g,d.latitudinal.value=a==="latitudinal"?1:0,o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=m,d.mipInt.value=y-i;const _=this._sizeLods[r],I=3*_*(r>y-_o?r-y+_o:0),T=4*(this._cubeSize-_);yd(t,I,T,3*_,2*_),l.setRenderTarget(t),l.render(h,Vg)}}function N3(n){const e=[],t=[],i=[],r=[];let s=n;const a=n-_o+1+sb.length;for(let o=0;o<a;o++){const l=Math.pow(2,s);t.push(l);let c=1/l;o>n-_o?c=sb[o-n+_o-1]:o===0&&(c=0),i.push(c);const u=1/(l-2),h=-u,d=1+u,p=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,v=6,f=3,g=2,x=1,y=new Float32Array(f*v*m),_=new Float32Array(g*v*m),I=new Float32Array(x*v*m);for(let w=0;w<m;w++){const C=w%3*2/3-1,H=w>2?0:-1,M=[C,H,0,C+2/3,H,0,C+2/3,H+1,0,C,H,0,C+2/3,H+1,0,C,H+1,0],b=E3[w];y.set(M,f*v*b),_.set(p,g*v*b);const k=[b,b,b,b,b,b];I.set(k,x*v*b)}const T=new ct;T.setAttribute("position",new wt(y,f)),T.setAttribute("uv",new wt(_,g)),T.setAttribute("faceIndex",new wt(I,x)),e.push(T),r.push(new Ft(T,null)),s>_o&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i,lodMeshes:r}}function lb(n,e,t){const i=new ui(n,e,t);return i.texture.mapping=Wn,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function yd(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Wg(n){const e=new Tt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Er,e.name=`PMREM_${n}`,e}function C3(n,e,t){const i=gn(new Array(aa).fill(0)),r=fe(new N(0,1,0)),s=fe(0),a=E(aa),o=fe(0),l=fe(1),c=yt(null),u=fe(0),h=E(1/e),d=E(1/t),p=E(n),m={n:a,latitudinal:o,weights:i,poleAxis:r,outputDirection:Gg,dTheta:s,samples:l,envMap:c,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},v=Wg("blur");return v.uniforms=m,v.fragmentNode=VT({...m,latitudinal:o.equal(1)}),v}function cb(n){const e=Wg("cubemap");return e.fragmentNode=Zh(n,Gg),e}function ub(n){const e=Wg("equirect");return e.fragmentNode=yt(n,vg(Gg),0),e}let R3=0;class hb{constructor(e="",t=[],i=0,r=[]){this.name=e,this.bindings=t,this.index=i,this.bindingsReference=r,this.id=R3++}}const db=new WeakMap,I3=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),L3=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),xd=n=>(n=Number(n),n+(n%1?"":".0"));class pb{constructor(e,t,i){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=i,this.scene=null,this.camera=null,this.nodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=vd(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new fd,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=db.get(this.renderer);return e===void 0&&(e=new S3,db.set(this.renderer,e)),e}createRenderTarget(e,t,i){return new ui(e,t,i)}createCubeRenderTarget(e,t){return new hT(e,t)}createPMREMGenerator(){return new A3(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const i=this.getBindGroupsCache(),r=[];let s=!0;for(const o of t)r.push(o),s=s&&o.groupNode.shared!==!0;let a;return s?(a=i.get(r),a===void 0&&(a=new hb(e,r,this.bindingsIndexes[e].group,r),i.set(r,a))):a=new hb(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const i=this.bindings[t];let r=i[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),i[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},i=this.bindings;for(const r of hf)for(const s in i[r]){const a=i[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,i)=>t.bindings[0].groupNode.order-i.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const i=e[t];this.bindingsIndexes[i.name].group=t,i.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType(),i=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==je.NONE&&this.updateNodes.push(e.getSelf()),i!==je.NONE&&this.updateBeforeNodes.push(e.getSelf()),r!==je.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Lt||e.magFilter===Xn||e.magFilter===bn||e.magFilter===Xi||e.minFilter===Lt||e.minFilter===Xn||e.minFilter===bn||e.minFilter===Xi}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const i=this.getDataFromNode(e);return i.cache===void 0&&(i.cache=new fd(t?this.getCache():null)),i.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new xe:e==="vec2"?t=new J:e==="vec3"?t=new N:e==="vec4"&&(t=new st)),e==="float")return xd(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${xd(t.r)}, ${xd(t.g)}, ${xd(t.b)} )`;const i=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(i===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(i===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(i===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(i>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(i>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const i=this.attributes;for(const s of i)if(s.name===e)return s;const r=new Pg(e,t);return i.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===ya)return"int";if(t===Nr)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const i=I3.get(e);return(t==="float"?"":t[0])+i}getTypeFromArray(e){return L3.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const i=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof Lv)&&s!==!0&&(a=this.getTypeFromArray(i)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),i=/vec([2-4])/.exec(t);return i!==null?Number(i[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=vd(this.stack),this.stacks.push(xf()||this.stack),Ul(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Ul(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,i=null){i=i===null?e.isGlobal(this)?this.globalCache:this.cache:i;let r=i.getData(e);return r===void 0&&(r={},i.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const i=this.getDataFromNode(e,t);return i.properties||(i.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const i=this.getDataFromNode(e);let r=i.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new Pg("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),i.bufferAttribute=r}return r}getStructTypeFromNode(e,t=this.shaderStage){const i=this.getDataFromNode(e,t);if(i.structType===void 0){const r=this.structs.index++;e.name=`StructType${r}`,this.structs[t].push(e),i.structType=e}return e}getUniformFromNode(e,t,i=this.shaderStage,r=null){r==="in"&&(console.warn('NodeBuilder: "in" is a reserved word, using "inValue" instead.',e,r),e.name="inValue",r=e.name);const s=this.getDataFromNode(e,i,this.globalCache);let a=s.uniform;if(a===void 0){const o=this.uniforms.index++;a=new eb(r||"nodeUniform"+o,t,e),this.uniforms[i].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,i=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const o=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+o.length),a=new Dg(t,i),o.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,i=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,o=a.length;t===null&&(t="nodeVarying"+o),s=new tb(t,i),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,i=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[i]||(this.codes[i]=[]),o=a.length;s=new ib("nodeCode"+o,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:i,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const o of i)this.addLineFlowCode(o)}addLineFlowCodeBlock(e,t,i){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(i,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
|
|
3864
|
+
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),i=this.flowChildNode(e,t);return this.flowsData.set(e,i),i}buildFunctionNode(e){const t=new Fg,i=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=i,t}flowShaderNode(e){const t=e.layout,i={[Symbol.iterator](){let a=0;const o=Object.values(this);return{next:()=>({value:o[a],done:a++>=o.length})}}};for(const a of t.inputs)i[a.name]=new Ug(a.type,a.name);e.layout=null;const r=e.call(i),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowStagesNode(e,t=null){const i=this.flow,r=this.vars,s=this.cache,a=this.buildStage,o=this.stack,l={code:""};this.flow=l,this.vars={},this.cache=new fd,this.stack=vd();for(const c of uf)this.setBuildStage(c),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=i,this.vars=r,this.cache=s,this.stack=o,this.setBuildStage(a),l}getFunctionOperator(){return null}flowChildNode(e,t=null){const i=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=i,r}flowNodeFromShaderStage(e,t,i=null,r=null){const s=this.shaderStage;this.setShaderStage(e);const a=this.flowChildNode(t,i);return r!==null&&(a.code+=`${this.tab+r} = ${a.result};
|
|
3865
3865
|
`),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(s),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const i=this.vars[e];if(i!==void 0)for(const r of i)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let i="";if(t!==void 0)for(const r of t)i+=r.code+`
|
|
3866
|
-
`;return i}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:i}=this;if(t!==null){let r=i.nodes.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new Tt),r.build(this)}else this.addFlow("compute",e);for(const r of
|
|
3867
|
-
`}}class pb{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,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={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,i)),i}updateBeforeNode(e){const t=e.getUpdateBeforeType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,i);r.get(i)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,i);r.get(i)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,i);r.get(i)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,i);r.get(i)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,i);r.get(i)!==this.frameId&&e.update(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,i);r.get(i)!==this.renderId&&e.update(this)!==!1&&r.set(i,this.renderId)}else t===je.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}}class Wg{constructor(e,t,i=null,r="",s=!1){this.type=e,this.name=t,this.count=i,this.qualifier=r,this.isConst=s}}Wg.isNodeFunctionInput=!0;class P3 extends qe{static get type(){return"StructTypeNode"}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class jg extends qe{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,i=[];for(let r=0;r<t.length;r++)i.push(t[r].getNodeType(e));this.nodeType=e.getStructTypeFromNode(new P3(i)).name}generate(e,t){const i=e.getOutputStructName(),r=this.members,s=i!==""?i+".":"";for(let a=0;a<r.length;a++){const o=r[a].build(e,t);e.addLineFlowCode(`${s}m${a} = ${o}`,this)}return i}}const D3=K(jg);function Xg(n,e){for(let t=0;t<n.length;t++)if(n[t].name===e)return t;return-1}class mb extends jg{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const t={...this.outputNodes,...e.outputNodes};return xd(t)}setup(e){const t=this.outputNodes,i=e.renderer.getRenderTarget(),r=[],s=i.textures;for(const a in t){const o=Xg(s,a);r[o]=ae(t[a])}return this.members=r,super.setup(e)}}const xd=K(mb);class fb extends qe{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let i=this._candidateFnCall;if(i===null){let r=null,s=-1;for(const a of this.functionNodes){const o=a.shaderNode.layout;if(o===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const l=o.inputs;if(t.length===l.length){let c=0;for(let u=0;u<t.length;u++){const h=t[u],d=l[u];h.getNodeType(e)===d.type?c++:c=0}c>s&&(r=a,s=c)}}this._candidateFnCall=i=r(...t)}return i}}const U3=K(fb),Di=n=>(...e)=>U3(n,...e);class Si extends $s{static get type(){return"TimerNode"}constructor(e=Si.LOCAL,t=1,i=0){super(i),this.scope=e,this.scale=t,this.updateType=je.FRAME}update(e){const t=this.scope,i=this.scale;t===Si.LOCAL?this.value+=e.deltaTime*i:t===Si.DELTA?this.value=e.deltaTime*i:t===Si.FRAME?this.value=e.frameId:this.value=e.time*i}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}Si.LOCAL="local",Si.GLOBAL="global",Si.DELTA="delta",Si.FRAME="frame";const qg=(n,e=0)=>G(new Si(Si.LOCAL,n,e)),O3=(n,e=0)=>G(new Si(Si.GLOBAL,n,e)),F3=(n,e=0)=>G(new Si(Si.DELTA,n,e)),V3=ge(Si,Si.FRAME).toUint();class gi extends qe{static get type(){return"OscNode"}constructor(e=gi.SINE,t=qg()){super(),this.method=e,this.timeNode=t}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){const e=this.method,t=G(this.timeNode);let i=null;return e===gi.SINE?i=t.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5):e===gi.SQUARE?i=t.fract().round():e===gi.TRIANGLE?i=t.add(.5).fract().mul(2).sub(1).abs():e===gi.SAWTOOTH&&(i=t.fract()),i}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}gi.SINE="sine",gi.SQUARE="square",gi.TRIANGLE="triangle",gi.SAWTOOTH="sawtooth";const B3=K(gi,gi.SINE),z3=K(gi,gi.SQUARE),k3=K(gi,gi.TRIANGLE),H3=K(gi,gi.SAWTOOTH);class gb extends qe{static get type(){return"SpriteSheetUVNode"}constructor(e,t=nt(),i=E(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=i}setup(){const{frameNode:e,uvNode:t,countNode:i}=this,{width:r,height:s}=i,a=e.mod(r.mul(s)).floor(),o=a.mod(r),l=s.sub(a.add(1).div(r).ceil()),c=i.reciprocal(),u=z(o,l);return t.add(u).mul(c)}}const G3=K(gb);class vb extends ls{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}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.bufferObject===!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.bufferObject===!0&&r!==!0?i=e.generatePBO(this):i=this.node.build(e):i=super.generate(e),r!==!0){const s=this.getNodeType(e);i=e.format(i,s,t)}return i}}const W3=K(vb);class yb extends qe{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,i=null,r=E(1),s=Zt,a=ur){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=i,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:i,scaleNode:r,positionNode:s,normalNode:a}=this;let o=a.abs().normalize();o=o.div(o.dot(D(1)));const l=s.yz.mul(r),c=s.zx.mul(r),u=s.xy.mul(r),h=e.value,d=t!==null?t.value:h,p=i!==null?i.value:h,m=yt(h,l).mul(o.x),v=yt(d,c).mul(o.y),f=yt(p,u).mul(o.z);return zt(m,v,f)}}const xb=K(yb),j3=(...n)=>xb(...n),Mo=new cn,oa=new N,To=new N,Yg=new N,uc=new Re,_d=new N(0,0,-1),Un=new st,hc=new N,Md=new N,dc=new st,Td=new J,_b=new ui,X3=fs.flipX();let $g=!1;class Mb extends mn{static get type(){return"ReflectorNode"}constructor(e={}){super(_b.texture,X3);const{target:t=new _t,resolution:i=1,generateMipmaps:r=!1,bounces:s=!0}=e;this.target=t,this.resolution=i,this.generateMipmaps=r,this.bounces=s,this.updateBeforeType=s?je.RENDER:je.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const i=this.resolution;t.getDrawingBufferSize(Td),e.setSize(Math.round(Td.width*i),Math.round(Td.height*i))}setup(e){return this._updateResolution(_b,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new ui(0,0,{type:wi}),this.generateMipmaps===!0&&(t.texture.minFilter=np,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&$g)return!1;$g=!0;const{scene:t,camera:i,renderer:r,material:s}=e,{target:a}=this,o=this.getVirtualCamera(i),l=this.getRenderTarget(o);if(r.getDrawingBufferSize(Td),this._updateResolution(l,r),To.setFromMatrixPosition(a.matrixWorld),Yg.setFromMatrixPosition(i.matrixWorld),uc.extractRotation(a.matrixWorld),oa.set(0,0,1),oa.applyMatrix4(uc),hc.subVectors(To,Yg),hc.dot(oa)>0)return;hc.reflect(oa).negate(),hc.add(To),uc.extractRotation(i.matrixWorld),_d.set(0,0,-1),_d.applyMatrix4(uc),_d.add(Yg),Md.subVectors(To,_d),Md.reflect(oa).negate(),Md.add(To),o.coordinateSystem=i.coordinateSystem,o.position.copy(hc),o.up.set(0,1,0),o.up.applyMatrix4(uc),o.up.reflect(oa),o.lookAt(Md),o.near=i.near,o.far=i.far,o.updateMatrixWorld(),o.projectionMatrix.copy(i.projectionMatrix),Mo.setFromNormalAndCoplanarPoint(oa,To),Mo.applyMatrix4(o.matrixWorldInverse),Un.set(Mo.normal.x,Mo.normal.y,Mo.normal.z,Mo.constant);const c=o.projectionMatrix;dc.x=(Math.sign(Un.x)+c.elements[8])/c.elements[0],dc.y=(Math.sign(Un.y)+c.elements[9])/c.elements[5],dc.z=-1,dc.w=(1+c.elements[10])/c.elements[14],Un.multiplyScalar(1/Un.dot(dc));const u=0;c.elements[2]=Un.x,c.elements[6]=Un.y,c.elements[10]=Un.z-u,c.elements[14]=Un.w,this.value=l.texture,s.visible=!1;const h=r.getRenderTarget(),d=r.getMRT();r.setMRT(null),r.setRenderTarget(l),r.render(t,o),r.setMRT(d),r.setRenderTarget(h),s.visible=!0,$g=!1}}const q3=n=>G(new Mb(n)),Jg=new Ps(-1,1,1,-1,0,1);class Y3 extends ct{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new De([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new De(t,2))}}const $3=new Y3;class vn extends Ft{constructor(e=null){super($3,e),this.camera=Jg,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,Jg)}render(e){e.render(this,Jg)}}const J3=new J;class Tb extends mn{static get type(){return"RTTNode"}constructor(e,t=null,i=null,r={type:wi}){const s=new ui(t,i,r);super(s.texture,nt()),this.node=e,this.width=t,this.height=i,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new vn(new Tt),this.updateBeforeType=je.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const i=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(i,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const i=e.getSize(J3);this.setSize(i.width,i.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new mn(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const bb=(n,...e)=>G(new Tb(G(n),...e)),Zi=(n,...e)=>n.isTextureNode?n:bb(n,...e);class Sb extends Yf{static get type(){return"VertexColorNode"}constructor(e=0){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 st(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const K3=(...n)=>G(new Sb(...n));class wb extends qe{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Z3=ge(wb);class sn extends qe{static get type(){return"SceneNode"}constructor(e=sn.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,i=this.scene!==null?this.scene:e.scene;let r;return t===sn.BACKGROUND_BLURRINESS?r=fi("backgroundBlurriness","float",i):t===sn.BACKGROUND_INTENSITY?r=fi("backgroundIntensity","float",i):console.error("THREE.SceneNode: Unknown scope:",t),r}}sn.BACKGROUND_BLURRINESS="backgroundBlurriness",sn.BACKGROUND_INTENSITY="backgroundIntensity";const Q3=ge(sn,sn.BACKGROUND_BLURRINESS),eD=ge(sn,sn.BACKGROUND_INTENSITY),Eb={Storage:"storage",ReadOnlyStorage:"read-only-storage"},Kg={WriteOnly:"write-only",ReadOnly:"read-only"};class Zg extends Zh{static get type(){return"StorageBufferNode"}constructor(e,t,i=0){super(e,t,i),this.isStorageBufferNode=!0,this.access=Eb.Storage,this.isAtomic=!1,this.bufferObject=!1,this.bufferCount=i,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"storageBuffer"}element(e){return W3(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Eb.ReadOnlyStorage)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}generate(e){if(e.isAvailable("storageBuffer"))return super.generate(e);const t=this.getNodeType(e);this._attribute===null&&(this._attribute=ql(this.value),this._varying=Ii(this._attribute));const i=this._varying.build(e,t);return e.registerTransform(i,this._attribute),i}}const tD=(n,e,t)=>G(new Zg(n,e,t)),iD=(n,e,t)=>G(new Zg(n,e,t).setBufferObject(!0));class Ab extends mn{static get type(){return"StorageTextureNode"}constructor(e,t,i=null){super(e,t),this.storeNode=i,this.isStorageTextureNode=!0,this.access=Kg.WriteOnly}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let i;return this.storeNode!==null?i=this.generateStore(e):i=super.generate(e,t),i}toReadOnly(){return this.setAccess(Kg.ReadOnly)}toWriteOnly(){return this.setAccess(Kg.WriteOnly)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:i,storeNode:r}=t,s=super.generate(e,"property"),a=i.build(e,"uvec2"),o=r.build(e,"vec4"),l=e.generateTextureStore(e,s,a,o);e.addLineFlowCode(l,this)}}const Nb=K(Ab),rD=(n,e,t)=>{const i=Nb(n,e,t);return t!==null&&i.append(),i};class Cb extends Kl{static get type(){return"UserDataNode"}constructor(e,t,i=null){super(e,t,i),this.userData=i}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const nD=(n,e,t)=>G(new Cb(n,e,t));class Rb extends pt{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const sD=K(Rb);let Qg=null;class Ib extends ac{static get type(){return"ViewportSharedTextureNode"}constructor(e=fs,t=null){Qg===null&&(Qg=new vm),super(e,t,Qg)}updateReference(){return this}}const aD=K(Ib),oD=new J;class Lb extends mn{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class Pb extends Lb{static get type(){return"PassMultipleTextureNode"}constructor(e,t,i=!1){super(e,null),this.textureName=t,this.previousTexture=i}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class bi extends pt{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 s=new Os;s.isRenderTargetTexture=!0,s.name="depth";const a=new ui(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wi,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this.updateBeforeType=je.FRAME,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=fe(0),this._cameraFar=fe(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,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(),t.isRenderTargetTexture=!0,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&&(this._textureNodes[e]=t=G(new Pb(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),this._previousTextureNodes[e]=t=G(new Pb(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=mg(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,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=oc(s,i,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===bi.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(oD);this.setSize(s.width,s.height);const a=t.getRenderTarget(),o=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const l in this._previousTextures)this.toggleTexture(l);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(i,r),t.setRenderTarget(a),t.setMRT(o)}setSize(e,t){this._width=e,this._height=t;const i=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(i,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}bi.COLOR="color",bi.DEPTH="depth";const lD=(n,e,t)=>G(new bi(bi.COLOR,n,e,t)),bo=(n,e)=>G(new Lb(n,e)),cD=(n,e)=>G(new bi(bi.DEPTH,n,e)),Db=new vn,Ub=new vn;class Ob extends pt{static get type(){return"GaussianBlurNode"}constructor(e,t=null,i=2){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=i,this._invSize=fe(new J),this._passDirection=fe(new J),this._horizontalRT=new ui,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new ui,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=bo(this,this._verticalRT.texture),this.updateBeforeType=je.RENDER,this.resolution=new J(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value,s=t.getRenderTarget(),a=t.getMRT(),o=i.value;Db.material=this._material,Ub.material=this._material,this.setSize(r.image.width,r.image.height);const l=r.type;this._horizontalRT.texture.type=l,this._verticalRT.texture.type=l,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),Db.render(t),i.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),Ub.render(t),t.setRenderTarget(s),t.setMRT(a),i.value=o}getTextureNode(){return this._textureNode}setup(e){const t=this.textureNode;if(t.isTextureNode!==!0)return console.error("GaussianBlurNode requires a TextureNode."),ae();const i=t.uvNode||nt(),r=z(this.directionNode||1),s=c=>t.uv(c),a=U(()=>{const c=3+2*this.sigma,u=this._getCoefficients(c),h=this._invSize,d=r.mul(this._passDirection),p=E(u[0]).toVar(),m=ae(s(i).mul(p)).toVar();for(let v=1;v<c;v++){const f=E(v),g=E(u[v]),x=z(d.mul(h.mul(f))).toVar(),y=ae(s(i.add(x))),_=ae(s(i.sub(x)));m.addAssign(y.add(_).mul(g)),p.addAssign(lt(2,g))}return m.div(p)}),o=this._material||(this._material=new Tt);o.fragmentNode=a().context(e.getSharedContext()),o.name="Gaussian_blur",o.needsUpdate=!0;const l=e.getNodeProperties(this);return l.textureNode=t,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose()}_getCoefficients(e){const t=[];for(let i=0;i<e;i++)t.push(.39894*Math.exp(-.5*i*i/(e*e))/e);return t}}const uD=(n,e,t)=>G(new Ob(Zi(n),e,t)),e0=new J,Fb=new vn;class Vb extends pt{static get type(){return"AfterImageNode"}constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=yt(),this.damp=fe(t),this._compRT=new ui,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new ui,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=bo(this,this._compRT.texture),this.updateBeforeType=je.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value.type;this._compRT.texture.type=r,this._oldRT.texture.type=r,t.getDrawingBufferSize(e0),this.setSize(e0.x,e0.y);const s=t.getRenderTarget(),a=i.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),Fb.render(t);const o=this._oldRT;this._oldRT=this._compRT,this._compRT=o,t.setRenderTarget(s),i.value=a}setup(e){const t=this.textureNode,i=this.textureNodeOld,r=t.uvNode||nt();i.uvNode=r;const s=u=>t.uv(u),a=U(([u,h])=>{const d=E(h).toVar(),p=ae(u).toVar();return ft(Gl(p.sub(d)),0)}),o=U(()=>{const u=ae(i),h=ae(s(r));return u.mulAssign(this.damp.mul(a(u,.1))),ft(h,u)}),l=this._materialComposed||(this._materialComposed=new Tt);l.name="AfterImage",l.fragmentNode=o(),Fb.material=l;const c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const hD=(n,e)=>G(new Vb(Zi(n),e)),dD=U(([n])=>Ui(n.rgb)),pD=U(([n,e=E(1)])=>e.mix(Ui(n.rgb),n.rgb)),mD=U(([n,e=E(1)])=>{const t=zt(n.r,n.g,n.b).div(3),i=n.r.max(n.g.max(n.b)),r=i.sub(t).mul(e).mul(-3);return rt(n.rgb,i,r)}),fD=U(([n,e=E(1)])=>{const t=D(.57735,.57735,.57735),i=e.cos();return D(n.rgb.mul(i).add(t.cross(n.rgb).mul(e.sin()).add(t.mul(qt(t,n.rgb).mul(i.oneMinus())))))}),gD=new N,Ui=(n,e=D(...vt.getLuminanceCoefficients(gD)))=>qt(n,e),Bb=(n,e)=>rt(D(0),n,Ui(n).sub(e).max(0)),zb=new vn;class kb extends pt{static get type(){return"AnamorphicNode"}constructor(e,t,i,r){super("vec4"),this.textureNode=e,this.tresholdNode=t,this.scaleNode=i,this.colorNode=D(.1,0,1),this.samples=r,this.resolution=new J(1,1),this._renderTarget=new ui,this._renderTarget.texture.name="anamorphic",this._invSize=fe(new J),this._textureNode=bo(this,this._renderTarget.texture),this.updateBeforeType=je.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value;this._renderTarget.texture.type=r.type;const s=t.getRenderTarget(),a=i.value;zb.material=this._material,this.setSize(r.image.width,r.image.height),t.setRenderTarget(this._renderTarget),zb.render(t),t.setRenderTarget(s),i.value=a}setup(e){const t=this.textureNode,i=t.uvNode||nt(),r=l=>t.uv(l),s=U(()=>{const l=this.samples,c=Math.floor(l/2),u=D(0).toVar();return gt({start:-c,end:c},({i:h})=>{const d=E(h).abs().div(c).oneMinus(),p=z(i.x.add(this._invSize.x.mul(h).mul(this.scaleNode)),i.y),m=r(p),v=Bb(m,this.tresholdNode).mul(d);u.addAssign(v)}),u.mul(this.colorNode)}),a=this._material||(this._material=new Tt);a.name="Anamorphic",a.fragmentNode=s();const o=e.getNodeProperties(this);return o.textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}}const vD=(n,e=.9,t=3,i=32)=>G(new kb(Zi(n),G(e),G(t),i));class Hb extends pt{static get type(){return"SobelOperatorNode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=je.RENDER,this._invSize=fe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const{textureNode:e}=this,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=this._invSize,s=yi(-1,-2,-1,0,0,0,1,2,1),a=yi(-1,0,1,-2,0,2,-1,0,1),o=Ui(i(t.add(r.mul(z(-1,-1)))).xyz),l=Ui(i(t.add(r.mul(z(-1,0)))).xyz),c=Ui(i(t.add(r.mul(z(-1,1)))).xyz),u=Ui(i(t.add(r.mul(z(0,-1)))).xyz),h=Ui(i(t.add(r.mul(z(0,0)))).xyz),d=Ui(i(t.add(r.mul(z(0,1)))).xyz),p=Ui(i(t.add(r.mul(z(1,-1)))).xyz),m=Ui(i(t.add(r.mul(z(1,0)))).xyz),v=Ui(i(t.add(r.mul(z(1,1)))).xyz),f=zt(s[0][0].mul(o),s[1][0].mul(u),s[2][0].mul(p),s[0][1].mul(l),s[1][1].mul(h),s[2][1].mul(m),s[0][2].mul(c),s[1][2].mul(d),s[2][2].mul(v)),g=zt(a[0][0].mul(o),a[1][0].mul(u),a[2][0].mul(p),a[0][1].mul(l),a[1][1].mul(h),a[2][1].mul(m),a[0][2].mul(c),a[1][2].mul(d),a[2][2].mul(v)),x=f.mul(f).add(g.mul(g)).sqrt();return ae(D(x),1)})()}}const yD=n=>G(new Hb(Zi(n)));class Gb extends pt{static get type(){return"DepthOfFieldNode"}constructor(e,t,i,r,s){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=i,this.apertureNode=r,this.maxblurNode=s,this._aspect=fe(0),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){const e=this.textureNode,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=z(1,this._aspect),s=this.focusNode.add(this.viewZNode),a=z(li(s.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),o=a.mul(.9),l=a.mul(.7),c=a.mul(.4);let u=ae(0);return u=u.add(i(t)),u=u.add(i(t.add(z(0,.4).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,.37).mul(r).mul(a)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(a)))),u=u.add(i(t.add(z(-.37,.15).mul(r).mul(a)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(a)))),u=u.add(i(t.add(z(.37,-.15).mul(r).mul(a)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(a)))),u=u.add(i(t.add(z(-.15,-.37).mul(r).mul(a)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(a)))),u=u.add(i(t.add(z(-.15,.37).mul(r).mul(a)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(a)))),u=u.add(i(t.add(z(.37,.15).mul(r).mul(a)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(a)))),u=u.add(i(t.add(z(-.37,-.15).mul(r).mul(a)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,-.37).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,.37).mul(r).mul(o)))),u=u.add(i(t.add(z(-.37,.15).mul(r).mul(o)))),u=u.add(i(t.add(z(.37,-.15).mul(r).mul(o)))),u=u.add(i(t.add(z(-.15,-.37).mul(r).mul(o)))),u=u.add(i(t.add(z(-.15,.37).mul(r).mul(o)))),u=u.add(i(t.add(z(.37,.15).mul(r).mul(o)))),u=u.add(i(t.add(z(-.37,-.15).mul(r).mul(o)))),u=u.add(i(t.add(z(.15,-.37).mul(r).mul(o)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(l)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(l)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(l)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(l)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(l)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(l)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(l)))),u=u.add(i(t.add(z(0,.4).mul(r).mul(l)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(c)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(c)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(c)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(c)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(c)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(c)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(c)))),u=u.add(i(t.add(z(0,.4).mul(r).mul(c)))),u=u.div(41),u.a=1,ae(u)})()}}const xD=(n,e,t=1,i=.025,r=1)=>G(new Gb(Zi(n),G(e),G(t),G(i),G(r)));class Wb extends pt{static get type(){return"DotScreenNode"}constructor(e,t=new J(.5,.5),i=1.57,r=1){super("vec4"),this.inputNode=e,this.center=fe(t),this.angle=fe(i),this.scale=fe(r)}setup(){const e=this.inputNode,t=U(()=>{const i=Ci(this.angle),r=Tr(this.angle),s=nt().mul(go).sub(this.center),a=z(r.mul(s.x).sub(i.mul(s.y)),i.mul(s.x).add(r.mul(s.y))).mul(this.scale);return Ci(a.x).mul(Ci(a.y)).mul(4)});return U(()=>{const i=e,r=zt(i.r,i.g,i.b).div(3);return ae(D(r.mul(10).sub(5).add(t())),i.a)})()}}const _D=(n,e,t,i)=>G(new Wb(G(n),e,t,i));class jb extends pt{static get type(){return"RGBShiftNode"}constructor(e,t=.005,i=0){super("vec4"),this.textureNode=e,this.amount=fe(t),this.angle=fe(i)}setup(){const{textureNode:e}=this,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=z(Tr(this.angle),Ci(this.angle)).mul(this.amount),s=i(t.add(r)),a=i(t),o=i(t.sub(r));return ae(s.r,a.g,o.b,a.a)})()}}const MD=(n,e,t)=>G(new jb(Zi(n),e,t));class Xb extends pt{static get type(){return"FilmNode"}constructor(e,t=null,i=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=i}setup(){const e=this.uvNode||nt();return U(()=>{const t=this.inputNode.rgb,i=zf(ds(e.add(qg())));let r=t.add(t.mul(li(i.add(.1),0,1)));return this.intensityNode!==null&&(r=rt(t,r,this.intensityNode)),ae(r,this.inputNode.a)})()}}const TD=K(Xb);class qb extends pt{static get type(){return"Lut3DNode"}constructor(e,t,i,r){super(),this.inputNode=e,this.lutNode=t,this.size=fe(i),this.intensityNode=r}setup(){const{inputNode:e,lutNode:t}=this,i=r=>t.uv(r);return U(()=>{const r=e,s=E(1).div(this.size),a=E(.5).div(this.size),o=D(a).add(r.rgb.mul(E(1).sub(s))),l=ae(i(o).rgb,r.a);return ae(rt(r,l,this.intensityNode))})()}}const bD=(n,e,t,i)=>G(new qb(G(n),G(e),t,G(i))),Yb=new vn,$b=new xe,SD=new J;class Jb extends pt{static get type(){return"GTAONode"}constructor(e,t,i){super(),this.depthNode=e,this.normalNode=t,this.radius=fe(.25),this.resolution=fe(new J),this.thickness=fe(1),this.distanceExponent=fe(1),this.distanceFallOff=fe(1),this.scale=fe(1),this.noiseNode=yt(wD()),this.cameraProjectionMatrix=fe(i.projectionMatrix),this.cameraProjectionMatrixInverse=fe(i.projectionMatrixInverse),this.SAMPLES=fe(16),this._aoRenderTarget=new ui,this._aoRenderTarget.texture.name="GTAONode.AO",this._material=null,this._textureNode=bo(this,this._aoRenderTarget.texture),this.updateBeforeType=je.FRAME}getTextureNode(){return this._textureNode}setSize(e,t){this.resolution.value.set(e,t),this._aoRenderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=t.getDrawingBufferSize(SD),r=t.getRenderTarget(),s=t.getMRT();t.getClearColor($b);const a=t.getClearAlpha();Yb.material=this._material,this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),Yb.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor($b,a)}setup(e){const t=nt(),i=c=>this.depthNode.uv(c).x,r=c=>this.noiseNode.uv(c),s=U(([c])=>{const u=this.cameraProjectionMatrix.mul(ae(c,1));let h=u.xy.div(u.w).mul(.5).add(.5).toVar();h=z(h.x,h.y.oneMinus());const d=i(h);return D(h,d)}),a=U(([c,u])=>{c=z(c.x,c.y.oneMinus()).mul(2).sub(1);const h=ae(D(c,u),1),d=ae(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),o=U(()=>{const c=i(t);c.greaterThanEqual(1).discard();const u=a(t,c),h=this.normalNode.rgb.normalize(),d=this.radius,p=ms(this.noiseNode,0);let m=z(t.x,t.y.oneMinus());m=m.mul(this.resolution.div(p));const v=r(m),f=v.xyz.mul(2).sub(1),g=D(f.xy,0).normalize(),x=D(g.y.mul(-1),g.x,0),y=yi(g,x,D(0,0,1)),_=this.SAMPLES.lessThan(30).select(3,5),I=zt(this.SAMPLES,_.sub(1)).div(_),T=E(0).toVar();return gt({start:P(0),end:_,type:"int",condition:"<"},({i:w})=>{const C=E(w).div(E(_)).mul(Qs),H=ae(Tr(C),Ci(C),0,zt(.5,lt(.5,v.w)));H.xyz=Mr(y.mul(H.xyz));const M=Mr(u.xyz.negate()),b=Mr(co(H.xyz,M)),k=co(b,M),j=Mr(h.sub(b.mul(qt(h,b)))),Y=co(j,b),re=z(qt(M,Y),qt(M,Y.negate())).toVar();gt({end:I,type:"int",name:"j",condition:"<"},({j:at})=>{const et=H.xyz.mul(d).mul(H.w).mul(Ji(Qr(E(at).add(1),E(I)),this.distanceExponent)),ie=s(u.add(et)),le=a(ie.xy,ie.z).sub(u);Le(It(le.z).lessThan(this.thickness),()=>{const Ye=qt(M,Mr(le));re.x.addAssign(ft(0,lt(Ye.sub(re.x),rt(1,E(2).div(E(at).add(2)),this.distanceFallOff))))});const be=s(u.sub(et)),Se=a(be.xy,be.z).sub(u);Le(It(Se.z).lessThan(this.thickness),()=>{const Ye=qt(M,Mr(Se));re.y.addAssign(ft(0,lt(Ye.sub(re.y),rt(1,E(2).div(E(at).add(2)),this.distanceFallOff))))})});const $=en(Pt(1,re.mul(re))),he=qt(j,k),Q=qt(j,M),ye=lt(.5,Gh(re.y).sub(Gh(re.x)).add($.x.mul(re.x).sub($.y.mul(re.y)))),Te=lt(.5,Pt(2,re.x.mul(re.x)).sub(re.y.mul(re.y))),Ve=he.mul(ye).add(Q.mul(Te));T.addAssign(Ve)}),T.assign(li(T.div(_),0,1)),T.assign(Ji(T,this.scale)),ae(D(T),1)}),l=this._material||(this._material=new Tt);return l.fragmentNode=o().context(e.getSharedContext()),l.name="GTAO",l.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}function wD(n=5){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=ED(e),i=t.length,r=new Uint8Array(i*4);for(let a=0;a<i;++a){const o=t[a],l=2*Math.PI*o/i,c=new N(Math.cos(l),Math.sin(l),0).normalize();r[a*4]=(c.x*.5+.5)*255,r[a*4+1]=(c.y*.5+.5)*255,r[a*4+2]=127,r[a*4+3]=255}const s=new Ur(r,e,e);return s.wrapS=Wn,s.wrapT=Wn,s.needsUpdate=!0,s}function ED(n){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=e*e,i=Array(t).fill(0);let r=Math.floor(e/2),s=e-1;for(let a=1;a<=t;){if(r===-1&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),i[r*e+s]!==0){s-=2,r++;continue}else i[r*e+s]=a++;s++,r--}return i}const AD=(n,e,t)=>G(new Jb(G(n),G(e),t));class Kb extends pt{static get type(){return"DenoiseNode"}constructor(e,t,i,r,s){super(),this.textureNode=e,this.depthNode=t,this.normalNode=i,this.noiseNode=r,this.cameraProjectionMatrixInverse=fe(s.projectionMatrixInverse),this.lumaPhi=fe(5),this.depthPhi=fe(5),this.normalPhi=fe(5),this.radius=fe(5),this.index=fe(0),this._resolution=fe(new J),this._sampleVectors=gn(ND(16,2,1)),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value;this._resolution.value.set(e.image.width,e.image.height)}setup(){const e=nt(),t=c=>this.textureNode.uv(c),i=c=>this.depthNode.uv(c).x,r=c=>this.normalNode.uv(c),s=c=>this.noiseNode.uv(c),a=U(([c,u])=>{c=z(c.x,c.y.oneMinus()).mul(2).sub(1);const h=ae(D(c,u),1),d=ae(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),o=U(([c,u,h,d])=>{const p=t(d),m=i(d),v=r(d).rgb.normalize(),f=p.rgb,g=a(d,m),x=qt(u,v).toVar(),y=Ji(ft(x,0),this.normalPhi).toVar(),_=It(Ui(f).sub(Ui(c))).toVar(),I=ft(E(1).sub(_.div(this.lumaPhi)),0).toVar(),T=It(qt(h.sub(g),u)).toVar(),w=ft(E(1).sub(T.div(this.depthPhi)),0),C=I.mul(w).mul(y);return ae(f.mul(C),C)}),l=U(([c])=>{const u=i(c),h=r(c).rgb.normalize(),d=t(c);Le(u.greaterThanEqual(1).or(qt(h,h).equal(0)),()=>d);const p=D(d.rgb),m=a(c,u),v=ms(this.noiseNode,0);let f=z(c.x,c.y.oneMinus());f=f.mul(this._resolution.div(v));const g=s(f),x=Ci(g.element(this.index.mod(4).mul(2).mul(Qs))),y=Tr(g.element(this.index.mod(4).mul(2).mul(Qs))),_=z(x,y),I=Ul(_.x,_.y.negate(),_.x,_.y),T=E(1).toVar(),w=D(d.rgb).toVar();return gt({start:P(0),end:P(16),type:"int",condition:"<"},({i:C})=>{const H=this._sampleVectors.element(C).toVar(),M=I.mul(H.xy.mul(E(1).add(H.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),b=c.add(M).toVar(),k=o(p,h,m,b);w.addAssign(k.xyz),T.addAssign(k.w)}),Le(T.greaterThan(E(0)),()=>{w.divAssign(T)}),ae(w,d.a)}).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return U(()=>l(e))()}}function ND(n,e,t){const i=CD(n,e,t),r=[];for(let s=0;s<n;s++){const a=i[s];r.push(a)}return r}function CD(n,e,t){const i=[];for(let r=0;r<n;r++){const s=2*Math.PI*e*r/n,a=Math.pow(r/(n-1),t);i.push(new N(Math.cos(s),Math.sin(s),a))}return i}const RD=(n,e,t,i,r)=>G(new Kb(Zi(n),G(e),G(t),G(i),r));class Zb extends pt{static get type(){return"FXAANode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=je.RENDER,this._invSize=fe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const e=this.textureNode.bias(-100),t=e.uvNode||nt(),i=l=>e.uv(l),r=(l,c,u)=>e.uv(l.add(c.mul(u))),s=P(5),a=U(([l,c])=>{const u=ae(c).toVar(),h=ae(l).toVar(),d=ae(It(h.sub(u))).toVar();return ft(ft(ft(d.r,d.g),d.b),d.a)}),o=U(([l,c,u,h])=>{const d=i(l).toVar(),p=r(l,z(0,-1),c.xy).toVar(),m=r(l,z(1,0),c.xy).toVar(),v=r(l,z(0,1),c.xy).toVar(),f=r(l,z(-1,0),c.xy).toVar(),g=a(d,v).toVar(),x=a(d,p).toVar(),y=a(d,m).toVar(),_=a(d,f).toVar(),I=ft(g,ft(x,ft(y,_))).toVar();Le(I.lessThan(u),()=>d);const T=Pt(g.add(x),y.add(_)).toVar();T.mulAssign(h),Le(It(T).lessThan(.3),()=>{const Ve=y.greaterThan(_).select(1,-1).toVar(),at=x.greaterThan(g).select(1,-1).toVar(),et=z(Ve,at).toVar(),ie=r(l,z(et.x,et.y),c.xy),le=a(d,ie).toVar(),be=r(l,z(et.x.negate(),et.y.negate()),c.xy),Se=a(d,be).toVar();T.assign(Se.sub(le)),T.mulAssign(h),Le(It(T).lessThan(.3),()=>{const Ye=v.add(p).add(m).add(f);return rt(d,Ye.mul(.25),.4)})});const w=z().toVar();Le(T.lessThanEqual(0),()=>{v.assign(f),p.assign(m),w.x.assign(0),w.y.assign(c.y)}).Else(()=>{w.x.assign(c.x),w.y.assign(0)});const C=a(d,v).toVar(),H=a(d,p).toVar();Le(C.lessThanEqual(H),()=>{v.assign(p)});const M=P(0).toVar(),b=P(0).toVar(),k=E(0).toVar(),j=E(0).toVar(),Y=z(l).toVar(),re=z(l).toVar(),$=P(0).toVar(),he=P(0).toVar();gt(s,({i:Ve})=>{const at=Ve.add(1).toVar();Le(M.equal(0),()=>{k.addAssign(at),Y.assign(l.add(w.mul(k)));const et=i(Y.xy),ie=a(et,d).toVar(),le=a(et,v).toVar();Le(ie.greaterThan(le),()=>{M.assign(1)}),$.assign(Ve)}),Le(b.equal(0),()=>{j.addAssign(at),re.assign(l.sub(w.mul(j)));const et=i(re.xy),ie=a(et,d).toVar(),le=a(et,v).toVar();Le(ie.greaterThan(le),()=>{b.assign(1)}),he.assign(Ve)}),Le(M.equal(1).or(b.equal(1)),()=>{nd()})}),Le(M.equal(0).and(b.equal(0)),()=>d);const Q=E(1).toVar(),ye=E(1).toVar();Le(M.equal(1),()=>{Q.assign(E($).div(E(s.sub(1))))}),Le(b.equal(1),()=>{ye.assign(E(he).div(E(s.sub(1))))});const Te=xi(Q,ye);return Te.assign(Ji(Te,.5)),Te.assign(E(1).sub(Te)),rt(d,v,Te.mul(.5))}).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return U(()=>{const l=E(.2),c=E(1).div(l);return o(t,this._invSize,l,c)})()}}const ID=n=>G(new Zb(Zi(n))),la=new vn,LD=new xe(0,0,0),Qb=new xe,PD=new J,DD=new J(1,0),UD=new J(0,1);class eS extends pt{static get type(){return"BloomNode"}constructor(e,t=1,i=0,r=0){super(),this.inputNode=e,this.strength=fe(t),this.radius=fe(i),this.threshold=fe(r),this.smoothWidth=fe(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new ui(1,1,{type:wi}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let s=0;s<this._nMips;s++){const a=new ui(1,1,{type:wi});a.texture.name="UnrealBloomPass.h"+s,a.texture.generateMipmaps=!1,this._renderTargetsHorizontal.push(a);const o=new ui(1,1,{type:wi});o.texture.name="UnrealBloomPass.v"+s,o.texture.generateMipmaps=!1,this._renderTargetsVertical.push(o)}this._compositeMaterial=null,this._highPassFilterMaterial=null,this._separableBlurMaterials=[],this._textureNodeBright=yt(this._renderTargetBright.texture),this._textureNodeBlur0=yt(this._renderTargetsVertical[0].texture),this._textureNodeBlur1=yt(this._renderTargetsVertical[1].texture),this._textureNodeBlur2=yt(this._renderTargetsVertical[2].texture),this._textureNodeBlur3=yt(this._renderTargetsVertical[3].texture),this._textureNodeBlur4=yt(this._renderTargetsVertical[4].texture),this._textureOutput=bo(this,this._renderTargetsHorizontal[0].texture),this.updateBeforeType=je.FRAME}getTextureNode(){return this._textureOutput}setSize(e,t){let i=Math.round(e/2),r=Math.round(t/2);this._renderTargetBright.setSize(i,r);for(let s=0;s<this._nMips;s++)this._renderTargetsHorizontal[s].setSize(i,r),this._renderTargetsVertical[s].setSize(i,r),this._separableBlurMaterials[s].invSize.value.set(1/i,1/r),i=Math.round(i/2),r=Math.round(r/2)}updateBefore(e){const{renderer:t}=e,i=t.getDrawingBufferSize(PD);this.setSize(i.width,i.height);const r=t.getRenderTarget(),s=t.getMRT();t.getClearColor(Qb);const a=t.getClearAlpha();this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(LD,0),t.setRenderTarget(this._renderTargetBright),la.material=this._highPassFilterMaterial,la.render(t);let o=this._renderTargetBright;for(let l=0;l<this._nMips;l++)la.material=this._separableBlurMaterials[l],this._separableBlurMaterials[l].colorTexture.value=o.texture,this._separableBlurMaterials[l].direction.value=DD,t.setRenderTarget(this._renderTargetsHorizontal[l]),t.clear(),la.render(t),this._separableBlurMaterials[l].colorTexture.value=this._renderTargetsHorizontal[l].texture,this._separableBlurMaterials[l].direction.value=UD,t.setRenderTarget(this._renderTargetsVertical[l]),t.clear(),la.render(t),o=this._renderTargetsVertical[l];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),la.material=this._compositeMaterial,la.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor(Qb,a)}setup(e){const t=U(()=>{const l=this.inputNode,c=Ui(l.rgb),u=Ki(this.threshold,this.threshold.add(this.smoothWidth),c);return rt(ae(0),l,u)});this._highPassFilterMaterial=this._highPassFilterMaterial||new Tt,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const i=[3,5,7,9,11];for(let l=0;l<this._nMips;l++)this._separableBlurMaterials.push(this._getSeperableBlurMaterial(e,i[l]));const r=gn([1,.8,.6,.4,.2]),s=gn([new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1)]),a=U(([l,c])=>{const u=E(1.2).sub(l);return rt(l,u,c)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),o=U(()=>{const l=a(r.element(0),this.radius).mul(ae(s.element(0),1)).mul(this._textureNodeBlur0),c=a(r.element(1),this.radius).mul(ae(s.element(1),1)).mul(this._textureNodeBlur1),u=a(r.element(2),this.radius).mul(ae(s.element(2),1)).mul(this._textureNodeBlur2),h=a(r.element(3),this.radius).mul(ae(s.element(3),1)).mul(this._textureNodeBlur3),d=a(r.element(4),this.radius).mul(ae(s.element(4),1)).mul(this._textureNodeBlur4);return l.add(c).add(u).add(h).add(d).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new Tt,this._compositeMaterial.fragmentNode=o().context(e.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;e<this._renderTargetsHorizontal.length;e++)this._renderTargetsHorizontal[e].dispose();for(let e=0;e<this._renderTargetsVertical.length;e++)this._renderTargetsVertical[e].dispose();this._renderTargetBright.dispose()}_getSeperableBlurMaterial(e,t){const i=[];for(let d=0;d<t;d++)i.push(.39894*Math.exp(-.5*d*d/(t*t))/t);const r=yt(),s=gn(i),a=fe(new J),o=fe(new J(.5,.5)),l=nt(),c=d=>r.uv(d),u=U(()=>{const d=s.element(0).toVar(),p=c(l).rgb.mul(d).toVar();return gt({start:P(1),end:P(t),type:"int",condition:"<"},({i:m})=>{const v=E(m),f=s.element(m),g=o.mul(a).mul(v),x=c(l.add(g)).rgb,y=c(l.sub(g)).rgb;p.addAssign(zt(x,y).mul(f)),d.addAssign(E(2).mul(f))}),ae(p.div(d),1)}),h=new Tt;return h.fragmentNode=u().context(e.getSharedContext()),h.name="Bloom_seperable",h.needsUpdate=!0,h.colorTexture=r,h.direction=o,h.invSize=a,h}}const OD=(n,e,t,i)=>G(new eS(G(n),e,t,i));class tS extends pt{static get type(){return"TransitionNode"}constructor(e,t,i,r,s,a){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=i,this.mixRatioNode=r,this.thresholdNode=s,this.useTextureNode=a}setup(){const{textureNodeA:e,textureNodeB:t,mixTextureNode:i,mixRatioNode:r,thresholdNode:s,useTextureNode:a}=this,o=l=>{const c=l.uvNode||nt();return l.uv(c)};return U(()=>{const l=o(e),c=o(t),u=ae().toVar();return Le(a.equal(P(1)),()=>{const h=o(i),d=r.mul(s.mul(2).add(1)).sub(s),p=li(Pt(h.r,d).mul(E(1).div(s)),0,1);u.assign(rt(l,c,p))}).Else(()=>{u.assign(rt(c,l,r))}),u})()}}const FD=(n,e,t,i=0,r=.1,s=0)=>G(new tS(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class VD extends pt{static get type(){return"PixelationNode"}constructor(e,t,i,r,s,a){super(),this.textureNode=e,this.depthNode=t,this.normalNode=i,this.pixelSize=r,this.normalEdgeStrength=s,this.depthEdgeStrength=a,this._resolution=fe(new st),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value,t=e.image.width,i=e.image.height;this._resolution.value.set(t,i,1/t,1/i)}setup(){const{textureNode:e,depthNode:t,normalNode:i}=this,r=e.uvNode||nt(),s=t.uvNode||nt(),a=i.uvNode||nt(),o=()=>e.uv(r),l=(p,m)=>t.uv(s.add(z(p,m).mul(this._resolution.zw))).r,c=(p,m)=>i.uv(a.add(z(p,m).mul(this._resolution.zw))).rgb.normalize(),u=p=>{const m=ar("float","diff");return m.addAssign(li(l(1,0).sub(p))),m.addAssign(li(l(-1,0).sub(p))),m.addAssign(li(l(0,1).sub(p))),m.addAssign(li(l(0,-1).sub(p))),hs(Ki(.01,.02,m).mul(2)).div(2)},h=(p,m,v,f)=>{const g=l(p,m).sub(v),x=c(p,m),y=D(1,1,1),_=qt(f.sub(x),y),I=li(Ki(-.01,.01,_),0,1),T=li(Gl(g.mul(.25).add(.0025)),0,1);return E(1).sub(qt(f,x)).mul(T).mul(I)},d=(p,m)=>{const v=ar("float","indicator");return v.addAssign(h(0,-1,p,m)),v.addAssign(h(0,1,p,m)),v.addAssign(h(-1,0,p,m)),v.addAssign(h(1,0,p,m)),Wl(.1,v)};return U(()=>{const p=o(),m=ar("float","depth"),v=ar("vec3","normal");Le(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),()=>{m.assign(l(0,0)),v.assign(c(0,0))});const f=ar("float","dei");Le(this.depthEdgeStrength.greaterThan(0),()=>{f.assign(u(m))});const g=ar("float","nei");Le(this.normalEdgeStrength.greaterThan(0),()=>{g.assign(d(m,v))});const x=f.greaterThan(0).select(E(1).sub(f.mul(this.depthEdgeStrength)),g.mul(this.normalEdgeStrength).add(1));return p.mul(x)})()}}const BD=(n,e,t,i=6,r=.3,s=.4)=>G(new VD(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class iS extends bi{static get type(){return"PixelationPassNode"}constructor(e,t,i=6,r=.3,s=.4){super("color",e,t,{minFilter:$t,magFilter:$t}),this.pixelSize=i,this.normalEdgeStrength=r,this.depthEdgeStrength=s,this.isPixelationPassNode=!0,this._mrt=xd({output:wf,normal:hr})}setSize(e,t){const i=this.pixelSize.value?this.pixelSize.value:this.pixelSize,r=Math.floor(e/i),s=Math.floor(t/i);super.setSize(r,s)}setup(){const e=super.getTextureNode("output"),t=super.getTextureNode("depth"),i=super.getTextureNode("normal");return BD(e,t,i,this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const zD=(n,e,t,i,r)=>G(new iS(n,e,t,i,r)),kD=new J;class rS extends bi{static get type(){return"SSAAPassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new xe(0),this.clearAlpha=0,this._currentClearColor=new xe,this.sampleWeight=fe(1),this.sampleRenderTarget=null,this._quadMesh=new vn}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(kD);this.setSize(s.width,s.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);const a=t.getClearAlpha(),o=t.getRenderTarget(),l=t.getMRT(),c=t.autoClear;this._cameraNear.value=r.near,this._cameraFar.value=r.far,t.setMRT(this.getMRT()),t.autoClear=!1;const u=HD[Math.max(0,Math.min(this.sampleLevel,5))],h=1/u.length,d=1/32,p={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},m=Object.assign({},r.view);m.enabled&&Object.assign(p,m);for(let v=0;v<u.length;v++){const f=u[v];if(r.setViewOffset&&r.setViewOffset(p.fullWidth,p.fullHeight,p.offsetX+f[0]*.0625,p.offsetY+f[1]*.0625,p.width,p.height),this.sampleWeight.value=h,this.unbiased){const g=-.5+(v+.5)/u.length;this.sampleWeight.value+=d*g}t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(i,r),t.setRenderTarget(this.renderTarget),v===0&&(t.setClearColor(0,0),t.clear()),this._quadMesh.render(t)}t.copyTextureToTexture(this.sampleRenderTarget.depthTexture,this.renderTarget.depthTexture),r.setViewOffset&&m.enabled?r.setViewOffset(m.fullWidth,m.fullHeight,m.offsetX,m.offsetY,m.width,m.height):r.clearViewOffset&&r.clearViewOffset(),t.setRenderTarget(o),t.setMRT(l),t.autoClear=c,t.setClearColor(this._currentClearColor,a)}setup(e){this.sampleRenderTarget===null&&(this.sampleRenderTarget=this.renderTarget.clone());let t;const i=this.getMRT();if(i!==null){const r={};for(const s in i.outputNodes){const a=Xg(this.sampleRenderTarget.textures,s);a>=0&&(r[s]=yt(this.sampleRenderTarget.textures[a]).mul(this.sampleWeight))}t=xd(r)}else t=yt(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new Tt,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=No,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}}const HD=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],GD=(n,e)=>G(new rS(n,e)),WD=new J;class nS extends bi{static get type(){return"StereoPassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new Xm,this.stereo.aspect=.5}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r,stereo:s,renderTarget:a}=this;this._pixelRatio=t.getPixelRatio(),s.cameraL.coordinateSystem=t.coordinateSystem,s.cameraR.coordinateSystem=t.coordinateSystem,s.update(r);const o=t.getSize(WD);this.setSize(o.width,o.height);const l=t.autoClear;t.autoClear=!1;const c=t.getRenderTarget(),u=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const h in this._previousTextures)this.toggleTexture(h);t.setRenderTarget(a),t.setMRT(this._mrt),t.clear(),a.scissorTest=!0,a.scissor.set(0,0,a.width/2,a.height),a.viewport.set(0,0,a.width/2,a.height),t.render(i,s.cameraL),a.scissor.set(a.width/2,0,a.width/2,a.height),a.viewport.set(a.width/2,0,a.width/2,a.height),t.render(i,s.cameraR),a.scissorTest=!1,t.setRenderTarget(c),t.setMRT(u),t.autoClear=l}}const jD=(n,e)=>G(new nS(n,e)),XD=new J,sS=new vn;class aS extends bi{static get type(){return"StereoCompositePassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new Xm;const i={minFilter:Lt,magFilter:$t,type:wi};this._renderTargetL=new ui(1,1,i),this._renderTargetR=new ui(1,1,i),this._mapLeft=yt(this._renderTargetL.texture),this._mapRight=yt(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){const{renderer:t}=e,{scene:i,stereo:r,renderTarget:s}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);const a=t.getSize(XD);this.setSize(a.width,a.height);const o=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(i,r.cameraL),t.setRenderTarget(this._renderTargetR),t.render(i,r.cameraR),t.setRenderTarget(s),sS.material=this._material,sS.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}}class oS extends aS{static get type(){return"AnaglyphPassNode"}constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=fe(new Ke().fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=fe(new Ke().fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){const t=nt(),i=U(()=>{const s=this._mapLeft.uv(t),a=this._mapRight.uv(t),o=li(this._colorMatrixLeft.mul(s.rgb).add(this._colorMatrixRight.mul(a.rgb)));return ae(o.rgb,ft(s.a,a.a))}),r=this._material||(this._material=new Tt);return r.fragmentNode=i().context(e.getSharedContext()),r.name="Anaglyph",r.needsUpdate=!0,super.setup(e)}}const qD=(n,e)=>G(new oS(n,e));class lS extends aS{static get type(){return"ParallaxBarrierPassNode"}constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){const t=nt(),i=U(()=>{const s=ae().toVar();return Le(Wh(vo.y,2).greaterThan(1),()=>{s.assign(this._mapLeft.uv(t))}).Else(()=>{s.assign(this._mapRight.uv(t))}),s}),r=this._material||(this._material=new Tt);return r.fragmentNode=i().context(e.getSharedContext()),r.needsUpdate=!0,super.setup(e)}}const YD=(n,e)=>G(new lS(n,e));class cS extends bi{static get type(){return"ToonOutlinePassNode"}constructor(e,t,i,r,s){super(bi.COLOR,e,t),this.colorNode=i,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,i=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,o,l,c,u)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const h=this._getOutlineMaterial(l);t.renderObject(r,s,a,o,h,c,u)}t.renderObject(r,s,a,o,l,c,u)}),super.updateBefore(e),t.setRenderObjectFunction(i)}_createMaterial(){const e=new Tt;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=si;const t=ur.negate(),i=lr.mul(fn),r=E(1),s=i.mul(ae(Zt,1)),a=i.mul(ae(Zt.add(t),1)),o=Mr(s.sub(a));return e.vertexNode=s.add(o.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=ae(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const $D=(n,e,t=new xe(0,0,0),i=.003,r=1)=>G(new cS(n,e,G(t),G(i),G(r)));class uS extends qe{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new vr,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:E()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=sf(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=af(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const bd=K(uS);class hS extends Map{get(e,t=null,...i){if(this.has(e))return super.get(e);if(t!==null){const r=t(...i);return this.set(e,r),r}}}class JD{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Sd=new hS;class dS extends qe{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new hS,this._output=bd(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const i=this._outputs;return i[e]===void 0?i[e]=bd(t):i[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const i=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),i[e]=t,i[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),i[e]=t,i[e].events.addEventListener("refresh",this.onRefresh)):i[e]===void 0?(i[e]=bd(t),i[e].events.addEventListener("refresh",this.onRefresh)):i[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i(...t)}async callAsync(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i.constructor.name==="AsyncFunction"?await i(...t):i(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(c,u)=>this.setOutput(c,u),i=new JD(this),r=Sd.get("THREE"),s=Sd.get("TSL"),a=this.getMethod(this.codeNode),o=[i,this._local,Sd,e,t,r,s];this._object=a(...o);const l=this._object.layout;if(l&&(l.cache===!1&&this._local.clear(),this._output.outputType=l.outputType||null,Array.isArray(l.elements)))for(const c of l.elements){const u=c.id||c.name;c.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=c.inputType),c.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=c.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let i=this.parameters[t];i.isScriptableNode&&(i=i.getDefaultOutput()),i.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:E()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],t=["layout","init","main","dispose"].join(", "),i="var "+t+`; var output = {};
|
|
3866
|
+
`;return i}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:i}=this;if(t!==null){let r=i.nodes.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new Tt),r.build(this)}else this.addFlow("compute",e);for(const r of uf){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of hf){this.setShaderStage(s);const a=this.flowNodes[s];for(const o of a)r==="generate"?this.flowNode(o):o.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new v3(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new y3(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new x3(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new _3(e);if(t==="color")return new M3(e);if(t==="mat3")return new T3(e);if(t==="mat4")return new b3(e);throw new Error(`Uniform "${t}" not declared.`)}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}format(e,t,i){if(t=this.getVectorType(t),i=this.getVectorType(i),t===i||i===null||this.isReference(i))return e;const r=this.getTypeLength(t),s=this.getTypeLength(i);return r===16&&s===9?`${this.getType(i)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&s===4?`${this.getType(i)}(${e}[0].xy, ${e}[1].xy)`:r>4||s>4||s===0?e:r===s?`${this.getType(i)}( ${e} )`:r>s?this.format(`${e}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(t)),i):s===4&&r>1?`${this.getType(i)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(i)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(i)&&(e=`${this.getType(this.getComponentType(i))}( ${e} )`),`${this.getType(i)}( ${e} )`)}getSignature(){return`// Three.js r${Bn} - Node System
|
|
3867
|
+
`}}class mb{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,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={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,i)),i}updateBeforeNode(e){const t=e.getUpdateBeforeType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,i);r.get(i)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,i);r.get(i)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,i);r.get(i)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,i);r.get(i)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,i);r.get(i)!==this.frameId&&e.update(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,i);r.get(i)!==this.renderId&&e.update(this)!==!1&&r.set(i,this.renderId)}else t===je.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}}class jg{constructor(e,t,i=null,r="",s=!1){this.type=e,this.name=t,this.count=i,this.qualifier=r,this.isConst=s}}jg.isNodeFunctionInput=!0;class P3 extends qe{static get type(){return"StructTypeNode"}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class Xg extends qe{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,i=[];for(let r=0;r<t.length;r++)i.push(t[r].getNodeType(e));this.nodeType=e.getStructTypeFromNode(new P3(i)).name}generate(e,t){const i=e.getOutputStructName(),r=this.members,s=i!==""?i+".":"";for(let a=0;a<r.length;a++){const o=r[a].build(e,t);e.addLineFlowCode(`${s}m${a} = ${o}`,this)}return i}}const D3=K(Xg);function qg(n,e){for(let t=0;t<n.length;t++)if(n[t].name===e)return t;return-1}class fb extends Xg{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const t={...this.outputNodes,...e.outputNodes};return _d(t)}setup(e){const t=this.outputNodes,i=e.renderer.getRenderTarget(),r=[],s=i.textures;for(const a in t){const o=qg(s,a);r[o]=ae(t[a])}return this.members=r,super.setup(e)}}const _d=K(fb);class gb extends qe{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let i=this._candidateFnCall;if(i===null){let r=null,s=-1;for(const a of this.functionNodes){const o=a.shaderNode.layout;if(o===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const l=o.inputs;if(t.length===l.length){let c=0;for(let u=0;u<t.length;u++){const h=t[u],d=l[u];h.getNodeType(e)===d.type?c++:c=0}c>s&&(r=a,s=c)}}this._candidateFnCall=i=r(...t)}return i}}const U3=K(gb),Di=n=>(...e)=>U3(n,...e);class Si extends Js{static get type(){return"TimerNode"}constructor(e=Si.LOCAL,t=1,i=0){super(i),this.scope=e,this.scale=t,this.updateType=je.FRAME}update(e){const t=this.scope,i=this.scale;t===Si.LOCAL?this.value+=e.deltaTime*i:t===Si.DELTA?this.value=e.deltaTime*i:t===Si.FRAME?this.value=e.frameId:this.value=e.time*i}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}Si.LOCAL="local",Si.GLOBAL="global",Si.DELTA="delta",Si.FRAME="frame";const Yg=(n,e=0)=>G(new Si(Si.LOCAL,n,e)),O3=(n,e=0)=>G(new Si(Si.GLOBAL,n,e)),F3=(n,e=0)=>G(new Si(Si.DELTA,n,e)),V3=ge(Si,Si.FRAME).toUint();class gi extends qe{static get type(){return"OscNode"}constructor(e=gi.SINE,t=Yg()){super(),this.method=e,this.timeNode=t}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){const e=this.method,t=G(this.timeNode);let i=null;return e===gi.SINE?i=t.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5):e===gi.SQUARE?i=t.fract().round():e===gi.TRIANGLE?i=t.add(.5).fract().mul(2).sub(1).abs():e===gi.SAWTOOTH&&(i=t.fract()),i}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}gi.SINE="sine",gi.SQUARE="square",gi.TRIANGLE="triangle",gi.SAWTOOTH="sawtooth";const B3=K(gi,gi.SINE),z3=K(gi,gi.SQUARE),k3=K(gi,gi.TRIANGLE),H3=K(gi,gi.SAWTOOTH);class vb extends qe{static get type(){return"SpriteSheetUVNode"}constructor(e,t=nt(),i=E(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=i}setup(){const{frameNode:e,uvNode:t,countNode:i}=this,{width:r,height:s}=i,a=e.mod(r.mul(s)).floor(),o=a.mod(r),l=s.sub(a.add(1).div(r).ceil()),c=i.reciprocal(),u=z(o,l);return t.add(u).mul(c)}}const G3=K(vb);class yb extends cs{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}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.bufferObject===!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.bufferObject===!0&&r!==!0?i=e.generatePBO(this):i=this.node.build(e):i=super.generate(e),r!==!0){const s=this.getNodeType(e);i=e.format(i,s,t)}return i}}const W3=K(yb);class xb extends qe{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,i=null,r=E(1),s=Zt,a=ur){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=i,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:i,scaleNode:r,positionNode:s,normalNode:a}=this;let o=a.abs().normalize();o=o.div(o.dot(D(1)));const l=s.yz.mul(r),c=s.zx.mul(r),u=s.xy.mul(r),h=e.value,d=t!==null?t.value:h,p=i!==null?i.value:h,m=yt(h,l).mul(o.x),v=yt(d,c).mul(o.y),f=yt(p,u).mul(o.z);return zt(m,v,f)}}const _b=K(xb),j3=(...n)=>_b(...n),To=new cn,la=new N,bo=new N,$g=new N,hc=new Re,Md=new N(0,0,-1),Un=new st,dc=new N,Td=new N,pc=new st,bd=new J,Mb=new ui,X3=gs.flipX();let Jg=!1;class Tb extends mn{static get type(){return"ReflectorNode"}constructor(e={}){super(Mb.texture,X3);const{target:t=new _t,resolution:i=1,generateMipmaps:r=!1,bounces:s=!0}=e;this.target=t,this.resolution=i,this.generateMipmaps=r,this.bounces=s,this.updateBeforeType=s?je.RENDER:je.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const i=this.resolution;t.getDrawingBufferSize(bd),e.setSize(Math.round(bd.width*i),Math.round(bd.height*i))}setup(e){return this._updateResolution(Mb,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new ui(0,0,{type:wi}),this.generateMipmaps===!0&&(t.texture.minFilter=sp,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Jg)return!1;Jg=!0;const{scene:t,camera:i,renderer:r,material:s}=e,{target:a}=this,o=this.getVirtualCamera(i),l=this.getRenderTarget(o);if(r.getDrawingBufferSize(bd),this._updateResolution(l,r),bo.setFromMatrixPosition(a.matrixWorld),$g.setFromMatrixPosition(i.matrixWorld),hc.extractRotation(a.matrixWorld),la.set(0,0,1),la.applyMatrix4(hc),dc.subVectors(bo,$g),dc.dot(la)>0)return;dc.reflect(la).negate(),dc.add(bo),hc.extractRotation(i.matrixWorld),Md.set(0,0,-1),Md.applyMatrix4(hc),Md.add($g),Td.subVectors(bo,Md),Td.reflect(la).negate(),Td.add(bo),o.coordinateSystem=i.coordinateSystem,o.position.copy(dc),o.up.set(0,1,0),o.up.applyMatrix4(hc),o.up.reflect(la),o.lookAt(Td),o.near=i.near,o.far=i.far,o.updateMatrixWorld(),o.projectionMatrix.copy(i.projectionMatrix),To.setFromNormalAndCoplanarPoint(la,bo),To.applyMatrix4(o.matrixWorldInverse),Un.set(To.normal.x,To.normal.y,To.normal.z,To.constant);const c=o.projectionMatrix;pc.x=(Math.sign(Un.x)+c.elements[8])/c.elements[0],pc.y=(Math.sign(Un.y)+c.elements[9])/c.elements[5],pc.z=-1,pc.w=(1+c.elements[10])/c.elements[14],Un.multiplyScalar(1/Un.dot(pc));const u=0;c.elements[2]=Un.x,c.elements[6]=Un.y,c.elements[10]=Un.z-u,c.elements[14]=Un.w,this.value=l.texture,s.visible=!1;const h=r.getRenderTarget(),d=r.getMRT();r.setMRT(null),r.setRenderTarget(l),r.render(t,o),r.setMRT(d),r.setRenderTarget(h),s.visible=!0,Jg=!1}}const q3=n=>G(new Tb(n)),Kg=new Ds(-1,1,1,-1,0,1);class Y3 extends ct{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new De([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new De(t,2))}}const $3=new Y3;class vn extends Ft{constructor(e=null){super($3,e),this.camera=Kg,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,Kg)}render(e){e.render(this,Kg)}}const J3=new J;class bb extends mn{static get type(){return"RTTNode"}constructor(e,t=null,i=null,r={type:wi}){const s=new ui(t,i,r);super(s.texture,nt()),this.node=e,this.width=t,this.height=i,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new vn(new Tt),this.updateBeforeType=je.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const i=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(i,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const i=e.getSize(J3);this.setSize(i.width,i.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new mn(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const Sb=(n,...e)=>G(new bb(G(n),...e)),Zi=(n,...e)=>n.isTextureNode?n:Sb(n,...e);class wb extends $f{static get type(){return"VertexColorNode"}constructor(e=0){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 st(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const K3=(...n)=>G(new wb(...n));class Eb extends qe{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Z3=ge(Eb);class sn extends qe{static get type(){return"SceneNode"}constructor(e=sn.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,i=this.scene!==null?this.scene:e.scene;let r;return t===sn.BACKGROUND_BLURRINESS?r=fi("backgroundBlurriness","float",i):t===sn.BACKGROUND_INTENSITY?r=fi("backgroundIntensity","float",i):console.error("THREE.SceneNode: Unknown scope:",t),r}}sn.BACKGROUND_BLURRINESS="backgroundBlurriness",sn.BACKGROUND_INTENSITY="backgroundIntensity";const Q3=ge(sn,sn.BACKGROUND_BLURRINESS),eD=ge(sn,sn.BACKGROUND_INTENSITY),Ab={Storage:"storage",ReadOnlyStorage:"read-only-storage"},Zg={WriteOnly:"write-only",ReadOnly:"read-only"};class Qg extends Qh{static get type(){return"StorageBufferNode"}constructor(e,t,i=0){super(e,t,i),this.isStorageBufferNode=!0,this.access=Ab.Storage,this.isAtomic=!1,this.bufferObject=!1,this.bufferCount=i,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"storageBuffer"}element(e){return W3(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Ab.ReadOnlyStorage)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}generate(e){if(e.isAvailable("storageBuffer"))return super.generate(e);const t=this.getNodeType(e);this._attribute===null&&(this._attribute=Yl(this.value),this._varying=Ii(this._attribute));const i=this._varying.build(e,t);return e.registerTransform(i,this._attribute),i}}const tD=(n,e,t)=>G(new Qg(n,e,t)),iD=(n,e,t)=>G(new Qg(n,e,t).setBufferObject(!0));class Nb extends mn{static get type(){return"StorageTextureNode"}constructor(e,t,i=null){super(e,t),this.storeNode=i,this.isStorageTextureNode=!0,this.access=Zg.WriteOnly}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let i;return this.storeNode!==null?i=this.generateStore(e):i=super.generate(e,t),i}toReadOnly(){return this.setAccess(Zg.ReadOnly)}toWriteOnly(){return this.setAccess(Zg.WriteOnly)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:i,storeNode:r}=t,s=super.generate(e,"property"),a=i.build(e,"uvec2"),o=r.build(e,"vec4"),l=e.generateTextureStore(e,s,a,o);e.addLineFlowCode(l,this)}}const Cb=K(Nb),rD=(n,e,t)=>{const i=Cb(n,e,t);return t!==null&&i.append(),i};class Rb extends Zl{static get type(){return"UserDataNode"}constructor(e,t,i=null){super(e,t,i),this.userData=i}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const nD=(n,e,t)=>G(new Rb(n,e,t));class Ib extends pt{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const sD=K(Ib);let e0=null;class Lb extends oc{static get type(){return"ViewportSharedTextureNode"}constructor(e=gs,t=null){e0===null&&(e0=new ym),super(e,t,e0)}updateReference(){return this}}const aD=K(Lb),oD=new J;class Pb extends mn{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class Db extends Pb{static get type(){return"PassMultipleTextureNode"}constructor(e,t,i=!1){super(e,null),this.textureName=t,this.previousTexture=i}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class bi extends pt{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 s=new Fs;s.isRenderTargetTexture=!0,s.name="depth";const a=new ui(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wi,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this.updateBeforeType=je.FRAME,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=fe(0),this._cameraFar=fe(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,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(),t.isRenderTargetTexture=!0,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&&(this._textureNodes[e]=t=G(new Db(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),this._previousTextureNodes[e]=t=G(new Db(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=fg(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,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=lc(s,i,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===bi.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(oD);this.setSize(s.width,s.height);const a=t.getRenderTarget(),o=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const l in this._previousTextures)this.toggleTexture(l);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(i,r),t.setRenderTarget(a),t.setMRT(o)}setSize(e,t){this._width=e,this._height=t;const i=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(i,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}bi.COLOR="color",bi.DEPTH="depth";const lD=(n,e,t)=>G(new bi(bi.COLOR,n,e,t)),So=(n,e)=>G(new Pb(n,e)),cD=(n,e)=>G(new bi(bi.DEPTH,n,e)),Ub=new vn,Ob=new vn;class Fb extends pt{static get type(){return"GaussianBlurNode"}constructor(e,t=null,i=2){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=i,this._invSize=fe(new J),this._passDirection=fe(new J),this._horizontalRT=new ui,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new ui,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=So(this,this._verticalRT.texture),this.updateBeforeType=je.RENDER,this.resolution=new J(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value,s=t.getRenderTarget(),a=t.getMRT(),o=i.value;Ub.material=this._material,Ob.material=this._material,this.setSize(r.image.width,r.image.height);const l=r.type;this._horizontalRT.texture.type=l,this._verticalRT.texture.type=l,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),Ub.render(t),i.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),Ob.render(t),t.setRenderTarget(s),t.setMRT(a),i.value=o}getTextureNode(){return this._textureNode}setup(e){const t=this.textureNode;if(t.isTextureNode!==!0)return console.error("GaussianBlurNode requires a TextureNode."),ae();const i=t.uvNode||nt(),r=z(this.directionNode||1),s=c=>t.uv(c),a=U(()=>{const c=3+2*this.sigma,u=this._getCoefficients(c),h=this._invSize,d=r.mul(this._passDirection),p=E(u[0]).toVar(),m=ae(s(i).mul(p)).toVar();for(let v=1;v<c;v++){const f=E(v),g=E(u[v]),x=z(d.mul(h.mul(f))).toVar(),y=ae(s(i.add(x))),_=ae(s(i.sub(x)));m.addAssign(y.add(_).mul(g)),p.addAssign(lt(2,g))}return m.div(p)}),o=this._material||(this._material=new Tt);o.fragmentNode=a().context(e.getSharedContext()),o.name="Gaussian_blur",o.needsUpdate=!0;const l=e.getNodeProperties(this);return l.textureNode=t,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose()}_getCoefficients(e){const t=[];for(let i=0;i<e;i++)t.push(.39894*Math.exp(-.5*i*i/(e*e))/e);return t}}const uD=(n,e,t)=>G(new Fb(Zi(n),e,t)),t0=new J,Vb=new vn;class Bb extends pt{static get type(){return"AfterImageNode"}constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=yt(),this.damp=fe(t),this._compRT=new ui,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new ui,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=So(this,this._compRT.texture),this.updateBeforeType=je.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value.type;this._compRT.texture.type=r,this._oldRT.texture.type=r,t.getDrawingBufferSize(t0),this.setSize(t0.x,t0.y);const s=t.getRenderTarget(),a=i.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),Vb.render(t);const o=this._oldRT;this._oldRT=this._compRT,this._compRT=o,t.setRenderTarget(s),i.value=a}setup(e){const t=this.textureNode,i=this.textureNodeOld,r=t.uvNode||nt();i.uvNode=r;const s=u=>t.uv(u),a=U(([u,h])=>{const d=E(h).toVar(),p=ae(u).toVar();return ft(Wl(p.sub(d)),0)}),o=U(()=>{const u=ae(i),h=ae(s(r));return u.mulAssign(this.damp.mul(a(u,.1))),ft(h,u)}),l=this._materialComposed||(this._materialComposed=new Tt);l.name="AfterImage",l.fragmentNode=o(),Vb.material=l;const c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const hD=(n,e)=>G(new Bb(Zi(n),e)),dD=U(([n])=>Ui(n.rgb)),pD=U(([n,e=E(1)])=>e.mix(Ui(n.rgb),n.rgb)),mD=U(([n,e=E(1)])=>{const t=zt(n.r,n.g,n.b).div(3),i=n.r.max(n.g.max(n.b)),r=i.sub(t).mul(e).mul(-3);return rt(n.rgb,i,r)}),fD=U(([n,e=E(1)])=>{const t=D(.57735,.57735,.57735),i=e.cos();return D(n.rgb.mul(i).add(t.cross(n.rgb).mul(e.sin()).add(t.mul(qt(t,n.rgb).mul(i.oneMinus())))))}),gD=new N,Ui=(n,e=D(...vt.getLuminanceCoefficients(gD)))=>qt(n,e),zb=(n,e)=>rt(D(0),n,Ui(n).sub(e).max(0)),kb=new vn;class Hb extends pt{static get type(){return"AnamorphicNode"}constructor(e,t,i,r){super("vec4"),this.textureNode=e,this.tresholdNode=t,this.scaleNode=i,this.colorNode=D(.1,0,1),this.samples=r,this.resolution=new J(1,1),this._renderTarget=new ui,this._renderTarget.texture.name="anamorphic",this._invSize=fe(new J),this._textureNode=So(this,this._renderTarget.texture),this.updateBeforeType=je.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value;this._renderTarget.texture.type=r.type;const s=t.getRenderTarget(),a=i.value;kb.material=this._material,this.setSize(r.image.width,r.image.height),t.setRenderTarget(this._renderTarget),kb.render(t),t.setRenderTarget(s),i.value=a}setup(e){const t=this.textureNode,i=t.uvNode||nt(),r=l=>t.uv(l),s=U(()=>{const l=this.samples,c=Math.floor(l/2),u=D(0).toVar();return gt({start:-c,end:c},({i:h})=>{const d=E(h).abs().div(c).oneMinus(),p=z(i.x.add(this._invSize.x.mul(h).mul(this.scaleNode)),i.y),m=r(p),v=zb(m,this.tresholdNode).mul(d);u.addAssign(v)}),u.mul(this.colorNode)}),a=this._material||(this._material=new Tt);a.name="Anamorphic",a.fragmentNode=s();const o=e.getNodeProperties(this);return o.textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}}const vD=(n,e=.9,t=3,i=32)=>G(new Hb(Zi(n),G(e),G(t),i));class Gb extends pt{static get type(){return"SobelOperatorNode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=je.RENDER,this._invSize=fe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const{textureNode:e}=this,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=this._invSize,s=yi(-1,-2,-1,0,0,0,1,2,1),a=yi(-1,0,1,-2,0,2,-1,0,1),o=Ui(i(t.add(r.mul(z(-1,-1)))).xyz),l=Ui(i(t.add(r.mul(z(-1,0)))).xyz),c=Ui(i(t.add(r.mul(z(-1,1)))).xyz),u=Ui(i(t.add(r.mul(z(0,-1)))).xyz),h=Ui(i(t.add(r.mul(z(0,0)))).xyz),d=Ui(i(t.add(r.mul(z(0,1)))).xyz),p=Ui(i(t.add(r.mul(z(1,-1)))).xyz),m=Ui(i(t.add(r.mul(z(1,0)))).xyz),v=Ui(i(t.add(r.mul(z(1,1)))).xyz),f=zt(s[0][0].mul(o),s[1][0].mul(u),s[2][0].mul(p),s[0][1].mul(l),s[1][1].mul(h),s[2][1].mul(m),s[0][2].mul(c),s[1][2].mul(d),s[2][2].mul(v)),g=zt(a[0][0].mul(o),a[1][0].mul(u),a[2][0].mul(p),a[0][1].mul(l),a[1][1].mul(h),a[2][1].mul(m),a[0][2].mul(c),a[1][2].mul(d),a[2][2].mul(v)),x=f.mul(f).add(g.mul(g)).sqrt();return ae(D(x),1)})()}}const yD=n=>G(new Gb(Zi(n)));class Wb extends pt{static get type(){return"DepthOfFieldNode"}constructor(e,t,i,r,s){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=i,this.apertureNode=r,this.maxblurNode=s,this._aspect=fe(0),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){const e=this.textureNode,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=z(1,this._aspect),s=this.focusNode.add(this.viewZNode),a=z(li(s.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),o=a.mul(.9),l=a.mul(.7),c=a.mul(.4);let u=ae(0);return u=u.add(i(t)),u=u.add(i(t.add(z(0,.4).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,.37).mul(r).mul(a)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(a)))),u=u.add(i(t.add(z(-.37,.15).mul(r).mul(a)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(a)))),u=u.add(i(t.add(z(.37,-.15).mul(r).mul(a)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(a)))),u=u.add(i(t.add(z(-.15,-.37).mul(r).mul(a)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(a)))),u=u.add(i(t.add(z(-.15,.37).mul(r).mul(a)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(a)))),u=u.add(i(t.add(z(.37,.15).mul(r).mul(a)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(a)))),u=u.add(i(t.add(z(-.37,-.15).mul(r).mul(a)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,-.37).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,.37).mul(r).mul(o)))),u=u.add(i(t.add(z(-.37,.15).mul(r).mul(o)))),u=u.add(i(t.add(z(.37,-.15).mul(r).mul(o)))),u=u.add(i(t.add(z(-.15,-.37).mul(r).mul(o)))),u=u.add(i(t.add(z(-.15,.37).mul(r).mul(o)))),u=u.add(i(t.add(z(.37,.15).mul(r).mul(o)))),u=u.add(i(t.add(z(-.37,-.15).mul(r).mul(o)))),u=u.add(i(t.add(z(.15,-.37).mul(r).mul(o)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(l)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(l)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(l)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(l)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(l)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(l)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(l)))),u=u.add(i(t.add(z(0,.4).mul(r).mul(l)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(c)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(c)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(c)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(c)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(c)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(c)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(c)))),u=u.add(i(t.add(z(0,.4).mul(r).mul(c)))),u=u.div(41),u.a=1,ae(u)})()}}const xD=(n,e,t=1,i=.025,r=1)=>G(new Wb(Zi(n),G(e),G(t),G(i),G(r)));class jb extends pt{static get type(){return"DotScreenNode"}constructor(e,t=new J(.5,.5),i=1.57,r=1){super("vec4"),this.inputNode=e,this.center=fe(t),this.angle=fe(i),this.scale=fe(r)}setup(){const e=this.inputNode,t=U(()=>{const i=Ci(this.angle),r=Tr(this.angle),s=nt().mul(vo).sub(this.center),a=z(r.mul(s.x).sub(i.mul(s.y)),i.mul(s.x).add(r.mul(s.y))).mul(this.scale);return Ci(a.x).mul(Ci(a.y)).mul(4)});return U(()=>{const i=e,r=zt(i.r,i.g,i.b).div(3);return ae(D(r.mul(10).sub(5).add(t())),i.a)})()}}const _D=(n,e,t,i)=>G(new jb(G(n),e,t,i));class Xb extends pt{static get type(){return"RGBShiftNode"}constructor(e,t=.005,i=0){super("vec4"),this.textureNode=e,this.amount=fe(t),this.angle=fe(i)}setup(){const{textureNode:e}=this,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=z(Tr(this.angle),Ci(this.angle)).mul(this.amount),s=i(t.add(r)),a=i(t),o=i(t.sub(r));return ae(s.r,a.g,o.b,a.a)})()}}const MD=(n,e,t)=>G(new Xb(Zi(n),e,t));class qb extends pt{static get type(){return"FilmNode"}constructor(e,t=null,i=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=i}setup(){const e=this.uvNode||nt();return U(()=>{const t=this.inputNode.rgb,i=kf(ps(e.add(Yg())));let r=t.add(t.mul(li(i.add(.1),0,1)));return this.intensityNode!==null&&(r=rt(t,r,this.intensityNode)),ae(r,this.inputNode.a)})()}}const TD=K(qb);class Yb extends pt{static get type(){return"Lut3DNode"}constructor(e,t,i,r){super(),this.inputNode=e,this.lutNode=t,this.size=fe(i),this.intensityNode=r}setup(){const{inputNode:e,lutNode:t}=this,i=r=>t.uv(r);return U(()=>{const r=e,s=E(1).div(this.size),a=E(.5).div(this.size),o=D(a).add(r.rgb.mul(E(1).sub(s))),l=ae(i(o).rgb,r.a);return ae(rt(r,l,this.intensityNode))})()}}const bD=(n,e,t,i)=>G(new Yb(G(n),G(e),t,G(i))),$b=new vn,Jb=new xe,SD=new J;class Kb extends pt{static get type(){return"GTAONode"}constructor(e,t,i){super(),this.depthNode=e,this.normalNode=t,this.radius=fe(.25),this.resolution=fe(new J),this.thickness=fe(1),this.distanceExponent=fe(1),this.distanceFallOff=fe(1),this.scale=fe(1),this.noiseNode=yt(wD()),this.cameraProjectionMatrix=fe(i.projectionMatrix),this.cameraProjectionMatrixInverse=fe(i.projectionMatrixInverse),this.SAMPLES=fe(16),this._aoRenderTarget=new ui,this._aoRenderTarget.texture.name="GTAONode.AO",this._material=null,this._textureNode=So(this,this._aoRenderTarget.texture),this.updateBeforeType=je.FRAME}getTextureNode(){return this._textureNode}setSize(e,t){this.resolution.value.set(e,t),this._aoRenderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=t.getDrawingBufferSize(SD),r=t.getRenderTarget(),s=t.getMRT();t.getClearColor(Jb);const a=t.getClearAlpha();$b.material=this._material,this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),$b.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor(Jb,a)}setup(e){const t=nt(),i=c=>this.depthNode.uv(c).x,r=c=>this.noiseNode.uv(c),s=U(([c])=>{const u=this.cameraProjectionMatrix.mul(ae(c,1));let h=u.xy.div(u.w).mul(.5).add(.5).toVar();h=z(h.x,h.y.oneMinus());const d=i(h);return D(h,d)}),a=U(([c,u])=>{c=z(c.x,c.y.oneMinus()).mul(2).sub(1);const h=ae(D(c,u),1),d=ae(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),o=U(()=>{const c=i(t);c.greaterThanEqual(1).discard();const u=a(t,c),h=this.normalNode.rgb.normalize(),d=this.radius,p=fs(this.noiseNode,0);let m=z(t.x,t.y.oneMinus());m=m.mul(this.resolution.div(p));const v=r(m),f=v.xyz.mul(2).sub(1),g=D(f.xy,0).normalize(),x=D(g.y.mul(-1),g.x,0),y=yi(g,x,D(0,0,1)),_=this.SAMPLES.lessThan(30).select(3,5),I=zt(this.SAMPLES,_.sub(1)).div(_),T=E(0).toVar();return gt({start:P(0),end:_,type:"int",condition:"<"},({i:w})=>{const C=E(w).div(E(_)).mul(ea),H=ae(Tr(C),Ci(C),0,zt(.5,lt(.5,v.w)));H.xyz=Mr(y.mul(H.xyz));const M=Mr(u.xyz.negate()),b=Mr(uo(H.xyz,M)),k=uo(b,M),j=Mr(h.sub(b.mul(qt(h,b)))),Y=uo(j,b),re=z(qt(M,Y),qt(M,Y.negate())).toVar();gt({end:I,type:"int",name:"j",condition:"<"},({j:at})=>{const et=H.xyz.mul(d).mul(H.w).mul(Ji(Qr(E(at).add(1),E(I)),this.distanceExponent)),ie=s(u.add(et)),le=a(ie.xy,ie.z).sub(u);Le(It(le.z).lessThan(this.thickness),()=>{const Ye=qt(M,Mr(le));re.x.addAssign(ft(0,lt(Ye.sub(re.x),rt(1,E(2).div(E(at).add(2)),this.distanceFallOff))))});const be=s(u.sub(et)),Se=a(be.xy,be.z).sub(u);Le(It(Se.z).lessThan(this.thickness),()=>{const Ye=qt(M,Mr(Se));re.y.addAssign(ft(0,lt(Ye.sub(re.y),rt(1,E(2).div(E(at).add(2)),this.distanceFallOff))))})});const $=en(Pt(1,re.mul(re))),he=qt(j,k),Q=qt(j,M),ye=lt(.5,Wh(re.y).sub(Wh(re.x)).add($.x.mul(re.x).sub($.y.mul(re.y)))),Te=lt(.5,Pt(2,re.x.mul(re.x)).sub(re.y.mul(re.y))),Ve=he.mul(ye).add(Q.mul(Te));T.addAssign(Ve)}),T.assign(li(T.div(_),0,1)),T.assign(Ji(T,this.scale)),ae(D(T),1)}),l=this._material||(this._material=new Tt);return l.fragmentNode=o().context(e.getSharedContext()),l.name="GTAO",l.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}function wD(n=5){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=ED(e),i=t.length,r=new Uint8Array(i*4);for(let a=0;a<i;++a){const o=t[a],l=2*Math.PI*o/i,c=new N(Math.cos(l),Math.sin(l),0).normalize();r[a*4]=(c.x*.5+.5)*255,r[a*4+1]=(c.y*.5+.5)*255,r[a*4+2]=127,r[a*4+3]=255}const s=new Ur(r,e,e);return s.wrapS=jn,s.wrapT=jn,s.needsUpdate=!0,s}function ED(n){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=e*e,i=Array(t).fill(0);let r=Math.floor(e/2),s=e-1;for(let a=1;a<=t;){if(r===-1&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),i[r*e+s]!==0){s-=2,r++;continue}else i[r*e+s]=a++;s++,r--}return i}const AD=(n,e,t)=>G(new Kb(G(n),G(e),t));class Zb extends pt{static get type(){return"DenoiseNode"}constructor(e,t,i,r,s){super(),this.textureNode=e,this.depthNode=t,this.normalNode=i,this.noiseNode=r,this.cameraProjectionMatrixInverse=fe(s.projectionMatrixInverse),this.lumaPhi=fe(5),this.depthPhi=fe(5),this.normalPhi=fe(5),this.radius=fe(5),this.index=fe(0),this._resolution=fe(new J),this._sampleVectors=gn(ND(16,2,1)),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value;this._resolution.value.set(e.image.width,e.image.height)}setup(){const e=nt(),t=c=>this.textureNode.uv(c),i=c=>this.depthNode.uv(c).x,r=c=>this.normalNode.uv(c),s=c=>this.noiseNode.uv(c),a=U(([c,u])=>{c=z(c.x,c.y.oneMinus()).mul(2).sub(1);const h=ae(D(c,u),1),d=ae(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),o=U(([c,u,h,d])=>{const p=t(d),m=i(d),v=r(d).rgb.normalize(),f=p.rgb,g=a(d,m),x=qt(u,v).toVar(),y=Ji(ft(x,0),this.normalPhi).toVar(),_=It(Ui(f).sub(Ui(c))).toVar(),I=ft(E(1).sub(_.div(this.lumaPhi)),0).toVar(),T=It(qt(h.sub(g),u)).toVar(),w=ft(E(1).sub(T.div(this.depthPhi)),0),C=I.mul(w).mul(y);return ae(f.mul(C),C)}),l=U(([c])=>{const u=i(c),h=r(c).rgb.normalize(),d=t(c);Le(u.greaterThanEqual(1).or(qt(h,h).equal(0)),()=>d);const p=D(d.rgb),m=a(c,u),v=fs(this.noiseNode,0);let f=z(c.x,c.y.oneMinus());f=f.mul(this._resolution.div(v));const g=s(f),x=Ci(g.element(this.index.mod(4).mul(2).mul(ea))),y=Tr(g.element(this.index.mod(4).mul(2).mul(ea))),_=z(x,y),I=Ol(_.x,_.y.negate(),_.x,_.y),T=E(1).toVar(),w=D(d.rgb).toVar();return gt({start:P(0),end:P(16),type:"int",condition:"<"},({i:C})=>{const H=this._sampleVectors.element(C).toVar(),M=I.mul(H.xy.mul(E(1).add(H.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),b=c.add(M).toVar(),k=o(p,h,m,b);w.addAssign(k.xyz),T.addAssign(k.w)}),Le(T.greaterThan(E(0)),()=>{w.divAssign(T)}),ae(w,d.a)}).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return U(()=>l(e))()}}function ND(n,e,t){const i=CD(n,e,t),r=[];for(let s=0;s<n;s++){const a=i[s];r.push(a)}return r}function CD(n,e,t){const i=[];for(let r=0;r<n;r++){const s=2*Math.PI*e*r/n,a=Math.pow(r/(n-1),t);i.push(new N(Math.cos(s),Math.sin(s),a))}return i}const RD=(n,e,t,i,r)=>G(new Zb(Zi(n),G(e),G(t),G(i),r));class Qb extends pt{static get type(){return"FXAANode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=je.RENDER,this._invSize=fe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const e=this.textureNode.bias(-100),t=e.uvNode||nt(),i=l=>e.uv(l),r=(l,c,u)=>e.uv(l.add(c.mul(u))),s=P(5),a=U(([l,c])=>{const u=ae(c).toVar(),h=ae(l).toVar(),d=ae(It(h.sub(u))).toVar();return ft(ft(ft(d.r,d.g),d.b),d.a)}),o=U(([l,c,u,h])=>{const d=i(l).toVar(),p=r(l,z(0,-1),c.xy).toVar(),m=r(l,z(1,0),c.xy).toVar(),v=r(l,z(0,1),c.xy).toVar(),f=r(l,z(-1,0),c.xy).toVar(),g=a(d,v).toVar(),x=a(d,p).toVar(),y=a(d,m).toVar(),_=a(d,f).toVar(),I=ft(g,ft(x,ft(y,_))).toVar();Le(I.lessThan(u),()=>d);const T=Pt(g.add(x),y.add(_)).toVar();T.mulAssign(h),Le(It(T).lessThan(.3),()=>{const Ve=y.greaterThan(_).select(1,-1).toVar(),at=x.greaterThan(g).select(1,-1).toVar(),et=z(Ve,at).toVar(),ie=r(l,z(et.x,et.y),c.xy),le=a(d,ie).toVar(),be=r(l,z(et.x.negate(),et.y.negate()),c.xy),Se=a(d,be).toVar();T.assign(Se.sub(le)),T.mulAssign(h),Le(It(T).lessThan(.3),()=>{const Ye=v.add(p).add(m).add(f);return rt(d,Ye.mul(.25),.4)})});const w=z().toVar();Le(T.lessThanEqual(0),()=>{v.assign(f),p.assign(m),w.x.assign(0),w.y.assign(c.y)}).Else(()=>{w.x.assign(c.x),w.y.assign(0)});const C=a(d,v).toVar(),H=a(d,p).toVar();Le(C.lessThanEqual(H),()=>{v.assign(p)});const M=P(0).toVar(),b=P(0).toVar(),k=E(0).toVar(),j=E(0).toVar(),Y=z(l).toVar(),re=z(l).toVar(),$=P(0).toVar(),he=P(0).toVar();gt(s,({i:Ve})=>{const at=Ve.add(1).toVar();Le(M.equal(0),()=>{k.addAssign(at),Y.assign(l.add(w.mul(k)));const et=i(Y.xy),ie=a(et,d).toVar(),le=a(et,v).toVar();Le(ie.greaterThan(le),()=>{M.assign(1)}),$.assign(Ve)}),Le(b.equal(0),()=>{j.addAssign(at),re.assign(l.sub(w.mul(j)));const et=i(re.xy),ie=a(et,d).toVar(),le=a(et,v).toVar();Le(ie.greaterThan(le),()=>{b.assign(1)}),he.assign(Ve)}),Le(M.equal(1).or(b.equal(1)),()=>{sd()})}),Le(M.equal(0).and(b.equal(0)),()=>d);const Q=E(1).toVar(),ye=E(1).toVar();Le(M.equal(1),()=>{Q.assign(E($).div(E(s.sub(1))))}),Le(b.equal(1),()=>{ye.assign(E(he).div(E(s.sub(1))))});const Te=xi(Q,ye);return Te.assign(Ji(Te,.5)),Te.assign(E(1).sub(Te)),rt(d,v,Te.mul(.5))}).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return U(()=>{const l=E(.2),c=E(1).div(l);return o(t,this._invSize,l,c)})()}}const ID=n=>G(new Qb(Zi(n))),ca=new vn,LD=new xe(0,0,0),eS=new xe,PD=new J,DD=new J(1,0),UD=new J(0,1);class tS extends pt{static get type(){return"BloomNode"}constructor(e,t=1,i=0,r=0){super(),this.inputNode=e,this.strength=fe(t),this.radius=fe(i),this.threshold=fe(r),this.smoothWidth=fe(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new ui(1,1,{type:wi}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let s=0;s<this._nMips;s++){const a=new ui(1,1,{type:wi});a.texture.name="UnrealBloomPass.h"+s,a.texture.generateMipmaps=!1,this._renderTargetsHorizontal.push(a);const o=new ui(1,1,{type:wi});o.texture.name="UnrealBloomPass.v"+s,o.texture.generateMipmaps=!1,this._renderTargetsVertical.push(o)}this._compositeMaterial=null,this._highPassFilterMaterial=null,this._separableBlurMaterials=[],this._textureNodeBright=yt(this._renderTargetBright.texture),this._textureNodeBlur0=yt(this._renderTargetsVertical[0].texture),this._textureNodeBlur1=yt(this._renderTargetsVertical[1].texture),this._textureNodeBlur2=yt(this._renderTargetsVertical[2].texture),this._textureNodeBlur3=yt(this._renderTargetsVertical[3].texture),this._textureNodeBlur4=yt(this._renderTargetsVertical[4].texture),this._textureOutput=So(this,this._renderTargetsHorizontal[0].texture),this.updateBeforeType=je.FRAME}getTextureNode(){return this._textureOutput}setSize(e,t){let i=Math.round(e/2),r=Math.round(t/2);this._renderTargetBright.setSize(i,r);for(let s=0;s<this._nMips;s++)this._renderTargetsHorizontal[s].setSize(i,r),this._renderTargetsVertical[s].setSize(i,r),this._separableBlurMaterials[s].invSize.value.set(1/i,1/r),i=Math.round(i/2),r=Math.round(r/2)}updateBefore(e){const{renderer:t}=e,i=t.getDrawingBufferSize(PD);this.setSize(i.width,i.height);const r=t.getRenderTarget(),s=t.getMRT();t.getClearColor(eS);const a=t.getClearAlpha();this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(LD,0),t.setRenderTarget(this._renderTargetBright),ca.material=this._highPassFilterMaterial,ca.render(t);let o=this._renderTargetBright;for(let l=0;l<this._nMips;l++)ca.material=this._separableBlurMaterials[l],this._separableBlurMaterials[l].colorTexture.value=o.texture,this._separableBlurMaterials[l].direction.value=DD,t.setRenderTarget(this._renderTargetsHorizontal[l]),t.clear(),ca.render(t),this._separableBlurMaterials[l].colorTexture.value=this._renderTargetsHorizontal[l].texture,this._separableBlurMaterials[l].direction.value=UD,t.setRenderTarget(this._renderTargetsVertical[l]),t.clear(),ca.render(t),o=this._renderTargetsVertical[l];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),ca.material=this._compositeMaterial,ca.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor(eS,a)}setup(e){const t=U(()=>{const l=this.inputNode,c=Ui(l.rgb),u=Ki(this.threshold,this.threshold.add(this.smoothWidth),c);return rt(ae(0),l,u)});this._highPassFilterMaterial=this._highPassFilterMaterial||new Tt,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const i=[3,5,7,9,11];for(let l=0;l<this._nMips;l++)this._separableBlurMaterials.push(this._getSeperableBlurMaterial(e,i[l]));const r=gn([1,.8,.6,.4,.2]),s=gn([new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1)]),a=U(([l,c])=>{const u=E(1.2).sub(l);return rt(l,u,c)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),o=U(()=>{const l=a(r.element(0),this.radius).mul(ae(s.element(0),1)).mul(this._textureNodeBlur0),c=a(r.element(1),this.radius).mul(ae(s.element(1),1)).mul(this._textureNodeBlur1),u=a(r.element(2),this.radius).mul(ae(s.element(2),1)).mul(this._textureNodeBlur2),h=a(r.element(3),this.radius).mul(ae(s.element(3),1)).mul(this._textureNodeBlur3),d=a(r.element(4),this.radius).mul(ae(s.element(4),1)).mul(this._textureNodeBlur4);return l.add(c).add(u).add(h).add(d).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new Tt,this._compositeMaterial.fragmentNode=o().context(e.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;e<this._renderTargetsHorizontal.length;e++)this._renderTargetsHorizontal[e].dispose();for(let e=0;e<this._renderTargetsVertical.length;e++)this._renderTargetsVertical[e].dispose();this._renderTargetBright.dispose()}_getSeperableBlurMaterial(e,t){const i=[];for(let d=0;d<t;d++)i.push(.39894*Math.exp(-.5*d*d/(t*t))/t);const r=yt(),s=gn(i),a=fe(new J),o=fe(new J(.5,.5)),l=nt(),c=d=>r.uv(d),u=U(()=>{const d=s.element(0).toVar(),p=c(l).rgb.mul(d).toVar();return gt({start:P(1),end:P(t),type:"int",condition:"<"},({i:m})=>{const v=E(m),f=s.element(m),g=o.mul(a).mul(v),x=c(l.add(g)).rgb,y=c(l.sub(g)).rgb;p.addAssign(zt(x,y).mul(f)),d.addAssign(E(2).mul(f))}),ae(p.div(d),1)}),h=new Tt;return h.fragmentNode=u().context(e.getSharedContext()),h.name="Bloom_seperable",h.needsUpdate=!0,h.colorTexture=r,h.direction=o,h.invSize=a,h}}const OD=(n,e,t,i)=>G(new tS(G(n),e,t,i));class iS extends pt{static get type(){return"TransitionNode"}constructor(e,t,i,r,s,a){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=i,this.mixRatioNode=r,this.thresholdNode=s,this.useTextureNode=a}setup(){const{textureNodeA:e,textureNodeB:t,mixTextureNode:i,mixRatioNode:r,thresholdNode:s,useTextureNode:a}=this,o=l=>{const c=l.uvNode||nt();return l.uv(c)};return U(()=>{const l=o(e),c=o(t),u=ae().toVar();return Le(a.equal(P(1)),()=>{const h=o(i),d=r.mul(s.mul(2).add(1)).sub(s),p=li(Pt(h.r,d).mul(E(1).div(s)),0,1);u.assign(rt(l,c,p))}).Else(()=>{u.assign(rt(c,l,r))}),u})()}}const FD=(n,e,t,i=0,r=.1,s=0)=>G(new iS(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class VD extends pt{static get type(){return"PixelationNode"}constructor(e,t,i,r,s,a){super(),this.textureNode=e,this.depthNode=t,this.normalNode=i,this.pixelSize=r,this.normalEdgeStrength=s,this.depthEdgeStrength=a,this._resolution=fe(new st),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value,t=e.image.width,i=e.image.height;this._resolution.value.set(t,i,1/t,1/i)}setup(){const{textureNode:e,depthNode:t,normalNode:i}=this,r=e.uvNode||nt(),s=t.uvNode||nt(),a=i.uvNode||nt(),o=()=>e.uv(r),l=(p,m)=>t.uv(s.add(z(p,m).mul(this._resolution.zw))).r,c=(p,m)=>i.uv(a.add(z(p,m).mul(this._resolution.zw))).rgb.normalize(),u=p=>{const m=ar("float","diff");return m.addAssign(li(l(1,0).sub(p))),m.addAssign(li(l(-1,0).sub(p))),m.addAssign(li(l(0,1).sub(p))),m.addAssign(li(l(0,-1).sub(p))),ds(Ki(.01,.02,m).mul(2)).div(2)},h=(p,m,v,f)=>{const g=l(p,m).sub(v),x=c(p,m),y=D(1,1,1),_=qt(f.sub(x),y),I=li(Ki(-.01,.01,_),0,1),T=li(Wl(g.mul(.25).add(.0025)),0,1);return E(1).sub(qt(f,x)).mul(T).mul(I)},d=(p,m)=>{const v=ar("float","indicator");return v.addAssign(h(0,-1,p,m)),v.addAssign(h(0,1,p,m)),v.addAssign(h(-1,0,p,m)),v.addAssign(h(1,0,p,m)),jl(.1,v)};return U(()=>{const p=o(),m=ar("float","depth"),v=ar("vec3","normal");Le(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),()=>{m.assign(l(0,0)),v.assign(c(0,0))});const f=ar("float","dei");Le(this.depthEdgeStrength.greaterThan(0),()=>{f.assign(u(m))});const g=ar("float","nei");Le(this.normalEdgeStrength.greaterThan(0),()=>{g.assign(d(m,v))});const x=f.greaterThan(0).select(E(1).sub(f.mul(this.depthEdgeStrength)),g.mul(this.normalEdgeStrength).add(1));return p.mul(x)})()}}const BD=(n,e,t,i=6,r=.3,s=.4)=>G(new VD(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class rS extends bi{static get type(){return"PixelationPassNode"}constructor(e,t,i=6,r=.3,s=.4){super("color",e,t,{minFilter:$t,magFilter:$t}),this.pixelSize=i,this.normalEdgeStrength=r,this.depthEdgeStrength=s,this.isPixelationPassNode=!0,this._mrt=_d({output:Ef,normal:hr})}setSize(e,t){const i=this.pixelSize.value?this.pixelSize.value:this.pixelSize,r=Math.floor(e/i),s=Math.floor(t/i);super.setSize(r,s)}setup(){const e=super.getTextureNode("output"),t=super.getTextureNode("depth"),i=super.getTextureNode("normal");return BD(e,t,i,this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const zD=(n,e,t,i,r)=>G(new rS(n,e,t,i,r)),kD=new J;class nS extends bi{static get type(){return"SSAAPassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new xe(0),this.clearAlpha=0,this._currentClearColor=new xe,this.sampleWeight=fe(1),this.sampleRenderTarget=null,this._quadMesh=new vn}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(kD);this.setSize(s.width,s.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);const a=t.getClearAlpha(),o=t.getRenderTarget(),l=t.getMRT(),c=t.autoClear;this._cameraNear.value=r.near,this._cameraFar.value=r.far,t.setMRT(this.getMRT()),t.autoClear=!1;const u=HD[Math.max(0,Math.min(this.sampleLevel,5))],h=1/u.length,d=1/32,p={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},m=Object.assign({},r.view);m.enabled&&Object.assign(p,m);for(let v=0;v<u.length;v++){const f=u[v];if(r.setViewOffset&&r.setViewOffset(p.fullWidth,p.fullHeight,p.offsetX+f[0]*.0625,p.offsetY+f[1]*.0625,p.width,p.height),this.sampleWeight.value=h,this.unbiased){const g=-.5+(v+.5)/u.length;this.sampleWeight.value+=d*g}t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(i,r),t.setRenderTarget(this.renderTarget),v===0&&(t.setClearColor(0,0),t.clear()),this._quadMesh.render(t)}t.copyTextureToTexture(this.sampleRenderTarget.depthTexture,this.renderTarget.depthTexture),r.setViewOffset&&m.enabled?r.setViewOffset(m.fullWidth,m.fullHeight,m.offsetX,m.offsetY,m.width,m.height):r.clearViewOffset&&r.clearViewOffset(),t.setRenderTarget(o),t.setMRT(l),t.autoClear=c,t.setClearColor(this._currentClearColor,a)}setup(e){this.sampleRenderTarget===null&&(this.sampleRenderTarget=this.renderTarget.clone());let t;const i=this.getMRT();if(i!==null){const r={};for(const s in i.outputNodes){const a=qg(this.sampleRenderTarget.textures,s);a>=0&&(r[s]=yt(this.sampleRenderTarget.textures[a]).mul(this.sampleWeight))}t=_d(r)}else t=yt(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new Tt,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=Co,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}}const HD=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],GD=(n,e)=>G(new nS(n,e)),WD=new J;class sS extends bi{static get type(){return"StereoPassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new qm,this.stereo.aspect=.5}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r,stereo:s,renderTarget:a}=this;this._pixelRatio=t.getPixelRatio(),s.cameraL.coordinateSystem=t.coordinateSystem,s.cameraR.coordinateSystem=t.coordinateSystem,s.update(r);const o=t.getSize(WD);this.setSize(o.width,o.height);const l=t.autoClear;t.autoClear=!1;const c=t.getRenderTarget(),u=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const h in this._previousTextures)this.toggleTexture(h);t.setRenderTarget(a),t.setMRT(this._mrt),t.clear(),a.scissorTest=!0,a.scissor.set(0,0,a.width/2,a.height),a.viewport.set(0,0,a.width/2,a.height),t.render(i,s.cameraL),a.scissor.set(a.width/2,0,a.width/2,a.height),a.viewport.set(a.width/2,0,a.width/2,a.height),t.render(i,s.cameraR),a.scissorTest=!1,t.setRenderTarget(c),t.setMRT(u),t.autoClear=l}}const jD=(n,e)=>G(new sS(n,e)),XD=new J,aS=new vn;class oS extends bi{static get type(){return"StereoCompositePassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new qm;const i={minFilter:Lt,magFilter:$t,type:wi};this._renderTargetL=new ui(1,1,i),this._renderTargetR=new ui(1,1,i),this._mapLeft=yt(this._renderTargetL.texture),this._mapRight=yt(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){const{renderer:t}=e,{scene:i,stereo:r,renderTarget:s}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);const a=t.getSize(XD);this.setSize(a.width,a.height);const o=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(i,r.cameraL),t.setRenderTarget(this._renderTargetR),t.render(i,r.cameraR),t.setRenderTarget(s),aS.material=this._material,aS.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}}class lS extends oS{static get type(){return"AnaglyphPassNode"}constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=fe(new Ke().fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=fe(new Ke().fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){const t=nt(),i=U(()=>{const s=this._mapLeft.uv(t),a=this._mapRight.uv(t),o=li(this._colorMatrixLeft.mul(s.rgb).add(this._colorMatrixRight.mul(a.rgb)));return ae(o.rgb,ft(s.a,a.a))}),r=this._material||(this._material=new Tt);return r.fragmentNode=i().context(e.getSharedContext()),r.name="Anaglyph",r.needsUpdate=!0,super.setup(e)}}const qD=(n,e)=>G(new lS(n,e));class cS extends oS{static get type(){return"ParallaxBarrierPassNode"}constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){const t=nt(),i=U(()=>{const s=ae().toVar();return Le(jh(yo.y,2).greaterThan(1),()=>{s.assign(this._mapLeft.uv(t))}).Else(()=>{s.assign(this._mapRight.uv(t))}),s}),r=this._material||(this._material=new Tt);return r.fragmentNode=i().context(e.getSharedContext()),r.needsUpdate=!0,super.setup(e)}}const YD=(n,e)=>G(new cS(n,e));class uS extends bi{static get type(){return"ToonOutlinePassNode"}constructor(e,t,i,r,s){super(bi.COLOR,e,t),this.colorNode=i,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,i=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,o,l,c,u)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const h=this._getOutlineMaterial(l);t.renderObject(r,s,a,o,h,c,u)}t.renderObject(r,s,a,o,l,c,u)}),super.updateBefore(e),t.setRenderObjectFunction(i)}_createMaterial(){const e=new Tt;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=si;const t=ur.negate(),i=lr.mul(fn),r=E(1),s=i.mul(ae(Zt,1)),a=i.mul(ae(Zt.add(t),1)),o=Mr(s.sub(a));return e.vertexNode=s.add(o.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=ae(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const $D=(n,e,t=new xe(0,0,0),i=.003,r=1)=>G(new uS(n,e,G(t),G(i),G(r)));class hS extends qe{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new vr,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:E()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=af(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=of(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Sd=K(hS);class dS extends Map{get(e,t=null,...i){if(this.has(e))return super.get(e);if(t!==null){const r=t(...i);return this.set(e,r),r}}}class JD{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const wd=new dS;class pS extends qe{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new dS,this._output=Sd(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const i=this._outputs;return i[e]===void 0?i[e]=Sd(t):i[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const i=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),i[e]=t,i[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),i[e]=t,i[e].events.addEventListener("refresh",this.onRefresh)):i[e]===void 0?(i[e]=Sd(t),i[e].events.addEventListener("refresh",this.onRefresh)):i[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i(...t)}async callAsync(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i.constructor.name==="AsyncFunction"?await i(...t):i(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(c,u)=>this.setOutput(c,u),i=new JD(this),r=wd.get("THREE"),s=wd.get("TSL"),a=this.getMethod(this.codeNode),o=[i,this._local,wd,e,t,r,s];this._object=a(...o);const l=this._object.layout;if(l&&(l.cache===!1&&this._local.clear(),this._output.outputType=l.outputType||null,Array.isArray(l.elements)))for(const c of l.elements){const u=c.id||c.name;c.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=c.inputType),c.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=c.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let i=this.parameters[t];i.isScriptableNode&&(i=i.getDefaultOutput()),i.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:E()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],t=["layout","init","main","dispose"].join(", "),i="var "+t+`; var output = {};
|
|
3868
3868
|
`,r=`
|
|
3869
|
-
return { ...output, `+t+" };",s=i+this.codeNode.code+r;return this._method=new Function(...e,s),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[Yx(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const i in this.parameters)t.push(this.parameters[i].getCacheKey(e));return $x(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const KD=K(dS);class wd extends qe{static get type(){return"FogNode"}constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const i=e.context.getViewZ;return i!==void 0&&(t=i(this)),(t||Pi.z).negate()}setup(){return this.factorNode}}const ZD=K(wd);class pS extends wd{static get type(){return"FogRangeNode"}constructor(e,t,i){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=i}setup(e){const t=this.getViewZNode(e);return Ki(this.nearNode,this.farNode,t)}}const QD=K(pS);class mS extends wd{static get type(){return"FogExp2Node"}constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),i=this.densityNode;return i.mul(i,t,t).negate().exp().oneMinus()}}const eU=K(mS);let ca=null,ua=null;class fS extends qe{static get type(){return"RangeNode"}constructor(e=E(),t=E()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Pn(this.minNode.value)),i=e.getTypeLength(Pn(this.maxNode.value));return t>i?t:i}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let i=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Pn(r)),o=e.getTypeLength(Pn(s));ca=ca||new st,ua=ua||new st,ca.setScalar(0),ua.setScalar(0),a===1?ca.setScalar(r):r.isColor?ca.set(r.r,r.g,r.b):ca.set(r.x,r.y,r.z||0,r.w||0),o===1?ua.setScalar(s):s.isColor?ua.set(s.r,s.g,s.b):ua.set(s.x,s.y,s.z||0,s.w||0);const l=4,c=l*t.count,u=new Float32Array(c);for(let d=0;d<c;d++){const p=d%l,m=ca.getComponent(p),v=ua.getComponent(p);u[d]=cu.lerp(m,v,Math.random())}const h=this.getNodeType(e);if(t.count<=4096)i=Jl(u,"vec4",t.count).element(ic).convert(h);else{const d=new Rn(u,4);e.geometry.setAttribute("__range"+this.id,d),i=Xh(d).convert(h)}}else i=E(0);return i}}const tU=K(fS),iU=U(({depthTexture:n,shadowCoord:e})=>yt(n,e.xy).compare(e.z)),rU=U(({depthTexture:n,shadowCoord:e,shadow:t})=>{const i=(v,f)=>yt(n,v).compare(f),r=fi("mapSize","vec2",t).setGroup(xt),s=fi("radius","float",t).setGroup(xt),a=z(1).div(r),o=a.x.negate().mul(s),l=a.y.negate().mul(s),c=a.x.mul(s),u=a.y.mul(s),h=o.div(2),d=l.div(2),p=c.div(2),m=u.div(2);return zt(i(e.xy.add(z(o,l)),e.z),i(e.xy.add(z(0,l)),e.z),i(e.xy.add(z(c,l)),e.z),i(e.xy.add(z(h,d)),e.z),i(e.xy.add(z(0,d)),e.z),i(e.xy.add(z(p,d)),e.z),i(e.xy.add(z(o,0)),e.z),i(e.xy.add(z(h,0)),e.z),i(e.xy,e.z),i(e.xy.add(z(p,0)),e.z),i(e.xy.add(z(c,0)),e.z),i(e.xy.add(z(h,m)),e.z),i(e.xy.add(z(0,m)),e.z),i(e.xy.add(z(p,m)),e.z),i(e.xy.add(z(o,u)),e.z),i(e.xy.add(z(0,u)),e.z),i(e.xy.add(z(c,u)),e.z)).mul(1/17)}),nU=U(({depthTexture:n,shadowCoord:e,shadow:t})=>{const i=(u,h)=>yt(n,u).compare(h),r=fi("mapSize","vec2",t).setGroup(xt),s=z(1).div(r),a=s.x,o=s.y,l=e.xy,c=ds(l.mul(r).add(.5));return l.subAssign(c.mul(s)),zt(i(l,e.z),i(l.add(z(a,0)),e.z),i(l.add(z(0,o)),e.z),i(l.add(s),e.z),rt(i(l.add(z(a.negate(),0)),e.z),i(l.add(z(a.mul(2),0)),e.z),c.x),rt(i(l.add(z(a.negate(),o)),e.z),i(l.add(z(a.mul(2),o)),e.z),c.x),rt(i(l.add(z(0,o.negate())),e.z),i(l.add(z(0,o.mul(2))),e.z),c.y),rt(i(l.add(z(a,o.negate())),e.z),i(l.add(z(a,o.mul(2))),e.z),c.y),rt(rt(i(l.add(z(a.negate(),o.negate())),e.z),i(l.add(z(a.mul(2),o.negate())),e.z),c.x),rt(i(l.add(z(a.negate(),o.mul(2))),e.z),i(l.add(z(a.mul(2),o.mul(2))),e.z),c.x),c.y)).mul(1/9)}),sU=U(({depthTexture:n,shadowCoord:e})=>{const t=E(1).toVar(),i=yt(n).uv(e.xy).rg,r=Wl(e.z,i.x);return Le(r.notEqual(E(1)),()=>{const s=e.z.sub(i.x),a=ft(0,i.y.mul(i.y));let o=a.div(a.add(s.mul(s)));o=li(Pt(o,.3).div(.95-.3)),t.assign(li(ft(r,o)))}),t}),aU=U(({samples:n,radius:e,size:t,shadowPass:i})=>{const r=E(0).toVar(),s=E(0).toVar(),a=n.lessThanEqual(E(1)).select(E(0),E(2).div(n.sub(1))),o=n.lessThanEqual(E(1)).select(E(0),E(-1));gt({start:P(0),end:P(n),type:"int",condition:"<"},({i:c})=>{const u=o.add(E(c).mul(a)),h=i.uv(zt(vo.xy,z(0,u).mul(e)).div(t)).x;r.addAssign(h),s.addAssign(h.mul(h))}),r.divAssign(n),s.divAssign(n);const l=en(s.sub(r.mul(r)));return z(r,l)}),oU=U(({samples:n,radius:e,size:t,shadowPass:i})=>{const r=E(0).toVar(),s=E(0).toVar(),a=n.lessThanEqual(E(1)).select(E(0),E(2).div(n.sub(1))),o=n.lessThanEqual(E(1)).select(E(0),E(-1));gt({start:P(0),end:P(n),type:"int",condition:"<"},({i:c})=>{const u=o.add(E(c).mul(a)),h=i.uv(zt(vo.xy,z(u,0).mul(e)).div(t));r.addAssign(h.x),s.addAssign(zt(h.y.mul(h.y),h.x.mul(h.x)))}),r.divAssign(n),s.divAssign(n);const l=en(s.sub(r.mul(r)));return z(r,l)}),lU=[iU,rU,nU,sU];let So=null;const Ed=new vn;class gs extends ia{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.updateType=je.FRAME,this.light=e,this.color=new xe,this.colorNode=fe(this.color).setGroup(xt),this.baseColorNode=null,this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this.isAnalyticLightNode=!0}getCacheKey(){return tf(super.getCacheKey(),this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadow(e){const{object:t,renderer:i}=e;if(i.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){So===null&&(So=new Tt,So.fragmentNode=ae(0,0,0,1),So.isShadowNodeMaterial=!0,So.name="ShadowMaterial");const s=i.shadowMap.type,a=this.light.shadow,o=new Os;o.compareFunction=vp;const l=e.createRenderTarget(a.mapSize.width,a.mapSize.height);if(l.depthTexture=o,a.camera.updateProjectionMatrix(),s===rr){o.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:ya,type:wi}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:ya,type:wi});const y=yt(o),_=yt(this.vsmShadowMapVertical.texture),I=fi("blurSamples","float",a).setGroup(xt),T=fi("radius","float",a).setGroup(xt),w=fi("mapSize","vec2",a).setGroup(xt);let C=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Tt);C.fragmentNode=aU({samples:I,radius:T,size:w,shadowPass:y}).context(e.getSharedContext()),C.name="VSMVertical",C=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Tt),C.fragmentNode=oU({samples:I,radius:T,size:w,shadowPass:_}).context(e.getSharedContext()),C.name="VSMHorizontal"}const c=fi("intensity","float",a).setGroup(xt),u=fi("bias","float",a).setGroup(xt),h=fi("normalBias","float",a).setGroup(xt),d=t.material.shadowPositionNode||Yh;let p=fe(a.matrix).setGroup(xt).mul(d.add(Jh.mul(h)));p=p.xyz.div(p.w);let m=p.z.add(u);i.coordinateSystem===Ss&&(m=m.mul(2).sub(1)),p=D(p.x,p.y.oneMinus(),m);const v=p.x.greaterThanEqual(0).and(p.x.lessThanEqual(1)).and(p.y.greaterThanEqual(0)).and(p.y.lessThanEqual(1)).and(p.z.lessThanEqual(1)),f=a.filterNode||lU[i.shadowMap.type]||null;if(f===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=yt(l.texture,p),x=v.select(f({depthTexture:s===rr?this.vsmShadowMapHorizontal.texture:o,shadowCoord:p,shadow:a}),E(1));this.shadowMap=l,this.light.shadow.map=l,this.shadowNode=x,this.shadowColorNode=r=this.colorNode.mul(rt(1,x.rgb.mix(g,1),c.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=r,this.updateBeforeType=je.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&this.disposeShadow()}updateShadow(e){const{shadowMap:t,light:i}=this,{renderer:r,scene:s,camera:a}=e,o=r.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;const c=s.overrideMaterial;s.overrideMaterial=So,t.setSize(i.shadow.mapSize.width,i.shadow.mapSize.height),i.shadow.updateMatrices(i),i.shadow.camera.layers.mask=a.layers.mask;const u=r.getRenderTarget(),h=r.getRenderObjectFunction();r.setRenderObjectFunction((d,...p)=>{(d.castShadow===!0||d.receiveShadow&&o===rr)&&r.renderObject(d,...p)}),r.setRenderTarget(t),r.render(s,i.shadow.camera),r.setRenderObjectFunction(h),i.isPointLight!==!0&&o===rr&&this.vsmPass(e,i),r.setRenderTarget(u),s.overrideMaterial=c}vsmPass(e,t){const{renderer:i}=e;this.vsmShadowMapVertical.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),i.setRenderTarget(this.vsmShadowMapVertical),Ed.material=this.vsmMaterialVertical,Ed.render(i),i.setRenderTarget(this.vsmShadowMapHorizontal),Ed.material=this.vsmMaterialHorizontal,Ed.render(i)}disposeShadow(){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),this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=je.NONE}updateBefore(e){const t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const t0=U(n=>{const{lightDistance:e,cutoffDistance:t,decayExponent:i}=n,r=e.pow(i).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)});let Ad;function i0(n){Ad=Ad||new WeakMap;let e=Ad.get(n);return e===void 0&&Ad.set(n,e={}),e}function r0(n){const e=i0(n);return e.position||(e.position=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.matrixWorld)))}function gS(n){const e=i0(n);return e.targetPosition||(e.targetPosition=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.target.matrixWorld)))}function Nd(n){const e=i0(n);return e.viewPosition||(e.viewPosition=fe(new N).setGroup(xt).onRenderUpdate(({camera:t},i)=>{i.value=i.value||new N,i.value.setFromMatrixPosition(n.matrixWorld),i.value.applyMatrix4(t.matrixWorldInverse)}))}const n0=n=>cr.transformDirection(r0(n).sub(gS(n))),cU=U(([n])=>{const e=n.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),s0=(n,e)=>Ji(lt(4,n.mul(Pt(1,n))),e),uU=(n,e)=>n.lessThan(.5)?s0(n.mul(2),e).div(2):Pt(1,s0(lt(Pt(1,n),2),e).div(2)),hU=(n,e,t)=>Ji(Qr(Ji(n,e),zt(Ji(n,e),Ji(Pt(1,n),t))),1/e),dU=(n,e)=>Ci(Qs.mul(e.mul(n).sub(1))).div(Qs.mul(e.mul(n).sub(1))),yn=U(([n])=>n.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),vS=U(([n])=>D(yn(n.z.add(yn(n.y.mul(1)))),yn(n.z.add(yn(n.x.mul(1)))),yn(n.y.add(yn(n.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),pU=U(([n,e,t])=>{const i=D(n).toVar(),r=E(1.4).toVar(),s=E(0).toVar(),a=D(i).toVar();return gt({start:E(0),end:E(3),type:"float",condition:"<="},()=>{const o=D(vS(a.mul(2))).toVar();i.addAssign(o.add(t.mul(E(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),i.mulAssign(1.2);const l=E(yn(i.z.add(yn(i.x.add(yn(i.y)))))).toVar();s.addAssign(l.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),mU=U(([n,e,t=z(.5)])=>Ig(n.sub(t),e).add(t)),fU=U(([n,e,t=z(.5)])=>{const i=n.sub(t),r=i.dot(i),s=r.mul(r).mul(e);return n.add(i.mul(s))}),gU=U(({position:n=null,horizontal:e=!0,vertical:t=!1})=>{let i;n!==null?(i=zr.toVar(),i[3][0]=n.x,i[3][1]=n.y,i[3][2]=n.z):i=zr;const r=cr.mul(i);return Il(e)&&(r[0][0]=zr[0].length(),r[0][1]=0,r[0][2]=0),Il(t)&&(r[1][0]=0,r[1][1]=zr[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,lr.mul(r).mul(Zt)}),vU=U(([n=null])=>{const e=sd();return sd(pg(n)).sub(e).lessThan(0).select(fs,n)}),yS=new WeakMap;class yU extends pt{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.updateType=je.OBJECT,this.updateAfterType=je.OBJECT,this.previousModelWorldMatrix=fe(new Re),this.previousProjectionMatrix=fe(new Re).setGroup(xt),this.previousCameraViewMatrix=fe(new Re)}update({frameId:e,camera:t,object:i}){const r=_S(i);this.previousModelWorldMatrix.value.copy(r);const s=xS(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new Re,s.previousCameraViewMatrix=new Re,s.currentProjectionMatrix=new Re,s.currentCameraViewMatrix=new Re,s.previousProjectionMatrix.copy(t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){_S(e).copy(e.matrixWorld)}setup(){const e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=lr.mul(fn).mul(Zt),i=this.previousProjectionMatrix.mul(e).mul(qh),r=t.xy.div(t.w),s=i.xy.div(i.w);return Pt(r,s)}}function xS(n){let e=yS.get(n);return e===void 0&&(e={},yS.set(n,e)),e}function _S(n,e=0){const t=xS(n);let i=t[e];return i===void 0&&(t[e]=i=new Re),i}const xU=ge(yU),_U=U(([n,e])=>xi(1,n.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),MU=U(([n,e])=>xi(n.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),TU=U(([n,e])=>n.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),bU=U(([n,e])=>rt(n.mul(2).mul(e),n.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Wl(.5,n))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),SU=U(([n,e,t=P(16)])=>{const i=o=>n.uv(o),r=nt(),s=i(r).toVar(),a=E(t);return gt({start:P(1),end:t,type:"int",condition:"<="},({i:o})=>{const l=e.mul(E(o).div(a.sub(1)).sub(.5));s.addAssign(i(r.add(l)))}),s.divAssign(a),s}),wU=U(([n,e=1])=>{const t=n,i=Ui(t.rgb),r=D(i),s=xi(1,ft(0,E(10).mul(i.sub(.45)))),a=r.mul(t.rgb).mul(2),o=E(2).mul(r.oneMinus()).mul(t.rgb.oneMinus()).oneMinus(),l=rt(a,o,s),c=t.a.mul(e),u=c.mul(l.rgb);return u.addAssign(t.rgb.mul(c.oneMinus())),ae(u,t.a)}),EU=U(([n])=>{const e=D(n);return ae(qt(e,D(.393,.769,.189)),qt(e,D(.349,.686,.168)),qt(e,D(.272,.534,.131)),n.a)}),MS=U(([n])=>{const e=n.mul(.9478672986).add(.0521327014).pow(2.4),t=n.mul(.0773993808),i=n.lessThanEqual(.04045);return rt(e,t,i)}).setLayout({name:"sRGBToLinearSRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),TS=U(([n])=>{const e=n.pow(.41666).mul(1.055).sub(.055),t=n.mul(12.92),i=n.lessThanEqual(.0031308);return rt(e,t,i)}).setLayout({name:"linearSRGBTosRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),bS=U(([n,e])=>n.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SS=U(([n,e])=>(n=n.mul(e),n.div(n.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wS=U(([n,e])=>{n=n.mul(e),n=n.sub(.004).max(0);const t=n.mul(n.mul(6.2).add(.5)),i=n.mul(n.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"}]}),AU=U(([n])=>{const e=n.mul(n.add(.0245786)).sub(90537e-9),t=n.mul(n.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),ES=U(([n,e])=>{const t=yi(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=yi(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return n=n.mul(e).div(.6),n=t.mul(n),n=AU(n),n=i.mul(n),n.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),NU=yi(D(1.6605,-.1246,-.0182),D(-.5876,1.1329,-.1006),D(-.0728,-.0083,1.1187)),CU=yi(D(.6274,.0691,.0164),D(.3293,.9195,.088),D(.0433,.0113,.8956)),RU=U(([n])=>{const e=D(n).toVar(),t=D(e.mul(e)).toVar(),i=D(t.mul(t)).toVar();return E(15.5).mul(i.mul(t)).sub(lt(40.14,i.mul(e))).add(lt(31.96,i).sub(lt(6.868,t.mul(e))).add(lt(.4298,t).add(lt(.1191,e).sub(.00232))))}),AS=U(([n,e])=>{const t=D(n).toVar(),i=yi(D(.856627153315983,.137318972929847,.11189821299995),D(.0951212405381588,.761241990602591,.0767994186031903),D(.0482516061458583,.101439036467562,.811302368396859)),r=yi(D(1.1271005818144368,-.1413297634984383,-.14132976349843826),D(-.11060664309660323,1.157823702216272,-.11060664309660294),D(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=E(-12.47393),a=E(4.026069);return t.mulAssign(e),t.assign(CU.mul(t)),t.assign(i.mul(t)),t.assign(ft(t,1e-10)),t.assign(Hl(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(li(t,0,1)),t.assign(RU(t)),t.assign(r.mul(t)),t.assign(Ji(ft(D(0),t),D(2.2))),t.assign(NU.mul(t)),t.assign(li(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),NS=U(([n,e])=>{const t=E(.76),i=E(.15);n=n.mul(e);const r=xi(n.r,xi(n.g,n.b)),s=Ri(r.lessThan(.08),r.sub(lt(6.25,r.mul(r))),.04);n.subAssign(s);const a=ft(n.r,ft(n.g,n.b));Le(a.lessThan(t),()=>n);const o=Pt(1,t),l=Pt(1,o.mul(o).div(a.add(o.sub(t))));n.mulAssign(l.div(a));const c=Pt(1,Qr(1,i.mul(a.sub(l)).add(1)));return rt(n,D(l),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class IU extends qe{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){e.hasBuiltin(this._builtinName)}generate(e,t){const i=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage==="compute"?e.format(i,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${i} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const Cd=(n,e)=>G(new IU(n,e)),LU=Cd("numWorkgroups","uvec3"),PU=Cd("workgroupId","uvec3"),DU=Cd("localId","uvec3"),UU=Cd("subgroupSize","uint");class OU extends qe{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:i}=e;i.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
|
|
3870
|
-
`):e.addLineFlowCode(`${t}Barrier()`,this)}}const a0=K(OU),FU=()=>a0("workgroup").append(),VU=()=>a0("storage").append(),BU=()=>a0("texture").append();class zU extends ls{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let i;const r=e.context.assign;if(i=super.generate(e),r!==!0){const s=this.getNodeType(e);i=e.format(i,s,t)}return i}}class kU extends qe{constructor(e,t,i=0){super(t),this.bufferType=t,this.bufferCount=i,this.isWorkgroupInfoNode=!0,this.scope=e}label(e){return this.name=e,this}getHash(){return this.uuid}setScope(e){return this.scope=e,this}getInputType(){return`${this.scope}Array`}element(e){return G(new zU(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const HU=(n,e)=>G(new kU("Workgroup",n,e));class Mi extends pt{static get type(){return"AtomicFunctionNode"}constructor(e,t,i,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=i,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,i=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,o=[];o.push(`&${s.build(e,r)}`),o.push(a.build(e,r));const l=`${e.getMethod(t,i)}( ${o.join(", ")} )`;if(this.storeNode!==null){const c=this.storeNode.build(e,r);e.addLineFlowCode(`${c} = ${l}`,this)}else e.addLineFlowCode(l,this)}}Mi.ATOMIC_LOAD="atomicLoad",Mi.ATOMIC_STORE="atomicStore",Mi.ATOMIC_ADD="atomicAdd",Mi.ATOMIC_SUB="atomicSub",Mi.ATOMIC_MAX="atomicMax",Mi.ATOMIC_MIN="atomicMin",Mi.ATOMIC_AND="atomicAnd",Mi.ATOMIC_OR="atomicOr",Mi.ATOMIC_XOR="atomicXor";const GU=K(Mi),On=(n,e,t,i)=>{const r=GU(n,e,t,i);return r.append(),r},WU=(n,e,t=null)=>On(Mi.ATOMIC_STORE,n,e,t),jU=(n,e,t=null)=>On(Mi.ATOMIC_ADD,n,e,t),XU=(n,e,t=null)=>On(Mi.ATOMIC_SUB,n,e,t),qU=(n,e,t=null)=>On(Mi.ATOMIC_MAX,n,e,t),YU=(n,e,t=null)=>On(Mi.ATOMIC_MIN,n,e,t),$U=(n,e,t=null)=>On(Mi.ATOMIC_AND,n,e,t),JU=(n,e,t=null)=>On(Mi.ATOMIC_OR,n,e,t),KU=(n,e,t=null)=>On(Mi.ATOMIC_XOR,n,e,t),ZU=U(([n=nt()])=>{const e=n.mul(2),t=e.x.floor(),i=e.y.floor();return t.add(i).mod(2).sign()}),pc=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=cs(n).toVar();return Ri(s,r,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Rd=U(([n,e])=>{const t=cs(e).toVar(),i=E(n).toVar();return Ri(t,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),ii=U(([n])=>{const e=E(n).toVar();return P(hs(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),kt=U(([n,e])=>{const t=E(n).toVar();return e.assign(ii(t)),t.sub(E(e))}),QU=U(([n,e,t,i,r,s])=>{const a=E(s).toVar(),o=E(r).toVar(),l=E(i).toVar(),c=E(t).toVar(),u=E(e).toVar(),h=E(n).toVar(),d=E(Pt(1,o)).toVar();return Pt(1,a).mul(h.mul(d).add(u.mul(o))).add(a.mul(c.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),eO=U(([n,e,t,i,r,s])=>{const a=E(s).toVar(),o=E(r).toVar(),l=D(i).toVar(),c=D(t).toVar(),u=D(e).toVar(),h=D(n).toVar(),d=E(Pt(1,o)).toVar();return Pt(1,a).mul(h.mul(d).add(u.mul(o))).add(a.mul(c.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),CS=Di([QU,eO]),tO=U(([n,e,t,i,r,s,a,o,l,c,u])=>{const h=E(u).toVar(),d=E(c).toVar(),p=E(l).toVar(),m=E(o).toVar(),v=E(a).toVar(),f=E(s).toVar(),g=E(r).toVar(),x=E(i).toVar(),y=E(t).toVar(),_=E(e).toVar(),I=E(n).toVar(),T=E(Pt(1,p)).toVar(),w=E(Pt(1,d)).toVar();return E(Pt(1,h)).toVar().mul(w.mul(I.mul(T).add(_.mul(p))).add(d.mul(y.mul(T).add(x.mul(p))))).add(h.mul(w.mul(g.mul(T).add(f.mul(p))).add(d.mul(v.mul(T).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),iO=U(([n,e,t,i,r,s,a,o,l,c,u])=>{const h=E(u).toVar(),d=E(c).toVar(),p=E(l).toVar(),m=D(o).toVar(),v=D(a).toVar(),f=D(s).toVar(),g=D(r).toVar(),x=D(i).toVar(),y=D(t).toVar(),_=D(e).toVar(),I=D(n).toVar(),T=E(Pt(1,p)).toVar(),w=E(Pt(1,d)).toVar();return E(Pt(1,h)).toVar().mul(w.mul(I.mul(T).add(_.mul(p))).add(d.mul(y.mul(T).add(x.mul(p))))).add(h.mul(w.mul(g.mul(T).add(f.mul(p))).add(d.mul(v.mul(T).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),RS=Di([tO,iO]),rO=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=_e(n).toVar(),a=_e(s.bitAnd(_e(7))).toVar(),o=E(pc(a.lessThan(_e(4)),r,i)).toVar(),l=E(lt(2,pc(a.lessThan(_e(4)),i,r))).toVar();return Rd(o,cs(a.bitAnd(_e(1)))).add(Rd(l,cs(a.bitAnd(_e(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),nO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=_e(n).toVar(),l=_e(o.bitAnd(_e(15))).toVar(),c=E(pc(l.lessThan(_e(8)),a,s)).toVar(),u=E(pc(l.lessThan(_e(4)),s,pc(l.equal(_e(12)).or(l.equal(_e(14))),a,r))).toVar();return Rd(c,cs(l.bitAnd(_e(1)))).add(Rd(u,cs(l.bitAnd(_e(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Ti=Di([rO,nO]),sO=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=lo(n).toVar();return D(Ti(s.x,r,i),Ti(s.y,r,i),Ti(s.z,r,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),aO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=lo(n).toVar();return D(Ti(o.x,a,s,r),Ti(o.y,a,s,r),Ti(o.z,a,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),kr=Di([sO,aO]),oO=U(([n])=>{const e=E(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),lO=U(([n])=>{const e=E(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),cO=U(([n])=>{const e=D(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),IS=Di([oO,cO]),uO=U(([n])=>{const e=D(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),LS=Di([lO,uO]),Sr=U(([n,e])=>{const t=P(e).toVar(),i=_e(n).toVar();return i.shiftLeft(t).bitOr(i.shiftRight(P(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),PS=U(([n,e,t])=>{n.subAssign(t),n.bitXorAssign(Sr(t,P(4))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Sr(n,P(6))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Sr(e,P(8))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(Sr(t,P(16))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Sr(n,P(19))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Sr(e,P(4))),e.addAssign(n)}),mc=U(([n,e,t])=>{const i=_e(t).toVar(),r=_e(e).toVar(),s=_e(n).toVar();return i.bitXorAssign(r),i.subAssign(Sr(r,P(14))),s.bitXorAssign(i),s.subAssign(Sr(i,P(11))),r.bitXorAssign(s),r.subAssign(Sr(s,P(25))),i.bitXorAssign(r),i.subAssign(Sr(r,P(16))),s.bitXorAssign(i),s.subAssign(Sr(i,P(4))),r.bitXorAssign(s),r.subAssign(Sr(s,P(14))),i.bitXorAssign(r),i.subAssign(Sr(r,P(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Wi=U(([n])=>{const e=_e(n).toVar();return E(e).div(E(_e(P(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),xn=U(([n])=>{const e=E(n).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),hO=U(([n])=>{const e=P(n).toVar(),t=_e(_e(1)).toVar(),i=_e(_e(P(3735928559)).add(t.shiftLeft(_e(2))).add(_e(13))).toVar();return mc(i.add(_e(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),dO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(_e(2)).toVar(),s=_e().toVar(),a=_e().toVar(),o=_e().toVar();return s.assign(a.assign(o.assign(_e(P(3735928559)).add(r.shiftLeft(_e(2))).add(_e(13))))),s.addAssign(_e(i)),a.addAssign(_e(t)),mc(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),pO=U(([n,e,t])=>{const i=P(t).toVar(),r=P(e).toVar(),s=P(n).toVar(),a=_e(_e(3)).toVar(),o=_e().toVar(),l=_e().toVar(),c=_e().toVar();return o.assign(l.assign(c.assign(_e(P(3735928559)).add(a.shiftLeft(_e(2))).add(_e(13))))),o.addAssign(_e(s)),l.addAssign(_e(r)),c.addAssign(_e(i)),mc(o,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),mO=U(([n,e,t,i])=>{const r=P(i).toVar(),s=P(t).toVar(),a=P(e).toVar(),o=P(n).toVar(),l=_e(_e(4)).toVar(),c=_e().toVar(),u=_e().toVar(),h=_e().toVar();return c.assign(u.assign(h.assign(_e(P(3735928559)).add(l.shiftLeft(_e(2))).add(_e(13))))),c.addAssign(_e(o)),u.addAssign(_e(a)),h.addAssign(_e(s)),PS(c,u,h),c.addAssign(_e(r)),mc(c,u,h)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),fO=U(([n,e,t,i,r])=>{const s=P(r).toVar(),a=P(i).toVar(),o=P(t).toVar(),l=P(e).toVar(),c=P(n).toVar(),u=_e(_e(5)).toVar(),h=_e().toVar(),d=_e().toVar(),p=_e().toVar();return h.assign(d.assign(p.assign(_e(P(3735928559)).add(u.shiftLeft(_e(2))).add(_e(13))))),h.addAssign(_e(c)),d.addAssign(_e(l)),p.addAssign(_e(o)),PS(h,d,p),h.addAssign(_e(a)),d.addAssign(_e(s)),mc(h,d,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Ct=Di([hO,dO,pO,mO,fO]),gO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(Ct(i,t)).toVar(),s=lo().toVar();return s.x.assign(r.bitAnd(P(255))),s.y.assign(r.shiftRight(P(8)).bitAnd(P(255))),s.z.assign(r.shiftRight(P(16)).bitAnd(P(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),vO=U(([n,e,t])=>{const i=P(t).toVar(),r=P(e).toVar(),s=P(n).toVar(),a=_e(Ct(s,r,i)).toVar(),o=lo().toVar();return o.x.assign(a.bitAnd(P(255))),o.y.assign(a.shiftRight(P(8)).bitAnd(P(255))),o.z.assign(a.shiftRight(P(16)).bitAnd(P(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Hr=Di([gO,vO]),yO=U(([n])=>{const e=z(n).toVar(),t=P().toVar(),i=P().toVar(),r=E(kt(e.x,t)).toVar(),s=E(kt(e.y,i)).toVar(),a=E(xn(r)).toVar(),o=E(xn(s)).toVar(),l=E(CS(Ti(Ct(t,i),r,s),Ti(Ct(t.add(P(1)),i),r.sub(1),s),Ti(Ct(t,i.add(P(1))),r,s.sub(1)),Ti(Ct(t.add(P(1)),i.add(P(1))),r.sub(1),s.sub(1)),a,o)).toVar();return IS(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),xO=U(([n])=>{const e=D(n).toVar(),t=P().toVar(),i=P().toVar(),r=P().toVar(),s=E(kt(e.x,t)).toVar(),a=E(kt(e.y,i)).toVar(),o=E(kt(e.z,r)).toVar(),l=E(xn(s)).toVar(),c=E(xn(a)).toVar(),u=E(xn(o)).toVar(),h=E(RS(Ti(Ct(t,i,r),s,a,o),Ti(Ct(t.add(P(1)),i,r),s.sub(1),a,o),Ti(Ct(t,i.add(P(1)),r),s,a.sub(1),o),Ti(Ct(t.add(P(1)),i.add(P(1)),r),s.sub(1),a.sub(1),o),Ti(Ct(t,i,r.add(P(1))),s,a,o.sub(1)),Ti(Ct(t.add(P(1)),i,r.add(P(1))),s.sub(1),a,o.sub(1)),Ti(Ct(t,i.add(P(1)),r.add(P(1))),s,a.sub(1),o.sub(1)),Ti(Ct(t.add(P(1)),i.add(P(1)),r.add(P(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return LS(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),o0=Di([yO,xO]),_O=U(([n])=>{const e=z(n).toVar(),t=P().toVar(),i=P().toVar(),r=E(kt(e.x,t)).toVar(),s=E(kt(e.y,i)).toVar(),a=E(xn(r)).toVar(),o=E(xn(s)).toVar(),l=D(CS(kr(Hr(t,i),r,s),kr(Hr(t.add(P(1)),i),r.sub(1),s),kr(Hr(t,i.add(P(1))),r,s.sub(1)),kr(Hr(t.add(P(1)),i.add(P(1))),r.sub(1),s.sub(1)),a,o)).toVar();return IS(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),MO=U(([n])=>{const e=D(n).toVar(),t=P().toVar(),i=P().toVar(),r=P().toVar(),s=E(kt(e.x,t)).toVar(),a=E(kt(e.y,i)).toVar(),o=E(kt(e.z,r)).toVar(),l=E(xn(s)).toVar(),c=E(xn(a)).toVar(),u=E(xn(o)).toVar(),h=D(RS(kr(Hr(t,i,r),s,a,o),kr(Hr(t.add(P(1)),i,r),s.sub(1),a,o),kr(Hr(t,i.add(P(1)),r),s,a.sub(1),o),kr(Hr(t.add(P(1)),i.add(P(1)),r),s.sub(1),a.sub(1),o),kr(Hr(t,i,r.add(P(1))),s,a,o.sub(1)),kr(Hr(t.add(P(1)),i,r.add(P(1))),s.sub(1),a,o.sub(1)),kr(Hr(t,i.add(P(1)),r.add(P(1))),s,a.sub(1),o.sub(1)),kr(Hr(t.add(P(1)),i.add(P(1)),r.add(P(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return LS(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),l0=Di([_O,MO]),TO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return Wi(Ct(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),bO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return Wi(Ct(t,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),SO=U(([n])=>{const e=D(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar();return Wi(Ct(t,i,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),wO=U(([n])=>{const e=ae(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar(),s=P(ii(e.w)).toVar();return Wi(Ct(t,i,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),EO=Di([TO,bO,SO,wO]),AO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return D(Wi(Ct(t,P(0))),Wi(Ct(t,P(1))),Wi(Ct(t,P(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),NO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return D(Wi(Ct(t,i,P(0))),Wi(Ct(t,i,P(1))),Wi(Ct(t,i,P(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),CO=U(([n])=>{const e=D(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar();return D(Wi(Ct(t,i,r,P(0))),Wi(Ct(t,i,r,P(1))),Wi(Ct(t,i,r,P(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),RO=U(([n])=>{const e=ae(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar(),s=P(ii(e.w)).toVar();return D(Wi(Ct(t,i,r,s,P(0))),Wi(Ct(t,i,r,s,P(1))),Wi(Ct(t,i,r,s,P(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),DS=Di([AO,NO,CO,RO]),Id=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=E(0).toVar(),c=E(1).toVar();return gt(a,()=>{l.addAssign(c.mul(o0(o))),c.mulAssign(r),o.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),US=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(0).toVar(),c=E(1).toVar();return gt(a,()=>{l.addAssign(c.mul(l0(o))),c.mulAssign(r),o.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),IO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar();return z(Id(o,a,s,r),Id(o.add(D(P(19),P(193),P(17))),a,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),LO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(US(o,a,s,r)).toVar(),c=E(Id(o.add(D(P(19),P(193),P(17))),a,s,r)).toVar();return ae(l,c)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),PO=U(([n,e,t,i,r,s,a])=>{const o=P(a).toVar(),l=E(s).toVar(),c=P(r).toVar(),u=P(i).toVar(),h=P(t).toVar(),d=P(e).toVar(),p=z(n).toVar(),m=D(DS(z(d.add(u),h.add(c)))).toVar(),v=z(m.x,m.y).toVar();v.subAssign(.5),v.mulAssign(l),v.addAssign(.5);const f=z(z(E(d),E(h)).add(v)).toVar(),g=z(f.sub(p)).toVar();return Le(o.equal(P(2)),()=>It(g.x).add(It(g.y))),Le(o.equal(P(3)),()=>ft(It(g.x),It(g.y))),qt(g,g)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),DO=U(([n,e,t,i,r,s,a,o,l])=>{const c=P(l).toVar(),u=E(o).toVar(),h=P(a).toVar(),d=P(s).toVar(),p=P(r).toVar(),m=P(i).toVar(),v=P(t).toVar(),f=P(e).toVar(),g=D(n).toVar(),x=D(DS(D(f.add(p),v.add(d),m.add(h)))).toVar();x.subAssign(.5),x.mulAssign(u),x.addAssign(.5);const y=D(D(E(f),E(v),E(m)).add(x)).toVar(),_=D(y.sub(g)).toVar();return Le(c.equal(P(2)),()=>It(_.x).add(It(_.y)).add(It(_.z))),Le(c.equal(P(3)),()=>ft(ft(It(_.x),It(_.y)),It(_.z))),qt(_,_)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),wo=Di([PO,DO]),UO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=E(1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(wo(l,u,h,a,o,r,i)).toVar();c.assign(xi(c,d))})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=z(1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(wo(l,u,h,a,o,r,i)).toVar();Le(d.lessThan(c.x),()=>{c.y.assign(c.x),c.x.assign(d)}).ElseIf(d.lessThan(c.y),()=>{c.y.assign(d)})})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),FO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=D(1e6,1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(wo(l,u,h,a,o,r,i)).toVar();Le(d.lessThan(c.x),()=>{c.z.assign(c.y),c.y.assign(c.x),c.x.assign(d)}).ElseIf(d.lessThan(c.y),()=>{c.z.assign(c.y),c.y.assign(d)}).ElseIf(d.lessThan(c.z),()=>{c.z.assign(d)})})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),VO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=E(1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(wo(c,h,d,p,a,o,l,r,i)).toVar();u.assign(xi(u,m))})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),BO=Di([UO,VO]),zO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=z(1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(wo(c,h,d,p,a,o,l,r,i)).toVar();Le(m.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.y.assign(m)})})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kO=Di([OO,zO]),HO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=D(1e6,1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(wo(c,h,d,p,a,o,l,r,i)).toVar();Le(m.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(m)}).ElseIf(m.lessThan(u.z),()=>{u.z.assign(m)})})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GO=Di([FO,HO]),WO=U(([n])=>{const e=n.y,t=n.z,i=D().toVar();return Le(e.lessThan(1e-4),()=>{i.assign(D(t,t,t))}).Else(()=>{let r=n.x;r=r.sub(hs(r)).mul(6).toVar();const s=P(Of(r)),a=r.sub(E(s)),o=t.mul(e.oneMinus()),l=t.mul(e.mul(a).oneMinus()),c=t.mul(e.mul(a.oneMinus()).oneMinus());Le(s.equal(P(0)),()=>{i.assign(D(t,c,o))}).ElseIf(s.equal(P(1)),()=>{i.assign(D(l,t,o))}).ElseIf(s.equal(P(2)),()=>{i.assign(D(o,t,c))}).ElseIf(s.equal(P(3)),()=>{i.assign(D(o,l,t))}).ElseIf(s.equal(P(4)),()=>{i.assign(D(c,o,t))}).Else(()=>{i.assign(D(t,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),jO=U(([n])=>{const e=D(n).toVar(),t=E(e.x).toVar(),i=E(e.y).toVar(),r=E(e.z).toVar(),s=E(xi(t,xi(i,r))).toVar(),a=E(ft(t,ft(i,r))).toVar(),o=E(a.sub(s)).toVar(),l=E().toVar(),c=E().toVar(),u=E().toVar();return u.assign(a),Le(a.greaterThan(0),()=>{c.assign(o.div(a))}).Else(()=>{c.assign(0)}),Le(c.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{Le(t.greaterThanEqual(a),()=>{l.assign(i.sub(r).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(zt(2,r.sub(t).div(o)))}).Else(()=>{l.assign(zt(4,t.sub(i).div(o)))}),l.mulAssign(1/6),Le(l.lessThan(0),()=>{l.addAssign(1)})}),D(l,c,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),XO=U(([n])=>{const e=D(n).toVar(),t=xf(If(e,D(.04045))).toVar(),i=D(e.div(12.92)).toVar(),r=D(Ji(ft(e.add(D(.055)),D(0)).div(1.055),D(2.4))).toVar();return rt(i,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),OS=(n,e)=>{n=E(n),e=E(e);const t=z(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Ki(n.sub(t),n.add(t),e)},FS=(n,e,t,i)=>rt(n,e,t[i].clamp()),qO=(n,e,t=nt())=>FS(n,e,t,"x"),YO=(n,e,t=nt())=>FS(n,e,t,"y"),VS=(n,e,t,i,r)=>rt(n,e,OS(t,i[r])),$O=(n,e,t,i=nt())=>VS(n,e,t,i,"x"),JO=(n,e,t,i=nt())=>VS(n,e,t,i,"y"),KO=(n=1,e=0,t=nt())=>t.mul(n).add(e),ZO=(n,e=1)=>(n=E(n),n.abs().pow(e).mul(n.sign())),QO=(n,e=1,t=.5)=>E(n).sub(t).mul(e).add(t),eF=(n=nt(),e=1,t=0)=>o0(n.convert("vec2|vec3")).mul(e).add(t),tF=(n=nt(),e=1,t=0)=>l0(n.convert("vec2|vec3")).mul(e).add(t),iF=(n=nt(),e=1,t=0)=>(n=n.convert("vec2|vec3"),ae(l0(n),o0(n.add(z(19,73)))).mul(e).add(t)),rF=(n=nt(),e=1)=>BO(n.convert("vec2|vec3"),e,P(1)),nF=(n=nt(),e=1)=>kO(n.convert("vec2|vec3"),e,P(1)),sF=(n=nt(),e=1)=>GO(n.convert("vec2|vec3"),e,P(1)),aF=(n=nt())=>EO(n.convert("vec2|vec3")),oF=(n=nt(),e=3,t=2,i=.5,r=1)=>Id(n,P(e),t,i).mul(r),lF=(n=nt(),e=3,t=2,i=.5,r=1)=>IO(n,P(e),t,i).mul(r),cF=(n=nt(),e=3,t=2,i=.5,r=1)=>US(n,P(e),t,i).mul(r),uF=(n=nt(),e=3,t=2,i=.5,r=1)=>LO(n,P(e),t,i).mul(r),BS=U(([n,e])=>{const t=n.x,i=n.y,r=n.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(i)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(i)),s=s.add(e.element(5).mul(2*.429043).mul(i).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(lt(t,t).sub(lt(i,i)))),s});class zS extends gs{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=fe(0).setGroup(xt),this.decayExponentNode=fe(0).setGroup(xt)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){const{colorNode:t,cutoffDistanceNode:i,decayExponentNode:r,light:s}=this,a=e.context.lightingModel,o=Nd(s).sub(Pi),l=o.normalize(),c=o.length(),u=t0({lightDistance:c,cutoffDistance:i,decayExponent:r}),h=t.mul(u),d=e.context.reflectedLight;a.direct({lightDirection:l,lightColor:h,reflectedLight:d},e.stack,e)}}class kS extends gs{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,i=this.colorNode,r=n0(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:i,reflectedLight:s},e.stack,e)}}const c0=new Re,Ld=new Re;let fc=null;class HS extends gs{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=fe(new N).setGroup(xt),this.halfWidth=fe(new N).setGroup(xt)}update(e){super.update(e);const{light:t}=this,i=e.camera.matrixWorldInverse;Ld.identity(),c0.copy(t.matrixWorld),c0.premultiply(i),Ld.extractRotation(c0),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Ld),this.halfHeight.value.applyMatrix4(Ld)}setup(e){super.setup(e);let t,i;e.isAvailable("float32Filterable")?(t=yt(fc.LTC_FLOAT_1),i=yt(fc.LTC_FLOAT_2)):(t=yt(fc.LTC_HALF_1),i=yt(fc.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,o=Nd(s),l=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:l,ltc_1:t,ltc_2:i},e.stack,e)}static setLTC(e){fc=e}}class u0 extends gs{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=fe(0).setGroup(xt),this.penumbraCosNode=fe(0).setGroup(xt),this.cutoffDistanceNode=fe(0).setGroup(xt),this.decayExponentNode=fe(0).setGroup(xt)}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){const{coneCosNode:t,penumbraCosNode:i}=this;return Ki(t,i,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:i,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,o=Nd(a).sub(Pi),l=o.normalize(),c=l.dot(n0(a)),u=this.getSpotAttenuation(c),h=o.length(),d=t0({lightDistance:h,cutoffDistance:r,decayExponent:s}),p=i.mul(u).mul(d),m=e.context.reflectedLight;t.direct({lightDirection:l,lightColor:p,reflectedLight:m},e.stack,e)}}class GS extends u0{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let i=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);i=yt(t,z(r,0),0).r}else i=super.getSpotAttenuation(e);return i}}class WS extends gs{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class jS extends gs{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=r0(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=fe(new xe).setGroup(xt)}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,s=hr.dot(r).mul(.5).add(.5),a=rt(i,t,s);e.context.irradiance.addAssign(a)}}class XS extends gs{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let i=0;i<9;i++)t.push(new N);this.lightProbe=gn(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=BS(Jh,this.lightProbe);e.context.irradiance.addAssign(t)}}class hF{parseFunction(){console.warn("Abstract function.")}}class qS{constructor(e,t,i="",r=""){this.type=e,this.inputs=t,this.name=i,this.precision=r}getCode(){console.warn("Abstract function.")}}qS.isNodeFunction=!0;const dF=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,pF=/[a-z_0-9]+/ig,YS="#pragma main",mF=n=>{n=n.trim();const e=n.indexOf(YS),t=e!==-1?n.slice(e+YS.length):n,i=t.match(dF);if(i!==null&&i.length===5){const r=i[4],s=[];let a=null;for(;(a=pF.exec(r))!==null;)s.push(a);const o=[];let l=0;for(;l<s.length;){const m=s[l][0]==="const";m===!0&&l++;let v=s[l][0];v==="in"||v==="out"||v==="inout"?l++:v="";const f=s[l++][0];let g=Number.parseInt(s[l][0]);Number.isNaN(g)===!1?l++:g=null;const x=s[l++][0];o.push(new Wg(f,x,g,v,m))}const c=t.substring(i[0].length),u=i[3]!==void 0?i[3]:"",h=i[2],d=i[1]!==void 0?i[1]:"",p=e!==-1?n.slice(0,e):"";return{type:h,inputs:o,name:u,precision:d,inputsCode:r,blockCode:c,headerCode:p}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class fF extends qS{constructor(e){const{type:t,inputs:i,name:r,precision:s,inputsCode:a,blockCode:o,headerCode:l}=mF(e);super(t,i,r,s),this.inputsCode=a,this.blockCode=o,this.headerCode=l}getCode(e=this.name){let t;const i=this.blockCode;if(i!==""){const{type:r,inputsCode:s,headerCode:a,precision:o}=this;let l=`${r} ${e} ( ${s.trim()} )`;o!==""&&(l=`${o} ${l}`),t=a+l+i}else t="";return t}}class $S extends hF{parseFunction(e){return new fF(e)}}class gF{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=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}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}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.name,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)){console.warn(`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)){console.warn(`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 vF extends Al{constructor(e,t,i,r,s,a){super(e,t,i,r,s,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class JS extends gF{constructor(){super(),this.addLight(zS,Mh),this.addLight(kS,Th),this.addLight(HS,Gm),this.addLight(u0,Al),this.addLight(WS,bh),this.addLight(jS,_h),this.addLight(XS,Wm),this.addLight(GS,vF),this.addToneMapping(bS,Ec),this.addToneMapping(SS,Ac),this.addToneMapping(wS,ip),this.addToneMapping(ES,Nc),this.addToneMapping(AS,Cc),this.addToneMapping(NS,Rc),this.addColorSpace(TS,jh(nr,Fi)),this.addColorSpace(MS,jh(Fi,nr))}}if(typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"169"}})),typeof window<"u"){try{import.meta&&(window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:import.meta.url,revision:"169"}))}catch{}window.__THREE__?(console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: 169"),console.warn(window.__THREE__IMPORTS__)):window.__THREE__="169"}const yF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Nc,AONode:Z1,AddEquation:Bn,AddOperation:tp,AdditiveAnimationBlendMode:pp,AdditiveBlending:No,AfterImageNode:Vb,AgXToneMapping:Cc,AlphaFormat:op,AlwaysCompare:dv,AlwaysDepth:Ro,AlwaysStencilFunc:ou,AmbientLight:bh,AmbientLightNode:WS,AnaglyphPassNode:oS,AnalyticLightNode:gs,AnamorphicNode:kb,AnimationAction:Tx,AnimationClip:no,AnimationLoader:VI,AnimationMixer:bx,AnimationObjectGroup:r2,AnimationUtils:DI,ArcCurve:Vy,ArrayCamera:Qp,ArrayElementNode:ls,ArrowHelper:v2,AssignNode:v_,AttachedBindMode:rp,AttributeNode:Yf,Audio:Ym,AudioAnalyser:qI,AudioContext:Eh,AudioListener:yx,AudioLoader:px,AxesHelper:Wx,BRDF_GGX:xg,BRDF_Lambert:ra,BackSide:si,BasicDepthPacking:mp,BasicEnvironmentNode:ad,BasicNodeLibrary:JS,BasicShadowMap:sw,BatchNode:H1,BatchedMesh:dm,BloomNode:eS,Bone:qu,BooleanKeyframeTrack:ss,Box2:c2,Box3:zi,Box3Helper:Hx,BoxGeometry:_n,BoxHelper:kx,Break:nd,BufferAttribute:wt,BufferAttributeNode:EM,BufferGeometry:ct,BufferGeometryLoader:lx,BufferNode:Zh,BumpMapNode:l1,BypassNode:IM,ByteType:sp,Cache:un,CacheNode:RM,Camera:ll,CameraHelper:zx,CanvasTexture:Fy,CapsuleGeometry:Dd,CatmullRomCurve3:Tm,CineonToneMapping:ip,CircleGeometry:Ud,ClampToEdgeWrapping:gr,Clock:qm,CodeNode:Ug,Color:xe,ColorKeyframeTrack:yh,ColorManagement:vt,ColorSpaceNode:Xl,CompressedArrayTexture:Uy,CompressedCubeTexture:Oy,CompressedTexture:yl,CompressedTextureLoader:BI,ComputeNode:NM,ConeGeometry:Od,ConstNode:Vr,ConstantAlphaFactor:V0,ConstantColorFactor:O0,ContextNode:kf,Continue:AL,Controls:Xx,ConvertNode:hf,CubeCamera:Iu,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,CubeTexture:Rs,CubeTextureLoader:zI,CubeTextureNode:e1,CubeUVReflectionMapping:Gn,CubicBezierCurve:bm,CubicBezierCurve3:zy,CubicInterpolant:Qy,CullFaceBack:qd,CullFaceFront:b0,CullFaceFrontBack:nw,CullFaceNone:T0,Curve:Or,CurvePath:Hy,CustomBlending:Zd,CustomToneMapping:z0,CylinderGeometry:da,Cylindrical:l2,DFGApprox:_g,D_GGX:gT,Data3DTexture:hu,DataArrayTexture:tl,DataTexture:Ur,DataTextureLoader:ix,DataUtils:Rv,DecrementStencilOp:J0,DecrementWrapStencilOp:Z0,DefaultLoadingManager:Bm,DenoiseNode:Kb,DepthFormat:qn,DepthOfFieldNode:Gb,DepthStencilFormat:Yn,DepthTexture:Os,DetachedBindMode:k0,DirectionalLight:Th,DirectionalLightHelper:Bx,DirectionalLightNode:kS,Discard:OM,DiscreteInterpolant:ex,DisplayP3ColorSpace:au,DodecahedronGeometry:Fd,DotScreenNode:Wb,DoubleSide:Wr,DstAlphaFactor:I0,DstColorFactor:P0,DynamicCopyUsage:gw,DynamicDrawUsage:bs,DynamicReadUsage:pw,EPSILON:F_,EdgesGeometry:Cm,EllipseCurve:rh,EnvironmentNode:HT,EqualCompare:lv,EqualDepth:Lo,EqualStencilFunc:iv,EquirectUVNode:cT,EquirectangularReflectionMapping:kn,EquirectangularRefractionMapping:Hn,Euler:dr,EventDispatcher:vr,ExpressionNode:UM,ExtrudeGeometry:yc,FXAANode:Zb,F_Schlick:yo,FileLoader:Kr,FilmNode:Xb,Float16BufferAttribute:Iv,Float32BufferAttribute:De,FloatType:Oi,Fn:U,Fog:tm,FogExp2:Pd,FogExp2Node:mS,FogNode:wd,FogRangeNode:pS,FramebufferTexture:vm,FrontFacingNode:jM,FrontSide:an,Frustum:Ha,FunctionCallNode:x_,FunctionNode:Og,FunctionOverloadingNode:fb,GLBufferAttribute:o2,GLSL1:yw,GLSL3:lu,GLSLNodeParser:$S,GTAONode:Jb,GaussianBlurNode:Ob,GreaterCompare:cv,GreaterDepth:Do,GreaterEqualCompare:hv,GreaterEqualDepth:Po,GreaterEqualStencilFunc:av,GreaterStencilFunc:nv,GridHelper:Ox,Group:Fs,HalfFloatType:wi,HemisphereLight:_h,HemisphereLightHelper:m2,HemisphereLightNode:jS,IESSpotLightNode:GS,INFINITY:H2,IcosahedronGeometry:Vd,If:Le,ImageBitmapLoader:dx,ImageLoader:El,ImageUtils:xv,IncrementStencilOp:$0,IncrementWrapStencilOp:K0,IndexNode:Bt,InstanceNode:z1,InstancedBufferAttribute:Rn,InstancedBufferGeometry:jm,InstancedInterleavedBuffer:Km,InstancedMesh:lm,InstancedPointsNodeMaterial:HL,Int16BufferAttribute:iE,Int32BufferAttribute:rE,Int8BufferAttribute:Qw,IntType:va,InterleavedBuffer:Xa,InterleavedBufferAttribute:Fn,Interpolant:eo,InterpolateDiscrete:Sa,InterpolateLinear:Xo,InterpolateSmooth:nu,InvertStencilOp:Q0,IrradianceNode:tT,JoinNode:Jx,KeepStencilOp:$n,KeyframeTrack:Fr,LOD:nm,LatheGeometry:vc,Layers:nl,LessCompare:vp,LessDepth:Io,LessEqualCompare:yp,LessEqualDepth:zn,LessEqualStencilFunc:rv,LessStencilFunc:tv,Light:as,LightProbe:Wm,LightProbeNode:XS,LightingContextNode:Q1,LightingModel:cc,LightingNode:ia,LightsNode:J1,Line:In,Line2NodeMaterial:YL,Line3:Ix,LineBasicMaterial:Ni,LineBasicNodeMaterial:WL,LineCurve:Sm,LineCurve3:ky,LineDashedMaterial:vh,LineDashedNodeMaterial:XL,LineLoop:mm,LineSegments:Jr,LinearDisplayP3ColorSpace:Yo,LinearFilter:Lt,LinearInterpolant:Vm,LinearMipMapLinearFilter:np,LinearMipMapNearestFilter:ow,LinearMipmapLinearFilter:Xi,LinearMipmapNearestFilter:jn,LinearSRGBColorSpace:nr,LinearToneMapping:Ec,LinearTransfer:$o,Loader:Gi,LoaderUtils:Sh,LoadingManager:xh,Loop:gt,LoopNode:X1,LoopOnce:hp,LoopPingPong:G0,LoopRepeat:dp,LuminanceAlphaFormat:cp,LuminanceFormat:lp,Lut3DNode:qb,MOUSE:_0,MRTNode:mb,MatcapUVNode:XT,Material:hi,MaterialLoader:Mc,MaterialNode:Z,MaterialReferenceNode:t1,MathUtils:cu,Matrix2:h0,Matrix3:Ke,Matrix4:Re,MaxEquation:Qd,MaxMipLevelNode:zM,Mesh:Ft,MeshBasicMaterial:$r,MeshBasicNodeMaterial:rP,MeshDepthMaterial:zu,MeshDistanceMaterial:Kp,MeshLambertMaterial:gh,MeshLambertNodeMaterial:lP,MeshMatcapMaterial:Um,MeshMatcapNodeMaterial:XP,MeshNormalMaterial:fh,MeshNormalNodeMaterial:KL,MeshPhongMaterial:mh,MeshPhongNodeMaterial:uP,MeshPhysicalMaterial:ph,MeshPhysicalNodeMaterial:jT,MeshSSSNodeMaterial:zP,MeshStandardMaterial:wl,MeshStandardNodeMaterial:WT,MeshToonMaterial:Dm,MeshToonNodeMaterial:WP,MinEquation:E0,MirroredRepeatWrapping:fa,MixOperation:ep,ModelNode:tn,ModelViewProjectionNode:F1,MorphNode:Y1,MultiplyBlending:Kd,MultiplyOperation:ma,NearestFilter:$t,NearestMipMapLinearFilter:aw,NearestMipMapNearestFilter:H0,NearestMipmapLinearFilter:bn,NearestMipmapNearestFilter:Lc,NeutralToneMapping:Rc,NeverCompare:ov,NeverDepth:Co,NeverStencilFunc:ev,NoBlending:Er,NoColorSpace:Cr,NoToneMapping:mr,Node:qe,NodeAttribute:Lg,NodeBuilder:db,NodeCache:md,NodeCode:tb,NodeFrame:pb,NodeFunctionInput:Wg,NodeLoader:KT,NodeMaterial:Tt,NodeMaterialLoader:ZT,NodeMaterialObserver:qx,NodeObjectLoader:i3,NodeShaderStage:of,NodeType:M2,NodeUniform:QT,NodeUpdateType:je,NodeUtils:_2,NodeVar:Pg,NodeVarying:eb,NormalAnimationBlendMode:su,NormalBlending:Tn,NormalMapNode:o1,NotEqualCompare:uv,NotEqualDepth:Uo,NotEqualStencilFunc:sv,NumberKeyframeTrack:to,Object3D:_t,Object3DNode:St,ObjectLoader:cx,ObjectSpaceNormalMap:gp,OctahedronGeometry:Eo,OneFactor:N0,OneMinusConstantAlphaFactor:B0,OneMinusConstantColorFactor:F0,OneMinusDstAlphaFactor:L0,OneMinusDstColorFactor:D0,OneMinusSrcAlphaFactor:wc,OneMinusSrcColorFactor:R0,OrthographicCamera:Ps,OscNode:gi,OutputStructNode:jg,P3Primaries:Ko,PCFShadowMap:Yd,PCFSoftShadowMap:$d,PI:Qs,PI2:G2,PMREMGenerator:Uu,PMREMNode:BT,ParallaxBarrierPassNode:lS,ParameterNode:Dg,PassNode:bi,Path:Ml,PerspectiveCamera:di,PhongLightingModel:vg,PhysicalLightingModel:cd,PixelationPassNode:iS,Plane:cn,PlaneGeometry:ha,PlaneHelper:g2,PointLight:Mh,PointLightHelper:d2,PointLightNode:zS,PointUVNode:wb,Points:gm,PointsMaterial:Za,PointsNodeMaterial:YP,PolarGridHelper:f2,PolyhedronGeometry:vs,PositionalAudio:_x,PosterizeNode:Rb,PropertyBinding:bt,PropertyMixer:Mx,PropertyNode:Et,QuadraticBezierCurve:wm,QuadraticBezierCurve3:Em,Quaternion:Bi,QuaternionKeyframeTrack:io,QuaternionLinearInterpolant:tx,RED_GREEN_RGTC2_Format:iu,RED_RGTC1_Format:up,REVISION:"169",RGBADepthPacking:fp,RGBAFormat:Ei,RGBAIntegerFormat:Bc,RGBA_ASTC_10x10_Format:Kc,RGBA_ASTC_10x5_Format:Yc,RGBA_ASTC_10x6_Format:$c,RGBA_ASTC_10x8_Format:Jc,RGBA_ASTC_12x10_Format:Zc,RGBA_ASTC_12x12_Format:Qc,RGBA_ASTC_4x4_Format:Go,RGBA_ASTC_5x4_Format:Hc,RGBA_ASTC_5x5_Format:Gc,RGBA_ASTC_6x5_Format:Wc,RGBA_ASTC_6x6_Format:Wo,RGBA_ASTC_8x5_Format:jc,RGBA_ASTC_8x6_Format:Xc,RGBA_ASTC_8x8_Format:qc,RGBA_BPTC_Format:ba,RGBA_ETC2_EAC_Format:Ho,RGBA_PVRTC_2BPPV1_Format:kc,RGBA_PVRTC_4BPPV1_Format:Bo,RGBA_S3TC_DXT1_Format:_a,RGBA_S3TC_DXT3_Format:Ma,RGBA_S3TC_DXT5_Format:Ta,RGBDepthPacking:cw,RGBFormat:Fc,RGBIntegerFormat:lw,RGBShiftNode:jb,RGB_BPTC_SIGNED_Format:eu,RGB_BPTC_UNSIGNED_Format:jo,RGB_ETC1_Format:zo,RGB_ETC2_Format:ko,RGB_PVRTC_2BPPV1_Format:zc,RGB_PVRTC_4BPPV1_Format:Vo,RGB_S3TC_DXT1_Format:xa,RGDepthPacking:uw,RGFormat:ya,RGIntegerFormat:Vc,RTTNode:Tb,RangeNode:fS,RawShaderMaterial:Pm,Ray:Ns,Raycaster:Ex,Rec709Primaries:Jo,RectAreaLight:Gm,RectAreaLightNode:HS,RedFormat:Oo,RedIntegerFormat:Fo,ReferenceNode:Kl,ReflectorNode:Mb,ReinhardToneMapping:Ac,RemapNode:qf,RenderOutputNode:FM,RenderTarget:ui,RendererReferenceNode:MM,RepeatWrapping:Wn,ReplaceStencilOp:Y0,Return:Y2,ReverseSubtractEquation:w0,RingGeometry:xc,RotateNode:YT,SIGNED_RED_GREEN_RGTC2_Format:ru,SIGNED_RED_RGTC1_Format:tu,SRGBColorSpace:Fi,SRGBTransfer:Ot,SSAAPassNode:rS,Scene:ku,SceneNode:sn,Schlick_to_F0:yT,ScreenNode:ri,ScriptableNode:dS,ScriptableValueNode:uS,SetNode:Kx,ShaderChunk:dt,ShaderLib:Dr,ShaderMaterial:Pr,ShaderNode:Ll,ShadowMaterial:dh,ShadowNodeMaterial:QP,Shape:ns,ShapeGeometry:Bd,ShapePath:jx,ShapeUtils:nn,ShortType:ap,Skeleton:gc,SkeletonHelper:h2,SkinnedMesh:om,SkinningNode:cg,SobelOperatorNode:Hb,Source:Jn,Sphere:Ai,SphereGeometry:Ao,Spherical:Nx,SphericalHarmonics3:ox,SplineCurve:Am,SplitNode:Ph,SpotLight:Al,SpotLightHelper:u2,SpotLightNode:u0,Sprite:rm,SpriteMaterial:ul,SpriteNodeMaterial:JP,SpriteSheetUVNode:gb,SrcAlphaFactor:Sc,SrcAlphaSaturateFactor:U0,SrcColorFactor:C0,StackNode:rb,StaticCopyUsage:fw,StaticDrawUsage:wa,StaticReadUsage:dw,StereoCamera:Xm,StereoPassNode:nS,StorageArrayElementNode:vb,StorageBufferNode:Zg,StorageTextureNode:Ab,StreamCopyUsage:vw,StreamDrawUsage:hw,StreamReadUsage:mw,StringKeyframeTrack:Hs,SubtractEquation:S0,SubtractiveBlending:Jd,TBNViewMatrix:ta,TOUCH:M0,TangentSpaceNormalMap:on,TempNode:pt,TetrahedronGeometry:zd,Texture:Wt,Texture3DNode:$T,TextureLoader:rx,TextureNode:mn,TextureSizeNode:BM,TextureUtils:BR,TimerNode:Si,ToneMappingNode:bM,ToonOutlinePassNode:cS,TorusGeometry:_c,TorusKnotGeometry:kd,TransitionNode:tS,Triangle:er,TriangleFanDrawMode:X0,TriangleStripDrawMode:j0,TrianglesDrawMode:W0,TriplanarTexturesNode:yb,TubeGeometry:Hd,UVMapping:Ic,Uint16BufferAttribute:Mu,Uint32BufferAttribute:Vp,Uint8BufferAttribute:eE,Uint8ClampedBufferAttribute:tE,Uniform:Sx,UniformArrayNode:Qf,UniformGroupNode:_f,UniformNode:$s,UniformsGroup:a2,UniformsLib:Me,UniformsUtils:kp,UnsignedByteType:jr,UnsignedInt101111Type:Oc,UnsignedInt248Type:Xn,UnsignedInt5999Type:Uc,UnsignedIntType:Nr,UnsignedShort4444Type:Pc,UnsignedShort5551Type:Dc,UnsignedShortType:ga,UserDataNode:Cb,VSMShadowMap:rr,V_GGX_SmithCorrelated:fT,VarNode:mM,VaryingNode:fM,Vector2:J,Vector3:N,Vector4:st,VectorKeyframeTrack:ro,VertexColorNode:Sb,VideoTexture:Dy,ViewportDepthNode:Qi,ViewportDepthTextureNode:sT,ViewportSharedTextureNode:Ib,ViewportTextureNode:ac,VolumeNodeMaterial:t3,WebGL3DRenderTarget:Gw,WebGLArrayRenderTarget:Hw,WebGLCoordinateSystem:Rr,WebGLCubeRenderTarget:Lu,WebGLMultipleRenderTargets:y2,WebGLRenderTarget:Ir,WebGLRenderer:py,WebGLUtils:dy,WebGPUCoordinateSystem:Ss,WireframeGeometry:Lm,WrapAroundEnding:qo,ZeroCurvatureEnding:Ms,ZeroFactor:A0,ZeroSlopeEnding:Ts,ZeroStencilOp:q0,abs:It,acesFilmicToneMapping:ES,acos:Gh,add:zt,addMethodChaining:te,addNodeElement:$2,afterImage:hD,agxToneMapping:AS,all:Lf,alphaT:Bh,anaglyphPass:qD,anamorphic:vD,and:E_,anisotropy:us,anisotropyB:Ks,anisotropyT:Vl,any:V_,ao:AD,append:s_,arrayBuffer:V2,asin:W_,assign:y_,atan:j_,atan2:eM,atomicAdd:jU,atomicAnd:$U,atomicFunc:On,atomicMax:qU,atomicMin:YU,atomicOr:JU,atomicStore:WU,atomicSub:XU,atomicXor:KU,attenuationColor:Nf,attenuationDistance:Af,attribute:_i,backgroundBlurriness:Q3,backgroundIntensity:eD,batch:G1,billboarding:gU,bitAnd:R_,bitNot:I_,bitOr:L_,bitXor:P_,bitangentGeometry:fL,bitangentLocal:gL,bitangentView:r1,bitangentWorld:vL,bitcast:W2,bleach:wU,bloom:OD,blur:FT,bool:cs,buffer:Jl,bufferAttribute:ql,bumpMap:c1,burn:_U,bvec2:l_,bvec3:xf,bvec4:d_,bypass:LM,cache:Yl,call:__,cameraFar:ho,cameraLogDepth:HM,cameraNear:uo,cameraNormalMatrix:Q2,cameraPosition:$f,cameraProjectionMatrix:lr,cameraProjectionMatrixInverse:K2,cameraViewMatrix:cr,cameraWorldMatrix:Z2,cbrt:oM,ceil:Uf,checker:ZU,cineonToneMapping:wS,clamp:li,clearcoat:Oh,clearcoatRoughness:Fl,code:fd,color:a_,colorSpaceToWorking:jf,colorToDirection:$L,compute:CM,cond:dM,context:Hf,convert:m_,convertToTexture:Zi,cos:Tr,createCanvasElement:fv,cross:co,cubeTexture:Kh,dFdx:Y_,dFdy:$_,dashSize:Zs,defaultBuildStages:cf,defaultShaderStages:lf,defined:Il,degrees:k_,denoise:RD,densityFog:eU,depth:fg,depthPass:cD,difference:rM,diffuseColor:Nt,directionToColor:lT,dispersion:Cf,distance:iM,div:Qr,dodge:MU,dof:xD,dot:qt,dotScreen:_D,drawIndex:B1,dynamicBufferAttribute:AM,element:p_,emissive:Tf,equal:M_,equals:B_,equirectUV:gg,exp:Pf,exp2:Hh,expression:ps,faceDirection:$l,faceForward:cM,film:TD,float:E,floor:hs,fog:ZD,fract:ds,frameGroup:z2,frameId:V3,frontFacing:XM,fwidth:Z_,fxaa:ID,gain:uU,gapSize:zl,gaussianBlur:uD,getColorSpaceMethod:jh,getConstNodeType:n_,getCurrentStack:yf,getDirection:UT,getDistanceAttenuation:t0,getGeometryRoughness:mT,getRoughness:yg,getShIrradianceAt:BS,getTextureIndex:Xg,global:Sd,glsl:o3,glslFn:l3,grayscale:dD,greaterThan:If,greaterThanEqual:w_,hash:cU,highPrecisionModelNormalViewMatrix:uL,highPrecisionModelViewMatrix:cL,hue:fD,instance:k1,instanceIndex:ic,instancedBufferAttribute:Xh,instancedDynamicBufferAttribute:Xf,int:P,inverseSqrt:H_,invocationLocalIndex:wL,invocationSubgroupIndex:SL,ior:kl,iridescence:Vh,iridescenceIOR:bf,iridescenceThickness:Sf,ivec2:dn,ivec3:c_,ivec4:u_,js:s3,label:pM,length:ea,lengthSq:Vf,lessThan:b_,lessThanEqual:S_,lightPosition:r0,lightTargetDirection:n0,lightTargetPosition:gS,lightViewPosition:Nd,lightingContext:eT,lights:K1,linearDepth:sd,linearSRGBTosRGB:TS,linearToneMapping:bS,localId:DU,log:Df,log2:Hl,loop:NL,luminance:Ui,lut3D:bD,mat2:Ul,mat3:yi,mat4:Ys,matcapUV:qT,materialAOMap:O1,materialAlphaTest:h1,materialAnisotropy:w1,materialAnisotropyVector:fo,materialAttenuationColor:P1,materialAttenuationDistance:L1,materialClearcoat:x1,materialClearcoatNormal:M1,materialClearcoatRoughness:_1,materialColor:mo,materialDispersion:U1,materialEmissive:p1,materialIOR:I1,materialIridescence:E1,materialIridescenceIOR:A1,materialIridescenceThickness:N1,materialLightMap:og,materialLineDashOffset:ag,materialLineDashSize:ng,materialLineGapSize:sg,materialLineScale:id,materialLineWidth:rd,materialMetalness:v1,materialNormal:y1,materialOpacity:ed,materialPointWidth:D1,materialReference:rn,materialReflectivity:td,materialRefractionRatio:$M,materialRotation:T1,materialRoughness:g1,materialSheen:b1,materialSheenRoughness:S1,materialShininess:d1,materialSpecular:m1,materialSpecularColor:f1,materialSpecularIntensity:rg,materialSpecularStrength:tc,materialThickness:R1,materialTransmission:C1,max:ft,maxMipLevel:kM,metalness:Ol,min:xi,mix:rt,mixElement:uM,mod:Wh,modInt:Rf,modelDirection:sL,modelNormalMatrix:GM,modelPosition:aL,modelScale:oL,modelViewMatrix:fn,modelViewPosition:lL,modelViewProjection:lg,modelWorldMatrix:zr,modelWorldMatrixInverse:WM,morphReference:$1,motionBlur:SU,mrt:xd,mul:lt,mx_aastep:OS,mx_cell_noise_float:aF,mx_contrast:QO,mx_fractal_noise_float:oF,mx_fractal_noise_vec2:lF,mx_fractal_noise_vec3:cF,mx_fractal_noise_vec4:uF,mx_hsvtorgb:WO,mx_noise_float:eF,mx_noise_vec3:tF,mx_noise_vec4:iF,mx_ramplr:qO,mx_ramptb:YO,mx_rgbtohsv:jO,mx_safepower:ZO,mx_splitlr:$O,mx_splittb:JO,mx_srgb_texture_to_lin_rec709:XO,mx_transform_uv:KO,mx_worley_noise_float:rF,mx_worley_noise_vec2:nF,mx_worley_noise_vec3:sF,negate:X_,neutralToneMapping:NS,nodeArray:qs,nodeImmutable:ge,nodeObject:G,nodeObjects:Pl,nodeProxy:K,normalFlat:qM,normalGeometry:$h,normalLocal:ur,normalMap:ig,normalView:hr,normalWorld:Jh,normalize:Mr,not:N_,notEqual:T_,numWorkgroups:LU,objectDirection:eL,objectGroup:g_,objectPosition:iL,objectScale:rL,objectViewPosition:nL,objectWorldMatrix:tL,oneMinus:q_,or:A_,orthographicDepthToViewZ:FL,oscSawtooth:H3,oscSine:B3,oscSquare:z3,oscTriangle:k3,output:wf,outputStruct:D3,overlay:bU,overloadingFn:Di,parabola:s0,parallaxBarrierPass:YD,parallaxDirection:s1,parallaxUV:xL,parameter:n3,pass:lD,passTexture:bo,pcurve:hU,perspectiveDepthToViewZ:mg,pixelationPass:zD,pmremTexture:zT,pointUV:Z3,pointWidth:k2,positionGeometry:Li,positionLocal:Zt,positionPrevious:qh,positionView:Pi,positionViewDirection:Vt,positionWorld:Yh,positionWorldDirection:Jf,posterize:sD,pow:Ji,pow2:Ff,pow3:nM,pow4:sM,property:ar,radians:z_,rand:zf,range:tU,rangeFog:QD,reciprocal:K_,reference:fi,referenceBuffer:eg,reflect:tM,reflectVector:ZM,reflectView:JM,reflector:q3,refract:Bf,refractVector:QM,refractView:KM,reinhardToneMapping:SS,remainder:O_,remap:PM,remapClamp:DM,renderGroup:xt,renderOutput:VM,rendererReference:TM,rgbShift:MD,rotate:Ig,rotateUV:mU,roughness:pn,round:J_,rtt:bb,sRGBToLinearSRGB:MS,sampler:J2,saturate:lM,saturation:pD,screen:TU,screenCoordinate:vo,screenSize:go,screenUV:fs,scriptable:KD,scriptableValue:bd,select:Ri,sepia:EU,setCurrentStack:Dl,shaderStages:uf,sharedUniformGroup:Mf,sheen:Js,sheenRoughness:Fh,shiftLeft:D_,shiftRight:U_,shininess:zh,sign:Gl,sin:Ci,sinc:dU,skinning:EL,skinningReference:j1,smoothstep:Ki,smoothstepElement:hM,sobel:yD,specularColor:or,specularF90:Bl,spherizeUV:fU,split:B2,spritesheetUV:G3,sqrt:en,ssaaPass:GD,stack:gd,step:Wl,stereoPass:jD,storage:tD,storageBarrier:VU,storageObject:iD,storageTexture:Nb,string:F2,sub:Pt,subgroupIndex:bL,subgroupSize:UU,tan:G_,tangentGeometry:Qh,tangentLocal:Zl,tangentView:Ql,tangentWorld:i1,temp:Gf,texture:yt,texture3D:JT,textureBarrier:BU,textureBicubic:AT,textureCubeUV:OT,textureLoad:Br,textureSize:ms,textureStore:rD,thickness:Ef,threshold:Bb,timerDelta:F3,timerGlobal:O3,timerLocal:qg,toOutputColorSpace:vM,toWorkingColorSpace:yM,toneMapping:SM,toneMappingExposure:wM,toonOutlinePass:$D,transformDirection:aM,transformNormal:YM,transformNormalToView:Zf,transformedBentNormalView:a1,transformedBitangentView:n1,transformedBitangentWorld:yL,transformedClearcoatNormalView:po,transformedNormalView:Yt,transformedNormalWorld:Kf,transformedTangentView:tg,transformedTangentWorld:mL,transition:FD,transmission:kh,transpose:Q_,tri:yn,tri3:vS,triNoise3D:pU,triplanarTexture:j3,triplanarTextures:xb,trunc:Of,tslFn:O2,uint:_e,uniform:fe,uniformArray:gn,uniformGroup:f_,uniforms:dL,userData:nD,uv:nt,uvec2:o_,uvec3:lo,uvec4:h_,varying:Ii,varyingProperty:Zr,vec2:z,vec3:D,vec4:ae,vectorComponents:so,velocity:xU,vertexColor:K3,vertexIndex:V1,vibrance:mD,viewZToOrthographicDepth:oc,viewZToPerspectiveDepth:aT,viewport:Dn,viewportBottomLeft:UL,viewportCoordinate:rT,viewportDepthTexture:pg,viewportLinearDepth:VL,viewportMipTexture:nT,viewportResolution:PL,viewportSafeUV:vU,viewportSharedTexture:aD,viewportSize:iT,viewportTexture:OL,viewportTopLeft:DL,viewportUV:LL,wgsl:a3,wgslFn:c3,workgroupArray:HU,workgroupBarrier:FU,workgroupId:PU,workingToColorSpace:xM,xor:C_},Symbol.toStringTag,{value:"Module"}));function xF(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("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 _F(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}export{Nc as ACESFilmicToneMapping,No as AdditiveBlending,Cc as AgXToneMapping,Ro as AlwaysDepth,ou as AlwaysStencilFunc,bh as AmbientLight,no as AnimationClip,bx as AnimationMixer,Qp as ArrayCamera,Ym as Audio,Eh as AudioContext,yx as AudioListener,px as AudioLoader,Wx as AxesHelper,si as BackSide,mp as BasicDepthPacking,JS as BasicNodeLibrary,dm as BatchedMesh,qu as Bone,ss as BooleanKeyframeTrack,zi as Box3,Hx as Box3Helper,_n as BoxGeometry,kx as BoxHelper,wt as BufferAttribute,ct as BufferGeometry,un as Cache,ll as Camera,zx as CameraHelper,Fy as CanvasTexture,Tm as CatmullRomCurve3,gr as ClampToEdgeWrapping,qm as Clock,xe as Color,yh as ColorKeyframeTrack,vt as ColorManagement,Uy as CompressedArrayTexture,Oy as CompressedCubeTexture,yl as CompressedTexture,Xx as Controls,Iu as CubeCamera,Rs as CubeTexture,Gn as CubeUVReflectionMapping,Or as Curve,Zd as CustomBlending,da as CylinderGeometry,hu as Data3DTexture,Ur as DataTexture,ix as DataTextureLoader,Rv as DataUtils,J0 as DecrementStencilOp,Z0 as DecrementWrapStencilOp,Bm as DefaultLoadingManager,qn as DepthFormat,Yn as DepthStencilFormat,Os as DepthTexture,Th as DirectionalLight,Bx as DirectionalLightHelper,Wr as DoubleSide,bs as DynamicDrawUsage,Cm as EdgesGeometry,Lo as EqualDepth,iv as EqualStencilFunc,kn as EquirectangularReflectionMapping,Hn as EquirectangularRefractionMapping,dr as Euler,vr as EventDispatcher,yc as ExtrudeGeometry,Kr as FileLoader,De as Float32BufferAttribute,Oi as FloatType,tm as Fog,an as FrontSide,Ha as Frustum,lu as GLSL3,$S as GLSLNodeParser,Do as GreaterDepth,Po as GreaterEqualDepth,av as GreaterEqualStencilFunc,nv as GreaterStencilFunc,Ox as GridHelper,Fs as Group,wi as HalfFloatType,_h as HemisphereLight,dx as ImageBitmapLoader,$0 as IncrementStencilOp,K0 as IncrementWrapStencilOp,Rn as InstancedBufferAttribute,jm as InstancedBufferGeometry,Km as InstancedInterleavedBuffer,lm as InstancedMesh,Xa as InterleavedBuffer,Fn as InterleavedBufferAttribute,eo as Interpolant,Sa as InterpolateDiscrete,Xo as InterpolateLinear,Q0 as InvertStencilOp,$n as KeepStencilOp,Fr as KeyframeTrack,nm as LOD,nl as Layers,Io as LessDepth,zn as LessEqualDepth,rv as LessEqualStencilFunc,tv as LessStencilFunc,In as Line,Ix as Line3,Ni as LineBasicMaterial,mm as LineLoop,Jr as LineSegments,Lt as LinearFilter,np as LinearMipMapLinearFilter,Xi as LinearMipmapLinearFilter,jn as LinearMipmapNearestFilter,nr as LinearSRGBColorSpace,Ec as LinearToneMapping,Gi as Loader,Sh as LoaderUtils,xh as LoadingManager,hp as LoopOnce,dp as LoopRepeat,_0 as MOUSE,hi as Material,cu as MathUtils,Ke as Matrix3,Re as Matrix4,Qd as MaxEquation,Ft as Mesh,$r as MeshBasicMaterial,zu as MeshDepthMaterial,gh as MeshLambertMaterial,fh as MeshNormalMaterial,mh as MeshPhongMaterial,ph as MeshPhysicalMaterial,wl as MeshStandardMaterial,fa as MirroredRepeatWrapping,$t as NearestFilter,H0 as NearestMipMapNearestFilter,bn as NearestMipmapLinearFilter,Lc as NearestMipmapNearestFilter,Rc as NeutralToneMapping,Co as NeverDepth,ev as NeverStencilFunc,Er as NoBlending,Cr as NoColorSpace,mr as NoToneMapping,qe as Node,db as NodeBuilder,pb as NodeFrame,Tn as NormalBlending,Uo as NotEqualDepth,sv as NotEqualStencilFunc,to as NumberKeyframeTrack,_t as Object3D,Eo as OctahedronGeometry,Ps as OrthographicCamera,$d as PCFSoftShadowMap$1,Uu as PMREMGenerator$1,di as PerspectiveCamera,cn as Plane,ha as PlaneGeometry,Mh as PointLight,gm as Points,Za as PointsMaterial,_x as PositionalAudio,bt as PropertyBinding,Bi as Quaternion,io as QuaternionKeyframeTrack,rw as REVISION,fp as RGBADepthPacking,Ei as RGBAFormat,Go as RGBA_ASTC_4x4_Format,Wo as RGBA_ASTC_6x6_Format,ba as RGBA_BPTC_Format,Ho as RGBA_ETC2_EAC_Format,Bo as RGBA_PVRTC_4BPPV1_Format,_a as RGBA_S3TC_DXT1_Format,Ma as RGBA_S3TC_DXT3_Format,Ta as RGBA_S3TC_DXT5_Format,Fc as RGBFormat,jo as RGB_BPTC_UNSIGNED_Format,zo as RGB_ETC1_Format,ko as RGB_ETC2_Format,Vo as RGB_PVRTC_4BPPV1_Format,xa as RGB_S3TC_DXT1_Format,ya as RGFormat,Pm as RawShaderMaterial,Ns as Ray,Ex as Raycaster,Oo as RedFormat,Ac as ReinhardToneMapping,Wn as RepeatWrapping,Y0 as ReplaceStencilOp,xc as RingGeometry,Fi as SRGBColorSpace,ku as Scene,dt as ShaderChunk,Dr as ShaderLib,Pr as ShaderMaterial,dh as ShadowMaterial,ns as Shape,jx as ShapePath,nn as ShapeUtils,gc as Skeleton,om as SkinnedMesh,Jn as Source,Ai as Sphere,Ao as SphereGeometry,Nx as Spherical,Al as SpotLight,rm as Sprite,ul as SpriteMaterial,yF as THREE,M0 as TOUCH,Wt as Texture,rx as TextureLoader,_c as TorusGeometry,er as Triangle,X0 as TriangleFanDrawMode,j0 as TriangleStripDrawMode,W0 as TrianglesDrawMode,Mu as Uint16BufferAttribute,Sx as Uniform$1,Me as UniformsLib,kp as UniformsUtils,jr as UnsignedByteType,Oc as UnsignedInt101111Type,Xn as UnsignedInt248Type,Uc as UnsignedInt5999Type,Nr as UnsignedIntType,J as Vector2,N as Vector3,st as Vector4,ro as VectorKeyframeTrack,Dy as VideoTexture,Lu as WebGLCubeRenderTarget,Ir as WebGLRenderTarget,py as WebGLRenderer,Lm as WireframeGeometry,q0 as ZeroStencilOp,xF as cloneUniforms,_F as cloneUniformsGroups,lf as defaultShaderStages,hr as normalView};
|
|
3869
|
+
return { ...output, `+t+" };",s=i+this.codeNode.code+r;return this._method=new Function(...e,s),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[$x(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const i in this.parameters)t.push(this.parameters[i].getCacheKey(e));return Jx(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const KD=K(pS);class Ed extends qe{static get type(){return"FogNode"}constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const i=e.context.getViewZ;return i!==void 0&&(t=i(this)),(t||Pi.z).negate()}setup(){return this.factorNode}}const ZD=K(Ed);class mS extends Ed{static get type(){return"FogRangeNode"}constructor(e,t,i){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=i}setup(e){const t=this.getViewZNode(e);return Ki(this.nearNode,this.farNode,t)}}const QD=K(mS);class fS extends Ed{static get type(){return"FogExp2Node"}constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),i=this.densityNode;return i.mul(i,t,t).negate().exp().oneMinus()}}const eU=K(fS);let ua=null,ha=null;class gS extends qe{static get type(){return"RangeNode"}constructor(e=E(),t=E()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Pn(this.minNode.value)),i=e.getTypeLength(Pn(this.maxNode.value));return t>i?t:i}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let i=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Pn(r)),o=e.getTypeLength(Pn(s));ua=ua||new st,ha=ha||new st,ua.setScalar(0),ha.setScalar(0),a===1?ua.setScalar(r):r.isColor?ua.set(r.r,r.g,r.b):ua.set(r.x,r.y,r.z||0,r.w||0),o===1?ha.setScalar(s):s.isColor?ha.set(s.r,s.g,s.b):ha.set(s.x,s.y,s.z||0,s.w||0);const l=4,c=l*t.count,u=new Float32Array(c);for(let d=0;d<c;d++){const p=d%l,m=ua.getComponent(p),v=ha.getComponent(p);u[d]=uu.lerp(m,v,Math.random())}const h=this.getNodeType(e);if(t.count<=4096)i=Kl(u,"vec4",t.count).element(rc).convert(h);else{const d=new Rn(u,4);e.geometry.setAttribute("__range"+this.id,d),i=qh(d).convert(h)}}else i=E(0);return i}}const tU=K(gS),iU=U(({depthTexture:n,shadowCoord:e})=>yt(n,e.xy).compare(e.z)),rU=U(({depthTexture:n,shadowCoord:e,shadow:t})=>{const i=(v,f)=>yt(n,v).compare(f),r=fi("mapSize","vec2",t).setGroup(xt),s=fi("radius","float",t).setGroup(xt),a=z(1).div(r),o=a.x.negate().mul(s),l=a.y.negate().mul(s),c=a.x.mul(s),u=a.y.mul(s),h=o.div(2),d=l.div(2),p=c.div(2),m=u.div(2);return zt(i(e.xy.add(z(o,l)),e.z),i(e.xy.add(z(0,l)),e.z),i(e.xy.add(z(c,l)),e.z),i(e.xy.add(z(h,d)),e.z),i(e.xy.add(z(0,d)),e.z),i(e.xy.add(z(p,d)),e.z),i(e.xy.add(z(o,0)),e.z),i(e.xy.add(z(h,0)),e.z),i(e.xy,e.z),i(e.xy.add(z(p,0)),e.z),i(e.xy.add(z(c,0)),e.z),i(e.xy.add(z(h,m)),e.z),i(e.xy.add(z(0,m)),e.z),i(e.xy.add(z(p,m)),e.z),i(e.xy.add(z(o,u)),e.z),i(e.xy.add(z(0,u)),e.z),i(e.xy.add(z(c,u)),e.z)).mul(1/17)}),nU=U(({depthTexture:n,shadowCoord:e,shadow:t})=>{const i=(u,h)=>yt(n,u).compare(h),r=fi("mapSize","vec2",t).setGroup(xt),s=z(1).div(r),a=s.x,o=s.y,l=e.xy,c=ps(l.mul(r).add(.5));return l.subAssign(c.mul(s)),zt(i(l,e.z),i(l.add(z(a,0)),e.z),i(l.add(z(0,o)),e.z),i(l.add(s),e.z),rt(i(l.add(z(a.negate(),0)),e.z),i(l.add(z(a.mul(2),0)),e.z),c.x),rt(i(l.add(z(a.negate(),o)),e.z),i(l.add(z(a.mul(2),o)),e.z),c.x),rt(i(l.add(z(0,o.negate())),e.z),i(l.add(z(0,o.mul(2))),e.z),c.y),rt(i(l.add(z(a,o.negate())),e.z),i(l.add(z(a,o.mul(2))),e.z),c.y),rt(rt(i(l.add(z(a.negate(),o.negate())),e.z),i(l.add(z(a.mul(2),o.negate())),e.z),c.x),rt(i(l.add(z(a.negate(),o.mul(2))),e.z),i(l.add(z(a.mul(2),o.mul(2))),e.z),c.x),c.y)).mul(1/9)}),sU=U(({depthTexture:n,shadowCoord:e})=>{const t=E(1).toVar(),i=yt(n).uv(e.xy).rg,r=jl(e.z,i.x);return Le(r.notEqual(E(1)),()=>{const s=e.z.sub(i.x),a=ft(0,i.y.mul(i.y));let o=a.div(a.add(s.mul(s)));o=li(Pt(o,.3).div(.95-.3)),t.assign(li(ft(r,o)))}),t}),aU=U(({samples:n,radius:e,size:t,shadowPass:i})=>{const r=E(0).toVar(),s=E(0).toVar(),a=n.lessThanEqual(E(1)).select(E(0),E(2).div(n.sub(1))),o=n.lessThanEqual(E(1)).select(E(0),E(-1));gt({start:P(0),end:P(n),type:"int",condition:"<"},({i:c})=>{const u=o.add(E(c).mul(a)),h=i.uv(zt(yo.xy,z(0,u).mul(e)).div(t)).x;r.addAssign(h),s.addAssign(h.mul(h))}),r.divAssign(n),s.divAssign(n);const l=en(s.sub(r.mul(r)));return z(r,l)}),oU=U(({samples:n,radius:e,size:t,shadowPass:i})=>{const r=E(0).toVar(),s=E(0).toVar(),a=n.lessThanEqual(E(1)).select(E(0),E(2).div(n.sub(1))),o=n.lessThanEqual(E(1)).select(E(0),E(-1));gt({start:P(0),end:P(n),type:"int",condition:"<"},({i:c})=>{const u=o.add(E(c).mul(a)),h=i.uv(zt(yo.xy,z(u,0).mul(e)).div(t));r.addAssign(h.x),s.addAssign(zt(h.y.mul(h.y),h.x.mul(h.x)))}),r.divAssign(n),s.divAssign(n);const l=en(s.sub(r.mul(r)));return z(r,l)}),lU=[iU,rU,nU,sU];let wo=null;const Ad=new vn;class vs extends ra{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.updateType=je.FRAME,this.light=e,this.color=new xe,this.colorNode=fe(this.color).setGroup(xt),this.baseColorNode=null,this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this.isAnalyticLightNode=!0}getCacheKey(){return rf(super.getCacheKey(),this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadow(e){const{object:t,renderer:i}=e;if(i.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){wo===null&&(wo=new Tt,wo.fragmentNode=ae(0,0,0,1),wo.isShadowNodeMaterial=!0,wo.name="ShadowMaterial");const s=i.shadowMap.type,a=this.light.shadow,o=new Fs;o.compareFunction=yp;const l=e.createRenderTarget(a.mapSize.width,a.mapSize.height);if(l.depthTexture=o,a.camera.updateProjectionMatrix(),s===rr){o.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:xa,type:wi}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:xa,type:wi});const y=yt(o),_=yt(this.vsmShadowMapVertical.texture),I=fi("blurSamples","float",a).setGroup(xt),T=fi("radius","float",a).setGroup(xt),w=fi("mapSize","vec2",a).setGroup(xt);let C=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Tt);C.fragmentNode=aU({samples:I,radius:T,size:w,shadowPass:y}).context(e.getSharedContext()),C.name="VSMVertical",C=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Tt),C.fragmentNode=oU({samples:I,radius:T,size:w,shadowPass:_}).context(e.getSharedContext()),C.name="VSMHorizontal"}const c=fi("intensity","float",a).setGroup(xt),u=fi("bias","float",a).setGroup(xt),h=fi("normalBias","float",a).setGroup(xt),d=t.material.shadowPositionNode||$h;let p=fe(a.matrix).setGroup(xt).mul(d.add(Kh.mul(h)));p=p.xyz.div(p.w);let m=p.z.add(u);i.coordinateSystem===ws&&(m=m.mul(2).sub(1)),p=D(p.x,p.y.oneMinus(),m);const v=p.x.greaterThanEqual(0).and(p.x.lessThanEqual(1)).and(p.y.greaterThanEqual(0)).and(p.y.lessThanEqual(1)).and(p.z.lessThanEqual(1)),f=a.filterNode||lU[i.shadowMap.type]||null;if(f===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=yt(l.texture,p),x=v.select(f({depthTexture:s===rr?this.vsmShadowMapHorizontal.texture:o,shadowCoord:p,shadow:a}),E(1));this.shadowMap=l,this.light.shadow.map=l,this.shadowNode=x,this.shadowColorNode=r=this.colorNode.mul(rt(1,x.rgb.mix(g,1),c.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=r,this.updateBeforeType=je.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&this.disposeShadow()}updateShadow(e){const{shadowMap:t,light:i}=this,{renderer:r,scene:s,camera:a}=e,o=r.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;const c=s.overrideMaterial;s.overrideMaterial=wo,t.setSize(i.shadow.mapSize.width,i.shadow.mapSize.height),i.shadow.updateMatrices(i),i.shadow.camera.layers.mask=a.layers.mask;const u=r.getRenderTarget(),h=r.getRenderObjectFunction();r.setRenderObjectFunction((d,...p)=>{(d.castShadow===!0||d.receiveShadow&&o===rr)&&r.renderObject(d,...p)}),r.setRenderTarget(t),r.render(s,i.shadow.camera),r.setRenderObjectFunction(h),i.isPointLight!==!0&&o===rr&&this.vsmPass(e,i),r.setRenderTarget(u),s.overrideMaterial=c}vsmPass(e,t){const{renderer:i}=e;this.vsmShadowMapVertical.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),i.setRenderTarget(this.vsmShadowMapVertical),Ad.material=this.vsmMaterialVertical,Ad.render(i),i.setRenderTarget(this.vsmShadowMapHorizontal),Ad.material=this.vsmMaterialHorizontal,Ad.render(i)}disposeShadow(){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),this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=je.NONE}updateBefore(e){const t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const i0=U(n=>{const{lightDistance:e,cutoffDistance:t,decayExponent:i}=n,r=e.pow(i).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)});let Nd;function r0(n){Nd=Nd||new WeakMap;let e=Nd.get(n);return e===void 0&&Nd.set(n,e={}),e}function n0(n){const e=r0(n);return e.position||(e.position=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.matrixWorld)))}function vS(n){const e=r0(n);return e.targetPosition||(e.targetPosition=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.target.matrixWorld)))}function Cd(n){const e=r0(n);return e.viewPosition||(e.viewPosition=fe(new N).setGroup(xt).onRenderUpdate(({camera:t},i)=>{i.value=i.value||new N,i.value.setFromMatrixPosition(n.matrixWorld),i.value.applyMatrix4(t.matrixWorldInverse)}))}const s0=n=>cr.transformDirection(n0(n).sub(vS(n))),cU=U(([n])=>{const e=n.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),a0=(n,e)=>Ji(lt(4,n.mul(Pt(1,n))),e),uU=(n,e)=>n.lessThan(.5)?a0(n.mul(2),e).div(2):Pt(1,a0(lt(Pt(1,n),2),e).div(2)),hU=(n,e,t)=>Ji(Qr(Ji(n,e),zt(Ji(n,e),Ji(Pt(1,n),t))),1/e),dU=(n,e)=>Ci(ea.mul(e.mul(n).sub(1))).div(ea.mul(e.mul(n).sub(1))),yn=U(([n])=>n.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),yS=U(([n])=>D(yn(n.z.add(yn(n.y.mul(1)))),yn(n.z.add(yn(n.x.mul(1)))),yn(n.y.add(yn(n.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),pU=U(([n,e,t])=>{const i=D(n).toVar(),r=E(1.4).toVar(),s=E(0).toVar(),a=D(i).toVar();return gt({start:E(0),end:E(3),type:"float",condition:"<="},()=>{const o=D(yS(a.mul(2))).toVar();i.addAssign(o.add(t.mul(E(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),i.mulAssign(1.2);const l=E(yn(i.z.add(yn(i.x.add(yn(i.y)))))).toVar();s.addAssign(l.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),mU=U(([n,e,t=z(.5)])=>Lg(n.sub(t),e).add(t)),fU=U(([n,e,t=z(.5)])=>{const i=n.sub(t),r=i.dot(i),s=r.mul(r).mul(e);return n.add(i.mul(s))}),gU=U(({position:n=null,horizontal:e=!0,vertical:t=!1})=>{let i;n!==null?(i=zr.toVar(),i[3][0]=n.x,i[3][1]=n.y,i[3][2]=n.z):i=zr;const r=cr.mul(i);return Ll(e)&&(r[0][0]=zr[0].length(),r[0][1]=0,r[0][2]=0),Ll(t)&&(r[1][0]=0,r[1][1]=zr[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,lr.mul(r).mul(Zt)}),vU=U(([n=null])=>{const e=ad();return ad(mg(n)).sub(e).lessThan(0).select(gs,n)}),xS=new WeakMap;class yU extends pt{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.updateType=je.OBJECT,this.updateAfterType=je.OBJECT,this.previousModelWorldMatrix=fe(new Re),this.previousProjectionMatrix=fe(new Re).setGroup(xt),this.previousCameraViewMatrix=fe(new Re)}update({frameId:e,camera:t,object:i}){const r=MS(i);this.previousModelWorldMatrix.value.copy(r);const s=_S(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new Re,s.previousCameraViewMatrix=new Re,s.currentProjectionMatrix=new Re,s.currentCameraViewMatrix=new Re,s.previousProjectionMatrix.copy(t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){MS(e).copy(e.matrixWorld)}setup(){const e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=lr.mul(fn).mul(Zt),i=this.previousProjectionMatrix.mul(e).mul(Yh),r=t.xy.div(t.w),s=i.xy.div(i.w);return Pt(r,s)}}function _S(n){let e=xS.get(n);return e===void 0&&(e={},xS.set(n,e)),e}function MS(n,e=0){const t=_S(n);let i=t[e];return i===void 0&&(t[e]=i=new Re),i}const xU=ge(yU),_U=U(([n,e])=>xi(1,n.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),MU=U(([n,e])=>xi(n.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),TU=U(([n,e])=>n.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),bU=U(([n,e])=>rt(n.mul(2).mul(e),n.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),jl(.5,n))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),SU=U(([n,e,t=P(16)])=>{const i=o=>n.uv(o),r=nt(),s=i(r).toVar(),a=E(t);return gt({start:P(1),end:t,type:"int",condition:"<="},({i:o})=>{const l=e.mul(E(o).div(a.sub(1)).sub(.5));s.addAssign(i(r.add(l)))}),s.divAssign(a),s}),wU=U(([n,e=1])=>{const t=n,i=Ui(t.rgb),r=D(i),s=xi(1,ft(0,E(10).mul(i.sub(.45)))),a=r.mul(t.rgb).mul(2),o=E(2).mul(r.oneMinus()).mul(t.rgb.oneMinus()).oneMinus(),l=rt(a,o,s),c=t.a.mul(e),u=c.mul(l.rgb);return u.addAssign(t.rgb.mul(c.oneMinus())),ae(u,t.a)}),EU=U(([n])=>{const e=D(n);return ae(qt(e,D(.393,.769,.189)),qt(e,D(.349,.686,.168)),qt(e,D(.272,.534,.131)),n.a)}),TS=U(([n])=>{const e=n.mul(.9478672986).add(.0521327014).pow(2.4),t=n.mul(.0773993808),i=n.lessThanEqual(.04045);return rt(e,t,i)}).setLayout({name:"sRGBToLinearSRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),bS=U(([n])=>{const e=n.pow(.41666).mul(1.055).sub(.055),t=n.mul(12.92),i=n.lessThanEqual(.0031308);return rt(e,t,i)}).setLayout({name:"linearSRGBTosRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),SS=U(([n,e])=>n.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wS=U(([n,e])=>(n=n.mul(e),n.div(n.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ES=U(([n,e])=>{n=n.mul(e),n=n.sub(.004).max(0);const t=n.mul(n.mul(6.2).add(.5)),i=n.mul(n.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"}]}),AU=U(([n])=>{const e=n.mul(n.add(.0245786)).sub(90537e-9),t=n.mul(n.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),AS=U(([n,e])=>{const t=yi(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=yi(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return n=n.mul(e).div(.6),n=t.mul(n),n=AU(n),n=i.mul(n),n.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),NU=yi(D(1.6605,-.1246,-.0182),D(-.5876,1.1329,-.1006),D(-.0728,-.0083,1.1187)),CU=yi(D(.6274,.0691,.0164),D(.3293,.9195,.088),D(.0433,.0113,.8956)),RU=U(([n])=>{const e=D(n).toVar(),t=D(e.mul(e)).toVar(),i=D(t.mul(t)).toVar();return E(15.5).mul(i.mul(t)).sub(lt(40.14,i.mul(e))).add(lt(31.96,i).sub(lt(6.868,t.mul(e))).add(lt(.4298,t).add(lt(.1191,e).sub(.00232))))}),NS=U(([n,e])=>{const t=D(n).toVar(),i=yi(D(.856627153315983,.137318972929847,.11189821299995),D(.0951212405381588,.761241990602591,.0767994186031903),D(.0482516061458583,.101439036467562,.811302368396859)),r=yi(D(1.1271005818144368,-.1413297634984383,-.14132976349843826),D(-.11060664309660323,1.157823702216272,-.11060664309660294),D(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=E(-12.47393),a=E(4.026069);return t.mulAssign(e),t.assign(CU.mul(t)),t.assign(i.mul(t)),t.assign(ft(t,1e-10)),t.assign(Gl(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(li(t,0,1)),t.assign(RU(t)),t.assign(r.mul(t)),t.assign(Ji(ft(D(0),t),D(2.2))),t.assign(NU.mul(t)),t.assign(li(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),CS=U(([n,e])=>{const t=E(.76),i=E(.15);n=n.mul(e);const r=xi(n.r,xi(n.g,n.b)),s=Ri(r.lessThan(.08),r.sub(lt(6.25,r.mul(r))),.04);n.subAssign(s);const a=ft(n.r,ft(n.g,n.b));Le(a.lessThan(t),()=>n);const o=Pt(1,t),l=Pt(1,o.mul(o).div(a.add(o.sub(t))));n.mulAssign(l.div(a));const c=Pt(1,Qr(1,i.mul(a.sub(l)).add(1)));return rt(n,D(l),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class IU extends qe{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){e.hasBuiltin(this._builtinName)}generate(e,t){const i=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage==="compute"?e.format(i,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${i} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const Rd=(n,e)=>G(new IU(n,e)),LU=Rd("numWorkgroups","uvec3"),PU=Rd("workgroupId","uvec3"),DU=Rd("localId","uvec3"),UU=Rd("subgroupSize","uint");class OU extends qe{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:i}=e;i.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
|
|
3870
|
+
`):e.addLineFlowCode(`${t}Barrier()`,this)}}const o0=K(OU),FU=()=>o0("workgroup").append(),VU=()=>o0("storage").append(),BU=()=>o0("texture").append();class zU extends cs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let i;const r=e.context.assign;if(i=super.generate(e),r!==!0){const s=this.getNodeType(e);i=e.format(i,s,t)}return i}}class kU extends qe{constructor(e,t,i=0){super(t),this.bufferType=t,this.bufferCount=i,this.isWorkgroupInfoNode=!0,this.scope=e}label(e){return this.name=e,this}getHash(){return this.uuid}setScope(e){return this.scope=e,this}getInputType(){return`${this.scope}Array`}element(e){return G(new zU(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const HU=(n,e)=>G(new kU("Workgroup",n,e));class Mi extends pt{static get type(){return"AtomicFunctionNode"}constructor(e,t,i,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=i,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,i=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,o=[];o.push(`&${s.build(e,r)}`),o.push(a.build(e,r));const l=`${e.getMethod(t,i)}( ${o.join(", ")} )`;if(this.storeNode!==null){const c=this.storeNode.build(e,r);e.addLineFlowCode(`${c} = ${l}`,this)}else e.addLineFlowCode(l,this)}}Mi.ATOMIC_LOAD="atomicLoad",Mi.ATOMIC_STORE="atomicStore",Mi.ATOMIC_ADD="atomicAdd",Mi.ATOMIC_SUB="atomicSub",Mi.ATOMIC_MAX="atomicMax",Mi.ATOMIC_MIN="atomicMin",Mi.ATOMIC_AND="atomicAnd",Mi.ATOMIC_OR="atomicOr",Mi.ATOMIC_XOR="atomicXor";const GU=K(Mi),On=(n,e,t,i)=>{const r=GU(n,e,t,i);return r.append(),r},WU=(n,e,t=null)=>On(Mi.ATOMIC_STORE,n,e,t),jU=(n,e,t=null)=>On(Mi.ATOMIC_ADD,n,e,t),XU=(n,e,t=null)=>On(Mi.ATOMIC_SUB,n,e,t),qU=(n,e,t=null)=>On(Mi.ATOMIC_MAX,n,e,t),YU=(n,e,t=null)=>On(Mi.ATOMIC_MIN,n,e,t),$U=(n,e,t=null)=>On(Mi.ATOMIC_AND,n,e,t),JU=(n,e,t=null)=>On(Mi.ATOMIC_OR,n,e,t),KU=(n,e,t=null)=>On(Mi.ATOMIC_XOR,n,e,t),ZU=U(([n=nt()])=>{const e=n.mul(2),t=e.x.floor(),i=e.y.floor();return t.add(i).mod(2).sign()}),mc=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=us(n).toVar();return Ri(s,r,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Id=U(([n,e])=>{const t=us(e).toVar(),i=E(n).toVar();return Ri(t,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),ii=U(([n])=>{const e=E(n).toVar();return P(ds(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),kt=U(([n,e])=>{const t=E(n).toVar();return e.assign(ii(t)),t.sub(E(e))}),QU=U(([n,e,t,i,r,s])=>{const a=E(s).toVar(),o=E(r).toVar(),l=E(i).toVar(),c=E(t).toVar(),u=E(e).toVar(),h=E(n).toVar(),d=E(Pt(1,o)).toVar();return Pt(1,a).mul(h.mul(d).add(u.mul(o))).add(a.mul(c.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),eO=U(([n,e,t,i,r,s])=>{const a=E(s).toVar(),o=E(r).toVar(),l=D(i).toVar(),c=D(t).toVar(),u=D(e).toVar(),h=D(n).toVar(),d=E(Pt(1,o)).toVar();return Pt(1,a).mul(h.mul(d).add(u.mul(o))).add(a.mul(c.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),RS=Di([QU,eO]),tO=U(([n,e,t,i,r,s,a,o,l,c,u])=>{const h=E(u).toVar(),d=E(c).toVar(),p=E(l).toVar(),m=E(o).toVar(),v=E(a).toVar(),f=E(s).toVar(),g=E(r).toVar(),x=E(i).toVar(),y=E(t).toVar(),_=E(e).toVar(),I=E(n).toVar(),T=E(Pt(1,p)).toVar(),w=E(Pt(1,d)).toVar();return E(Pt(1,h)).toVar().mul(w.mul(I.mul(T).add(_.mul(p))).add(d.mul(y.mul(T).add(x.mul(p))))).add(h.mul(w.mul(g.mul(T).add(f.mul(p))).add(d.mul(v.mul(T).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),iO=U(([n,e,t,i,r,s,a,o,l,c,u])=>{const h=E(u).toVar(),d=E(c).toVar(),p=E(l).toVar(),m=D(o).toVar(),v=D(a).toVar(),f=D(s).toVar(),g=D(r).toVar(),x=D(i).toVar(),y=D(t).toVar(),_=D(e).toVar(),I=D(n).toVar(),T=E(Pt(1,p)).toVar(),w=E(Pt(1,d)).toVar();return E(Pt(1,h)).toVar().mul(w.mul(I.mul(T).add(_.mul(p))).add(d.mul(y.mul(T).add(x.mul(p))))).add(h.mul(w.mul(g.mul(T).add(f.mul(p))).add(d.mul(v.mul(T).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),IS=Di([tO,iO]),rO=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=_e(n).toVar(),a=_e(s.bitAnd(_e(7))).toVar(),o=E(mc(a.lessThan(_e(4)),r,i)).toVar(),l=E(lt(2,mc(a.lessThan(_e(4)),i,r))).toVar();return Id(o,us(a.bitAnd(_e(1)))).add(Id(l,us(a.bitAnd(_e(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),nO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=_e(n).toVar(),l=_e(o.bitAnd(_e(15))).toVar(),c=E(mc(l.lessThan(_e(8)),a,s)).toVar(),u=E(mc(l.lessThan(_e(4)),s,mc(l.equal(_e(12)).or(l.equal(_e(14))),a,r))).toVar();return Id(c,us(l.bitAnd(_e(1)))).add(Id(u,us(l.bitAnd(_e(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Ti=Di([rO,nO]),sO=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=co(n).toVar();return D(Ti(s.x,r,i),Ti(s.y,r,i),Ti(s.z,r,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),aO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=co(n).toVar();return D(Ti(o.x,a,s,r),Ti(o.y,a,s,r),Ti(o.z,a,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),kr=Di([sO,aO]),oO=U(([n])=>{const e=E(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),lO=U(([n])=>{const e=E(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),cO=U(([n])=>{const e=D(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),LS=Di([oO,cO]),uO=U(([n])=>{const e=D(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),PS=Di([lO,uO]),Sr=U(([n,e])=>{const t=P(e).toVar(),i=_e(n).toVar();return i.shiftLeft(t).bitOr(i.shiftRight(P(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),DS=U(([n,e,t])=>{n.subAssign(t),n.bitXorAssign(Sr(t,P(4))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Sr(n,P(6))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Sr(e,P(8))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(Sr(t,P(16))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Sr(n,P(19))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Sr(e,P(4))),e.addAssign(n)}),fc=U(([n,e,t])=>{const i=_e(t).toVar(),r=_e(e).toVar(),s=_e(n).toVar();return i.bitXorAssign(r),i.subAssign(Sr(r,P(14))),s.bitXorAssign(i),s.subAssign(Sr(i,P(11))),r.bitXorAssign(s),r.subAssign(Sr(s,P(25))),i.bitXorAssign(r),i.subAssign(Sr(r,P(16))),s.bitXorAssign(i),s.subAssign(Sr(i,P(4))),r.bitXorAssign(s),r.subAssign(Sr(s,P(14))),i.bitXorAssign(r),i.subAssign(Sr(r,P(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Wi=U(([n])=>{const e=_e(n).toVar();return E(e).div(E(_e(P(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),xn=U(([n])=>{const e=E(n).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),hO=U(([n])=>{const e=P(n).toVar(),t=_e(_e(1)).toVar(),i=_e(_e(P(3735928559)).add(t.shiftLeft(_e(2))).add(_e(13))).toVar();return fc(i.add(_e(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),dO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(_e(2)).toVar(),s=_e().toVar(),a=_e().toVar(),o=_e().toVar();return s.assign(a.assign(o.assign(_e(P(3735928559)).add(r.shiftLeft(_e(2))).add(_e(13))))),s.addAssign(_e(i)),a.addAssign(_e(t)),fc(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),pO=U(([n,e,t])=>{const i=P(t).toVar(),r=P(e).toVar(),s=P(n).toVar(),a=_e(_e(3)).toVar(),o=_e().toVar(),l=_e().toVar(),c=_e().toVar();return o.assign(l.assign(c.assign(_e(P(3735928559)).add(a.shiftLeft(_e(2))).add(_e(13))))),o.addAssign(_e(s)),l.addAssign(_e(r)),c.addAssign(_e(i)),fc(o,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),mO=U(([n,e,t,i])=>{const r=P(i).toVar(),s=P(t).toVar(),a=P(e).toVar(),o=P(n).toVar(),l=_e(_e(4)).toVar(),c=_e().toVar(),u=_e().toVar(),h=_e().toVar();return c.assign(u.assign(h.assign(_e(P(3735928559)).add(l.shiftLeft(_e(2))).add(_e(13))))),c.addAssign(_e(o)),u.addAssign(_e(a)),h.addAssign(_e(s)),DS(c,u,h),c.addAssign(_e(r)),fc(c,u,h)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),fO=U(([n,e,t,i,r])=>{const s=P(r).toVar(),a=P(i).toVar(),o=P(t).toVar(),l=P(e).toVar(),c=P(n).toVar(),u=_e(_e(5)).toVar(),h=_e().toVar(),d=_e().toVar(),p=_e().toVar();return h.assign(d.assign(p.assign(_e(P(3735928559)).add(u.shiftLeft(_e(2))).add(_e(13))))),h.addAssign(_e(c)),d.addAssign(_e(l)),p.addAssign(_e(o)),DS(h,d,p),h.addAssign(_e(a)),d.addAssign(_e(s)),fc(h,d,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Ct=Di([hO,dO,pO,mO,fO]),gO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(Ct(i,t)).toVar(),s=co().toVar();return s.x.assign(r.bitAnd(P(255))),s.y.assign(r.shiftRight(P(8)).bitAnd(P(255))),s.z.assign(r.shiftRight(P(16)).bitAnd(P(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),vO=U(([n,e,t])=>{const i=P(t).toVar(),r=P(e).toVar(),s=P(n).toVar(),a=_e(Ct(s,r,i)).toVar(),o=co().toVar();return o.x.assign(a.bitAnd(P(255))),o.y.assign(a.shiftRight(P(8)).bitAnd(P(255))),o.z.assign(a.shiftRight(P(16)).bitAnd(P(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Hr=Di([gO,vO]),yO=U(([n])=>{const e=z(n).toVar(),t=P().toVar(),i=P().toVar(),r=E(kt(e.x,t)).toVar(),s=E(kt(e.y,i)).toVar(),a=E(xn(r)).toVar(),o=E(xn(s)).toVar(),l=E(RS(Ti(Ct(t,i),r,s),Ti(Ct(t.add(P(1)),i),r.sub(1),s),Ti(Ct(t,i.add(P(1))),r,s.sub(1)),Ti(Ct(t.add(P(1)),i.add(P(1))),r.sub(1),s.sub(1)),a,o)).toVar();return LS(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),xO=U(([n])=>{const e=D(n).toVar(),t=P().toVar(),i=P().toVar(),r=P().toVar(),s=E(kt(e.x,t)).toVar(),a=E(kt(e.y,i)).toVar(),o=E(kt(e.z,r)).toVar(),l=E(xn(s)).toVar(),c=E(xn(a)).toVar(),u=E(xn(o)).toVar(),h=E(IS(Ti(Ct(t,i,r),s,a,o),Ti(Ct(t.add(P(1)),i,r),s.sub(1),a,o),Ti(Ct(t,i.add(P(1)),r),s,a.sub(1),o),Ti(Ct(t.add(P(1)),i.add(P(1)),r),s.sub(1),a.sub(1),o),Ti(Ct(t,i,r.add(P(1))),s,a,o.sub(1)),Ti(Ct(t.add(P(1)),i,r.add(P(1))),s.sub(1),a,o.sub(1)),Ti(Ct(t,i.add(P(1)),r.add(P(1))),s,a.sub(1),o.sub(1)),Ti(Ct(t.add(P(1)),i.add(P(1)),r.add(P(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return PS(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),l0=Di([yO,xO]),_O=U(([n])=>{const e=z(n).toVar(),t=P().toVar(),i=P().toVar(),r=E(kt(e.x,t)).toVar(),s=E(kt(e.y,i)).toVar(),a=E(xn(r)).toVar(),o=E(xn(s)).toVar(),l=D(RS(kr(Hr(t,i),r,s),kr(Hr(t.add(P(1)),i),r.sub(1),s),kr(Hr(t,i.add(P(1))),r,s.sub(1)),kr(Hr(t.add(P(1)),i.add(P(1))),r.sub(1),s.sub(1)),a,o)).toVar();return LS(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),MO=U(([n])=>{const e=D(n).toVar(),t=P().toVar(),i=P().toVar(),r=P().toVar(),s=E(kt(e.x,t)).toVar(),a=E(kt(e.y,i)).toVar(),o=E(kt(e.z,r)).toVar(),l=E(xn(s)).toVar(),c=E(xn(a)).toVar(),u=E(xn(o)).toVar(),h=D(IS(kr(Hr(t,i,r),s,a,o),kr(Hr(t.add(P(1)),i,r),s.sub(1),a,o),kr(Hr(t,i.add(P(1)),r),s,a.sub(1),o),kr(Hr(t.add(P(1)),i.add(P(1)),r),s.sub(1),a.sub(1),o),kr(Hr(t,i,r.add(P(1))),s,a,o.sub(1)),kr(Hr(t.add(P(1)),i,r.add(P(1))),s.sub(1),a,o.sub(1)),kr(Hr(t,i.add(P(1)),r.add(P(1))),s,a.sub(1),o.sub(1)),kr(Hr(t.add(P(1)),i.add(P(1)),r.add(P(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return PS(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),c0=Di([_O,MO]),TO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return Wi(Ct(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),bO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return Wi(Ct(t,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),SO=U(([n])=>{const e=D(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar();return Wi(Ct(t,i,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),wO=U(([n])=>{const e=ae(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar(),s=P(ii(e.w)).toVar();return Wi(Ct(t,i,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),EO=Di([TO,bO,SO,wO]),AO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return D(Wi(Ct(t,P(0))),Wi(Ct(t,P(1))),Wi(Ct(t,P(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),NO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return D(Wi(Ct(t,i,P(0))),Wi(Ct(t,i,P(1))),Wi(Ct(t,i,P(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),CO=U(([n])=>{const e=D(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar();return D(Wi(Ct(t,i,r,P(0))),Wi(Ct(t,i,r,P(1))),Wi(Ct(t,i,r,P(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),RO=U(([n])=>{const e=ae(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar(),s=P(ii(e.w)).toVar();return D(Wi(Ct(t,i,r,s,P(0))),Wi(Ct(t,i,r,s,P(1))),Wi(Ct(t,i,r,s,P(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),US=Di([AO,NO,CO,RO]),Ld=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=E(0).toVar(),c=E(1).toVar();return gt(a,()=>{l.addAssign(c.mul(l0(o))),c.mulAssign(r),o.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),OS=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(0).toVar(),c=E(1).toVar();return gt(a,()=>{l.addAssign(c.mul(c0(o))),c.mulAssign(r),o.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),IO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar();return z(Ld(o,a,s,r),Ld(o.add(D(P(19),P(193),P(17))),a,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),LO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(OS(o,a,s,r)).toVar(),c=E(Ld(o.add(D(P(19),P(193),P(17))),a,s,r)).toVar();return ae(l,c)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),PO=U(([n,e,t,i,r,s,a])=>{const o=P(a).toVar(),l=E(s).toVar(),c=P(r).toVar(),u=P(i).toVar(),h=P(t).toVar(),d=P(e).toVar(),p=z(n).toVar(),m=D(US(z(d.add(u),h.add(c)))).toVar(),v=z(m.x,m.y).toVar();v.subAssign(.5),v.mulAssign(l),v.addAssign(.5);const f=z(z(E(d),E(h)).add(v)).toVar(),g=z(f.sub(p)).toVar();return Le(o.equal(P(2)),()=>It(g.x).add(It(g.y))),Le(o.equal(P(3)),()=>ft(It(g.x),It(g.y))),qt(g,g)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),DO=U(([n,e,t,i,r,s,a,o,l])=>{const c=P(l).toVar(),u=E(o).toVar(),h=P(a).toVar(),d=P(s).toVar(),p=P(r).toVar(),m=P(i).toVar(),v=P(t).toVar(),f=P(e).toVar(),g=D(n).toVar(),x=D(US(D(f.add(p),v.add(d),m.add(h)))).toVar();x.subAssign(.5),x.mulAssign(u),x.addAssign(.5);const y=D(D(E(f),E(v),E(m)).add(x)).toVar(),_=D(y.sub(g)).toVar();return Le(c.equal(P(2)),()=>It(_.x).add(It(_.y)).add(It(_.z))),Le(c.equal(P(3)),()=>ft(ft(It(_.x),It(_.y)),It(_.z))),qt(_,_)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Eo=Di([PO,DO]),UO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=E(1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(Eo(l,u,h,a,o,r,i)).toVar();c.assign(xi(c,d))})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=z(1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(Eo(l,u,h,a,o,r,i)).toVar();Le(d.lessThan(c.x),()=>{c.y.assign(c.x),c.x.assign(d)}).ElseIf(d.lessThan(c.y),()=>{c.y.assign(d)})})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),FO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=D(1e6,1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(Eo(l,u,h,a,o,r,i)).toVar();Le(d.lessThan(c.x),()=>{c.z.assign(c.y),c.y.assign(c.x),c.x.assign(d)}).ElseIf(d.lessThan(c.y),()=>{c.z.assign(c.y),c.y.assign(d)}).ElseIf(d.lessThan(c.z),()=>{c.z.assign(d)})})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),VO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=E(1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(Eo(c,h,d,p,a,o,l,r,i)).toVar();u.assign(xi(u,m))})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),BO=Di([UO,VO]),zO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=z(1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(Eo(c,h,d,p,a,o,l,r,i)).toVar();Le(m.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.y.assign(m)})})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kO=Di([OO,zO]),HO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=D(1e6,1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(Eo(c,h,d,p,a,o,l,r,i)).toVar();Le(m.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(m)}).ElseIf(m.lessThan(u.z),()=>{u.z.assign(m)})})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GO=Di([FO,HO]),WO=U(([n])=>{const e=n.y,t=n.z,i=D().toVar();return Le(e.lessThan(1e-4),()=>{i.assign(D(t,t,t))}).Else(()=>{let r=n.x;r=r.sub(ds(r)).mul(6).toVar();const s=P(Ff(r)),a=r.sub(E(s)),o=t.mul(e.oneMinus()),l=t.mul(e.mul(a).oneMinus()),c=t.mul(e.mul(a.oneMinus()).oneMinus());Le(s.equal(P(0)),()=>{i.assign(D(t,c,o))}).ElseIf(s.equal(P(1)),()=>{i.assign(D(l,t,o))}).ElseIf(s.equal(P(2)),()=>{i.assign(D(o,t,c))}).ElseIf(s.equal(P(3)),()=>{i.assign(D(o,l,t))}).ElseIf(s.equal(P(4)),()=>{i.assign(D(c,o,t))}).Else(()=>{i.assign(D(t,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),jO=U(([n])=>{const e=D(n).toVar(),t=E(e.x).toVar(),i=E(e.y).toVar(),r=E(e.z).toVar(),s=E(xi(t,xi(i,r))).toVar(),a=E(ft(t,ft(i,r))).toVar(),o=E(a.sub(s)).toVar(),l=E().toVar(),c=E().toVar(),u=E().toVar();return u.assign(a),Le(a.greaterThan(0),()=>{c.assign(o.div(a))}).Else(()=>{c.assign(0)}),Le(c.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{Le(t.greaterThanEqual(a),()=>{l.assign(i.sub(r).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(zt(2,r.sub(t).div(o)))}).Else(()=>{l.assign(zt(4,t.sub(i).div(o)))}),l.mulAssign(1/6),Le(l.lessThan(0),()=>{l.addAssign(1)})}),D(l,c,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),XO=U(([n])=>{const e=D(n).toVar(),t=_f(Lf(e,D(.04045))).toVar(),i=D(e.div(12.92)).toVar(),r=D(Ji(ft(e.add(D(.055)),D(0)).div(1.055),D(2.4))).toVar();return rt(i,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),FS=(n,e)=>{n=E(n),e=E(e);const t=z(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Ki(n.sub(t),n.add(t),e)},VS=(n,e,t,i)=>rt(n,e,t[i].clamp()),qO=(n,e,t=nt())=>VS(n,e,t,"x"),YO=(n,e,t=nt())=>VS(n,e,t,"y"),BS=(n,e,t,i,r)=>rt(n,e,FS(t,i[r])),$O=(n,e,t,i=nt())=>BS(n,e,t,i,"x"),JO=(n,e,t,i=nt())=>BS(n,e,t,i,"y"),KO=(n=1,e=0,t=nt())=>t.mul(n).add(e),ZO=(n,e=1)=>(n=E(n),n.abs().pow(e).mul(n.sign())),QO=(n,e=1,t=.5)=>E(n).sub(t).mul(e).add(t),eF=(n=nt(),e=1,t=0)=>l0(n.convert("vec2|vec3")).mul(e).add(t),tF=(n=nt(),e=1,t=0)=>c0(n.convert("vec2|vec3")).mul(e).add(t),iF=(n=nt(),e=1,t=0)=>(n=n.convert("vec2|vec3"),ae(c0(n),l0(n.add(z(19,73)))).mul(e).add(t)),rF=(n=nt(),e=1)=>BO(n.convert("vec2|vec3"),e,P(1)),nF=(n=nt(),e=1)=>kO(n.convert("vec2|vec3"),e,P(1)),sF=(n=nt(),e=1)=>GO(n.convert("vec2|vec3"),e,P(1)),aF=(n=nt())=>EO(n.convert("vec2|vec3")),oF=(n=nt(),e=3,t=2,i=.5,r=1)=>Ld(n,P(e),t,i).mul(r),lF=(n=nt(),e=3,t=2,i=.5,r=1)=>IO(n,P(e),t,i).mul(r),cF=(n=nt(),e=3,t=2,i=.5,r=1)=>OS(n,P(e),t,i).mul(r),uF=(n=nt(),e=3,t=2,i=.5,r=1)=>LO(n,P(e),t,i).mul(r),zS=U(([n,e])=>{const t=n.x,i=n.y,r=n.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(i)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(i)),s=s.add(e.element(5).mul(2*.429043).mul(i).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(lt(t,t).sub(lt(i,i)))),s});class kS extends vs{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=fe(0).setGroup(xt),this.decayExponentNode=fe(0).setGroup(xt)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){const{colorNode:t,cutoffDistanceNode:i,decayExponentNode:r,light:s}=this,a=e.context.lightingModel,o=Cd(s).sub(Pi),l=o.normalize(),c=o.length(),u=i0({lightDistance:c,cutoffDistance:i,decayExponent:r}),h=t.mul(u),d=e.context.reflectedLight;a.direct({lightDirection:l,lightColor:h,reflectedLight:d},e.stack,e)}}class HS extends vs{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,i=this.colorNode,r=s0(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:i,reflectedLight:s},e.stack,e)}}const u0=new Re,Pd=new Re;let gc=null;class GS extends vs{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=fe(new N).setGroup(xt),this.halfWidth=fe(new N).setGroup(xt)}update(e){super.update(e);const{light:t}=this,i=e.camera.matrixWorldInverse;Pd.identity(),u0.copy(t.matrixWorld),u0.premultiply(i),Pd.extractRotation(u0),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Pd),this.halfHeight.value.applyMatrix4(Pd)}setup(e){super.setup(e);let t,i;e.isAvailable("float32Filterable")?(t=yt(gc.LTC_FLOAT_1),i=yt(gc.LTC_FLOAT_2)):(t=yt(gc.LTC_HALF_1),i=yt(gc.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,o=Cd(s),l=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:l,ltc_1:t,ltc_2:i},e.stack,e)}static setLTC(e){gc=e}}class h0 extends vs{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=fe(0).setGroup(xt),this.penumbraCosNode=fe(0).setGroup(xt),this.cutoffDistanceNode=fe(0).setGroup(xt),this.decayExponentNode=fe(0).setGroup(xt)}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){const{coneCosNode:t,penumbraCosNode:i}=this;return Ki(t,i,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:i,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,o=Cd(a).sub(Pi),l=o.normalize(),c=l.dot(s0(a)),u=this.getSpotAttenuation(c),h=o.length(),d=i0({lightDistance:h,cutoffDistance:r,decayExponent:s}),p=i.mul(u).mul(d),m=e.context.reflectedLight;t.direct({lightDirection:l,lightColor:p,reflectedLight:m},e.stack,e)}}class WS extends h0{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let i=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);i=yt(t,z(r,0),0).r}else i=super.getSpotAttenuation(e);return i}}class jS extends vs{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class XS extends vs{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=n0(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=fe(new xe).setGroup(xt)}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,s=hr.dot(r).mul(.5).add(.5),a=rt(i,t,s);e.context.irradiance.addAssign(a)}}class qS extends vs{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let i=0;i<9;i++)t.push(new N);this.lightProbe=gn(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=zS(Kh,this.lightProbe);e.context.irradiance.addAssign(t)}}class hF{parseFunction(){console.warn("Abstract function.")}}class YS{constructor(e,t,i="",r=""){this.type=e,this.inputs=t,this.name=i,this.precision=r}getCode(){console.warn("Abstract function.")}}YS.isNodeFunction=!0;const dF=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,pF=/[a-z_0-9]+/ig,$S="#pragma main",mF=n=>{n=n.trim();const e=n.indexOf($S),t=e!==-1?n.slice(e+$S.length):n,i=t.match(dF);if(i!==null&&i.length===5){const r=i[4],s=[];let a=null;for(;(a=pF.exec(r))!==null;)s.push(a);const o=[];let l=0;for(;l<s.length;){const m=s[l][0]==="const";m===!0&&l++;let v=s[l][0];v==="in"||v==="out"||v==="inout"?l++:v="";const f=s[l++][0];let g=Number.parseInt(s[l][0]);Number.isNaN(g)===!1?l++:g=null;const x=s[l++][0];o.push(new jg(f,x,g,v,m))}const c=t.substring(i[0].length),u=i[3]!==void 0?i[3]:"",h=i[2],d=i[1]!==void 0?i[1]:"",p=e!==-1?n.slice(0,e):"";return{type:h,inputs:o,name:u,precision:d,inputsCode:r,blockCode:c,headerCode:p}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class fF extends YS{constructor(e){const{type:t,inputs:i,name:r,precision:s,inputsCode:a,blockCode:o,headerCode:l}=mF(e);super(t,i,r,s),this.inputsCode=a,this.blockCode=o,this.headerCode=l}getCode(e=this.name){let t;const i=this.blockCode;if(i!==""){const{type:r,inputsCode:s,headerCode:a,precision:o}=this;let l=`${r} ${e} ( ${s.trim()} )`;o!==""&&(l=`${o} ${l}`),t=a+l+i}else t="";return t}}class JS extends hF{parseFunction(e){return new fF(e)}}class gF{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=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}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}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.name,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)){console.warn(`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)){console.warn(`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 vF extends Nl{constructor(e,t,i,r,s,a){super(e,t,i,r,s,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class KS extends gF{constructor(){super(),this.addLight(kS,Th),this.addLight(HS,bh),this.addLight(GS,Wm),this.addLight(h0,Nl),this.addLight(jS,Sh),this.addLight(XS,Mh),this.addLight(qS,jm),this.addLight(WS,vF),this.addToneMapping(SS,Ac),this.addToneMapping(wS,Nc),this.addToneMapping(ES,rp),this.addToneMapping(AS,Cc),this.addToneMapping(NS,Rc),this.addToneMapping(CS,Ic),this.addColorSpace(bS,Xh(nr,Fi)),this.addColorSpace(TS,Xh(Fi,nr))}}if(typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Bn}})),typeof window<"u"){try{import.meta&&(window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:import.meta.url,revision:Bn}))}catch{}window.__THREE__?(console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+Bn),console.warn(window.__THREE__IMPORTS__)):window.__THREE__=Bn}const yF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Cc,AONode:Q1,AddEquation:zn,AddOperation:ip,AdditiveAnimationBlendMode:mp,AdditiveBlending:Co,AfterImageNode:Bb,AgXToneMapping:Rc,AlphaFormat:lp,AlwaysCompare:pv,AlwaysDepth:Io,AlwaysStencilFunc:lu,AmbientLight:Sh,AmbientLightNode:jS,AnaglyphPassNode:lS,AnalyticLightNode:vs,AnamorphicNode:Hb,AnimationAction:bx,AnimationClip:so,AnimationLoader:VI,AnimationMixer:Sx,AnimationObjectGroup:r2,AnimationUtils:DI,ArcCurve:By,ArrayCamera:em,ArrayElementNode:cs,ArrowHelper:v2,AssignNode:y_,AttachedBindMode:np,AttributeNode:$f,Audio:$m,AudioAnalyser:qI,AudioContext:Ah,AudioListener:xx,AudioLoader:mx,AxesHelper:jx,BRDF_GGX:_g,BRDF_Lambert:na,BackSide:si,BasicDepthPacking:fp,BasicEnvironmentNode:od,BasicNodeLibrary:KS,BasicShadowMap:sw,BatchNode:G1,BatchedMesh:pm,BloomNode:tS,Bone:Yu,BooleanKeyframeTrack:as,Box2:c2,Box3:zi,Box3Helper:Gx,BoxGeometry:_n,BoxHelper:Hx,Break:sd,BufferAttribute:wt,BufferAttributeNode:AM,BufferGeometry:ct,BufferGeometryLoader:cx,BufferNode:Qh,BumpMapNode:c1,BypassNode:LM,ByteType:ap,Cache:un,CacheNode:IM,Camera:cl,CameraHelper:kx,CanvasTexture:Vy,CapsuleGeometry:Ud,CatmullRomCurve3:bm,CineonToneMapping:rp,CircleGeometry:Od,ClampToEdgeWrapping:gr,Clock:Ym,CodeNode:Og,Color:xe,ColorKeyframeTrack:xh,ColorManagement:vt,ColorSpaceNode:ql,CompressedArrayTexture:Oy,CompressedCubeTexture:Fy,CompressedTexture:xl,CompressedTextureLoader:BI,ComputeNode:CM,ConeGeometry:Fd,ConstNode:Vr,ConstantAlphaFactor:B0,ConstantColorFactor:F0,ContextNode:Hf,Continue:AL,Controls:qx,ConvertNode:df,CubeCamera:Lu,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,CubeTexture:Is,CubeTextureLoader:zI,CubeTextureNode:t1,CubeUVReflectionMapping:Wn,CubicBezierCurve:Sm,CubicBezierCurve3:ky,CubicInterpolant:ex,CullFaceBack:Yd,CullFaceFront:S0,CullFaceFrontBack:nw,CullFaceNone:b0,Curve:Or,CurvePath:Gy,CustomBlending:Qd,CustomToneMapping:k0,CylinderGeometry:pa,Cylindrical:l2,DFGApprox:Mg,D_GGX:vT,Data3DTexture:du,DataArrayTexture:il,DataTexture:Ur,DataTextureLoader:rx,DataUtils:Iv,DecrementStencilOp:K0,DecrementWrapStencilOp:Q0,DefaultLoadingManager:zm,DenoiseNode:Zb,DepthFormat:Yn,DepthOfFieldNode:Wb,DepthStencilFormat:$n,DepthTexture:Fs,DetachedBindMode:H0,DirectionalLight:bh,DirectionalLightHelper:zx,DirectionalLightNode:HS,Discard:FM,DiscreteInterpolant:tx,DisplayP3ColorSpace:ou,DodecahedronGeometry:Vd,DotScreenNode:jb,DoubleSide:Wr,DstAlphaFactor:L0,DstColorFactor:D0,DynamicCopyUsage:gw,DynamicDrawUsage:Ss,DynamicReadUsage:pw,EPSILON:V_,EdgesGeometry:Rm,EllipseCurve:nh,EnvironmentNode:GT,EqualCompare:cv,EqualDepth:Po,EqualStencilFunc:rv,EquirectUVNode:uT,EquirectangularReflectionMapping:Hn,EquirectangularRefractionMapping:Gn,Euler:dr,EventDispatcher:vr,ExpressionNode:OM,ExtrudeGeometry:xc,FXAANode:Qb,F_Schlick:xo,FileLoader:Kr,FilmNode:qb,Float16BufferAttribute:Lv,Float32BufferAttribute:De,FloatType:Oi,Fn:U,Fog:im,FogExp2:Dd,FogExp2Node:fS,FogNode:Ed,FogRangeNode:mS,FramebufferTexture:ym,FrontFacingNode:XM,FrontSide:an,Frustum:Ga,FunctionCallNode:__,FunctionNode:Fg,FunctionOverloadingNode:gb,GLBufferAttribute:o2,GLSL1:yw,GLSL3:cu,GLSLNodeParser:JS,GTAONode:Kb,GaussianBlurNode:Fb,GreaterCompare:uv,GreaterDepth:Uo,GreaterEqualCompare:dv,GreaterEqualDepth:Do,GreaterEqualStencilFunc:ov,GreaterStencilFunc:sv,GridHelper:Fx,Group:Vs,HalfFloatType:wi,HemisphereLight:Mh,HemisphereLightHelper:m2,HemisphereLightNode:XS,IESSpotLightNode:WS,INFINITY:H2,IcosahedronGeometry:Bd,If:Le,ImageBitmapLoader:px,ImageLoader:Al,ImageUtils:_v,IncrementStencilOp:J0,IncrementWrapStencilOp:Z0,IndexNode:Bt,InstanceNode:k1,InstancedBufferAttribute:Rn,InstancedBufferGeometry:Xm,InstancedInterleavedBuffer:Zm,InstancedMesh:cm,InstancedPointsNodeMaterial:HL,Int16BufferAttribute:iE,Int32BufferAttribute:rE,Int8BufferAttribute:Qw,IntType:ya,InterleavedBuffer:qa,InterleavedBufferAttribute:Fn,Interpolant:to,InterpolateDiscrete:wa,InterpolateLinear:qo,InterpolateSmooth:su,InvertStencilOp:ev,IrradianceNode:iT,JoinNode:Kx,KeepStencilOp:Jn,KeyframeTrack:Fr,LOD:sm,LatheGeometry:yc,Layers:sl,LessCompare:yp,LessDepth:Lo,LessEqualCompare:xp,LessEqualDepth:kn,LessEqualStencilFunc:nv,LessStencilFunc:iv,Light:os,LightProbe:jm,LightProbeNode:qS,LightingContextNode:eT,LightingModel:uc,LightingNode:ra,LightsNode:K1,Line:In,Line2NodeMaterial:YL,Line3:Lx,LineBasicMaterial:Ni,LineBasicNodeMaterial:WL,LineCurve:wm,LineCurve3:Hy,LineDashedMaterial:yh,LineDashedNodeMaterial:XL,LineLoop:fm,LineSegments:Jr,LinearDisplayP3ColorSpace:$o,LinearFilter:Lt,LinearInterpolant:Bm,LinearMipMapLinearFilter:sp,LinearMipMapNearestFilter:ow,LinearMipmapLinearFilter:Xi,LinearMipmapNearestFilter:Xn,LinearSRGBColorSpace:nr,LinearToneMapping:Ac,LinearTransfer:Jo,Loader:Gi,LoaderUtils:wh,LoadingManager:_h,Loop:gt,LoopNode:q1,LoopOnce:dp,LoopPingPong:W0,LoopRepeat:pp,LuminanceAlphaFormat:up,LuminanceFormat:cp,Lut3DNode:Yb,MOUSE:M0,MRTNode:fb,MatcapUVNode:qT,Material:hi,MaterialLoader:Tc,MaterialNode:Z,MaterialReferenceNode:i1,MathUtils:uu,Matrix2:d0,Matrix3:Ke,Matrix4:Re,MaxEquation:ep,MaxMipLevelNode:kM,Mesh:Ft,MeshBasicMaterial:$r,MeshBasicNodeMaterial:rP,MeshDepthMaterial:ku,MeshDistanceMaterial:Zp,MeshLambertMaterial:vh,MeshLambertNodeMaterial:lP,MeshMatcapMaterial:Om,MeshMatcapNodeMaterial:XP,MeshNormalMaterial:gh,MeshNormalNodeMaterial:KL,MeshPhongMaterial:fh,MeshPhongNodeMaterial:uP,MeshPhysicalMaterial:mh,MeshPhysicalNodeMaterial:XT,MeshSSSNodeMaterial:zP,MeshStandardMaterial:El,MeshStandardNodeMaterial:jT,MeshToonMaterial:Um,MeshToonNodeMaterial:WP,MinEquation:A0,MirroredRepeatWrapping:ga,MixOperation:tp,ModelNode:tn,ModelViewProjectionNode:V1,MorphNode:$1,MultiplyBlending:Zd,MultiplyOperation:fa,NearestFilter:$t,NearestMipMapLinearFilter:aw,NearestMipMapNearestFilter:G0,NearestMipmapLinearFilter:bn,NearestMipmapNearestFilter:Pc,NeutralToneMapping:Ic,NeverCompare:lv,NeverDepth:Ro,NeverStencilFunc:tv,NoBlending:Er,NoColorSpace:Cr,NoToneMapping:mr,Node:qe,NodeAttribute:Pg,NodeBuilder:pb,NodeCache:fd,NodeCode:ib,NodeFrame:mb,NodeFunctionInput:jg,NodeLoader:ZT,NodeMaterial:Tt,NodeMaterialLoader:QT,NodeMaterialObserver:Yx,NodeObjectLoader:i3,NodeShaderStage:lf,NodeType:M2,NodeUniform:eb,NodeUpdateType:je,NodeUtils:_2,NodeVar:Dg,NodeVarying:tb,NormalAnimationBlendMode:au,NormalBlending:Tn,NormalMapNode:l1,NotEqualCompare:hv,NotEqualDepth:Oo,NotEqualStencilFunc:av,NumberKeyframeTrack:io,Object3D:_t,Object3DNode:St,ObjectLoader:ux,ObjectSpaceNormalMap:vp,OctahedronGeometry:Ao,OneFactor:C0,OneMinusConstantAlphaFactor:z0,OneMinusConstantColorFactor:V0,OneMinusDstAlphaFactor:P0,OneMinusDstColorFactor:U0,OneMinusSrcAlphaFactor:Ec,OneMinusSrcColorFactor:I0,OrthographicCamera:Ds,OscNode:gi,OutputStructNode:Xg,P3Primaries:Zo,PCFShadowMap:$d,PCFSoftShadowMap:Jd,PI:ea,PI2:G2,PMREMGenerator:Ou,PMREMNode:zT,ParallaxBarrierPassNode:cS,ParameterNode:Ug,PassNode:bi,Path:Tl,PerspectiveCamera:di,PhongLightingModel:yg,PhysicalLightingModel:ud,PixelationPassNode:rS,Plane:cn,PlaneGeometry:da,PlaneHelper:g2,PointLight:Th,PointLightHelper:d2,PointLightNode:kS,PointUVNode:Eb,Points:vm,PointsMaterial:Qa,PointsNodeMaterial:YP,PolarGridHelper:f2,PolyhedronGeometry:ys,PositionalAudio:Mx,PosterizeNode:Ib,PropertyBinding:bt,PropertyMixer:Tx,PropertyNode:Et,QuadraticBezierCurve:Em,QuadraticBezierCurve3:Am,Quaternion:Bi,QuaternionKeyframeTrack:ro,QuaternionLinearInterpolant:ix,RED_GREEN_RGTC2_Format:ru,RED_RGTC1_Format:hp,REVISION:Bn,RGBADepthPacking:gp,RGBAFormat:Ei,RGBAIntegerFormat:zc,RGBA_ASTC_10x10_Format:Zc,RGBA_ASTC_10x5_Format:$c,RGBA_ASTC_10x6_Format:Jc,RGBA_ASTC_10x8_Format:Kc,RGBA_ASTC_12x10_Format:Qc,RGBA_ASTC_12x12_Format:eu,RGBA_ASTC_4x4_Format:Wo,RGBA_ASTC_5x4_Format:Gc,RGBA_ASTC_5x5_Format:Wc,RGBA_ASTC_6x5_Format:jc,RGBA_ASTC_6x6_Format:jo,RGBA_ASTC_8x5_Format:Xc,RGBA_ASTC_8x6_Format:qc,RGBA_ASTC_8x8_Format:Yc,RGBA_BPTC_Format:Sa,RGBA_ETC2_EAC_Format:Go,RGBA_PVRTC_2BPPV1_Format:Hc,RGBA_PVRTC_4BPPV1_Format:zo,RGBA_S3TC_DXT1_Format:Ma,RGBA_S3TC_DXT3_Format:Ta,RGBA_S3TC_DXT5_Format:ba,RGBDepthPacking:cw,RGBFormat:Vc,RGBIntegerFormat:lw,RGBShiftNode:Xb,RGB_BPTC_SIGNED_Format:tu,RGB_BPTC_UNSIGNED_Format:Xo,RGB_ETC1_Format:ko,RGB_ETC2_Format:Ho,RGB_PVRTC_2BPPV1_Format:kc,RGB_PVRTC_4BPPV1_Format:Bo,RGB_S3TC_DXT1_Format:_a,RGDepthPacking:uw,RGFormat:xa,RGIntegerFormat:Bc,RTTNode:bb,RangeNode:gS,RawShaderMaterial:Dm,Ray:Cs,Raycaster:Ax,Rec709Primaries:Ko,RectAreaLight:Wm,RectAreaLightNode:GS,RedFormat:Fo,RedIntegerFormat:Vo,ReferenceNode:Zl,ReflectorNode:Tb,ReinhardToneMapping:Nc,RemapNode:Yf,RenderOutputNode:VM,RenderTarget:ui,RendererReferenceNode:TM,RepeatWrapping:jn,ReplaceStencilOp:$0,Return:Y2,ReverseSubtractEquation:E0,RingGeometry:_c,RotateNode:$T,SIGNED_RED_GREEN_RGTC2_Format:nu,SIGNED_RED_RGTC1_Format:iu,SRGBColorSpace:Fi,SRGBTransfer:Ot,SSAAPassNode:nS,Scene:Hu,SceneNode:sn,Schlick_to_F0:xT,ScreenNode:ri,ScriptableNode:pS,ScriptableValueNode:hS,SetNode:Zx,ShaderChunk:dt,ShaderLib:Dr,ShaderMaterial:Pr,ShaderNode:Pl,ShadowMaterial:ph,ShadowNodeMaterial:QP,Shape:ss,ShapeGeometry:zd,ShapePath:Xx,ShapeUtils:nn,ShortType:op,Skeleton:vc,SkeletonHelper:h2,SkinnedMesh:lm,SkinningNode:ug,SobelOperatorNode:Gb,Source:Kn,Sphere:Ai,SphereGeometry:No,Spherical:Cx,SphericalHarmonics3:lx,SplineCurve:Nm,SplitNode:Dh,SpotLight:Nl,SpotLightHelper:u2,SpotLightNode:h0,Sprite:nm,SpriteMaterial:hl,SpriteNodeMaterial:JP,SpriteSheetUVNode:vb,SrcAlphaFactor:wc,SrcAlphaSaturateFactor:O0,SrcColorFactor:R0,StackNode:nb,StaticCopyUsage:fw,StaticDrawUsage:Ea,StaticReadUsage:dw,StereoCamera:qm,StereoPassNode:sS,StorageArrayElementNode:yb,StorageBufferNode:Qg,StorageTextureNode:Nb,StreamCopyUsage:vw,StreamDrawUsage:hw,StreamReadUsage:mw,StringKeyframeTrack:Gs,SubtractEquation:w0,SubtractiveBlending:Kd,TBNViewMatrix:ia,TOUCH:T0,TangentSpaceNormalMap:on,TempNode:pt,TetrahedronGeometry:kd,Texture:Wt,Texture3DNode:JT,TextureLoader:nx,TextureNode:mn,TextureSizeNode:zM,TextureUtils:BR,TimerNode:Si,ToneMappingNode:SM,ToonOutlinePassNode:uS,TorusGeometry:Mc,TorusKnotGeometry:Hd,TransitionNode:iS,Triangle:er,TriangleFanDrawMode:q0,TriangleStripDrawMode:X0,TrianglesDrawMode:j0,TriplanarTexturesNode:xb,TubeGeometry:Gd,UVMapping:Lc,Uint16BufferAttribute:Tu,Uint32BufferAttribute:Bp,Uint8BufferAttribute:eE,Uint8ClampedBufferAttribute:tE,Uniform:wx,UniformArrayNode:eg,UniformGroupNode:Mf,UniformNode:Js,UniformsGroup:a2,UniformsLib:Me,UniformsUtils:Hp,UnsignedByteType:jr,UnsignedInt101111Type:Fc,UnsignedInt248Type:qn,UnsignedInt5999Type:Oc,UnsignedIntType:Nr,UnsignedShort4444Type:Dc,UnsignedShort5551Type:Uc,UnsignedShortType:va,UserDataNode:Rb,VSMShadowMap:rr,V_GGX_SmithCorrelated:gT,VarNode:fM,VaryingNode:gM,Vector2:J,Vector3:N,Vector4:st,VectorKeyframeTrack:no,VertexColorNode:wb,VideoTexture:Uy,ViewportDepthNode:Qi,ViewportDepthTextureNode:aT,ViewportSharedTextureNode:Lb,ViewportTextureNode:oc,VolumeNodeMaterial:t3,WebGL3DRenderTarget:Gw,WebGLArrayRenderTarget:Hw,WebGLCoordinateSystem:Rr,WebGLCubeRenderTarget:Pu,WebGLMultipleRenderTargets:y2,WebGLRenderTarget:Ir,WebGLRenderer:my,WebGLUtils:py,WebGPUCoordinateSystem:ws,WireframeGeometry:Pm,WrapAroundEnding:Yo,ZeroCurvatureEnding:Ts,ZeroFactor:N0,ZeroSlopeEnding:bs,ZeroStencilOp:Y0,abs:It,acesFilmicToneMapping:AS,acos:Wh,add:zt,addMethodChaining:te,addNodeElement:$2,afterImage:hD,agxToneMapping:NS,all:Pf,alphaT:zh,anaglyphPass:qD,anamorphic:vD,and:A_,anisotropy:hs,anisotropyB:Zs,anisotropyT:Bl,any:B_,ao:AD,append:a_,arrayBuffer:V2,asin:j_,assign:x_,atan:X_,atan2:tM,atomicAdd:jU,atomicAnd:$U,atomicFunc:On,atomicMax:qU,atomicMin:YU,atomicOr:JU,atomicStore:WU,atomicSub:XU,atomicXor:KU,attenuationColor:Cf,attenuationDistance:Nf,attribute:_i,backgroundBlurriness:Q3,backgroundIntensity:eD,batch:W1,billboarding:gU,bitAnd:I_,bitNot:L_,bitOr:P_,bitXor:D_,bitangentGeometry:fL,bitangentLocal:gL,bitangentView:n1,bitangentWorld:vL,bitcast:W2,bleach:wU,bloom:OD,blur:VT,bool:us,buffer:Kl,bufferAttribute:Yl,bumpMap:u1,burn:_U,bvec2:c_,bvec3:_f,bvec4:p_,bypass:PM,cache:$l,call:M_,cameraFar:po,cameraLogDepth:GM,cameraNear:ho,cameraNormalMatrix:Q2,cameraPosition:Jf,cameraProjectionMatrix:lr,cameraProjectionMatrixInverse:K2,cameraViewMatrix:cr,cameraWorldMatrix:Z2,cbrt:lM,ceil:Of,checker:ZU,cineonToneMapping:ES,clamp:li,clearcoat:Fh,clearcoatRoughness:Vl,code:gd,color:o_,colorSpaceToWorking:Xf,colorToDirection:$L,compute:RM,cond:pM,context:Gf,convert:f_,convertToTexture:Zi,cos:Tr,createCanvasElement:gv,cross:uo,cubeTexture:Zh,dFdx:$_,dFdy:J_,dashSize:Qs,defaultBuildStages:uf,defaultShaderStages:cf,defined:Ll,degrees:H_,denoise:RD,densityFog:eU,depth:gg,depthPass:cD,difference:nM,diffuseColor:Nt,directionToColor:cT,dispersion:Rf,distance:rM,div:Qr,dodge:MU,dof:xD,dot:qt,dotScreen:_D,drawIndex:z1,dynamicBufferAttribute:NM,element:m_,emissive:bf,equal:T_,equals:z_,equirectUV:vg,exp:Df,exp2:Gh,expression:ms,faceDirection:Jl,faceForward:uM,film:TD,float:E,floor:ds,fog:ZD,fract:ps,frameGroup:z2,frameId:V3,frontFacing:qM,fwidth:Q_,fxaa:ID,gain:uU,gapSize:kl,gaussianBlur:uD,getColorSpaceMethod:Xh,getConstNodeType:s_,getCurrentStack:xf,getDirection:OT,getDistanceAttenuation:i0,getGeometryRoughness:fT,getRoughness:xg,getShIrradianceAt:zS,getTextureIndex:qg,global:wd,glsl:o3,glslFn:l3,grayscale:dD,greaterThan:Lf,greaterThanEqual:E_,hash:cU,highPrecisionModelNormalViewMatrix:uL,highPrecisionModelViewMatrix:cL,hue:fD,instance:H1,instanceIndex:rc,instancedBufferAttribute:qh,instancedDynamicBufferAttribute:qf,int:P,inverseSqrt:G_,invocationLocalIndex:wL,invocationSubgroupIndex:SL,ior:Hl,iridescence:Bh,iridescenceIOR:Sf,iridescenceThickness:wf,ivec2:dn,ivec3:u_,ivec4:h_,js:s3,label:mM,length:ta,lengthSq:Bf,lessThan:S_,lessThanEqual:w_,lightPosition:n0,lightTargetDirection:s0,lightTargetPosition:vS,lightViewPosition:Cd,lightingContext:tT,lights:Z1,linearDepth:ad,linearSRGBTosRGB:bS,linearToneMapping:SS,localId:DU,log:Uf,log2:Gl,loop:NL,luminance:Ui,lut3D:bD,mat2:Ol,mat3:yi,mat4:$s,matcapUV:YT,materialAOMap:F1,materialAlphaTest:d1,materialAnisotropy:E1,materialAnisotropyVector:go,materialAttenuationColor:D1,materialAttenuationDistance:P1,materialClearcoat:_1,materialClearcoatNormal:T1,materialClearcoatRoughness:M1,materialColor:fo,materialDispersion:O1,materialEmissive:m1,materialIOR:L1,materialIridescence:A1,materialIridescenceIOR:N1,materialIridescenceThickness:C1,materialLightMap:lg,materialLineDashOffset:og,materialLineDashSize:sg,materialLineGapSize:ag,materialLineScale:rd,materialLineWidth:nd,materialMetalness:y1,materialNormal:x1,materialOpacity:td,materialPointWidth:U1,materialReference:rn,materialReflectivity:id,materialRefractionRatio:JM,materialRotation:b1,materialRoughness:v1,materialSheen:S1,materialSheenRoughness:w1,materialShininess:p1,materialSpecular:f1,materialSpecularColor:g1,materialSpecularIntensity:ng,materialSpecularStrength:ic,materialThickness:I1,materialTransmission:R1,max:ft,maxMipLevel:HM,metalness:Fl,min:xi,mix:rt,mixElement:hM,mod:jh,modInt:If,modelDirection:sL,modelNormalMatrix:WM,modelPosition:aL,modelScale:oL,modelViewMatrix:fn,modelViewPosition:lL,modelViewProjection:cg,modelWorldMatrix:zr,modelWorldMatrixInverse:jM,morphReference:J1,motionBlur:SU,mrt:_d,mul:lt,mx_aastep:FS,mx_cell_noise_float:aF,mx_contrast:QO,mx_fractal_noise_float:oF,mx_fractal_noise_vec2:lF,mx_fractal_noise_vec3:cF,mx_fractal_noise_vec4:uF,mx_hsvtorgb:WO,mx_noise_float:eF,mx_noise_vec3:tF,mx_noise_vec4:iF,mx_ramplr:qO,mx_ramptb:YO,mx_rgbtohsv:jO,mx_safepower:ZO,mx_splitlr:$O,mx_splittb:JO,mx_srgb_texture_to_lin_rec709:XO,mx_transform_uv:KO,mx_worley_noise_float:rF,mx_worley_noise_vec2:nF,mx_worley_noise_vec3:sF,negate:q_,neutralToneMapping:CS,nodeArray:Ys,nodeImmutable:ge,nodeObject:G,nodeObjects:Dl,nodeProxy:K,normalFlat:YM,normalGeometry:Jh,normalLocal:ur,normalMap:rg,normalView:hr,normalWorld:Kh,normalize:Mr,not:C_,notEqual:b_,numWorkgroups:LU,objectDirection:eL,objectGroup:v_,objectPosition:iL,objectScale:rL,objectViewPosition:nL,objectWorldMatrix:tL,oneMinus:Y_,or:N_,orthographicDepthToViewZ:FL,oscSawtooth:H3,oscSine:B3,oscSquare:z3,oscTriangle:k3,output:Ef,outputStruct:D3,overlay:bU,overloadingFn:Di,parabola:a0,parallaxBarrierPass:YD,parallaxDirection:a1,parallaxUV:xL,parameter:n3,pass:lD,passTexture:So,pcurve:hU,perspectiveDepthToViewZ:fg,pixelationPass:zD,pmremTexture:kT,pointUV:Z3,pointWidth:k2,positionGeometry:Li,positionLocal:Zt,positionPrevious:Yh,positionView:Pi,positionViewDirection:Vt,positionWorld:$h,positionWorldDirection:Kf,posterize:sD,pow:Ji,pow2:Vf,pow3:sM,pow4:aM,property:ar,radians:k_,rand:kf,range:tU,rangeFog:QD,reciprocal:Z_,reference:fi,referenceBuffer:tg,reflect:iM,reflectVector:QM,reflectView:KM,reflector:q3,refract:zf,refractVector:e1,refractView:ZM,reinhardToneMapping:wS,remainder:F_,remap:DM,remapClamp:UM,renderGroup:xt,renderOutput:BM,rendererReference:bM,rgbShift:MD,rotate:Lg,rotateUV:mU,roughness:pn,round:K_,rtt:Sb,sRGBToLinearSRGB:TS,sampler:J2,saturate:cM,saturation:pD,screen:TU,screenCoordinate:yo,screenSize:vo,screenUV:gs,scriptable:KD,scriptableValue:Sd,select:Ri,sepia:EU,setCurrentStack:Ul,shaderStages:hf,sharedUniformGroup:Tf,sheen:Ks,sheenRoughness:Vh,shiftLeft:U_,shiftRight:O_,shininess:kh,sign:Wl,sin:Ci,sinc:dU,skinning:EL,skinningReference:X1,smoothstep:Ki,smoothstepElement:dM,sobel:yD,specularColor:or,specularF90:zl,spherizeUV:fU,split:B2,spritesheetUV:G3,sqrt:en,ssaaPass:GD,stack:vd,step:jl,stereoPass:jD,storage:tD,storageBarrier:VU,storageObject:iD,storageTexture:Cb,string:F2,sub:Pt,subgroupIndex:bL,subgroupSize:UU,tan:W_,tangentGeometry:ed,tangentLocal:Ql,tangentView:ec,tangentWorld:r1,temp:Wf,texture:yt,texture3D:KT,textureBarrier:BU,textureBicubic:NT,textureCubeUV:FT,textureLoad:Br,textureSize:fs,textureStore:rD,thickness:Af,threshold:zb,timerDelta:F3,timerGlobal:O3,timerLocal:Yg,toOutputColorSpace:yM,toWorkingColorSpace:xM,toneMapping:wM,toneMappingExposure:EM,toonOutlinePass:$D,transformDirection:oM,transformNormal:$M,transformNormalToView:Qf,transformedBentNormalView:o1,transformedBitangentView:s1,transformedBitangentWorld:yL,transformedClearcoatNormalView:mo,transformedNormalView:Yt,transformedNormalWorld:Zf,transformedTangentView:ig,transformedTangentWorld:mL,transition:FD,transmission:Hh,transpose:eM,tri:yn,tri3:yS,triNoise3D:pU,triplanarTexture:j3,triplanarTextures:_b,trunc:Ff,tslFn:O2,uint:_e,uniform:fe,uniformArray:gn,uniformGroup:g_,uniforms:dL,userData:nD,uv:nt,uvec2:l_,uvec3:co,uvec4:d_,varying:Ii,varyingProperty:Zr,vec2:z,vec3:D,vec4:ae,vectorComponents:ao,velocity:xU,vertexColor:K3,vertexIndex:B1,vibrance:mD,viewZToOrthographicDepth:lc,viewZToPerspectiveDepth:oT,viewport:Dn,viewportBottomLeft:UL,viewportCoordinate:nT,viewportDepthTexture:mg,viewportLinearDepth:VL,viewportMipTexture:sT,viewportResolution:PL,viewportSafeUV:vU,viewportSharedTexture:aD,viewportSize:rT,viewportTexture:OL,viewportTopLeft:DL,viewportUV:LL,wgsl:a3,wgslFn:c3,workgroupArray:HU,workgroupBarrier:FU,workgroupId:PU,workingToColorSpace:_M,xor:R_},Symbol.toStringTag,{value:"Module"}));function xF(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("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 _F(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}export{Cc as ACESFilmicToneMapping,Co as AdditiveBlending,Rc as AgXToneMapping,Io as AlwaysDepth,lu as AlwaysStencilFunc,Sh as AmbientLight,so as AnimationClip,Sx as AnimationMixer,em as ArrayCamera,$m as Audio,Ah as AudioContext,xx as AudioListener,mx as AudioLoader,jx as AxesHelper,si as BackSide,fp as BasicDepthPacking,KS as BasicNodeLibrary,pm as BatchedMesh,Yu as Bone,as as BooleanKeyframeTrack,zi as Box3,Gx as Box3Helper,_n as BoxGeometry,Hx as BoxHelper,wt as BufferAttribute,ct as BufferGeometry,un as Cache,cl as Camera,kx as CameraHelper,Vy as CanvasTexture,bm as CatmullRomCurve3,gr as ClampToEdgeWrapping,Ym as Clock,xe as Color,xh as ColorKeyframeTrack,vt as ColorManagement,Oy as CompressedArrayTexture,Fy as CompressedCubeTexture,xl as CompressedTexture,qx as Controls,Lu as CubeCamera,Is as CubeTexture,Wn as CubeUVReflectionMapping,Or as Curve,Qd as CustomBlending,pa as CylinderGeometry,du as Data3DTexture,Ur as DataTexture,rx as DataTextureLoader,Iv as DataUtils,K0 as DecrementStencilOp,Q0 as DecrementWrapStencilOp,zm as DefaultLoadingManager,Yn as DepthFormat,$n as DepthStencilFormat,Fs as DepthTexture,bh as DirectionalLight,zx as DirectionalLightHelper,Wr as DoubleSide,Ss as DynamicDrawUsage,Rm as EdgesGeometry,Po as EqualDepth,rv as EqualStencilFunc,Hn as EquirectangularReflectionMapping,Gn as EquirectangularRefractionMapping,dr as Euler,vr as EventDispatcher,xc as ExtrudeGeometry,Kr as FileLoader,De as Float32BufferAttribute,Oi as FloatType,im as Fog,an as FrontSide,Ga as Frustum,cu as GLSL3,JS as GLSLNodeParser,Uo as GreaterDepth,Do as GreaterEqualDepth,ov as GreaterEqualStencilFunc,sv as GreaterStencilFunc,Fx as GridHelper,Vs as Group,wi as HalfFloatType,Mh as HemisphereLight,px as ImageBitmapLoader,J0 as IncrementStencilOp,Z0 as IncrementWrapStencilOp,Rn as InstancedBufferAttribute,Xm as InstancedBufferGeometry,Zm as InstancedInterleavedBuffer,cm as InstancedMesh,qa as InterleavedBuffer,Fn as InterleavedBufferAttribute,to as Interpolant,wa as InterpolateDiscrete,qo as InterpolateLinear,ev as InvertStencilOp,Jn as KeepStencilOp,Fr as KeyframeTrack,sm as LOD,sl as Layers,Lo as LessDepth,kn as LessEqualDepth,nv as LessEqualStencilFunc,iv as LessStencilFunc,In as Line,Lx as Line3,Ni as LineBasicMaterial,fm as LineLoop,Jr as LineSegments,Lt as LinearFilter,sp as LinearMipMapLinearFilter,Xi as LinearMipmapLinearFilter,Xn as LinearMipmapNearestFilter,nr as LinearSRGBColorSpace,Ac as LinearToneMapping,Gi as Loader,wh as LoaderUtils,_h as LoadingManager,dp as LoopOnce,pp as LoopRepeat,M0 as MOUSE,hi as Material,uu as MathUtils,Ke as Matrix3,Re as Matrix4,ep as MaxEquation,Ft as Mesh,$r as MeshBasicMaterial,ku as MeshDepthMaterial,vh as MeshLambertMaterial,gh as MeshNormalMaterial,fh as MeshPhongMaterial,mh as MeshPhysicalMaterial,El as MeshStandardMaterial,ga as MirroredRepeatWrapping,$t as NearestFilter,G0 as NearestMipMapNearestFilter,bn as NearestMipmapLinearFilter,Pc as NearestMipmapNearestFilter,Ic as NeutralToneMapping,Ro as NeverDepth,tv as NeverStencilFunc,Er as NoBlending,Cr as NoColorSpace,mr as NoToneMapping,qe as Node,pb as NodeBuilder,mb as NodeFrame,Tn as NormalBlending,Oo as NotEqualDepth,av as NotEqualStencilFunc,io as NumberKeyframeTrack,_t as Object3D,Ao as OctahedronGeometry,Ds as OrthographicCamera,Jd as PCFSoftShadowMap$1,Ou as PMREMGenerator$1,di as PerspectiveCamera,cn as Plane,da as PlaneGeometry,Th as PointLight,vm as Points,Qa as PointsMaterial,Mx as PositionalAudio,bt as PropertyBinding,Bi as Quaternion,ro as QuaternionKeyframeTrack,Bn as REVISION,gp as RGBADepthPacking,Ei as RGBAFormat,Wo as RGBA_ASTC_4x4_Format,jo as RGBA_ASTC_6x6_Format,Sa as RGBA_BPTC_Format,Go as RGBA_ETC2_EAC_Format,zo as RGBA_PVRTC_4BPPV1_Format,Ma as RGBA_S3TC_DXT1_Format,Ta as RGBA_S3TC_DXT3_Format,ba as RGBA_S3TC_DXT5_Format,Vc as RGBFormat,Xo as RGB_BPTC_UNSIGNED_Format,ko as RGB_ETC1_Format,Ho as RGB_ETC2_Format,Bo as RGB_PVRTC_4BPPV1_Format,_a as RGB_S3TC_DXT1_Format,xa as RGFormat,Dm as RawShaderMaterial,Cs as Ray,Ax as Raycaster,Fo as RedFormat,Nc as ReinhardToneMapping,jn as RepeatWrapping,$0 as ReplaceStencilOp,_c as RingGeometry,Fi as SRGBColorSpace,Hu as Scene,dt as ShaderChunk,Dr as ShaderLib,Pr as ShaderMaterial,ph as ShadowMaterial,ss as Shape,Xx as ShapePath,nn as ShapeUtils,vc as Skeleton,lm as SkinnedMesh,Kn as Source,Ai as Sphere,No as SphereGeometry,Cx as Spherical,Nl as SpotLight,nm as Sprite,hl as SpriteMaterial,yF as THREE,T0 as TOUCH,Wt as Texture,nx as TextureLoader,Mc as TorusGeometry,er as Triangle,q0 as TriangleFanDrawMode,X0 as TriangleStripDrawMode,j0 as TrianglesDrawMode,Tu as Uint16BufferAttribute,wx as Uniform$1,Me as UniformsLib,Hp as UniformsUtils,jr as UnsignedByteType,Fc as UnsignedInt101111Type,qn as UnsignedInt248Type,Oc as UnsignedInt5999Type,Nr as UnsignedIntType,J as Vector2,N as Vector3,st as Vector4,no as VectorKeyframeTrack,Uy as VideoTexture,Pu as WebGLCubeRenderTarget,Ir as WebGLRenderTarget,my as WebGLRenderer,Pm as WireframeGeometry,Y0 as ZeroStencilOp,xF as cloneUniforms,_F as cloneUniformsGroups,cf as defaultShaderStages,hr as normalView};
|