@needle-tools/engine 4.11.0-next.8bfb2f5 → 4.11.0

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/components.needle.json +1 -1
  3. package/dist/{gltf-progressive-CXVECA3a.js → gltf-progressive-BvlZQAkt.js} +3 -3
  4. package/dist/{gltf-progressive-D4Z_Khp3.min.js → gltf-progressive-CftVUJy3.min.js} +1 -1
  5. package/dist/{gltf-progressive-CHeORqEv.umd.cjs → gltf-progressive-GwdQV1Qx.umd.cjs} +1 -1
  6. package/dist/{needle-engine.bundle-lul9TfB2.js → needle-engine.bundle-Dh4X0Qy5.js} +6264 -6202
  7. package/dist/{needle-engine.bundle-8EmDJd2O.umd.cjs → needle-engine.bundle-DhRclTK5.umd.cjs} +142 -142
  8. package/dist/{needle-engine.bundle-DtF-fcok.min.js → needle-engine.bundle-IPerDSpg.min.js} +144 -144
  9. package/dist/needle-engine.d.ts +6 -0
  10. package/dist/needle-engine.js +4 -4
  11. package/dist/needle-engine.min.js +1 -1
  12. package/dist/needle-engine.umd.cjs +1 -1
  13. package/dist/{postprocessing-DQ2pynXW.js → postprocessing-CJC0Npcd.js} +2 -2
  14. package/dist/{postprocessing-BsnRNRRS.umd.cjs → postprocessing-DrM4PWU3.umd.cjs} +1 -1
  15. package/dist/{postprocessing-BHMVuZQ1.min.js → postprocessing-l7zsdO_Q.min.js} +1 -1
  16. package/dist/{three-qw28ZtTy.min.js → three-BDW9I486.min.js} +13 -13
  17. package/dist/{three-CJSAehtG.js → three-MHVqtJYj.js} +1 -0
  18. package/dist/{three-examples-Doq0rvFU.js → three-examples-C5Ht-QFN.js} +1 -1
  19. package/dist/{three-examples-Deqc1bNw.umd.cjs → three-examples-CgwGHSgz.umd.cjs} +1 -1
  20. package/dist/{three-examples-BivkhnvN.min.js → three-examples-fvEPSC8L.min.js} +1 -1
  21. package/dist/{three-B-jwTHao.umd.cjs → three-iFaDq9U3.umd.cjs} +13 -13
  22. package/dist/{three-mesh-ui-CktOi6oI.js → three-mesh-ui-BjWTTk1R.js} +1 -1
  23. package/dist/{three-mesh-ui-CsHwj9cJ.umd.cjs → three-mesh-ui-Bm32sS2a.umd.cjs} +1 -1
  24. package/dist/{three-mesh-ui-DhYXcXZe.min.js → three-mesh-ui-CLdkp21K.min.js} +1 -1
  25. package/dist/{vendor-BcsPRUmt.umd.cjs → vendor-CAWj5cBK.umd.cjs} +2 -2
  26. package/dist/{vendor-CyfN5nor.js → vendor-DJBpoQcM.js} +608 -599
  27. package/dist/{vendor-DyavoogU.min.js → vendor-DWGd3dEf.min.js} +20 -20
  28. package/lib/engine/js-extensions/Object3D.d.ts +6 -0
  29. package/lib/engine/js-extensions/Object3D.js +15 -0
  30. package/lib/engine/js-extensions/Object3D.js.map +1 -1
  31. package/lib/engine-components/Collider.d.ts +26 -0
  32. package/lib/engine-components/Collider.js +26 -0
  33. package/lib/engine-components/Collider.js.map +1 -1
  34. package/lib/engine-components/ContactShadows.d.ts +11 -2
  35. package/lib/engine-components/ContactShadows.js +11 -2
  36. package/lib/engine-components/ContactShadows.js.map +1 -1
  37. package/lib/engine-components/DropListener.d.ts +3 -0
  38. package/lib/engine-components/DropListener.js +44 -21
  39. package/lib/engine-components/DropListener.js.map +1 -1
  40. package/lib/engine-components/Duplicatable.d.ts +2 -2
  41. package/lib/engine-components/Duplicatable.js +2 -2
  42. package/lib/engine-components/EventList.d.ts +18 -1
  43. package/lib/engine-components/EventList.js +18 -1
  44. package/lib/engine-components/EventList.js.map +1 -1
  45. package/lib/engine-components/GroundProjection.d.ts +3 -0
  46. package/lib/engine-components/GroundProjection.js +3 -0
  47. package/lib/engine-components/GroundProjection.js.map +1 -1
  48. package/lib/engine-components/Interactable.d.ts +4 -0
  49. package/lib/engine-components/Interactable.js +4 -0
  50. package/lib/engine-components/Interactable.js.map +1 -1
  51. package/lib/engine-components/OrbitControls.d.ts +4 -2
  52. package/lib/engine-components/OrbitControls.js +31 -3
  53. package/lib/engine-components/OrbitControls.js.map +1 -1
  54. package/lib/engine-components/RigidBody.d.ts +5 -0
  55. package/lib/engine-components/RigidBody.js +5 -0
  56. package/lib/engine-components/RigidBody.js.map +1 -1
  57. package/lib/engine-components/SeeThrough.js +20 -0
  58. package/lib/engine-components/SeeThrough.js.map +1 -1
  59. package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +4 -2
  60. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +69 -14
  61. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
  62. package/lib/engine-components/ui/Text.js +6 -1
  63. package/lib/engine-components/ui/Text.js.map +1 -1
  64. package/lib/engine-components/utils/LookAt.d.ts +3 -0
  65. package/lib/engine-components/utils/LookAt.js +3 -0
  66. package/lib/engine-components/utils/LookAt.js.map +1 -1
  67. package/lib/engine-components/utils/OpenURL.d.ts +2 -1
  68. package/lib/engine-components/utils/OpenURL.js +2 -1
  69. package/lib/engine-components/utils/OpenURL.js.map +1 -1
  70. package/lib/engine-components/web/ScrollFollow.js +1 -2
  71. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  72. package/lib/engine-components/webxr/WebARCameraBackground.d.ts +2 -0
  73. package/lib/engine-components/webxr/WebARCameraBackground.js +2 -0
  74. package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
  75. package/lib/engine-components/webxr/WebARSessionRoot.d.ts +1 -1
  76. package/lib/engine-components/webxr/WebARSessionRoot.js +1 -1
  77. package/lib/engine-components/webxr/WebXR.d.ts +2 -0
  78. package/lib/engine-components/webxr/WebXR.js +2 -0
  79. package/lib/engine-components/webxr/WebXR.js.map +1 -1
  80. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +29 -0
  81. package/lib/engine-components/webxr/WebXRImageTracking.js +29 -0
  82. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  83. package/package.json +3 -3
  84. package/plugins/vite/index.js +4 -1
  85. package/plugins/vite/needle-app.js +103 -57
  86. package/src/engine/js-extensions/Object3D.ts +24 -0
  87. package/src/engine-components/Collider.ts +27 -1
  88. package/src/engine-components/ContactShadows.ts +12 -4
  89. package/src/engine-components/DropListener.ts +45 -24
  90. package/src/engine-components/Duplicatable.ts +2 -2
  91. package/src/engine-components/EventList.ts +18 -1
  92. package/src/engine-components/GroundProjection.ts +4 -1
  93. package/src/engine-components/Interactable.ts +4 -1
  94. package/src/engine-components/OrbitControls.ts +27 -3
  95. package/src/engine-components/RigidBody.ts +6 -1
  96. package/src/engine-components/SeeThrough.ts +42 -2
  97. package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +117 -17
  98. package/src/engine-components/ui/Text.ts +11 -2
  99. package/src/engine-components/utils/LookAt.ts +3 -0
  100. package/src/engine-components/utils/OpenURL.ts +3 -2
  101. package/src/engine-components/web/ScrollFollow.ts +1 -1
  102. package/src/engine-components/webxr/WebARCameraBackground.ts +2 -0
  103. package/src/engine-components/webxr/WebARSessionRoot.ts +1 -1
  104. package/src/engine-components/webxr/WebXR.ts +2 -0
  105. package/src/engine-components/webxr/WebXRImageTracking.ts +30 -3
@@ -2,11 +2,11 @@
2
2
  * @license
3
3
  * Copyright 2010-2024 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
- */const QS="169",g0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},v0={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},y0=0,Wd=1,x0=2,ew=3,tw=0,jd=1,Xd=2,rr=3,an=0,si=1,Wr=2,Er=0,_n=1,Ao=2,qd=3,Yd=4,$d=5,Vn=100,_0=101,M0=102,T0=103,Jd=104,b0=200,S0=201,w0=202,E0=203,bc=204,Sc=205,A0=206,N0=207,C0=208,R0=209,I0=210,L0=211,P0=212,D0=213,U0=214,No=0,Co=1,Ro=2,Bn=3,Io=4,Lo=5,Po=6,Do=7,pa=0,Kd=1,Zd=2,mr=0,wc=1,Ec=2,Qd=3,Ac=4,O0=5,Nc=6,Cc=7,ep="attached",F0="detached",Rc=300,fr=301,Ar=302,zn=303,kn=304,Hn=306,Gn=1e3,gr=1001,ma=1002,$t=1003,Ic=1004,iw=1004,Mn=1005,rw=1005,Lt=1006,Wn=1007,nw=1007,ji=1008,V0=1008,jr=1009,tp=1010,ip=1011,fa=1012,ga=1013,Nr=1014,Oi=1015,wi=1016,Lc=1017,Pc=1018,jn=1020,Dc=35902,Uc=35899,rp=1021,Oc=1022,Ei=1023,np=1024,sp=1025,Xn=1026,qn=1027,Uo=1028,Oo=1029,va=1030,Fc=1031,sw=1032,Vc=1033,ya=33776,xa=33777,_a=33778,Ma=33779,Fo=35840,Bc=35841,Vo=35842,zc=35843,Bo=36196,zo=37492,ko=37496,Ho=37808,kc=37809,Hc=37810,Gc=37811,Go=37812,Wc=37813,jc=37814,Xc=37815,qc=37816,Yc=37817,$c=37818,Jc=37819,Kc=37820,Zc=37821,Ta=36492,Qc=36494,Wo=36495,ap=36283,eu=36284,tu=36285,iu=36286,op=2200,lp=2201,B0=2202,ba=2300,jo=2301,ru=2302,xs=2400,_s=2401,Xo=2402,nu=2500,cp=2501,z0=0,k0=1,H0=2,up=3200,hp=3201,aw=3202,ow=3203,on=0,dp=1,Cr="",Fi="srgb",nr="srgb-linear",su="display-p3",qo="display-p3-linear",Yo="linear",Ot="srgb",$o="rec709",Jo="p3",G0=0,Yn=7680,W0=7681,j0=7682,X0=7683,q0=34055,Y0=34056,$0=5386,J0=512,K0=513,Z0=514,Q0=515,ev=516,tv=517,iv=518,au=519,rv=512,pp=513,nv=514,mp=515,sv=516,av=517,ov=518,lv=519,Sa=35044,Ms=35048,lw=35040,cw=35045,uw=35049,hw=35041,dw=35046,pw=35050,mw=35042,fw="100",ou="300 es",Rr=2e3,Ts=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 cv=1234567;const bs=Math.PI/180,wa=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 fp(n,e){return(n%e+e)%e}function gw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function vw(n,e,t){return n!==e?(t-n)/(e-n):0}function Ko(n,e,t){return(1-t)*n+t*e}function yw(n,e,t,i){return Ko(n,e,1-Math.exp(-t*i))}function xw(n,e=1){return e-Math.abs(fp(n,e*2)-e)}function _w(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function Mw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Tw(n,e){return n+Math.floor(Math.random()*(e-n+1))}function bw(n,e){return n+Math.random()*(e-n)}function Sw(n){return n*(.5-Math.random())}function ww(n){n!==void 0&&(cv=n);let e=cv+=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 Ew(n){return n*bs}function Aw(n){return n*wa}function Nw(n){return(n&n-1)===0&&n!==0}function Cw(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Rw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Iw(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 Xi(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 lu={DEG2RAD:bs,RAD2DEG:wa,generateUUID:yr,clamp:Jt,euclideanModulo:fp,mapLinear:gw,inverseLerp:vw,lerp:Ko,damp:yw,pingpong:xw,smoothstep:_w,smootherstep:Mw,randInt:Tw,randFloat:bw,randFloatSpread:Sw,seededRandom:ww,degToRad:Ew,radToDeg:Aw,isPowerOfTwo:Nw,ceilPowerOfTwo:Cw,floorPowerOfTwo:Rw,setQuaternionFromProperEuler:Iw,normalize:ht,denormalize:Xi};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(gp.makeScale(e,t)),this}rotate(e){return this.premultiply(gp.makeRotation(-e)),this}translate(e,t){return this.premultiply(gp.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 gp=new Ke;function uv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const Lw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ea(n,e){return new Lw[n](e)}function Zo(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function hv(){const n=Zo("canvas");return n.style.display="block",n}const dv={};function cu(n){n in dv||(dv[n]=!0,console.warn(n))}function Pw(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 Dw(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 Uw(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 pv=new Ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),mv=new Ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Qo={[nr]:{transfer:Yo,primaries:$o,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n,fromReference:n=>n},[Fi]:{transfer:Ot,primaries:$o,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[qo]:{transfer:Yo,primaries:Jo,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.applyMatrix3(mv),fromReference:n=>n.applyMatrix3(pv)},[su]:{transfer:Ot,primaries:Jo,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.convertSRGBToLinear().applyMatrix3(mv),fromReference:n=>n.applyMatrix3(pv).convertLinearToSRGB()}},Ow=new Set([nr,qo]),vt={enabled:!0,_workingColorSpace:nr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Ow.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=Qo[e].toReference,r=Qo[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 Qo[n].primaries},getTransfer:function(n){return n===Cr?Yo:Qo[n].transfer},getLuminanceCoefficients:function(n,e=this._workingColorSpace){return n.fromArray(Qo[e].luminanceCoefficients)}};function Aa(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function vp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Na;class fv{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Na===void 0&&(Na=Zo("canvas")),Na.width=e.width,Na.height=e.height;const i=Na.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Na}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=Zo("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]=Aa(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(Aa(t[i]/255)*255):t[i]=Aa(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 Fw=0;class $n{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Fw++}),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(yp(r[a].image)):s.push(yp(r[a]))}else s=yp(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function yp(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?fv.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 Vw=0;class Wt extends vr{constructor(e=Wt.DEFAULT_IMAGE,t=Wt.DEFAULT_MAPPING,i=gr,r=gr,s=Lt,a=ji,o=Ei,l=jr,c=Wt.DEFAULT_ANISOTROPY,u=Cr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Vw++}),this.uuid=yr(),this.name="",this.source=new $n(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!==Rc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Gn:e.x=e.x-Math.floor(e.x);break;case gr:e.x=e.x<0?0:1;break;case ma:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Gn:e.y=e.y-Math.floor(e.y);break;case gr:e.y=e.y<0?0:1;break;case ma:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Wt.DEFAULT_IMAGE=null,Wt.DEFAULT_MAPPING=Rc,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 $n(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 el 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 Bw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new el(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class uu 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 zw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new uu(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class qi{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(gv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(gv.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 xp.copy(this).projectOnVector(e),this.sub(xp)}reflect(e){return this.sub(xp.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 xp=new N,gv=new qi;class Bi{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(),hu.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),hu.copy(i.boundingBox)),hu.applyMatrix4(e.matrixWorld),this.union(hu)}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(tl),du.subVectors(this.max,tl),Ca.subVectors(e.a,tl),Ra.subVectors(e.b,tl),Ia.subVectors(e.c,tl),Jn.subVectors(Ra,Ca),Kn.subVectors(Ia,Ra),Ss.subVectors(Ca,Ia);let t=[0,-Jn.z,Jn.y,0,-Kn.z,Kn.y,0,-Ss.z,Ss.y,Jn.z,0,-Jn.x,Kn.z,0,-Kn.x,Ss.z,0,-Ss.x,-Jn.y,Jn.x,0,-Kn.y,Kn.x,0,-Ss.y,Ss.x,0];return!_p(t,Ca,Ra,Ia,du)||(t=[1,0,0,0,1,0,0,0,1],!_p(t,Ca,Ra,Ia,du))?!1:(pu.crossVectors(Jn,Kn),t=[pu.x,pu.y,pu.z],_p(t,Ca,Ra,Ia,du))}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:(Tn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Tn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Tn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Tn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Tn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Tn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Tn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Tn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Tn),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 Tn=[new N,new N,new N,new N,new N,new N,new N,new N],Xr=new N,hu=new Bi,Ca=new N,Ra=new N,Ia=new N,Jn=new N,Kn=new N,Ss=new N,tl=new N,du=new N,pu=new N,ws=new N;function _p(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){ws.fromArray(n,s);const o=r.x*Math.abs(ws.x)+r.y*Math.abs(ws.y)+r.z*Math.abs(ws.z),l=e.dot(ws),c=t.dot(ws),u=i.dot(ws);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const kw=new Bi,il=new N,Mp=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):kw.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;il.subVectors(e,this.center);const t=il.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(il,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):(Mp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(il.copy(e.center).add(Mp)),this.expandByPoint(il.copy(e.center).sub(Mp))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const bn=new N,Tp=new N,mu=new N,Zn=new N,bp=new N,fu=new N,Sp=new N;class Es{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,bn)),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=bn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(bn.copy(this.origin).addScaledVector(this.direction,t),bn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Tp.copy(e).add(t).multiplyScalar(.5),mu.copy(t).sub(e).normalize(),Zn.copy(this.origin).sub(Tp);const s=e.distanceTo(t)*.5,a=-this.direction.dot(mu),o=Zn.dot(this.direction),l=-Zn.dot(mu),c=Zn.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(Tp).addScaledVector(mu,d),p}intersectSphere(e,t){bn.subVectors(e.center,this.origin);const i=bn.dot(this.direction),r=bn.dot(bn)-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,bn)!==null}intersectTriangle(e,t,i,r,s){bp.subVectors(t,e),fu.subVectors(i,e),Sp.crossVectors(bp,fu);let a=this.direction.dot(Sp),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Zn.subVectors(this.origin,e);const l=o*this.direction.dot(fu.crossVectors(Zn,fu));if(l<0)return null;const c=o*this.direction.dot(bp.cross(Zn));if(c<0||l+c>a)return null;const u=-o*Zn.dot(Sp);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/La.setFromMatrixColumn(e,0).length(),s=1/La.setFromMatrixColumn(e,1).length(),a=1/La.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(Hw,e,Gw)}lookAt(e,t,i){const r=this.elements;return xr.subVectors(e,t),xr.lengthSq()===0&&(xr.z=1),xr.normalize(),Qn.crossVectors(i,xr),Qn.lengthSq()===0&&(Math.abs(i.z)===1?xr.x+=1e-4:xr.z+=1e-4,xr.normalize(),Qn.crossVectors(i,xr)),Qn.normalize(),gu.crossVectors(xr,Qn),r[0]=Qn.x,r[4]=gu.x,r[8]=xr.x,r[1]=Qn.y,r[5]=gu.y,r[9]=xr.y,r[2]=Qn.z,r[6]=gu.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=La.set(r[0],r[1],r[2]).length();const a=La.set(r[4],r[5],r[6]).length(),o=La.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===Ts)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===Ts)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 La=new N,qr=new Re,Hw=new N(0,0,0),Gw=new N(1,1,1),Qn=new N,gu=new N,xr=new N,vv=new Re,yv=new qi;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 vv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(vv,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return yv.setFromEuler(this),this.setFromQuaternion(yv,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 rl{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 Ww=0;const xv=new N,Pa=new qi,Sn=new Re,vu=new N,nl=new N,jw=new N,Xw=new qi,_v=new N(1,0,0),Mv=new N(0,1,0),Tv=new N(0,0,1),bv={type:"added"},qw={type:"removed"},Da={type:"childadded",child:null},wp={type:"childremoved",child:null};class _t extends vr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ww++}),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 qi,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 rl,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 Pa.setFromAxisAngle(e,t),this.quaternion.multiply(Pa),this}rotateOnWorldAxis(e,t){return Pa.setFromAxisAngle(e,t),this.quaternion.premultiply(Pa),this}rotateX(e){return this.rotateOnAxis(_v,e)}rotateY(e){return this.rotateOnAxis(Mv,e)}rotateZ(e){return this.rotateOnAxis(Tv,e)}translateOnAxis(e,t){return xv.copy(e).applyQuaternion(this.quaternion),this.position.add(xv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(_v,e)}translateY(e){return this.translateOnAxis(Mv,e)}translateZ(e){return this.translateOnAxis(Tv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Sn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?vu.copy(e):vu.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),nl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Sn.lookAt(nl,vu,this.up):Sn.lookAt(vu,nl,this.up),this.quaternion.setFromRotationMatrix(Sn),r&&(Sn.extractRotation(r.matrixWorld),Pa.setFromRotationMatrix(Sn),this.quaternion.premultiply(Pa.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(bv),Da.child=e,this.dispatchEvent(Da),Da.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(qw),wp.child=e,this.dispatchEvent(wp),wp.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),Sn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Sn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Sn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(bv),Da.child=e,this.dispatchEvent(Da),Da.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(nl,e,jw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,Xw,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,wn=new N,Ep=new N,En=new N,Ua=new N,Oa=new N,Sv=new N,Ap=new N,Np=new N,Cp=new N,Rp=new st,Ip=new st,Lp=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),wn.subVectors(i,t),Ep.subVectors(e,t);const a=Yr.dot(Yr),o=Yr.dot(wn),l=Yr.dot(Ep),c=wn.dot(wn),u=wn.dot(Ep),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,En)===null?!1:En.x>=0&&En.y>=0&&En.x+En.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,En)===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,En.x),l.addScaledVector(a,En.y),l.addScaledVector(o,En.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return Rp.setScalar(0),Ip.setScalar(0),Lp.setScalar(0),Rp.fromBufferAttribute(e,t),Ip.fromBufferAttribute(e,i),Lp.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Rp,s.x),a.addScaledVector(Ip,s.y),a.addScaledVector(Lp,s.z),a}static isFrontFacing(e,t,i,r){return Yr.subVectors(i,t),wn.subVectors(e,t),Yr.cross(wn).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),wn.subVectors(this.a,this.b),Yr.cross(wn).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;Ua.subVectors(r,i),Oa.subVectors(s,i),Ap.subVectors(e,i);const l=Ua.dot(Ap),c=Oa.dot(Ap);if(l<=0&&c<=0)return t.copy(i);Np.subVectors(e,r);const u=Ua.dot(Np),h=Oa.dot(Np);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(Ua,a);Cp.subVectors(e,s);const p=Ua.dot(Cp),m=Oa.dot(Cp);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(Oa,o);const f=u*m-p*h;if(f<=0&&h-u>=0&&p-m>=0)return Sv.subVectors(s,r),o=(h-u)/(h-u+(p-m)),t.copy(r).addScaledVector(Sv,o);const g=1/(f+v+d);return a=v*g,o=d*g,t.copy(i).addScaledVector(Ua,a).addScaledVector(Oa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const wv={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},es={h:0,s:0,l:0},yu={h:0,s:0,l:0};function Pp(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=fp(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=Pp(a,s,e+1/3),this.g=Pp(a,s,e),this.b=Pp(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=wv[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=Aa(e.r),this.g=Aa(e.g),this.b=Aa(e.b),this}copyLinearToSRGB(e){return this.r=vp(e.r),this.g=vp(e.g),this.b=vp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fi){return vt.fromWorkingColorSpace(zi.copy(this),e),Math.round(Jt(zi.r*255,0,255))*65536+Math.round(Jt(zi.g*255,0,255))*256+Math.round(Jt(zi.b*255,0,255))}getHexString(e=Fi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vt.workingColorSpace){vt.fromWorkingColorSpace(zi.copy(this),t);const i=zi.r,r=zi.g,s=zi.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(zi.copy(this),t),e.r=zi.r,e.g=zi.g,e.b=zi.b,e}getStyle(e=Fi){vt.fromWorkingColorSpace(zi.copy(this),e);const t=zi.r,i=zi.g,r=zi.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(es),this.setHSL(es.h+e,es.s+t,es.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(es),e.getHSL(yu);const i=Ko(es.h,yu.h,t),r=Ko(es.s,yu.s,t),s=Ko(es.l,yu.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 zi=new xe;xe.NAMES=wv;let Yw=0;class hi extends vr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Yw++}),this.uuid=yr(),this.name="",this.type="Material",this.blending=_n,this.side=an,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bc,this.blendDst=Sc,this.blendEquation=Vn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xe(0,0,0),this.blendAlpha=0,this.depthFunc=Bn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=au,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yn,this.stencilZFail=Yn,this.stencilZPass=Yn,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!==_n&&(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!==bc&&(i.blendSrc=this.blendSrc),this.blendDst!==Sc&&(i.blendDst=this.blendDst),this.blendEquation!==Vn&&(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!==Bn&&(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!==au&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yn&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Yn&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Yn&&(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=pa,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 An=$w();function $w(){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),An.floatView[0]=n;const e=An.uint32View[0],t=e>>23&511;return An.baseTable[t]+((e&8388607)>>An.shiftTable[t])}function sl(n){const e=n>>10;return An.uint32View[0]=An.mantissaTable[An.offsetTable[e]+(n&1023)]+An.exponentTable[e],An.floatView[0]}const Ev={toHalfFloat:sr,fromHalfFloat:sl},ai=new N,xu=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=Sa,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++)xu.fromBufferAttribute(this,t),xu.applyMatrix3(e),this.setXY(t,xu.x,xu.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=Xi(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=Xi(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=Xi(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=Xi(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=Xi(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!==Sa&&(e.usage=this.usage),e}}class Jw extends wt{constructor(e,t,i){super(new Int8Array(e),t,i)}}class Kw extends wt{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class Zw extends wt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class Qw extends wt{constructor(e,t,i){super(new Int16Array(e),t,i)}}class _u extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class eE extends wt{constructor(e,t,i){super(new Int32Array(e),t,i)}}class Dp extends wt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Av extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=sl(this.array[e*this.itemSize]);return this.normalized&&(t=Xi(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=sl(this.array[e*this.itemSize+1]);return this.normalized&&(t=Xi(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=sl(this.array[e*this.itemSize+2]);return this.normalized&&(t=Xi(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=sl(this.array[e*this.itemSize+3]);return this.normalized&&(t=Xi(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 tE=0;const Lr=new Re,Up=new _t,Fa=new N,_r=new Bi,al=new Bi,vi=new N;class ct extends vr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:tE++}),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(uv(e)?Dp:_u)(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 Up.lookAt(e),Up.updateMatrix(),this.applyMatrix4(Up.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fa).negate(),this.translate(Fa.x,Fa.y,Fa.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 Bi);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];al.setFromBufferAttribute(o),this.morphTargetsRelative?(vi.addVectors(_r.min,al.min),_r.expandByPoint(vi),vi.addVectors(_r.max,al.max),_r.expandByPoint(vi)):(_r.expandByPoint(al.min),_r.expandByPoint(al.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&&(Fa.fromBufferAttribute(e,c),vi.add(Fa)),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 Nv=new Re,As=new Es,Mu=new Ai,Cv=new N,Tu=new N,bu=new N,Su=new N,Op=new N,wu=new N,Rv=new N,Eu=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){wu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],h=s[l];u!==0&&(Op.fromBufferAttribute(h,e),a?wu.addScaledVector(Op,u):wu.addScaledVector(Op.sub(t),u))}t.add(wu)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Mu.copy(i.boundingSphere),Mu.applyMatrix4(s),As.copy(e.ray).recast(e.near),!(Mu.containsPoint(As.origin)===!1&&(As.intersectSphere(Mu,Cv)===null||As.origin.distanceToSquared(Cv)>(e.far-e.near)**2))&&(Nv.copy(s).invert(),As.copy(e.ray).applyMatrix4(Nv),!(i.boundingBox!==null&&As.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,As)))}_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=Au(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=Au(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=Au(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=Au(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}}function iE(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;Eu.copy(o),Eu.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Eu);return c<t.near||c>t.far?null:{distance:c,point:Eu.clone(),object:n}}function Au(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,Tu),n.getVertexPosition(l,bu),n.getVertexPosition(c,Su);const u=iE(n,e,t,i,Tu,bu,Su,Rv);if(u){const h=new N;er.getBarycoord(Rv,Tu,bu,Su,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(Tu,bu,Su,d.normal),u.face=d,u.barycoord=h}return u}class yn 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 yn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Va(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=Va(n[t]);for(const r in i)e[r]=i[r]}return e}function rE(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Iv(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:vt.workingColorSpace}const Fp={clone:Va,merge:Yi};var nE=`void main() {
5
+ */const QS="169",g0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},v0={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},y0=0,Wd=1,x0=2,ew=3,tw=0,jd=1,Xd=2,rr=3,an=0,si=1,Wr=2,Er=0,_n=1,Ao=2,qd=3,Yd=4,$d=5,Vn=100,_0=101,M0=102,T0=103,Jd=104,b0=200,S0=201,w0=202,E0=203,bc=204,Sc=205,A0=206,N0=207,C0=208,R0=209,I0=210,L0=211,P0=212,D0=213,U0=214,No=0,Co=1,Ro=2,Bn=3,Io=4,Lo=5,Po=6,Do=7,pa=0,Kd=1,Zd=2,mr=0,wc=1,Ec=2,Qd=3,Ac=4,O0=5,Nc=6,Cc=7,ep="attached",F0="detached",Rc=300,fr=301,Ar=302,zn=303,kn=304,Hn=306,Gn=1e3,gr=1001,ma=1002,$t=1003,Ic=1004,iw=1004,Mn=1005,rw=1005,Lt=1006,Wn=1007,nw=1007,ji=1008,V0=1008,jr=1009,tp=1010,ip=1011,fa=1012,ga=1013,Nr=1014,Oi=1015,wi=1016,Lc=1017,Pc=1018,jn=1020,Dc=35902,Uc=35899,rp=1021,Oc=1022,Ei=1023,np=1024,sp=1025,Xn=1026,qn=1027,Uo=1028,Oo=1029,va=1030,Fc=1031,sw=1032,Vc=1033,ya=33776,xa=33777,_a=33778,Ma=33779,Fo=35840,Bc=35841,Vo=35842,zc=35843,Bo=36196,zo=37492,ko=37496,Ho=37808,kc=37809,Hc=37810,Gc=37811,Go=37812,Wc=37813,jc=37814,Xc=37815,qc=37816,Yc=37817,$c=37818,Jc=37819,Kc=37820,Zc=37821,Ta=36492,Qc=36494,Wo=36495,ap=36283,eu=36284,tu=36285,iu=36286,op=2200,lp=2201,B0=2202,ba=2300,jo=2301,ru=2302,_s=2400,Ms=2401,Xo=2402,nu=2500,cp=2501,z0=0,k0=1,H0=2,up=3200,hp=3201,aw=3202,ow=3203,on=0,dp=1,Cr="",Fi="srgb",nr="srgb-linear",su="display-p3",qo="display-p3-linear",Yo="linear",Ot="srgb",$o="rec709",Jo="p3",G0=0,Yn=7680,W0=7681,j0=7682,X0=7683,q0=34055,Y0=34056,$0=5386,J0=512,K0=513,Z0=514,Q0=515,ev=516,tv=517,iv=518,au=519,rv=512,pp=513,nv=514,mp=515,sv=516,av=517,ov=518,lv=519,Sa=35044,Ts=35048,lw=35040,cw=35045,uw=35049,hw=35041,dw=35046,pw=35050,mw=35042,fw="100",ou="300 es",Rr=2e3,bs=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 cv=1234567;const Ss=Math.PI/180,wa=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 fp(n,e){return(n%e+e)%e}function gw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function vw(n,e,t){return n!==e?(t-n)/(e-n):0}function Ko(n,e,t){return(1-t)*n+t*e}function yw(n,e,t,i){return Ko(n,e,1-Math.exp(-t*i))}function xw(n,e=1){return e-Math.abs(fp(n,e*2)-e)}function _w(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function Mw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Tw(n,e){return n+Math.floor(Math.random()*(e-n+1))}function bw(n,e){return n+Math.random()*(e-n)}function Sw(n){return n*(.5-Math.random())}function ww(n){n!==void 0&&(cv=n);let e=cv+=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 Ew(n){return n*Ss}function Aw(n){return n*wa}function Nw(n){return(n&n-1)===0&&n!==0}function Cw(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Rw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Iw(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 Xi(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 lu={DEG2RAD:Ss,RAD2DEG:wa,generateUUID:yr,clamp:Jt,euclideanModulo:fp,mapLinear:gw,inverseLerp:vw,lerp:Ko,damp:yw,pingpong:xw,smoothstep:_w,smootherstep:Mw,randInt:Tw,randFloat:bw,randFloatSpread:Sw,seededRandom:ww,degToRad:Ew,radToDeg:Aw,isPowerOfTwo:Nw,ceilPowerOfTwo:Cw,floorPowerOfTwo:Rw,setQuaternionFromProperEuler:Iw,normalize:ht,denormalize:Xi};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(gp.makeScale(e,t)),this}rotate(e){return this.premultiply(gp.makeRotation(-e)),this}translate(e,t){return this.premultiply(gp.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 gp=new Ke;function uv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const Lw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ea(n,e){return new Lw[n](e)}function Zo(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function hv(){const n=Zo("canvas");return n.style.display="block",n}const dv={};function cu(n){n in dv||(dv[n]=!0,console.warn(n))}function Pw(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 Dw(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 Uw(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 pv=new Ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),mv=new Ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Qo={[nr]:{transfer:Yo,primaries:$o,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n,fromReference:n=>n},[Fi]:{transfer:Ot,primaries:$o,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[qo]:{transfer:Yo,primaries:Jo,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.applyMatrix3(mv),fromReference:n=>n.applyMatrix3(pv)},[su]:{transfer:Ot,primaries:Jo,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.convertSRGBToLinear().applyMatrix3(mv),fromReference:n=>n.applyMatrix3(pv).convertLinearToSRGB()}},Ow=new Set([nr,qo]),vt={enabled:!0,_workingColorSpace:nr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Ow.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=Qo[e].toReference,r=Qo[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 Qo[n].primaries},getTransfer:function(n){return n===Cr?Yo:Qo[n].transfer},getLuminanceCoefficients:function(n,e=this._workingColorSpace){return n.fromArray(Qo[e].luminanceCoefficients)}};function Aa(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function vp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Na;class fv{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Na===void 0&&(Na=Zo("canvas")),Na.width=e.width,Na.height=e.height;const i=Na.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Na}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=Zo("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]=Aa(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(Aa(t[i]/255)*255):t[i]=Aa(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 Fw=0;class $n{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Fw++}),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(yp(r[a].image)):s.push(yp(r[a]))}else s=yp(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function yp(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?fv.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 Vw=0;class Wt extends vr{constructor(e=Wt.DEFAULT_IMAGE,t=Wt.DEFAULT_MAPPING,i=gr,r=gr,s=Lt,a=ji,o=Ei,l=jr,c=Wt.DEFAULT_ANISOTROPY,u=Cr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Vw++}),this.uuid=yr(),this.name="",this.source=new $n(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!==Rc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Gn:e.x=e.x-Math.floor(e.x);break;case gr:e.x=e.x<0?0:1;break;case ma:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Gn:e.y=e.y-Math.floor(e.y);break;case gr:e.y=e.y<0?0:1;break;case ma:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Wt.DEFAULT_IMAGE=null,Wt.DEFAULT_MAPPING=Rc,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 $n(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 el 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 Bw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new el(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class uu 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 zw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new uu(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class qi{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(gv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(gv.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 xp.copy(this).projectOnVector(e),this.sub(xp)}reflect(e){return this.sub(xp.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 xp=new N,gv=new qi;class Bi{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(),hu.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),hu.copy(i.boundingBox)),hu.applyMatrix4(e.matrixWorld),this.union(hu)}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(tl),du.subVectors(this.max,tl),Ca.subVectors(e.a,tl),Ra.subVectors(e.b,tl),Ia.subVectors(e.c,tl),Jn.subVectors(Ra,Ca),Kn.subVectors(Ia,Ra),ws.subVectors(Ca,Ia);let t=[0,-Jn.z,Jn.y,0,-Kn.z,Kn.y,0,-ws.z,ws.y,Jn.z,0,-Jn.x,Kn.z,0,-Kn.x,ws.z,0,-ws.x,-Jn.y,Jn.x,0,-Kn.y,Kn.x,0,-ws.y,ws.x,0];return!_p(t,Ca,Ra,Ia,du)||(t=[1,0,0,0,1,0,0,0,1],!_p(t,Ca,Ra,Ia,du))?!1:(pu.crossVectors(Jn,Kn),t=[pu.x,pu.y,pu.z],_p(t,Ca,Ra,Ia,du))}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:(Tn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Tn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Tn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Tn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Tn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Tn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Tn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Tn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Tn),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 Tn=[new N,new N,new N,new N,new N,new N,new N,new N],Xr=new N,hu=new Bi,Ca=new N,Ra=new N,Ia=new N,Jn=new N,Kn=new N,ws=new N,tl=new N,du=new N,pu=new N,Es=new N;function _p(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Es.fromArray(n,s);const o=r.x*Math.abs(Es.x)+r.y*Math.abs(Es.y)+r.z*Math.abs(Es.z),l=e.dot(Es),c=t.dot(Es),u=i.dot(Es);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const kw=new Bi,il=new N,Mp=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):kw.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;il.subVectors(e,this.center);const t=il.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(il,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):(Mp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(il.copy(e.center).add(Mp)),this.expandByPoint(il.copy(e.center).sub(Mp))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const bn=new N,Tp=new N,mu=new N,Zn=new N,bp=new N,fu=new N,Sp=new N;class As{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,bn)),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=bn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(bn.copy(this.origin).addScaledVector(this.direction,t),bn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Tp.copy(e).add(t).multiplyScalar(.5),mu.copy(t).sub(e).normalize(),Zn.copy(this.origin).sub(Tp);const s=e.distanceTo(t)*.5,a=-this.direction.dot(mu),o=Zn.dot(this.direction),l=-Zn.dot(mu),c=Zn.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(Tp).addScaledVector(mu,d),p}intersectSphere(e,t){bn.subVectors(e.center,this.origin);const i=bn.dot(this.direction),r=bn.dot(bn)-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,bn)!==null}intersectTriangle(e,t,i,r,s){bp.subVectors(t,e),fu.subVectors(i,e),Sp.crossVectors(bp,fu);let a=this.direction.dot(Sp),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Zn.subVectors(this.origin,e);const l=o*this.direction.dot(fu.crossVectors(Zn,fu));if(l<0)return null;const c=o*this.direction.dot(bp.cross(Zn));if(c<0||l+c>a)return null;const u=-o*Zn.dot(Sp);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/La.setFromMatrixColumn(e,0).length(),s=1/La.setFromMatrixColumn(e,1).length(),a=1/La.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(Hw,e,Gw)}lookAt(e,t,i){const r=this.elements;return xr.subVectors(e,t),xr.lengthSq()===0&&(xr.z=1),xr.normalize(),Qn.crossVectors(i,xr),Qn.lengthSq()===0&&(Math.abs(i.z)===1?xr.x+=1e-4:xr.z+=1e-4,xr.normalize(),Qn.crossVectors(i,xr)),Qn.normalize(),gu.crossVectors(xr,Qn),r[0]=Qn.x,r[4]=gu.x,r[8]=xr.x,r[1]=Qn.y,r[5]=gu.y,r[9]=xr.y,r[2]=Qn.z,r[6]=gu.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=La.set(r[0],r[1],r[2]).length();const a=La.set(r[4],r[5],r[6]).length(),o=La.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===bs)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===bs)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 La=new N,qr=new Re,Hw=new N(0,0,0),Gw=new N(1,1,1),Qn=new N,gu=new N,xr=new N,vv=new Re,yv=new qi;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 vv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(vv,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return yv.setFromEuler(this),this.setFromQuaternion(yv,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 rl{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 Ww=0;const xv=new N,Pa=new qi,Sn=new Re,vu=new N,nl=new N,jw=new N,Xw=new qi,_v=new N(1,0,0),Mv=new N(0,1,0),Tv=new N(0,0,1),bv={type:"added"},qw={type:"removed"},Da={type:"childadded",child:null},wp={type:"childremoved",child:null};class _t extends vr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ww++}),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 qi,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 rl,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 Pa.setFromAxisAngle(e,t),this.quaternion.multiply(Pa),this}rotateOnWorldAxis(e,t){return Pa.setFromAxisAngle(e,t),this.quaternion.premultiply(Pa),this}rotateX(e){return this.rotateOnAxis(_v,e)}rotateY(e){return this.rotateOnAxis(Mv,e)}rotateZ(e){return this.rotateOnAxis(Tv,e)}translateOnAxis(e,t){return xv.copy(e).applyQuaternion(this.quaternion),this.position.add(xv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(_v,e)}translateY(e){return this.translateOnAxis(Mv,e)}translateZ(e){return this.translateOnAxis(Tv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Sn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?vu.copy(e):vu.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),nl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Sn.lookAt(nl,vu,this.up):Sn.lookAt(vu,nl,this.up),this.quaternion.setFromRotationMatrix(Sn),r&&(Sn.extractRotation(r.matrixWorld),Pa.setFromRotationMatrix(Sn),this.quaternion.premultiply(Pa.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(bv),Da.child=e,this.dispatchEvent(Da),Da.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(qw),wp.child=e,this.dispatchEvent(wp),wp.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),Sn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Sn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Sn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(bv),Da.child=e,this.dispatchEvent(Da),Da.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(nl,e,jw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,Xw,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,wn=new N,Ep=new N,En=new N,Ua=new N,Oa=new N,Sv=new N,Ap=new N,Np=new N,Cp=new N,Rp=new st,Ip=new st,Lp=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),wn.subVectors(i,t),Ep.subVectors(e,t);const a=Yr.dot(Yr),o=Yr.dot(wn),l=Yr.dot(Ep),c=wn.dot(wn),u=wn.dot(Ep),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,En)===null?!1:En.x>=0&&En.y>=0&&En.x+En.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,En)===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,En.x),l.addScaledVector(a,En.y),l.addScaledVector(o,En.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return Rp.setScalar(0),Ip.setScalar(0),Lp.setScalar(0),Rp.fromBufferAttribute(e,t),Ip.fromBufferAttribute(e,i),Lp.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Rp,s.x),a.addScaledVector(Ip,s.y),a.addScaledVector(Lp,s.z),a}static isFrontFacing(e,t,i,r){return Yr.subVectors(i,t),wn.subVectors(e,t),Yr.cross(wn).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),wn.subVectors(this.a,this.b),Yr.cross(wn).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;Ua.subVectors(r,i),Oa.subVectors(s,i),Ap.subVectors(e,i);const l=Ua.dot(Ap),c=Oa.dot(Ap);if(l<=0&&c<=0)return t.copy(i);Np.subVectors(e,r);const u=Ua.dot(Np),h=Oa.dot(Np);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(Ua,a);Cp.subVectors(e,s);const p=Ua.dot(Cp),m=Oa.dot(Cp);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(Oa,o);const f=u*m-p*h;if(f<=0&&h-u>=0&&p-m>=0)return Sv.subVectors(s,r),o=(h-u)/(h-u+(p-m)),t.copy(r).addScaledVector(Sv,o);const g=1/(f+v+d);return a=v*g,o=d*g,t.copy(i).addScaledVector(Ua,a).addScaledVector(Oa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const wv={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},es={h:0,s:0,l:0},yu={h:0,s:0,l:0};function Pp(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=fp(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=Pp(a,s,e+1/3),this.g=Pp(a,s,e),this.b=Pp(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=wv[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=Aa(e.r),this.g=Aa(e.g),this.b=Aa(e.b),this}copyLinearToSRGB(e){return this.r=vp(e.r),this.g=vp(e.g),this.b=vp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fi){return vt.fromWorkingColorSpace(zi.copy(this),e),Math.round(Jt(zi.r*255,0,255))*65536+Math.round(Jt(zi.g*255,0,255))*256+Math.round(Jt(zi.b*255,0,255))}getHexString(e=Fi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vt.workingColorSpace){vt.fromWorkingColorSpace(zi.copy(this),t);const i=zi.r,r=zi.g,s=zi.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(zi.copy(this),t),e.r=zi.r,e.g=zi.g,e.b=zi.b,e}getStyle(e=Fi){vt.fromWorkingColorSpace(zi.copy(this),e);const t=zi.r,i=zi.g,r=zi.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(es),this.setHSL(es.h+e,es.s+t,es.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(es),e.getHSL(yu);const i=Ko(es.h,yu.h,t),r=Ko(es.s,yu.s,t),s=Ko(es.l,yu.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 zi=new xe;xe.NAMES=wv;let Yw=0;class hi extends vr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Yw++}),this.uuid=yr(),this.name="",this.type="Material",this.blending=_n,this.side=an,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bc,this.blendDst=Sc,this.blendEquation=Vn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xe(0,0,0),this.blendAlpha=0,this.depthFunc=Bn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=au,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yn,this.stencilZFail=Yn,this.stencilZPass=Yn,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!==_n&&(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!==bc&&(i.blendSrc=this.blendSrc),this.blendDst!==Sc&&(i.blendDst=this.blendDst),this.blendEquation!==Vn&&(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!==Bn&&(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!==au&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yn&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Yn&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Yn&&(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=pa,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 An=$w();function $w(){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),An.floatView[0]=n;const e=An.uint32View[0],t=e>>23&511;return An.baseTable[t]+((e&8388607)>>An.shiftTable[t])}function sl(n){const e=n>>10;return An.uint32View[0]=An.mantissaTable[An.offsetTable[e]+(n&1023)]+An.exponentTable[e],An.floatView[0]}const Ev={toHalfFloat:sr,fromHalfFloat:sl},ai=new N,xu=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=Sa,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++)xu.fromBufferAttribute(this,t),xu.applyMatrix3(e),this.setXY(t,xu.x,xu.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=Xi(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=Xi(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=Xi(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=Xi(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=Xi(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!==Sa&&(e.usage=this.usage),e}}class Jw extends wt{constructor(e,t,i){super(new Int8Array(e),t,i)}}class Kw extends wt{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class Zw extends wt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class Qw extends wt{constructor(e,t,i){super(new Int16Array(e),t,i)}}class _u extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class eE extends wt{constructor(e,t,i){super(new Int32Array(e),t,i)}}class Dp extends wt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Av extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=sl(this.array[e*this.itemSize]);return this.normalized&&(t=Xi(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=sl(this.array[e*this.itemSize+1]);return this.normalized&&(t=Xi(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=sl(this.array[e*this.itemSize+2]);return this.normalized&&(t=Xi(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=sl(this.array[e*this.itemSize+3]);return this.normalized&&(t=Xi(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 tE=0;const Lr=new Re,Up=new _t,Fa=new N,_r=new Bi,al=new Bi,vi=new N;class ct extends vr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:tE++}),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(uv(e)?Dp:_u)(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 Up.lookAt(e),Up.updateMatrix(),this.applyMatrix4(Up.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fa).negate(),this.translate(Fa.x,Fa.y,Fa.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 Bi);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];al.setFromBufferAttribute(o),this.morphTargetsRelative?(vi.addVectors(_r.min,al.min),_r.expandByPoint(vi),vi.addVectors(_r.max,al.max),_r.expandByPoint(vi)):(_r.expandByPoint(al.min),_r.expandByPoint(al.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&&(Fa.fromBufferAttribute(e,c),vi.add(Fa)),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 Nv=new Re,Ns=new As,Mu=new Ai,Cv=new N,Tu=new N,bu=new N,Su=new N,Op=new N,wu=new N,Rv=new N,Eu=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){wu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],h=s[l];u!==0&&(Op.fromBufferAttribute(h,e),a?wu.addScaledVector(Op,u):wu.addScaledVector(Op.sub(t),u))}t.add(wu)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Mu.copy(i.boundingSphere),Mu.applyMatrix4(s),Ns.copy(e.ray).recast(e.near),!(Mu.containsPoint(Ns.origin)===!1&&(Ns.intersectSphere(Mu,Cv)===null||Ns.origin.distanceToSquared(Cv)>(e.far-e.near)**2))&&(Nv.copy(s).invert(),Ns.copy(e.ray).applyMatrix4(Nv),!(i.boundingBox!==null&&Ns.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ns)))}_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=Au(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=Au(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=Au(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=Au(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}}function iE(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;Eu.copy(o),Eu.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Eu);return c<t.near||c>t.far?null:{distance:c,point:Eu.clone(),object:n}}function Au(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,Tu),n.getVertexPosition(l,bu),n.getVertexPosition(c,Su);const u=iE(n,e,t,i,Tu,bu,Su,Rv);if(u){const h=new N;er.getBarycoord(Rv,Tu,bu,Su,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(Tu,bu,Su,d.normal),u.face=d,u.barycoord=h}return u}class yn 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 yn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Va(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=Va(n[t]);for(const r in i)e[r]=i[r]}return e}function rE(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Iv(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:vt.workingColorSpace}const Fp={clone:Va,merge:Yi};var nE=`void main() {
6
6
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
7
  }`,sE=`void main() {
8
8
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
- }`;class Pr extends hi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=nE,this.fragmentShader=sE,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=Va(e.uniforms),this.uniformsGroups=rE(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}}class ol 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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const ts=new N,Lv=new J,Pv=new J;class di extends ol{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=wa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(bs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return wa*2*Math.atan(Math.tan(bs*.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){ts.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ts.x,ts.y).multiplyScalar(-e/ts.z),ts.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ts.x,ts.y).multiplyScalar(-e/ts.z)}getViewSize(e,t){return this.getViewBounds(e,Lv,Pv),t.subVectors(Pv,Lv)}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(bs*.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 Ba=-90,za=1;class Nu extends _t{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new di(Ba,za,e,t);r.layers=this.layers,this.add(r);const s=new di(Ba,za,e,t);s.layers=this.layers,this.add(s);const a=new di(Ba,za,e,t);a.layers=this.layers,this.add(a);const o=new di(Ba,za,e,t);o.layers=this.layers,this.add(o);const l=new di(Ba,za,e,t);l.layers=this.layers,this.add(l);const c=new di(Ba,za,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===Ts)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 Ns 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 Cu 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 Ns(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:`
9
+ }`;class Pr extends hi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=nE,this.fragmentShader=sE,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=Va(e.uniforms),this.uniformsGroups=rE(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}}class ol 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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const ts=new N,Lv=new J,Pv=new J;class di extends ol{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=wa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ss*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return wa*2*Math.atan(Math.tan(Ss*.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){ts.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ts.x,ts.y).multiplyScalar(-e/ts.z),ts.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ts.x,ts.y).multiplyScalar(-e/ts.z)}getViewSize(e,t){return this.getViewBounds(e,Lv,Pv),t.subVectors(Pv,Lv)}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(Ss*.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 Ba=-90,za=1;class Nu extends _t{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new di(Ba,za,e,t);r.layers=this.layers,this.add(r);const s=new di(Ba,za,e,t);s.layers=this.layers,this.add(s);const a=new di(Ba,za,e,t);a.layers=this.layers,this.add(a);const o=new di(Ba,za,e,t);o.layers=this.layers,this.add(o);const l=new di(Ba,za,e,t);l.layers=this.layers,this.add(l);const c=new di(Ba,za,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===bs)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 Cs 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 Cu 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 Cs(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:`
10
10
 
11
11
  varying vec3 vWorldDirection;
12
12
 
@@ -41,7 +41,7 @@
41
41
  gl_FragColor = texture2D( tEquirect, sampleUV );
42
42
 
43
43
  }
44
- `},r=new yn(5,5,5),s=new Pr({name:"CubemapFromEquirect",uniforms:Va(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===ji&&(t.minFilter=Lt),new Nu(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 Vp=new N,aE=new N,oE=new Ke;class ln{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=Vp.subVectors(i,t).cross(aE.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(Vp),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||oE.getNormalMatrix(e),r=this.coplanarPoint(Vp).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 Cs=new Ai,Ru=new N;class ka{constructor(e=new ln,t=new ln,i=new ln,r=new ln,s=new ln,a=new ln){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===Ts)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(),Cs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Cs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Cs)}intersectsSprite(e){return Cs.center.set(0,0,0),Cs.radius=.7071067811865476,Cs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Cs)}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(Ru.x=r.normal.x>0?e.max.x:e.min.x,Ru.y=r.normal.y>0?e.max.y:e.min.y,Ru.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ru)<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 Dv(){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 lE(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 ua 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 ua(e.width,e.height,e.widthSegments,e.heightSegments)}}var cE=`#ifdef USE_ALPHAHASH
44
+ `},r=new yn(5,5,5),s=new Pr({name:"CubemapFromEquirect",uniforms:Va(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===ji&&(t.minFilter=Lt),new Nu(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 Vp=new N,aE=new N,oE=new Ke;class ln{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=Vp.subVectors(i,t).cross(aE.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(Vp),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||oE.getNormalMatrix(e),r=this.coplanarPoint(Vp).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 Rs=new Ai,Ru=new N;class ka{constructor(e=new ln,t=new ln,i=new ln,r=new ln,s=new ln,a=new ln){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===bs)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(),Rs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Rs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rs)}intersectsSprite(e){return Rs.center.set(0,0,0),Rs.radius=.7071067811865476,Rs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rs)}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(Ru.x=r.normal.x>0?e.max.x:e.min.x,Ru.y=r.normal.y>0?e.max.y:e.min.y,Ru.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ru)<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 Dv(){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 lE(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 ua 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 ua(e.width,e.height,e.widthSegments,e.heightSegments)}}var cE=`#ifdef USE_ALPHAHASH
45
45
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
46
46
  #endif`,uE=`#ifdef USE_ALPHAHASH
47
47
  const float ALPHA_HASH_SCALE = 0.05;
@@ -3592,7 +3592,7 @@ void main() {
3592
3592
  #include <tonemapping_fragment>
3593
3593
  #include <colorspace_fragment>
3594
3594
  #include <fog_fragment>
3595
- }`,dt={alphahash_fragment:cE,alphahash_pars_fragment:uE,alphamap_fragment:hE,alphamap_pars_fragment:dE,alphatest_fragment:pE,alphatest_pars_fragment:mE,aomap_fragment:fE,aomap_pars_fragment:gE,batching_pars_vertex:vE,batching_vertex:yE,begin_vertex:xE,beginnormal_vertex:_E,bsdfs:ME,iridescence_fragment:TE,bumpmap_pars_fragment:bE,clipping_planes_fragment:SE,clipping_planes_pars_fragment:wE,clipping_planes_pars_vertex:EE,clipping_planes_vertex:AE,color_fragment:NE,color_pars_fragment:CE,color_pars_vertex:RE,color_vertex:IE,common:LE,cube_uv_reflection_fragment:PE,defaultnormal_vertex:DE,displacementmap_pars_vertex:UE,displacementmap_vertex:OE,emissivemap_fragment:FE,emissivemap_pars_fragment:VE,colorspace_fragment:BE,colorspace_pars_fragment:zE,envmap_fragment:kE,envmap_common_pars_fragment:HE,envmap_pars_fragment:GE,envmap_pars_vertex:WE,envmap_physical_pars_fragment:tA,envmap_vertex:jE,fog_vertex:XE,fog_pars_vertex:qE,fog_fragment:YE,fog_pars_fragment:$E,gradientmap_pars_fragment:JE,lightmap_pars_fragment:KE,lights_lambert_fragment:ZE,lights_lambert_pars_fragment:QE,lights_pars_begin:eA,lights_toon_fragment:iA,lights_toon_pars_fragment:rA,lights_phong_fragment:nA,lights_phong_pars_fragment:sA,lights_physical_fragment:aA,lights_physical_pars_fragment:oA,lights_fragment_begin:lA,lights_fragment_maps:cA,lights_fragment_end:uA,logdepthbuf_fragment:hA,logdepthbuf_pars_fragment:dA,logdepthbuf_pars_vertex:pA,logdepthbuf_vertex:mA,map_fragment:fA,map_pars_fragment:gA,map_particle_fragment:vA,map_particle_pars_fragment:yA,metalnessmap_fragment:xA,metalnessmap_pars_fragment:_A,morphinstance_vertex:MA,morphcolor_vertex:TA,morphnormal_vertex:bA,morphtarget_pars_vertex:SA,morphtarget_vertex:wA,normal_fragment_begin:EA,normal_fragment_maps:AA,normal_pars_fragment:NA,normal_pars_vertex:CA,normal_vertex:RA,normalmap_pars_fragment:IA,clearcoat_normal_fragment_begin:LA,clearcoat_normal_fragment_maps:PA,clearcoat_pars_fragment:DA,iridescence_pars_fragment:UA,opaque_fragment:OA,packing:FA,premultiplied_alpha_fragment:VA,project_vertex:BA,dithering_fragment:zA,dithering_pars_fragment:kA,roughnessmap_fragment:HA,roughnessmap_pars_fragment:GA,shadowmap_pars_fragment:WA,shadowmap_pars_vertex:jA,shadowmap_vertex:XA,shadowmask_pars_fragment:qA,skinbase_vertex:YA,skinning_pars_vertex:$A,skinning_vertex:JA,skinnormal_vertex:KA,specularmap_fragment:ZA,specularmap_pars_fragment:QA,tonemapping_fragment:eN,tonemapping_pars_fragment:tN,transmission_fragment:iN,transmission_pars_fragment:rN,uv_pars_fragment:nN,uv_pars_vertex:sN,uv_vertex:aN,worldpos_vertex:oN,background_vert:lN,background_frag:cN,backgroundCube_vert:uN,backgroundCube_frag:hN,cube_vert:dN,cube_frag:pN,depth_vert:mN,depth_frag:fN,distanceRGBA_vert:gN,distanceRGBA_frag:vN,equirect_vert:yN,equirect_frag:xN,linedashed_vert:_N,linedashed_frag:MN,meshbasic_vert:TN,meshbasic_frag:bN,meshlambert_vert:SN,meshlambert_frag:wN,meshmatcap_vert:EN,meshmatcap_frag:AN,meshnormal_vert:NN,meshnormal_frag:CN,meshphong_vert:RN,meshphong_frag:IN,meshphysical_vert:LN,meshphysical_frag:PN,meshtoon_vert:DN,meshtoon_frag:UN,points_vert:ON,points_frag:FN,shadow_vert:VN,shadow_frag:BN,sprite_vert:zN,sprite_frag:kN},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 Iu={r:0,b:0,g:0},Rs=new dr,HN=new Re;function GN(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===Hn)?(u===void 0&&(u=new Ft(new yn(1,1,1),new Pr({name:"BackgroundCubeMaterial",uniforms:Va(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)),Rs.copy(y.backgroundRotation),Rs.x*=-1,Rs.y*=-1,Rs.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Rs.y*=-1,Rs.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(HN.makeRotationFromEuler(Rs)),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 ua(2,2),new Pr({name:"BackgroundMaterial",uniforms:Va(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(Iu,Iv(n)),i.buffers.color.setClear(Iu.r,Iu.g,Iu.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 WN(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===ga;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 jN(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 XN(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 qN(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new ln,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 YN(n){let e=new WeakMap;function t(a,o){return o===zn?a.mapping=fr:o===kn&&(a.mapping=Ar),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===zn||o===kn)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 Cu(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 Is extends ol{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 Ha=4,Uv=[.125,.215,.35,.446,.526,.582],Ls=20,Bp=new Is,Ov=new xe;let zp=null,kp=0,Hp=0,Gp=!1;const Ps=(1+Math.sqrt(5))/2,Ga=1/Ps,Fv=[new N(-Ps,Ga,0),new N(Ps,Ga,0),new N(-Ga,0,Ps),new N(Ga,0,Ps),new N(0,Ps,-Ga),new N(0,Ps,Ga),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)];let Lu=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){zp=this._renderer.getRenderTarget(),kp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=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=kv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zv(),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(zp,kp,Hp),this._renderer.xr.enabled=Gp,n.scissorTest=!1,Pu(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),zp=this._renderer.getRenderTarget(),kp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=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=Bv(n,e,t),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Vv(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==n||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Bv(n,e,t);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Vv(s)),this._blurMaterial=$N(s,n,e)}return i}_compileMaterial(n){const e=new Ft(this._lodPlanes[0],n);this._renderer.compile(e,Bp)}_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(Ov),o.toneMapping=mr,o.autoClear=!1;const u=new $r({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1}),h=new Ft(new yn,u);let d=!1;const p=n.background;p?p.isColor&&(u.color.copy(p),n.background=null,d=!0):(u.color.copy(Ov),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;Pu(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=kv()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zv());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;Pu(e,0,0,3*o,2*o),t.setRenderTarget(e),t.render(s,Bp)}_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=Fv[(i-r-1)%Fv.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*Ls-1),m=r/p,v=isFinite(r)?1+Math.floor(c*m):Ls;v>Ls&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Ls}`);const f=[];let g=0;for(let T=0;T<Ls;++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-Ha?i-x+Ha:0),I=4*(this._cubeSize-y);Pu(e,_,I,3*y,2*y),o.setRenderTarget(e),o.render(u,Bp)}};function Vv(n){const e=[],t=[],i=[];let r=n;const s=n-Ha+1+Uv.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>n-Ha?l=Uv[a-n+Ha-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>Ha&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Bv(n,e,t){const i=new Ir(n,e,t);return i.texture.mapping=Hn,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Pu(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function $N(n,e,t){const i=new Float32Array(Ls),r=new N(0,1,0);return new Pr({name:"SphericalGaussianBlur",defines:{n:Ls,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:Wp(),fragmentShader:`
3595
+ }`,dt={alphahash_fragment:cE,alphahash_pars_fragment:uE,alphamap_fragment:hE,alphamap_pars_fragment:dE,alphatest_fragment:pE,alphatest_pars_fragment:mE,aomap_fragment:fE,aomap_pars_fragment:gE,batching_pars_vertex:vE,batching_vertex:yE,begin_vertex:xE,beginnormal_vertex:_E,bsdfs:ME,iridescence_fragment:TE,bumpmap_pars_fragment:bE,clipping_planes_fragment:SE,clipping_planes_pars_fragment:wE,clipping_planes_pars_vertex:EE,clipping_planes_vertex:AE,color_fragment:NE,color_pars_fragment:CE,color_pars_vertex:RE,color_vertex:IE,common:LE,cube_uv_reflection_fragment:PE,defaultnormal_vertex:DE,displacementmap_pars_vertex:UE,displacementmap_vertex:OE,emissivemap_fragment:FE,emissivemap_pars_fragment:VE,colorspace_fragment:BE,colorspace_pars_fragment:zE,envmap_fragment:kE,envmap_common_pars_fragment:HE,envmap_pars_fragment:GE,envmap_pars_vertex:WE,envmap_physical_pars_fragment:tA,envmap_vertex:jE,fog_vertex:XE,fog_pars_vertex:qE,fog_fragment:YE,fog_pars_fragment:$E,gradientmap_pars_fragment:JE,lightmap_pars_fragment:KE,lights_lambert_fragment:ZE,lights_lambert_pars_fragment:QE,lights_pars_begin:eA,lights_toon_fragment:iA,lights_toon_pars_fragment:rA,lights_phong_fragment:nA,lights_phong_pars_fragment:sA,lights_physical_fragment:aA,lights_physical_pars_fragment:oA,lights_fragment_begin:lA,lights_fragment_maps:cA,lights_fragment_end:uA,logdepthbuf_fragment:hA,logdepthbuf_pars_fragment:dA,logdepthbuf_pars_vertex:pA,logdepthbuf_vertex:mA,map_fragment:fA,map_pars_fragment:gA,map_particle_fragment:vA,map_particle_pars_fragment:yA,metalnessmap_fragment:xA,metalnessmap_pars_fragment:_A,morphinstance_vertex:MA,morphcolor_vertex:TA,morphnormal_vertex:bA,morphtarget_pars_vertex:SA,morphtarget_vertex:wA,normal_fragment_begin:EA,normal_fragment_maps:AA,normal_pars_fragment:NA,normal_pars_vertex:CA,normal_vertex:RA,normalmap_pars_fragment:IA,clearcoat_normal_fragment_begin:LA,clearcoat_normal_fragment_maps:PA,clearcoat_pars_fragment:DA,iridescence_pars_fragment:UA,opaque_fragment:OA,packing:FA,premultiplied_alpha_fragment:VA,project_vertex:BA,dithering_fragment:zA,dithering_pars_fragment:kA,roughnessmap_fragment:HA,roughnessmap_pars_fragment:GA,shadowmap_pars_fragment:WA,shadowmap_pars_vertex:jA,shadowmap_vertex:XA,shadowmask_pars_fragment:qA,skinbase_vertex:YA,skinning_pars_vertex:$A,skinning_vertex:JA,skinnormal_vertex:KA,specularmap_fragment:ZA,specularmap_pars_fragment:QA,tonemapping_fragment:eN,tonemapping_pars_fragment:tN,transmission_fragment:iN,transmission_pars_fragment:rN,uv_pars_fragment:nN,uv_pars_vertex:sN,uv_vertex:aN,worldpos_vertex:oN,background_vert:lN,background_frag:cN,backgroundCube_vert:uN,backgroundCube_frag:hN,cube_vert:dN,cube_frag:pN,depth_vert:mN,depth_frag:fN,distanceRGBA_vert:gN,distanceRGBA_frag:vN,equirect_vert:yN,equirect_frag:xN,linedashed_vert:_N,linedashed_frag:MN,meshbasic_vert:TN,meshbasic_frag:bN,meshlambert_vert:SN,meshlambert_frag:wN,meshmatcap_vert:EN,meshmatcap_frag:AN,meshnormal_vert:NN,meshnormal_frag:CN,meshphong_vert:RN,meshphong_frag:IN,meshphysical_vert:LN,meshphysical_frag:PN,meshtoon_vert:DN,meshtoon_frag:UN,points_vert:ON,points_frag:FN,shadow_vert:VN,shadow_frag:BN,sprite_vert:zN,sprite_frag:kN},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 Iu={r:0,b:0,g:0},Is=new dr,HN=new Re;function GN(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===Hn)?(u===void 0&&(u=new Ft(new yn(1,1,1),new Pr({name:"BackgroundCubeMaterial",uniforms:Va(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)),Is.copy(y.backgroundRotation),Is.x*=-1,Is.y*=-1,Is.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Is.y*=-1,Is.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(HN.makeRotationFromEuler(Is)),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 ua(2,2),new Pr({name:"BackgroundMaterial",uniforms:Va(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(Iu,Iv(n)),i.buffers.color.setClear(Iu.r,Iu.g,Iu.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 WN(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===ga;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 jN(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 XN(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 qN(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new ln,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 YN(n){let e=new WeakMap;function t(a,o){return o===zn?a.mapping=fr:o===kn&&(a.mapping=Ar),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===zn||o===kn)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 Cu(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 Ls extends ol{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 Ha=4,Uv=[.125,.215,.35,.446,.526,.582],Ps=20,Bp=new Ls,Ov=new xe;let zp=null,kp=0,Hp=0,Gp=!1;const Ds=(1+Math.sqrt(5))/2,Ga=1/Ds,Fv=[new N(-Ds,Ga,0),new N(Ds,Ga,0),new N(-Ga,0,Ds),new N(Ga,0,Ds),new N(0,Ds,-Ga),new N(0,Ds,Ga),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)];let Lu=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){zp=this._renderer.getRenderTarget(),kp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=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=kv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zv(),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(zp,kp,Hp),this._renderer.xr.enabled=Gp,n.scissorTest=!1,Pu(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),zp=this._renderer.getRenderTarget(),kp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=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=Bv(n,e,t),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Vv(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==n||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Bv(n,e,t);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Vv(s)),this._blurMaterial=$N(s,n,e)}return i}_compileMaterial(n){const e=new Ft(this._lodPlanes[0],n);this._renderer.compile(e,Bp)}_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(Ov),o.toneMapping=mr,o.autoClear=!1;const u=new $r({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1}),h=new Ft(new yn,u);let d=!1;const p=n.background;p?p.isColor&&(u.color.copy(p),n.background=null,d=!0):(u.color.copy(Ov),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;Pu(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=kv()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zv());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;Pu(e,0,0,3*o,2*o),t.setRenderTarget(e),t.render(s,Bp)}_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=Fv[(i-r-1)%Fv.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*Ps-1),m=r/p,v=isFinite(r)?1+Math.floor(c*m):Ps;v>Ps&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Ps}`);const f=[];let g=0;for(let T=0;T<Ps;++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-Ha?i-x+Ha:0),I=4*(this._cubeSize-y);Pu(e,_,I,3*y,2*y),o.setRenderTarget(e),o.render(u,Bp)}};function Vv(n){const e=[],t=[],i=[];let r=n;const s=n-Ha+1+Uv.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>n-Ha?l=Uv[a-n+Ha-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>Ha&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Bv(n,e,t){const i=new Ir(n,e,t);return i.texture.mapping=Hn,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Pu(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function $N(n,e,t){const i=new Float32Array(Ps),r=new N(0,1,0);return new Pr({name:"SphericalGaussianBlur",defines:{n:Ps,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:Wp(),fragmentShader:`
3596
3596
 
3597
3597
  precision mediump float;
3598
3598
  precision mediump int;
@@ -3742,7 +3742,7 @@ void main() {
3742
3742
  gl_Position = vec4( position, 1.0 );
3743
3743
 
3744
3744
  }
3745
- `}function JN(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===zn||l===kn,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 Lu(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 Lu(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 KN(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&&cu("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function ZN(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(uv(d)?Dp:_u)(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 QN(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 eC(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 tC(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 el(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 iC(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 Ds extends Wt{constructor(e,t,i,r,s,a,o,l,c,u=Xn){if(u!==Xn&&u!==qn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Xn&&(i=Nr),i===void 0&&u===qn&&(i=jn),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 Hv=new Wt,Gv=new Ds(1,1),Wv=new el,jv=new uu,Xv=new Ns,qv=[],Yv=[],$v=new Float32Array(16),Jv=new Float32Array(9),Kv=new Float32Array(4);function Wa(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=qv[r];if(s===void 0&&(s=new Float32Array(r),qv[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 Du(n,e){let t=Yv[e];t===void 0&&(t=new Int32Array(e),Yv[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function rC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function nC(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 sC(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 aC(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 oC(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;Kv.set(i),n.uniformMatrix2fv(this.addr,!1,Kv),mi(t,i)}}function lC(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;Jv.set(i),n.uniformMatrix3fv(this.addr,!1,Jv),mi(t,i)}}function cC(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;$v.set(i),n.uniformMatrix4fv(this.addr,!1,$v),mi(t,i)}}function uC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function hC(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 dC(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 pC(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 mC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function fC(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 gC(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 vC(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 yC(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?(Gv.compareFunction=mp,s=Gv):s=Hv,t.setTexture2D(e||s,r)}function xC(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 _C(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Xv,r)}function MC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Wv,r)}function TC(n){switch(n){case 5126:return rC;case 35664:return nC;case 35665:return sC;case 35666:return aC;case 35674:return oC;case 35675:return lC;case 35676:return cC;case 5124:case 35670:return uC;case 35667:case 35671:return hC;case 35668:case 35672:return dC;case 35669:case 35673:return pC;case 5125:return mC;case 36294:return fC;case 36295:return gC;case 36296:return vC;case 35678:case 36198:case 36298:case 36306:case 35682:return yC;case 35679:case 36299:case 36307:return xC;case 35680:case 36300:case 36308:case 36293:return _C;case 36289:case 36303:case 36311:case 36292:return MC}}function bC(n,e){n.uniform1fv(this.addr,e)}function SC(n,e){const t=Wa(e,this.size,2);n.uniform2fv(this.addr,t)}function wC(n,e){const t=Wa(e,this.size,3);n.uniform3fv(this.addr,t)}function EC(n,e){const t=Wa(e,this.size,4);n.uniform4fv(this.addr,t)}function AC(n,e){const t=Wa(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function NC(n,e){const t=Wa(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function CC(n,e){const t=Wa(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function RC(n,e){n.uniform1iv(this.addr,e)}function IC(n,e){n.uniform2iv(this.addr,e)}function LC(n,e){n.uniform3iv(this.addr,e)}function PC(n,e){n.uniform4iv(this.addr,e)}function DC(n,e){n.uniform1uiv(this.addr,e)}function UC(n,e){n.uniform2uiv(this.addr,e)}function OC(n,e){n.uniform3uiv(this.addr,e)}function FC(n,e){n.uniform4uiv(this.addr,e)}function VC(n,e,t){const i=this.cache,r=e.length,s=Du(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Hv,s[a])}function BC(n,e,t){const i=this.cache,r=e.length,s=Du(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 zC(n,e,t){const i=this.cache,r=e.length,s=Du(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Xv,s[a])}function kC(n,e,t){const i=this.cache,r=e.length,s=Du(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Wv,s[a])}function HC(n){switch(n){case 5126:return bC;case 35664:return SC;case 35665:return wC;case 35666:return EC;case 35674:return AC;case 35675:return NC;case 35676:return CC;case 5124:case 35670:return RC;case 35667:case 35671:return IC;case 35668:case 35672:return LC;case 35669:case 35673:return PC;case 5125:return DC;case 36294:return UC;case 36295:return OC;case 36296:return FC;case 35678:case 36198:case 36298:case 36306:case 35682:return VC;case 35679:case 36299:case 36307:return BC;case 35680:case 36300:case 36308:case 36293:return zC;case 36289:case 36303:case 36311:case 36292:return kC}}class GC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=TC(t.type)}}class WC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=HC(t.type)}}class jC{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 Zv(n,e){n.seq.push(e),n.map[e.id]=e}function XC(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){Zv(t,c===void 0?new GC(o,n,e):new WC(o,n,e));break}else{let u=t.map[o];u===void 0&&(u=new jC(o),Zv(t,u)),t=u}}}class Uu{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);XC(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 Qv(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const qC=37297;let YC=0;function $C(n,e){const t=n.split(`
3745
+ `}function JN(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===zn||l===kn,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 Lu(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 Lu(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 KN(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&&cu("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function ZN(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(uv(d)?Dp:_u)(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 QN(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 eC(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 tC(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 el(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 iC(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 Us extends Wt{constructor(e,t,i,r,s,a,o,l,c,u=Xn){if(u!==Xn&&u!==qn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Xn&&(i=Nr),i===void 0&&u===qn&&(i=jn),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 Hv=new Wt,Gv=new Us(1,1),Wv=new el,jv=new uu,Xv=new Cs,qv=[],Yv=[],$v=new Float32Array(16),Jv=new Float32Array(9),Kv=new Float32Array(4);function Wa(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=qv[r];if(s===void 0&&(s=new Float32Array(r),qv[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 Du(n,e){let t=Yv[e];t===void 0&&(t=new Int32Array(e),Yv[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function rC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function nC(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 sC(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 aC(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 oC(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;Kv.set(i),n.uniformMatrix2fv(this.addr,!1,Kv),mi(t,i)}}function lC(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;Jv.set(i),n.uniformMatrix3fv(this.addr,!1,Jv),mi(t,i)}}function cC(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;$v.set(i),n.uniformMatrix4fv(this.addr,!1,$v),mi(t,i)}}function uC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function hC(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 dC(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 pC(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 mC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function fC(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 gC(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 vC(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 yC(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?(Gv.compareFunction=mp,s=Gv):s=Hv,t.setTexture2D(e||s,r)}function xC(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 _C(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Xv,r)}function MC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Wv,r)}function TC(n){switch(n){case 5126:return rC;case 35664:return nC;case 35665:return sC;case 35666:return aC;case 35674:return oC;case 35675:return lC;case 35676:return cC;case 5124:case 35670:return uC;case 35667:case 35671:return hC;case 35668:case 35672:return dC;case 35669:case 35673:return pC;case 5125:return mC;case 36294:return fC;case 36295:return gC;case 36296:return vC;case 35678:case 36198:case 36298:case 36306:case 35682:return yC;case 35679:case 36299:case 36307:return xC;case 35680:case 36300:case 36308:case 36293:return _C;case 36289:case 36303:case 36311:case 36292:return MC}}function bC(n,e){n.uniform1fv(this.addr,e)}function SC(n,e){const t=Wa(e,this.size,2);n.uniform2fv(this.addr,t)}function wC(n,e){const t=Wa(e,this.size,3);n.uniform3fv(this.addr,t)}function EC(n,e){const t=Wa(e,this.size,4);n.uniform4fv(this.addr,t)}function AC(n,e){const t=Wa(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function NC(n,e){const t=Wa(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function CC(n,e){const t=Wa(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function RC(n,e){n.uniform1iv(this.addr,e)}function IC(n,e){n.uniform2iv(this.addr,e)}function LC(n,e){n.uniform3iv(this.addr,e)}function PC(n,e){n.uniform4iv(this.addr,e)}function DC(n,e){n.uniform1uiv(this.addr,e)}function UC(n,e){n.uniform2uiv(this.addr,e)}function OC(n,e){n.uniform3uiv(this.addr,e)}function FC(n,e){n.uniform4uiv(this.addr,e)}function VC(n,e,t){const i=this.cache,r=e.length,s=Du(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Hv,s[a])}function BC(n,e,t){const i=this.cache,r=e.length,s=Du(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 zC(n,e,t){const i=this.cache,r=e.length,s=Du(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Xv,s[a])}function kC(n,e,t){const i=this.cache,r=e.length,s=Du(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Wv,s[a])}function HC(n){switch(n){case 5126:return bC;case 35664:return SC;case 35665:return wC;case 35666:return EC;case 35674:return AC;case 35675:return NC;case 35676:return CC;case 5124:case 35670:return RC;case 35667:case 35671:return IC;case 35668:case 35672:return LC;case 35669:case 35673:return PC;case 5125:return DC;case 36294:return UC;case 36295:return OC;case 36296:return FC;case 35678:case 36198:case 36298:case 36306:case 35682:return VC;case 35679:case 36299:case 36307:return BC;case 35680:case 36300:case 36308:case 36293:return zC;case 36289:case 36303:case 36311:case 36292:return kC}}class GC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=TC(t.type)}}class WC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=HC(t.type)}}class jC{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 Zv(n,e){n.seq.push(e),n.map[e.id]=e}function XC(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){Zv(t,c===void 0?new GC(o,n,e):new WC(o,n,e));break}else{let u=t.map[o];u===void 0&&(u=new jC(o),Zv(t,u)),t=u}}}class Uu{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);XC(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 Qv(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const qC=37297;let YC=0;function $C(n,e){const t=n.split(`
3746
3746
  `),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(`
3747
3747
  `)}function JC(n){const e=vt.getPrimaries(vt.workingColorSpace),t=vt.getPrimaries(n);let i;switch(e===t?i="":e===Jo&&t===$o?i="LinearDisplayP3ToLinearSRGB":e===$o&&t===Jo&&(i="LinearSRGBToLinearDisplayP3"),n){case nr:case qo:return[i,"LinearTransferOETF"];case Fi:case su:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function ey(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()+`
3748
3748
 
@@ -3820,7 +3820,7 @@ void main() {
3820
3820
  squared_mean = squared_mean / samples;
3821
3821
  float std_dev = sqrt( squared_mean - mean * mean );
3822
3822
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3823
- }`;function CR(n,e,t){let i=new ka;const r=new J,s=new J,a=new st,o=new Fu({depthPacking:hp}),l=new qp,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:AR,fragmentShader:NR}),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=jd;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 RR={[No]:Co,[Ro]:Po,[Io]:Do,[Bn]:Lo,[Co]:No,[Po]:Ro,[Do]:Io,[Lo]:Bn};function IR(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=RR[Ae]),oe!==Ae){switch(Ae){case No:n.depthFunc(n.NEVER);break;case Co:n.depthFunc(n.ALWAYS);break;case Ro:n.depthFunc(n.LESS);break;case Bn:n.depthFunc(n.LEQUAL);break;case Io:n.depthFunc(n.EQUAL);break;case Lo:n.depthFunc(n.GEQUAL);break;case Po:n.depthFunc(n.GREATER);break;case Do: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,xn){(ee!==At||oe!==ir||Ne!==xn)&&(n.stencilFunc(At,ir,xn),ee=At,oe=ir,Ne=xn)},setOp:function(At,ir,xn){(Ae!==At||Ut!==ir||ni!==xn)&&(n.stencilOp(At,ir,xn),Ae=At,Ut=ir,ni=xn)},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(Bn),pe(!1),Ue(Wd),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={[Vn]:n.FUNC_ADD,[_0]:n.FUNC_SUBTRACT,[M0]:n.FUNC_REVERSE_SUBTRACT};ce[T0]=n.MIN,ce[Jd]=n.MAX;const ue={[b0]:n.ZERO,[S0]:n.ONE,[w0]:n.SRC_COLOR,[bc]:n.SRC_ALPHA,[I0]:n.SRC_ALPHA_SATURATE,[C0]:n.DST_COLOR,[A0]:n.DST_ALPHA,[E0]:n.ONE_MINUS_SRC_COLOR,[Sc]:n.ONE_MINUS_SRC_ALPHA,[R0]:n.ONE_MINUS_DST_COLOR,[N0]:n.ONE_MINUS_DST_ALPHA,[L0]:n.CONSTANT_COLOR,[P0]:n.ONE_MINUS_CONSTANT_COLOR,[D0]:n.CONSTANT_ALPHA,[U0]: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!==$d){if(O!==v||At!==C){if((f!==Vn||y!==Vn)&&(n.blendEquation(n.FUNC_ADD),f=Vn,y=Vn),At)switch(O){case _n:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ao:n.blendFunc(n.ONE,n.ONE);break;case qd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Yd: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 _n:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ao:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case qd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Yd: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===_n&&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!==y0?(be(n.CULL_FACE),O!==M&&(O===Wd?n.cullFace(n.BACK):O===x0?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 LR(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 PR(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 DR(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function Yp(n,e,t,i){const r=UR(i);switch(t){case rp:return n*e;case np:return n*e;case sp:return n*e*2;case Uo:return n*e/r.components*r.byteLength;case Oo:return n*e/r.components*r.byteLength;case va:return n*e*2/r.components*r.byteLength;case Fc:return n*e*2/r.components*r.byteLength;case Oc:return n*e*3/r.components*r.byteLength;case Ei:return n*e*4/r.components*r.byteLength;case Vc:return n*e*4/r.components*r.byteLength;case ya:case xa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case _a:case Ma:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Bc:case zc:return Math.max(n,16)*Math.max(e,8)/4;case Fo:case Vo:return Math.max(n,8)*Math.max(e,8)/2;case Bo:case zo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ko:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ho:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case kc:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Hc:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Gc:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Go:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Wc:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case jc:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Xc:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case qc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Yc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case $c:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Jc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Kc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Zc:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Ta:case Qc:case Wo:return Math.ceil(n/4)*Math.ceil(e/4)*16;case ap:case eu:return Math.ceil(n/4)*Math.ceil(e/4)*8;case tu:case iu:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function UR(n){switch(n){case jr:case tp:return{byteLength:1,components:1};case fa:case ip:case wi:return{byteLength:2,components:1};case Lc:case Pc:return{byteLength:2,components:4};case Nr:case ga:case Oi:return{byteLength:4,components:1};case Dc:case Uc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}const OR={contain:LR,cover:PR,fill:DR,getByteLength:Yp};function FR(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):Zo("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?Yo: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===jn?W=n.DEPTH24_STENCIL8:S===Oi?W=n.DEPTH32F_STENCIL8:S===fa&&(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===jn?W=n.DEPTH_COMPONENT24:S===Oi?W=n.DEPTH_COMPONENT32F:S===fa&&(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={[Gn]:n.REPEAT,[gr]:n.CLAMP_TO_EDGE,[ma]:n.MIRRORED_REPEAT},ye={[$t]:n.NEAREST,[Ic]:n.NEAREST_MIPMAP_NEAREST,[Mn]:n.NEAREST_MIPMAP_LINEAR,[Lt]:n.LINEAR,[Wn]:n.LINEAR_MIPMAP_NEAREST,[ji]:n.LINEAR_MIPMAP_LINEAR},Te={[rv]:n.NEVER,[lv]:n.ALWAYS,[pp]:n.LESS,[mp]:n.LEQUAL,[nv]:n.EQUAL,[ov]:n.GEQUAL,[sv]:n.GREATER,[av]:n.NOTEQUAL};function Ve(R,S){if(S.type===Oi&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Lt||S.magFilter===Wn||S.magFilter===Mn||S.magFilter===ji||S.minFilter===Lt||S.minFilter===Wn||S.minFilter===Mn||S.minFilter===ji)&&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!==Mn&&S.minFilter!==ji||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===qn,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=Yp(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=Yp(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===Xn)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===qn)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 ly(n,e){function t(i,r=Cr){let s;const a=vt.getTransfer(r);if(i===jr)return n.UNSIGNED_BYTE;if(i===Lc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Pc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Dc)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Uc)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===tp)return n.BYTE;if(i===ip)return n.SHORT;if(i===fa)return n.UNSIGNED_SHORT;if(i===ga)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===rp)return n.ALPHA;if(i===Oc)return n.RGB;if(i===Ei)return n.RGBA;if(i===np)return n.LUMINANCE;if(i===sp)return n.LUMINANCE_ALPHA;if(i===Xn)return n.DEPTH_COMPONENT;if(i===qn)return n.DEPTH_STENCIL;if(i===Uo)return n.RED;if(i===Oo)return n.RED_INTEGER;if(i===va)return n.RG;if(i===Fc)return n.RG_INTEGER;if(i===Vc)return n.RGBA_INTEGER;if(i===ya||i===xa||i===_a||i===Ma)if(a===Ot)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ya)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===xa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===_a)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ma)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ya)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===xa)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===_a)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ma)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Fo||i===Bc||i===Vo||i===zc)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Fo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Bc)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Vo)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===zc)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Bo||i===zo||i===ko)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Bo||i===zo)return a===Ot?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===ko)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Ho||i===kc||i===Hc||i===Gc||i===Go||i===Wc||i===jc||i===Xc||i===qc||i===Yc||i===$c||i===Jc||i===Kc||i===Zc)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Ho)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===kc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Hc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Gc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Go)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Wc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Xc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===qc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Yc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===$c)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Kc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Zc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ta||i===Qc||i===Wo)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Ta)return a===Ot?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Qc)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Wo)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ap||i===eu||i===tu||i===iu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Ta)return s.COMPRESSED_RED_RGTC1_EXT;if(i===eu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===tu)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===iu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===jn?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class $p extends di{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Us extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const VR={type:"move"};class Jp{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Us,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 Us,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 Us,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(VR)))}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 Us;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const BR=`
3823
+ }`;function CR(n,e,t){let i=new ka;const r=new J,s=new J,a=new st,o=new Fu({depthPacking:hp}),l=new qp,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:AR,fragmentShader:NR}),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=jd;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 RR={[No]:Co,[Ro]:Po,[Io]:Do,[Bn]:Lo,[Co]:No,[Po]:Ro,[Do]:Io,[Lo]:Bn};function IR(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=RR[Ae]),oe!==Ae){switch(Ae){case No:n.depthFunc(n.NEVER);break;case Co:n.depthFunc(n.ALWAYS);break;case Ro:n.depthFunc(n.LESS);break;case Bn:n.depthFunc(n.LEQUAL);break;case Io:n.depthFunc(n.EQUAL);break;case Lo:n.depthFunc(n.GEQUAL);break;case Po:n.depthFunc(n.GREATER);break;case Do: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,xn){(ee!==At||oe!==ir||Ne!==xn)&&(n.stencilFunc(At,ir,xn),ee=At,oe=ir,Ne=xn)},setOp:function(At,ir,xn){(Ae!==At||Ut!==ir||ni!==xn)&&(n.stencilOp(At,ir,xn),Ae=At,Ut=ir,ni=xn)},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(Bn),pe(!1),Ue(Wd),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={[Vn]:n.FUNC_ADD,[_0]:n.FUNC_SUBTRACT,[M0]:n.FUNC_REVERSE_SUBTRACT};ce[T0]=n.MIN,ce[Jd]=n.MAX;const ue={[b0]:n.ZERO,[S0]:n.ONE,[w0]:n.SRC_COLOR,[bc]:n.SRC_ALPHA,[I0]:n.SRC_ALPHA_SATURATE,[C0]:n.DST_COLOR,[A0]:n.DST_ALPHA,[E0]:n.ONE_MINUS_SRC_COLOR,[Sc]:n.ONE_MINUS_SRC_ALPHA,[R0]:n.ONE_MINUS_DST_COLOR,[N0]:n.ONE_MINUS_DST_ALPHA,[L0]:n.CONSTANT_COLOR,[P0]:n.ONE_MINUS_CONSTANT_COLOR,[D0]:n.CONSTANT_ALPHA,[U0]: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!==$d){if(O!==v||At!==C){if((f!==Vn||y!==Vn)&&(n.blendEquation(n.FUNC_ADD),f=Vn,y=Vn),At)switch(O){case _n:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ao:n.blendFunc(n.ONE,n.ONE);break;case qd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Yd: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 _n:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ao:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case qd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Yd: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===_n&&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!==y0?(be(n.CULL_FACE),O!==M&&(O===Wd?n.cullFace(n.BACK):O===x0?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 LR(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 PR(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 DR(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function Yp(n,e,t,i){const r=UR(i);switch(t){case rp:return n*e;case np:return n*e;case sp:return n*e*2;case Uo:return n*e/r.components*r.byteLength;case Oo:return n*e/r.components*r.byteLength;case va:return n*e*2/r.components*r.byteLength;case Fc:return n*e*2/r.components*r.byteLength;case Oc:return n*e*3/r.components*r.byteLength;case Ei:return n*e*4/r.components*r.byteLength;case Vc:return n*e*4/r.components*r.byteLength;case ya:case xa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case _a:case Ma:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Bc:case zc:return Math.max(n,16)*Math.max(e,8)/4;case Fo:case Vo:return Math.max(n,8)*Math.max(e,8)/2;case Bo:case zo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ko:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ho:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case kc:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Hc:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Gc:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Go:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Wc:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case jc:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Xc:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case qc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Yc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case $c:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Jc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Kc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Zc:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Ta:case Qc:case Wo:return Math.ceil(n/4)*Math.ceil(e/4)*16;case ap:case eu:return Math.ceil(n/4)*Math.ceil(e/4)*8;case tu:case iu:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function UR(n){switch(n){case jr:case tp:return{byteLength:1,components:1};case fa:case ip:case wi:return{byteLength:2,components:1};case Lc:case Pc:return{byteLength:2,components:4};case Nr:case ga:case Oi:return{byteLength:4,components:1};case Dc:case Uc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}const OR={contain:LR,cover:PR,fill:DR,getByteLength:Yp};function FR(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):Zo("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?Yo: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===jn?W=n.DEPTH24_STENCIL8:S===Oi?W=n.DEPTH32F_STENCIL8:S===fa&&(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===jn?W=n.DEPTH_COMPONENT24:S===Oi?W=n.DEPTH_COMPONENT32F:S===fa&&(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={[Gn]:n.REPEAT,[gr]:n.CLAMP_TO_EDGE,[ma]:n.MIRRORED_REPEAT},ye={[$t]:n.NEAREST,[Ic]:n.NEAREST_MIPMAP_NEAREST,[Mn]:n.NEAREST_MIPMAP_LINEAR,[Lt]:n.LINEAR,[Wn]:n.LINEAR_MIPMAP_NEAREST,[ji]:n.LINEAR_MIPMAP_LINEAR},Te={[rv]:n.NEVER,[lv]:n.ALWAYS,[pp]:n.LESS,[mp]:n.LEQUAL,[nv]:n.EQUAL,[ov]:n.GEQUAL,[sv]:n.GREATER,[av]:n.NOTEQUAL};function Ve(R,S){if(S.type===Oi&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Lt||S.magFilter===Wn||S.magFilter===Mn||S.magFilter===ji||S.minFilter===Lt||S.minFilter===Wn||S.minFilter===Mn||S.minFilter===ji)&&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!==Mn&&S.minFilter!==ji||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===qn,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=Yp(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=Yp(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===Xn)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===qn)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 ly(n,e){function t(i,r=Cr){let s;const a=vt.getTransfer(r);if(i===jr)return n.UNSIGNED_BYTE;if(i===Lc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Pc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Dc)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Uc)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===tp)return n.BYTE;if(i===ip)return n.SHORT;if(i===fa)return n.UNSIGNED_SHORT;if(i===ga)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===rp)return n.ALPHA;if(i===Oc)return n.RGB;if(i===Ei)return n.RGBA;if(i===np)return n.LUMINANCE;if(i===sp)return n.LUMINANCE_ALPHA;if(i===Xn)return n.DEPTH_COMPONENT;if(i===qn)return n.DEPTH_STENCIL;if(i===Uo)return n.RED;if(i===Oo)return n.RED_INTEGER;if(i===va)return n.RG;if(i===Fc)return n.RG_INTEGER;if(i===Vc)return n.RGBA_INTEGER;if(i===ya||i===xa||i===_a||i===Ma)if(a===Ot)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ya)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===xa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===_a)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ma)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ya)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===xa)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===_a)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ma)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Fo||i===Bc||i===Vo||i===zc)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Fo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Bc)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Vo)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===zc)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Bo||i===zo||i===ko)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Bo||i===zo)return a===Ot?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===ko)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Ho||i===kc||i===Hc||i===Gc||i===Go||i===Wc||i===jc||i===Xc||i===qc||i===Yc||i===$c||i===Jc||i===Kc||i===Zc)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Ho)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===kc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Hc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Gc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Go)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Wc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Xc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===qc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Yc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===$c)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Kc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Zc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ta||i===Qc||i===Wo)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Ta)return a===Ot?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Qc)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Wo)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ap||i===eu||i===tu||i===iu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Ta)return s.COMPRESSED_RED_RGTC1_EXT;if(i===eu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===tu)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===iu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===jn?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class $p extends di{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Os extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const VR={type:"move"};class Jp{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Os,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 Os,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 Os,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(VR)))}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 Os;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const BR=`
3824
3824
  void main() {
3825
3825
 
3826
3826
  gl_Position = vec4( position, 1.0 );
@@ -3844,7 +3844,7 @@ void main() {
3844
3844
 
3845
3845
  }
3846
3846
 
3847
- }`;class kR{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:BR,fragmentShader:zR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ft(new ua(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class HR 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 kR,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 $p;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 Jp,y[ie]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getGripSpace()},this.getHand=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,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?qn:Xn,be=f.stencil?jn: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 Ds(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=wa*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 Dv;et.setAnimationLoop(at),this.setAnimationLoop=function(ie){Ve=ie},this.dispose=function(){}}}const Os=new dr,GR=new Re;function WR(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,Iv(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,Os.copy(_),Os.x*=-1,Os.y*=-1,Os.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Os.y*=-1,Os.z*=-1),f.envMapRotation.value.setFromMatrix4(GR.makeRotationFromEuler(Os)),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 jR(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 cy{constructor(e={}){const{canvas:t=hv(),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 ka;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 KN(L),pe.init(),ut=new ly(L,pe),Ue=new XN(L,pe,e,ut),we=new IR(L),Ue.reverseDepthBuffer&&we.buffers.depth.setReversed(!0),$e=new eC(L),Be=new yR,R=new FR(L,pe,we,Be,Ue,ut,$e),S=new YN(y),W=new JN(y),ne=new lE(L),Dt=new WN(L,ne),de=new ZN(L,ne,$e,Dt),se=new iC(L,de,ne,$e),it=new tC(L,Ue,R),ve=new qN(Be),ke=new vR(y,S,W,pe,Ue,Dt,ve),Ee=new WR(y,Be),Pe=new _R,mt=new ER(pe),tt=new GN(y,S,W,we,se,d,l),ze=new CR(y,se,Ue),O=new jR(L,$e,Ue,we),Oe=new jN(L,pe,$e),Mt=new QN(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 HR(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===Vc||me===Fc||me===Oo}if(F){const me=w.texture.type,Ie=me===jr||me===Nr||me===fa||me===jn||me===Lc||me===Pc,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",l0),ee.removeEventListener("sessionend",c0),vs.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=$S(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,Wi=F._multiDrawCounts,ys=F._multiDrawCount,Gr=Ge?ne.get(Ge).bytesPerElement:1,da=Be.get(q).currentProgram.getUniforms();for(let pr=0;pr<ys;pr++)da.setValue(L,"_gl_DrawID",pr),Ht.render(Xe[pr]/Gr,Wi[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,Wi=Math.min(X.instanceCount,Xe);Ht.renderInstances(Rt,Qt,Wi)}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,Tc(A,B,X),A.side=an,A.needsUpdate=!0,Tc(A,B,X),A.side=Wr):Tc(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 xn(A){ir&&ir(A)}function l0(){vs.stop()}function c0(){vs.start()}const vs=new Dv;vs.setAnimationLoop(xn),typeof self<"u"&&vs.setContext(self),this.setAnimationLoop=function(A){ir=A,ee.setAnimationLoop(A),A===null?vs.stop():vs.start()},ee.addEventListener("sessionstart",l0),ee.addEventListener("sessionend",c0),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&&zd(me,B,-1/0,y.sortObjects)}zd(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];h0(q,F,A,Ge)}ce&&tt.render(A);for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];u0(v,A,Ge,Ge.viewport)}}else F.length>0&&h0(q,F,A,B),ce&&tt.render(A),u0(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 zd(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++)zd(F[me],B,X,q)}function u0(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&&Mc(F,B,X),me.length>0&&Mc(me,B,X),Ie.length>0&&Mc(Ie,B,X),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function h0(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:ji,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),Mc(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,d0(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 Mc(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)&&d0(Fe,B,X,Ge,Qe,Ze)}}function d0(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 Tc(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 m0(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),m0(A,Fe),q.needsLights=KS(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 p0(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=Uu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function m0(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 $S(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),Wi=f.state.lights;if(ie===!0&&(le===!0||A!==H)){const wr=A===H&&q.id===C;ve.setState(q,A,wr)}let ys=!1;q.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Wi.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)&&(ys=!0):(ys=!0,Xe.__version=q.version);let Gr=Xe.currentProgram;ys===!0&&(Gr=Tc(q,B,F));let da=!1,pr=!1,kd=!1;const ei=Gr.getUniforms(),Fn=Xe.uniforms;if(we.useProgram(Gr.program)&&(da=!0,pr=!0,kd=!0),q.id!==C&&(C=q.id,pr=!0),da||H!==A){Ue.reverseDepthBuffer?(be.copy(A.projectionMatrix),Dw(be),Uw(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,kd=!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 Hd=X.morphAttributes;if((Hd.position!==void 0||Hd.normal!==void 0||Hd.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&&(Fn.envMap.value=Ge,Fn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&B.environment!==null&&(Fn.envMapIntensity.value=B.environmentIntensity),pr&&(ei.setValue(L,"toneMappingExposure",y.toneMappingExposure),Xe.needsLights&&JS(Fn,kd),me&&q.fog===!0&&Ee.refreshFogUniforms(Fn,me),Ee.refreshMaterialUniforms(Fn,q,he,$,f.state.transmissionRenderTarget[A.id]),Uu.upload(L,p0(Xe),Fn,R)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Uu.upload(L,p0(Xe),Fn,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 Gd=0,ZS=wr.length;Gd<ZS;Gd++){const f0=wr[Gd];O.update(f0,Gr),O.bind(f0,Gr)}}return Gr}function JS(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 KS(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 Pw(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&&(cu("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&&(cu("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),Wi=A.isCompressedTexture?A.mipmaps[F]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Wi.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,Wi.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,F,Qe,Ze,Wi.width,Wi.height,Je,Wi.data):L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi),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&&(cu("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 Wi=L.getParameter(L.UNPACK_ROW_LENGTH),ys=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Gr=L.getParameter(L.UNPACK_SKIP_PIXELS),da=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,Wi),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ys),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Gr),L.pixelStorei(L.UNPACK_SKIP_ROWS,da),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===su?"display-p3":"srgb",t.unpackColorSpace=vt.workingColorSpace===qo?"display-p3":"srgb"}}class Rd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Rd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let Kp=class qS{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 qS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Vu 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 ja{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Sa,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 On{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=Xi(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=Xi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xi(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 On(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 cl 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 Xa;const ul=new N,qa=new N,Ya=new N,$a=new J,hl=new J,uy=new Re,Bu=new N,dl=new N,zu=new N,hy=new J,Zp=new J,dy=new J;class Qp extends _t{constructor(e=new cl){if(super(),this.isSprite=!0,this.type="Sprite",Xa===void 0){Xa=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 ja(t,5);Xa.setIndex([0,1,2,0,2,3]),Xa.setAttribute("position",new On(i,3,0,!1)),Xa.setAttribute("uv",new On(i,2,3,!1))}this.geometry=Xa,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.'),qa.setFromMatrixScale(this.matrixWorld),uy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ya.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&qa.multiplyScalar(-Ya.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const a=this.center;ku(Bu.set(-.5,-.5,0),Ya,a,qa,r,s),ku(dl.set(.5,-.5,0),Ya,a,qa,r,s),ku(zu.set(.5,.5,0),Ya,a,qa,r,s),hy.set(0,0),Zp.set(1,0),dy.set(1,1);let o=e.ray.intersectTriangle(Bu,dl,zu,!1,ul);if(o===null&&(ku(dl.set(-.5,.5,0),Ya,a,qa,r,s),Zp.set(0,1),o=e.ray.intersectTriangle(Bu,zu,dl,!1,ul),o===null))return;const l=e.ray.origin.distanceTo(ul);l<e.near||l>e.far||t.push({distance:l,point:ul.clone(),uv:er.getInterpolation(ul,Bu,dl,zu,hy,Zp,dy,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 ku(n,e,t,i,r,s){$a.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(hl.x=s*$a.x-r*$a.y,hl.y=r*$a.x+s*$a.y):hl.copy($a),n.copy(e),n.x+=hl.x,n.y+=hl.y,n.applyMatrix4(uy)}const Hu=new N,py=new N;class em 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){Hu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Hu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Hu.setFromMatrixPosition(e.matrixWorld),py.setFromMatrixPosition(this.matrixWorld);const i=Hu.distanceTo(py)/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 my=new N,fy=new st,gy=new st,XR=new N,vy=new Re,Gu=new N,tm=new Ai,yy=new Re,im=new Es;class rm extends Ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ep,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 Bi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Gu),this.boundingBox.expandByPoint(Gu)}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,Gu),this.boundingSphere.expandByPoint(Gu)}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(),tm.copy(this.boundingSphere),tm.applyMatrix4(r),e.ray.intersectsSphere(tm)!==!1&&(yy.copy(r).invert(),im.copy(e.ray).applyMatrix4(yy),!(this.boundingBox!==null&&im.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,im)))}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===ep?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===F0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;fy.fromBufferAttribute(r.attributes.skinIndex,e),gy.fromBufferAttribute(r.attributes.skinWeight,e),my.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=gy.getComponent(s);if(a!==0){const o=fy.getComponent(s);vy.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(XR.copy(my).applyMatrix4(vy),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Wu 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 xy=new Re,qR=new Re;class fc{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:qR;xy.multiplyMatrices(o,t[s]),xy.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new fc(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 Wu),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 Nn 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 Ja=new Re,_y=new Re,ju=[],My=new Bi,YR=new Re,pl=new Ft,ml=new Ai;class nm extends Ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Nn(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,YR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Bi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ja),My.copy(e.boundingBox).applyMatrix4(Ja),this.boundingBox.union(My)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ja),ml.copy(e.boundingSphere).applyMatrix4(Ja),this.boundingSphere.union(ml)}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(pl.geometry=this.geometry,pl.material=this.material,pl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ml.copy(this.boundingSphere),ml.applyMatrix4(i),e.ray.intersectsSphere(ml)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Ja),_y.multiplyMatrices(i,Ja),pl.matrixWorld=_y,pl.raycast(e,ju);for(let a=0,o=ju.length;a<o;a++){const l=ju[a];l.instanceId=s,l.object=this,t.push(l)}ju.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Nn(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,Uo,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 $R(n,e){return n.z-e.z}function JR(n,e){return e.z-n.z}class KR{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 is=new Re,sm=new Re,ZR=new Re,QR=new xe(1,1,1),Ty=new Re,am=new ka,Xu=new Bi,Fs=new Ai,fl=new N,by=new N,eI=new N,om=new KR,ki=new Ft,qu=[];function tI(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 lm 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,Oo,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 Bi);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,is),this.getBoundingBoxAt(s,Xu).applyMatrix4(is),e.union(Xu)}}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,is),this.getBoundingSphereAt(s,Fs).applyMatrix4(is),e.union(Fs)}}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;ZR.toArray(s,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(QR.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 Bi,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);tI(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(fl.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,Xu),Xu.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)),fl.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(fl))}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;ki.material=this.material,ki.geometry.index=a.index,ki.geometry.attributes=a.attributes,ki.geometry.boundingBox===null&&(ki.geometry.boundingBox=new Bi),ki.geometry.boundingSphere===null&&(ki.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];ki.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,ki.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,ki.geometry.boundingBox),this.getBoundingSphereAt(c,ki.geometry.boundingSphere),ki.raycast(e,qu);for(let h=0,d=qu.length;h<d;h++){const p=qu[h];p.object=this,p.batchId=o,t.push(p)}qu.length=0}ki.material=null,ki.geometry.index=null,ki.geometry.attributes={},ki.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&&(Ty.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),am.setFromProjectionMatrix(Ty,e.coordinateSystem));let v=0;if(this.sortObjects){sm.copy(this.matrixWorld).invert(),fl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(sm),by.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(sm);for(let x=0,y=l.length;x<y;x++)if(l[x].visible&&l[x].active){const _=l[x].geometryIndex;this.getMatrixAt(x,is),this.getBoundingSphereAt(_,Fs).applyMatrix4(is);let I=!1;if(d&&(I=!am.intersectsSphere(Fs)),!I){const T=eI.subVectors(Fs.center,fl).dot(by);om.push(h[_],T,x)}}const f=om.list,g=this.customSort;g===null?f.sort(s.transparent?JR:$R):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++}om.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,is),this.getBoundingSphereAt(x,Fs).applyMatrix4(is),y=!am.intersectsSphere(Fs)),!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 Yu=new N,$u=new N,Sy=new Re,gl=new Es,Ju=new Ai,cm=new N,wy=new N;class Cn 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++)Yu.fromBufferAttribute(t,r-1),$u.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Yu.distanceTo($u);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(),Ju.copy(i.boundingSphere),Ju.applyMatrix4(r),Ju.radius+=s,e.ray.intersectsSphere(Ju)===!1)return;Sy.copy(r).invert(),gl.copy(e.ray).applyMatrix4(Sy);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=Ku(this,e,gl,l,f,g);x&&t.push(x)}if(this.isLineLoop){const m=u.getX(p-1),v=u.getX(d),f=Ku(this,e,gl,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=Ku(this,e,gl,l,m,m+1);f&&t.push(f)}if(this.isLineLoop){const m=Ku(this,e,gl,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 Ku(n,e,t,i,r,s){const a=n.geometry.attributes.position;if(Yu.fromBufferAttribute(a,r),$u.fromBufferAttribute(a,s),t.distanceSqToSegment(Yu,$u,cm,wy)>i)return;cm.applyMatrix4(n.matrixWorld);const o=e.ray.origin.distanceTo(cm);if(!(o<e.near||o>e.far))return{distance:o,point:wy.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const Ey=new N,Ay=new N;class Jr extends Cn{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)Ey.fromBufferAttribute(t,r),Ay.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ey.distanceTo(Ay);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class um extends Cn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Ka 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 Ny=new Re,hm=new Es,Zu=new Ai,Qu=new N;class dm extends _t{constructor(e=new ct,t=new Ka){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(),Zu.copy(i.boundingSphere),Zu.applyMatrix4(r),Zu.radius+=s,e.ray.intersectsSphere(Zu)===!1)return;Ny.copy(r).invert(),hm.copy(e.ray).applyMatrix4(Ny);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);Qu.fromBufferAttribute(u,v),Cy(Qu,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++)Qu.fromBufferAttribute(u,p),Cy(Qu,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 Cy(n,e,t,i,r,s,a){const o=hm.distanceSqToPoint(n);if(o<t){const l=new N;hm.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 Ry 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 pm 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 vl 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 Iy extends vl{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 Ly extends vl{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 Py 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 eh 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 Dy extends eh{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function mm(){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 th=new N,fm=new mm,gm=new mm,vm=new mm;class ym 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]:(th.subVectors(r[0],r[1]).add(r[0]),c=th);const h=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(th.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=th),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),fm.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,v,f),gm.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,v,f),vm.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,v,f)}else this.curveType==="catmullrom"&&(fm.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),gm.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),vm.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(fm.calc(l),gm.calc(l),vm.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 Uy(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 iI(n,e){const t=1-n;return t*t*e}function rI(n,e){return 2*(1-n)*n*e}function nI(n,e){return n*n*e}function yl(n,e,t,i){return iI(n,e)+rI(n,t)+nI(n,i)}function sI(n,e){const t=1-n;return t*t*t*e}function aI(n,e){const t=1-n;return 3*t*t*n*e}function oI(n,e){return 3*(1-n)*n*n*e}function lI(n,e){return n*n*n*e}function xl(n,e,t,i,r){return sI(n,e)+aI(n,t)+oI(n,i)+lI(n,r)}class xm 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(xl(e,r.x,s.x,a.x,o.x),xl(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 Oy 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(xl(e,r.x,s.x,a.x,o.x),xl(e,r.y,s.y,a.y,o.y),xl(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 _m 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 Fy 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 Mm 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(yl(e,r.x,s.x,a.x),yl(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 Tm 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(yl(e,r.x,s.x,a.x),yl(e,r.y,s.y,a.y),yl(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 bm 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(Uy(o,l.x,c.x,u.x,h.x),Uy(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 ih=Object.freeze({__proto__:null,ArcCurve:Dy,CatmullRomCurve3:ym,CubicBezierCurve:xm,CubicBezierCurve3:Oy,EllipseCurve:eh,LineCurve:_m,LineCurve3:Fy,QuadraticBezierCurve:Mm,QuadraticBezierCurve3:Tm,SplineCurve:bm});class Vy 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 ih[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 ih[r.type]().fromJSON(r))}return this}}class _l extends Vy{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 _m(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 Mm(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 xm(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 bm(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 eh(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 gc 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 gc(e.points,e.segments,e.phiStart,e.phiLength)}}class Id extends gc{constructor(e=1,t=1,i=4,r=8){const s=new _l;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 Id(e.radius,e.length,e.capSegments,e.radialSegments)}}class Ld 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 Ld(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ha 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 ha(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Pd extends ha{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 Pd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class fs 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 fs(e.vertices,e.indices,e.radius,e.details)}}class Dd extends fs{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 Dd(e.radius,e.detail)}}const rh=new N,nh=new N,Sm=new N,sh=new er;class wm 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(bs*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}=sh;if(m.fromBufferAttribute(a,l[0]),v.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),sh.getNormal(Sm),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=sh[c[g]],T=sh[c[x]],w=`${y}_${_}`,C=`${_}_${y}`;C in h&&h[C]?(Sm.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:Sm.clone()})}}for(const p in h)if(h[p]){const{index0:m,index1:v}=h[p];rh.fromBufferAttribute(a,m),nh.fromBufferAttribute(a,v),d.push(rh.x,rh.y,rh.z),d.push(nh.x,nh.y,nh.z)}this.setAttribute("position",new De(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class rs extends _l{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 _l().fromJSON(r))}return this}}const cI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=By(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=mI(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 Ml(s,a,t,o,l,p,0),a}};function By(n,e,t,i,r){let s,a;if(r===wI(n,e,t,i)>0)for(s=e;s<t;s+=i)a=Hy(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=Hy(s,n[s],n[s+1],a);return a&&ah(a,a.next)&&(bl(a),a=a.next),a}function Vs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(ah(t,t.next)||Xt(t.prev,t,t.next)===0)){if(bl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Ml(n,e,t,i,r,s,a){if(!n)return;!a&&s&&xI(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?hI(n,i,r,s):uI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),bl(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=dI(Vs(n),e,t),Ml(n,e,t,i,r,s,2)):a===2&&pI(n,e,t,i,r,s):Ml(Vs(n),e,t,i,r,s,1);break}}}function uI(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&&Za(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 hI(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=Em(p,m,e,t,i),x=Em(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&&Za(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&&Za(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&&Za(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&&Za(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function dI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!ah(r,s)&&zy(r,i,i.next,s)&&Tl(r,s)&&Tl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),bl(i),bl(i.next),i=n=s),i=i.next}while(i!==n);return Vs(i)}function pI(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&TI(a,o)){let l=ky(a,o);a=Vs(a,a.next),l=Vs(l,l.next),Ml(a,e,t,i,r,s,0),Ml(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function mI(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=By(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(MI(c));for(r.sort(fI),s=0;s<r.length;s++)t=gI(r[s],t);return t}function fI(n,e){return n.x-e.x}function gI(n,e){const t=vI(n,e);if(!t)return e;const i=ky(t,n);return Vs(i,i.next),Vs(t,t.next)}function vI(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&&Za(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),Tl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&yI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function yI(n,e){return Xt(n.prev,n,e.prev)<0&&Xt(e.next,n,n.next)<0}function xI(n,e,t,i){let r=n;do r.z===0&&(r.z=Em(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,_I(r)}function _I(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 Em(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 MI(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 Za(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 TI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!bI(n,e)&&(Tl(n,e)&&Tl(e,n)&&SI(n,e)&&(Xt(n.prev,n,e.prev)||Xt(n,e.prev,e))||ah(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 ah(n,e){return n.x===e.x&&n.y===e.y}function zy(n,e,t,i){const r=lh(Xt(n,e,t)),s=lh(Xt(n,e,i)),a=lh(Xt(t,i,n)),o=lh(Xt(t,i,e));return!!(r!==s&&a!==o||r===0&&oh(n,t,e)||s===0&&oh(n,i,e)||a===0&&oh(t,n,i)||o===0&&oh(t,e,i))}function oh(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 lh(n){return n>0?1:n<0?-1:0}function bI(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&&zy(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Tl(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 SI(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 ky(n,e){const t=new Am(n.i,n.x,n.y),i=new Am(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 Hy(n,e,t,i){const r=new Am(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 bl(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 Am(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 wI(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=[];Gy(e),Wy(i,e);let a=e.length;t.forEach(Gy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,Wy(i,t[l]);const o=cI.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Gy(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Wy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class vc extends ct{constructor(e=new rs([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:EI;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 AI(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 ih[r.type]().fromJSON(r)),new vc(i,e.options)}}const EI={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 AI(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 Ud extends fs{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 Ud(e.radius,e.detail)}}class wo extends fs{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 wo(e.radius,e.detail)}}class yc 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 yc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Od extends ct{constructor(e=new rs([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 NI(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 Od(i,e.curveSegments)}}function NI(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 Eo 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 Eo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Fd extends fs{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 Fd(e.radius,e.detail)}}class xc 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 xc(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Vd 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 Vd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Bd extends ct{constructor(e=new Tm(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 Bd(new ih[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Nm 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 Xy=Object.freeze({__proto__:null,BoxGeometry:yn,CapsuleGeometry:Id,CircleGeometry:Ld,ConeGeometry:Pd,CylinderGeometry:ha,DodecahedronGeometry:Dd,EdgesGeometry:wm,ExtrudeGeometry:vc,IcosahedronGeometry:Ud,LatheGeometry:gc,OctahedronGeometry:wo,PlaneGeometry:ua,PolyhedronGeometry:fs,RingGeometry:yc,ShapeGeometry:Od,SphereGeometry:Eo,TetrahedronGeometry:Fd,TorusGeometry:xc,TorusKnotGeometry:Vd,TubeGeometry:Bd,WireframeGeometry:Nm});class ch 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 Cm extends Pr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Sl 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 uh extends Sl{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 hh 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=pa,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 Rm 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 dh 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 ph 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=pa,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 Im 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 mh 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 Bs(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 qy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Yy(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 Lm(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 Pm(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 CI(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=Bs(h,c.times.constructor),c.values=Bs(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 RI(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 qi().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")qi.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=cp,n}const II={convertArray:Bs,isTypedArray:qy,getKeyframeOrder:Yy,sortedArray:Lm,flattenJSON:Pm,subclip:CI,makeClipAdditive:RI};class Qa{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 $y extends Qa{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:xs,endingEnd:xs}}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 _s:s=e,o=2*t-i;break;case Xo: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 _s:a=e,l=2*i-t;break;case Xo: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 Dm extends Qa{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 Jy extends Qa{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=Bs(t,this.TimeBufferType),this.values=Bs(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:Bs(e.times,Array),values:Bs(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Jy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Dm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new $y(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ba:t=this.InterpolantFactoryMethodDiscrete;break;case jo:t=this.InterpolantFactoryMethodLinear;break;case ru: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 ba;case this.InterpolantFactoryMethodLinear:return jo;case this.InterpolantFactoryMethodSmooth:return ru}}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&&qy(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()===ru,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=jo;class zs extends Fr{constructor(e,t,i){super(e,t,i)}}zs.prototype.ValueTypeName="bool",zs.prototype.ValueBufferType=Array,zs.prototype.DefaultInterpolation=ba,zs.prototype.InterpolantFactoryMethodLinear=void 0,zs.prototype.InterpolantFactoryMethodSmooth=void 0;class fh extends Fr{}fh.prototype.ValueTypeName="color";class eo extends Fr{}eo.prototype.ValueTypeName="number";class Ky extends Qa{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)qi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class to extends Fr{InterpolantFactoryMethodLinear(e){return new Ky(this.times,this.values,this.getValueSize(),e)}}to.prototype.ValueTypeName="quaternion",to.prototype.InterpolantFactoryMethodSmooth=void 0;class ks extends Fr{constructor(e,t,i){super(e,t,i)}}ks.prototype.ValueTypeName="string",ks.prototype.ValueBufferType=Array,ks.prototype.DefaultInterpolation=ba,ks.prototype.InterpolantFactoryMethodLinear=void 0,ks.prototype.InterpolantFactoryMethodSmooth=void 0;class io extends Fr{}io.prototype.ValueTypeName="vector";class ro{constructor(e="",t=-1,i=[],r=nu){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(PI(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=Yy(l);l=Lm(l,1,u),c=Lm(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new eo(".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=[];Pm(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 eo(".morphTargetInfluence["+m+"]",v,f))}l=d.length*a}else{const d=".bones["+t[u].name+"]";i(io,d+".position",h,"pos",r),i(to,d+".quaternion",h,"rot",r),i(io,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 LI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return eo;case"vector":case"vector2":case"vector3":case"vector4":return io;case"color":return fh;case"quaternion":return to;case"bool":case"boolean":return zs;case"string":return ks}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function PI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=LI(n.type);if(n.times===void 0){const t=[],i=[];Pm(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 Rn={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 gh{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 Um=new gh;class Hi{constructor(e){this.manager=e!==void 0?e:Um,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}}Hi.DEFAULT_MATERIAL_NAME="__DEFAULT";const In={};class DI extends Error{constructor(e,t){super(e),this.response=t}}class Kr extends Hi{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=Rn.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(In[e]!==void 0){In[e].push({onLoad:t,onProgress:i,onError:r});return}In[e]=[],In[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=In[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 DI(`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=>{Rn.add(e,c);const u=In[e];delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=In[e];if(u===void 0)throw this.manager.itemError(e),c;delete In[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 UI extends Hi{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=ro.parse(e[i]);t.push(r)}return t}}class OI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=[],o=new vl,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 wl extends Hi{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=Rn.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Zo("img");function l(){u(),Rn.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 FI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Ns;s.colorSpace=Fi;const a=new wl(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 Zy extends Hi{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=ji),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 Qy extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Wt,a=new wl(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 ns 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 vh extends ns{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 Om=new Re,ex=new N,tx=new N;class Fm{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 ka,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;ex.setFromMatrixPosition(e.matrixWorld),t.position.copy(ex),tx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(tx),t.updateMatrixWorld(),Om.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Om),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Om)}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 VI extends Fm{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=wa*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 El extends ns{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 VI}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 ix=new Re,Al=new N,Vm=new N;class BI extends Fm{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()),Al.setFromMatrixPosition(e.matrixWorld),i.position.copy(Al),Vm.copy(i.position),Vm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Vm),i.updateMatrixWorld(),r.makeTranslation(-Al.x,-Al.y,-Al.z),ix.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ix)}}class yh extends ns{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 BI}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 zI extends Fm{constructor(){super(new Is(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xh extends ns{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 zI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _h extends ns{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Bm extends ns{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 rx{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 zm extends ns{constructor(e=new rx,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 _c extends Hi{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 _c.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ch,SpriteMaterial:cl,RawShaderMaterial:Cm,ShaderMaterial:Pr,PointsMaterial:Ka,MeshPhysicalMaterial:uh,MeshStandardMaterial:Sl,MeshPhongMaterial:hh,MeshToonMaterial:Rm,MeshNormalMaterial:dh,MeshLambertMaterial:ph,MeshDepthMaterial:Fu,MeshDistanceMaterial:qp,MeshBasicMaterial:$r,MeshMatcapMaterial:Im,LineDashedMaterial:mh,LineBasicMaterial:Ni,Material:hi};return new t[e]}}class Mh{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 km 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 nx extends Hi{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=Ea(m.type,v),g=new ja(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 km:new ct,o=e.data.index;if(o!==void 0){const d=Ea(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 On(v,p.itemSize,p.offset,p.normalized)}else{const v=Ea(p.type,p.array),f=p.isInstancedBufferAttribute?Nn: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 On(y,g.itemSize,g.offset,g.normalized)}else{const y=Ea(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 sx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=this.path===""?Mh.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===""?Mh.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 rs().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 fc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new nx;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 Xy?o=Xy[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 _c;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=ro.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:Ea(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new gh(t);s=new wl(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 $n(p)}else{const p=o(h.url);r[h.uuid]=new $n(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:Ea(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new wl(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 $n(u)}else{const u=await s(l.url);i[l.uuid]=new $n(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 Ns,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,kI)),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],ax),u.wrapT=i(o.wrap[1],ax)),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,ox)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,ox)),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 Vu,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 Kp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Rd(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 Is(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 _h(e.color,e.intensity);break;case"DirectionalLight":a=new xh(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new yh(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Bm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new El(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new vh(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new zm().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),h=l(e.material),a=new rm(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 nm(u,h,d),a.instanceMatrix=new Nn(new Float32Array(p.array),16),m!==void 0&&(a.instanceColor=new Nn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),h=l(e.material),a=new lm(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 Bi;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 em;break;case"Line":a=new Cn(o(e.geometry),l(e.material));break;case"LineLoop":a=new um(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 dm(o(e.geometry),l(e.material));break;case"Sprite":a=new Qp(l(e.material));break;case"Group":a=new Us;break;case"Bone":a=new Wu;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 kI={UVMapping:Rc,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,EquirectangularReflectionMapping:zn,EquirectangularRefractionMapping:kn,CubeUVReflectionMapping:Hn},ax={RepeatWrapping:Gn,ClampToEdgeWrapping:gr,MirroredRepeatWrapping:ma},ox={NearestFilter:$t,NearestMipmapNearestFilter:Ic,NearestMipmapLinearFilter:Mn,LinearFilter:Lt,LinearMipmapNearestFilter:Wn,LinearMipmapLinearFilter:ji};class lx extends Hi{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=Rn.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 Rn.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Rn.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Rn.add(e,l),s.manager.itemStart(e)}}let Th;class bh{static getContext(){return Th===void 0&&(Th=new(window.AudioContext||window.webkitAudioContext)),Th}static setContext(e){Th=e}}class cx extends Hi{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);bh.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 ux=new Re,hx=new Re,Hs=new Re;class Hm{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,Hs.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,s=t.near*Math.tan(bs*t.fov*.5)/t.zoom;let a,o;hx.elements[12]=-i,ux.elements[12]=i,a=-s*t.aspect+r,o=s*t.aspect+r,Hs.elements[0]=2*t.near/(o-a),Hs.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Hs),a=-s*t.aspect-r,o=s*t.aspect-r,Hs.elements[0]=2*t.near/(o-a),Hs.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Hs)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(hx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(ux)}}class Gm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=dx(),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=dx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function dx(){return performance.now()}const cn=new N,px=new qi,HI=new N,Gs=new N;let mx=class extends _t{constructor(){super(),this.type="AudioListener",this.context=bh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Gm}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(cn,px,HI),!(!Number.isFinite(cn.x)||!Number.isFinite(cn.y)||!Number.isFinite(cn.z)))if(Gs.set(0,0,-1).applyQuaternion(px),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(cn.x,i),e.positionY.linearRampToValueAtTime(cn.y,i),e.positionZ.linearRampToValueAtTime(cn.z,i),e.forwardX.linearRampToValueAtTime(Gs.x,i),e.forwardY.linearRampToValueAtTime(Gs.y,i),e.forwardZ.linearRampToValueAtTime(Gs.z,i),e.upX.linearRampToValueAtTime(t.x,i),e.upY.linearRampToValueAtTime(t.y,i),e.upZ.linearRampToValueAtTime(t.z,i)}else e.setPosition(cn.x,cn.y,cn.z),e.setOrientation(Gs.x,Gs.y,Gs.z,t.x,t.y,t.z)}};class Wm 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 Ws=new N,fx=new qi,GI=new N,js=new N;class gx extends Wm{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(Ws,fx,GI),js.set(0,0,1).applyQuaternion(fx);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ws.x,i),t.positionY.linearRampToValueAtTime(Ws.y,i),t.positionZ.linearRampToValueAtTime(Ws.z,i),t.orientationX.linearRampToValueAtTime(js.x,i),t.orientationY.linearRampToValueAtTime(js.y,i),t.orientationZ.linearRampToValueAtTime(js.z,i)}else t.setPosition(Ws.x,Ws.y,Ws.z),t.setOrientation(js.x,js.y,js.z)}}class WI{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 vx{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){qi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;qi.multiplyQuaternionsFlat(e,a,e,t,e,i),qi.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="\\[\\]\\.:\\/",jI=new RegExp("["+jm+"]","g"),Xm="[^"+jm+"]",XI="[^"+jm.replace("\\.","")+"]",qI=/((?:WC+[\/:])*)/.source.replace("WC",Xm),YI=/(WCOD+)?/.source.replace("WCOD",XI),$I=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Xm),JI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Xm),KI=new RegExp("^"+qI+YI+$I+JI+"$"),ZI=["material","materials","bones","map"];class QI{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(jI,"")}static parseTrackName(e){const t=KI.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);ZI.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=QI,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 e2{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 yx{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:xs,endingEnd:xs};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=lp,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 cp:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case nu: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===B0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===op){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=_s,r.endingEnd=_s):(e?r.endingStart=this.zeroSlopeAtStart?_s:xs:r.endingStart=Xo,t?r.endingEnd=this.zeroSlopeAtEnd?_s:xs:r.endingEnd=Xo)}_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 t2=new Float32Array(1);class xx 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 vx(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 Dm(new Float32Array(2),new Float32Array(2),1,t2),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"?ro.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=nu),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 yx(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"?ro.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 _x=class YS{constructor(e){this.value=e}clone(){return new YS(this.value.clone===void 0?this.value:this.value.clone())}},i2=0;class r2 extends vr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:i2++}),this.name="",this.usage=Sa,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 qm extends ja{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 n2{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 Mx=new Re;class Tx{constructor(e,t,i=0,r=1/0){this.ray=new Es(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new rl,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 Mx.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Mx),this}intersectObject(e,t=!0,i=[]){return Ym(e,this,i,t),i.sort(bx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Ym(e[r],this,i,t);return i.sort(bx),i}}function bx(n,e){return n.distance-e.distance}function Ym(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++)Ym(s[a],e,t,!0)}}class Sx{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 s2{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 o0{constructor(e,t,i,r){o0.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 wx=new J;class a2{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=wx.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,wx).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 Ex=new N,Sh=new N;class Ax{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){Ex.subVectors(e,this.start),Sh.subVectors(this.end,this.start);const i=Sh.dot(Sh);let r=Sh.dot(Ex)/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 Nx=new N;class o2 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),Nx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Nx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const ss=new N,wh=new Re,$m=new Re;class l2 extends Jr{constructor(e){const t=Cx(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");$m.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(wh.multiplyMatrices($m,o.matrixWorld),ss.setFromMatrixPosition(wh),r.setXYZ(a,ss.x,ss.y,ss.z),wh.multiplyMatrices($m,o.parent.matrixWorld),ss.setFromMatrixPosition(wh),r.setXYZ(a+1,ss.x,ss.y,ss.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Cx(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Cx(n.children[t]));return e}class c2 extends Ft{constructor(e,t,i){const r=new Eo(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 u2=new N,Rx=new xe,Ix=new xe;class h2 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 wo(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");Rx.copy(this.light.color),Ix.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Rx:Ix;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(u2.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Lx=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 d2 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 Px=new N,Eh=new N,Dx=new N;class Ux 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 Cn(r,s),this.add(this.lightPlane),r=new ct,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Cn(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),Px.setFromMatrixPosition(this.light.matrixWorld),Eh.setFromMatrixPosition(this.light.target.matrixWorld),Dx.subVectors(Eh,Px),this.lightPlane.lookAt(Eh),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(Eh),this.targetLine.scale.z=Dx.length()}}const Ah=new N,Kt=new ol;class Ox 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){Ah.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],Ah.x,Ah.y,Ah.z)}}const Nh=new Bi;class Fx 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&&Nh.setFromObject(this.object),Nh.isEmpty())return;const t=Nh.min,i=Nh.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 Vx 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 p2 extends Cn{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 Bx=new N;let Ch,Jm;class m2 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",Ch===void 0&&(Ch=new ct,Ch.setAttribute("position",new De([0,0,0,0,1,0],3)),Jm=new ha(0,.5,1,5,1),Jm.translate(0,-.5,0)),this.position.copy(t),this.line=new Cn(Ch,new Ni({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ft(Jm,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{Bx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Bx,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 zx=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 kx{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new _l,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 rs;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 rs,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 rs,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 Hx 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 f2 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 g2=["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 Gx{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=g2,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 Nl(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 Wx=n=>Nl(n),jx=n=>Nl(n),Km=(...n)=>Nl(n);function Zm(n,e=!1){const t=[];n.isNode===!0&&(t.push(n.id),n=n.getSelf());for(const{property:i,childNode:r}of Cl(n))t.push(t,Nl(i.slice(0,-4)),r.getCacheKey(e));return Nl(t)}function*Cl(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 Ln(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 Qm(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"?tf(e[0]):null}function ef(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 tf(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0)).buffer}var v2=Object.freeze({__proto__:null,arrayBufferToBase64:ef,base64ToArrayBuffer:tf,getCacheKey:Zm,getNodeChildren:Cl,getValueFromType:Qm,getValueType:Ln,hash:Km,hashArray:jx,hashString:Wx});const rf={VERTEX:"vertex",FRAGMENT:"fragment"},je={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},y2={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},nf=["fragment","vertex"],sf=["setup","analyze","generate"],af=[...nf,"compute"],no=["x","y","z","w"];let x2=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=lu.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:x2++})}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 Cl(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=Zm(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 Cl(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 as 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 of 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 Xx 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 _2=no.join("");class Rh 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(no.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===_2.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 qx 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=no[h];d===i[0]?(u.push(o),h+=i.length-1):u.push(l+"."+d)}return`${e.getType(s)}( ${u.join(", ")} )`}}class M2 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=no[h];d===t[u]?(c.push("1.0 - "+(o+"."+d)),u++):c.push(o+"."+d)}return`${e.getType(r)}( ${c.join(", ")} )`}}class lf 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?Ln(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=Ln(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=ef(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Qm(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 lf{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 so=null;const ao=new Map;function te(n,e){if(ao.has(n)){console.warn(`Redefinition of method chaining ${n}`);return}if(typeof e!="function")throw new Error(`Node element ${n} is not a function`);ao.set(n,e)}const Yx=n=>n.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),$x=n=>Yx(n).split("").sort().join(""),Jx={setup(n,e){const t=e.shift();return n(Ll(t),...e)},get(n,e,t){if(typeof e=="string"&&n[e]===void 0){if(n.isStackNode!==!0&&e==="assign")return(...i)=>(so.assign(t,...i),t);if(ao.has(e)){const i=ao.get(e);return n.isStackNode?(...r)=>t.add(i(...r)):(...r)=>i(t,...r)}else{if(e==="self")return n;if(e.endsWith("Assign")&&ao.has(e.slice(0,e.length-6))){const i=ao.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=Yx(e),G(new Rh(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(3).toLowerCase()),i=>G(new qx(n,e,i));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(4).toLowerCase()),()=>G(new M2(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 Rh(n,e));if(/^\d+$/.test(e)===!0)return G(new as(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)}},cf=new WeakMap,Kx=new WeakMap,T2=function(n,e=null){const t=Ln(n);if(t==="node"){let i=cf.get(n);return i===void 0&&(i=new Proxy(n,Jx),cf.set(n,i),cf.set(i,i)),i}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return G(pf(n,e));if(t==="shader")return U(n)}return n},b2=function(n,e=null){for(const t in n)n[t]=G(n[t],e);return n},S2=function(n,e=null){const t=n.length;for(let i=0;i<t;i++)n[i]=G(n[i],e);return n},w2=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(...Xs(s))):t!==null?(t=G(t),(...s)=>r(new n(e,...Xs(s),t))):(...s)=>r(new n(e,...Xs(s)))},E2=function(n,...e){return G(new n(...Xs(e)))};class A2 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=Kx.get(e.constructor);a===void 0&&(a=new WeakMap,Kx.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 N2 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 Ll(e),G(new A2(this,e))}setup(){return this.call()}}const C2=[!1,!0],R2=[0,1,2,3],I2=[-1,-2],Zx=[.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],uf=new Map;for(const n of C2)uf.set(n,new Vr(n));const hf=new Map;for(const n of R2)hf.set(n,new Vr(n,"uint"));const df=new Map([...hf].map(n=>new Vr(n.value,"int")));for(const n of I2)df.set(n,new Vr(n,"int"));const Ih=new Map([...df].map(n=>new Vr(n.value)));for(const n of Zx)Ih.set(n,new Vr(n));for(const n of Zx)Ih.set(-n,new Vr(-n));const Lh={bool:uf,uint:hf,ints:df,float:Ih},Qx=new Map([...uf,...Ih]),pf=(n,e)=>Qx.has(n)?Qx.get(n):n.isNode===!0?n:new Vr(n,e),L2=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=[Qm(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return G(e.get(t[0]));if(t.length===1){const r=pf(t[0],n);return L2(r)===n?G(r):G(new of(r,n))}const i=t.map(r=>pf(r));return G(new Xx(i,n))}},Rl=n=>typeof n=="object"&&n!==null?n.value:n,e_=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function Il(n,e){return new Proxy(new N2(n,e),Jx)}const G=(n,e=null)=>T2(n,e),Ll=(n,e=null)=>new b2(n,e),Xs=(n,e=null)=>new S2(n,e),K=(...n)=>new w2(...n),ge=(...n)=>new E2(...n),U=(n,e)=>{const t=new Il(n,e),i=(...r)=>{let s;return Ll(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},P2=(...n)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...n));te("toGlobal",n=>(n.global=!0,n));const Pl=n=>{so=n},mf=()=>so,Le=(...n)=>so.If(...n);function t_(n){return so&&so.add(n),n}te("append",t_);const i_=new oi("color"),E=new oi("float",Lh.float),P=new oi("int",Lh.ints),_e=new oi("uint",Lh.uint),os=new oi("bool",Lh.bool),z=new oi("vec2"),un=new oi("ivec2"),r_=new oi("uvec2"),n_=new oi("bvec2"),D=new oi("vec3"),s_=new oi("ivec3"),oo=new oi("uvec3"),ff=new oi("bvec3"),ae=new oi("vec4"),a_=new oi("ivec4"),o_=new oi("uvec4"),l_=new oi("bvec4"),Dl=new oi("mat2"),yi=new oi("mat3"),qs=new oi("mat4"),D2=(n="")=>G(new Vr(n,"string")),U2=n=>G(new Vr(n,"ArrayBuffer"));te("toColor",i_),te("toFloat",E),te("toInt",P),te("toUint",_e),te("toBool",os),te("toVec2",z),te("toIVec2",un),te("toUVec2",r_),te("toBVec2",n_),te("toVec3",D),te("toIVec3",s_),te("toUVec3",oo),te("toBVec3",ff),te("toVec4",ae),te("toIVec4",a_),te("toUVec4",o_),te("toBVec4",l_),te("toMat2",Dl),te("toMat3",yi),te("toMat4",qs);const c_=K(as),u_=(n,e)=>G(new of(G(n),e)),O2=(n,e)=>G(new Rh(G(n),e));te("element",c_),te("convert",u_);class gf 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 h_=n=>new gf(n),vf=(n,e=0)=>new gf(n,!0,e),F2=vf("frame"),xt=vf("render"),d_=h_("object");class Ys extends lf{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=d_}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=e_(e||n),i=n&&n.isNode===!0?n.node&&n.node.value||n.value:n;return G(new Ys(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"),yf=ge(Et,"vec3","EmissiveColor"),hn=ge(Et,"float","Roughness"),Ul=ge(Et,"float","Metalness"),Ph=ge(Et,"float","Clearcoat"),Ol=ge(Et,"float","ClearcoatRoughness"),$s=ge(Et,"vec3","Sheen"),Dh=ge(Et,"float","SheenRoughness"),Uh=ge(Et,"float","Iridescence"),xf=ge(Et,"float","IridescenceIOR"),_f=ge(Et,"float","IridescenceThickness"),Oh=ge(Et,"float","AlphaT"),ls=ge(Et,"float","Anisotropy"),Fl=ge(Et,"vec3","AnisotropyT"),Js=ge(Et,"vec3","AnisotropyB"),or=ge(Et,"color","SpecularColor"),Vl=ge(Et,"float","SpecularF90"),Fh=ge(Et,"float","Shininess"),Mf=ge(Et,"vec4","Output"),Ks=ge(Et,"float","dashSize"),Bl=ge(Et,"float","gapSize"),V2=ge(Et,"float","pointWidth"),zl=ge(Et,"float","IOR"),Vh=ge(Et,"float","Transmission"),Tf=ge(Et,"float","Thickness"),bf=ge(Et,"float","AttenuationDistance"),Sf=ge(Et,"color","AttenuationColor"),wf=ge(Et,"float","Dispersion");class p_ 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 no.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 m_=K(p_);te("assign",m_);class f_ 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 g_=(n,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Xs(e):Ll(e[0]),G(new f_(G(n),e)));te("call",g_);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,"/"),Ef=K(Gt,"%"),v_=K(Gt,"=="),y_=K(Gt,"!="),x_=K(Gt,"<"),Af=K(Gt,">"),__=K(Gt,"<="),M_=K(Gt,">="),T_=K(Gt,"&&"),b_=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,">>");te("add",zt),te("sub",Pt),te("mul",lt),te("div",Qr),te("modInt",Ef),te("equal",v_),te("notEqual",y_),te("lessThan",x_),te("greaterThan",Af),te("lessThanEqual",__),te("greaterThanEqual",M_),te("and",T_),te("or",b_),te("not",S_),te("xor",w_),te("bitAnd",E_),te("bitNot",A_),te("bitOr",N_),te("bitXor",C_),te("shiftLeft",R_),te("shiftRight",I_);const L_=(...n)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Ef(...n));te("remainder",L_);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 P_=E(1e-6),B2=E(1e6),Zs=E(Math.PI),z2=E(Math.PI*2),Nf=K(V,V.ALL),D_=K(V,V.ANY),U_=K(V,V.EQUALS),O_=K(V,V.RADIANS),F_=K(V,V.DEGREES),Cf=K(V,V.EXP),Bh=K(V,V.EXP2),Rf=K(V,V.LOG),kl=K(V,V.LOG2),en=K(V,V.SQRT),V_=K(V,V.INVERSE_SQRT),cs=K(V,V.FLOOR),If=K(V,V.CEIL),Mr=K(V,V.NORMALIZE),us=K(V,V.FRACT),Ci=K(V,V.SIN),Tr=K(V,V.COS),B_=K(V,V.TAN),z_=K(V,V.ASIN),zh=K(V,V.ACOS),k_=K(V,V.ATAN),It=K(V,V.ABS),Hl=K(V,V.SIGN),Qs=K(V,V.LENGTH),H_=K(V,V.NEGATE),G_=K(V,V.ONE_MINUS),W_=K(V,V.DFDX),j_=K(V,V.DFDY),X_=K(V,V.ROUND),q_=K(V,V.RECIPROCAL),Lf=K(V,V.TRUNC),Y_=K(V,V.FWIDTH),k2=K(V,V.BITCAST),$_=K(V,V.TRANSPOSE),J_=K(V,V.ATAN2),xi=K(V,V.MIN),ft=K(V,V.MAX),kh=K(V,V.MOD),Gl=K(V,V.STEP),K_=K(V,V.REFLECT),Z_=K(V,V.DISTANCE),Q_=K(V,V.DIFFERENCE),qt=K(V,V.DOT),lo=K(V,V.CROSS),Ji=K(V,V.POW),Pf=K(V,V.POW,2),eM=K(V,V.POW,3),tM=K(V,V.POW,4),iM=K(V,V.TRANSFORM_DIRECTION),rM=n=>lt(Hl(n),Ji(It(n),1/3)),Df=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))),nM=n=>li(n),Uf=K(V,V.REFRACT),Ki=K(V,V.SMOOTHSTEP),sM=K(V,V.FACEFORWARD),Of=U(([n])=>{const e=43758.5453,t=qt(n.xy,z(12.9898,78.233)),i=kh(t,Zs);return us(Ci(i).mul(e))}),aM=(n,e,t)=>rt(e,t,n),oM=(n,e,t)=>Ki(e,t,n);te("all",Nf),te("any",D_),te("equals",U_),te("radians",O_),te("degrees",F_),te("exp",Cf),te("exp2",Bh),te("log",Rf),te("log2",kl),te("sqrt",en),te("inverseSqrt",V_),te("floor",cs),te("ceil",If),te("normalize",Mr),te("fract",us),te("sin",Ci),te("cos",Tr),te("tan",B_),te("asin",z_),te("acos",zh),te("atan",k_),te("abs",It),te("sign",Hl),te("length",Qs),te("lengthSq",Df),te("negate",H_),te("oneMinus",G_),te("dFdx",W_),te("dFdy",j_),te("round",X_),te("reciprocal",q_),te("trunc",Lf),te("fwidth",Y_),te("atan2",J_),te("min",xi),te("max",ft),te("mod",kh),te("step",Gl),te("reflect",K_),te("distance",Z_),te("dot",qt),te("cross",lo),te("pow",Ji),te("pow2",Pf),te("pow3",eM),te("pow4",tM),te("transformDirection",iM),te("mix",aM),te("clamp",li),te("refract",Uf),te("smoothstep",oM),te("faceForward",sM),te("difference",Q_),te("saturate",nM),te("cbrt",rM),te("transpose",$_),te("rand",Of);class H2 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(`
3847
+ }`;class kR{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:BR,fragmentShader:zR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ft(new ua(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class HR 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 kR,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 $p;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 Jp,y[ie]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getGripSpace()},this.getHand=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,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?qn:Xn,be=f.stencil?jn: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 Us(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=wa*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 Dv;et.setAnimationLoop(at),this.setAnimationLoop=function(ie){Ve=ie},this.dispose=function(){}}}const Fs=new dr,GR=new Re;function WR(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,Iv(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,Fs.copy(_),Fs.x*=-1,Fs.y*=-1,Fs.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Fs.y*=-1,Fs.z*=-1),f.envMapRotation.value.setFromMatrix4(GR.makeRotationFromEuler(Fs)),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 jR(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 cy{constructor(e={}){const{canvas:t=hv(),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 ka;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 KN(L),pe.init(),ut=new ly(L,pe),Ue=new XN(L,pe,e,ut),we=new IR(L),Ue.reverseDepthBuffer&&we.buffers.depth.setReversed(!0),$e=new eC(L),Be=new yR,R=new FR(L,pe,we,Be,Ue,ut,$e),S=new YN(y),W=new JN(y),ne=new lE(L),Dt=new WN(L,ne),de=new ZN(L,ne,$e,Dt),se=new iC(L,de,ne,$e),it=new tC(L,Ue,R),ve=new qN(Be),ke=new vR(y,S,W,pe,Ue,Dt,ve),Ee=new WR(y,Be),Pe=new _R,mt=new ER(pe),tt=new GN(y,S,W,we,se,d,l),ze=new CR(y,se,Ue),O=new jR(L,$e,Ue,we),Oe=new jN(L,pe,$e),Mt=new QN(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 HR(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===Vc||me===Fc||me===Oo}if(F){const me=w.texture.type,Ie=me===jr||me===Nr||me===fa||me===jn||me===Lc||me===Pc,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",l0),ee.removeEventListener("sessionend",c0),ys.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=$S(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,Wi=F._multiDrawCounts,xs=F._multiDrawCount,Gr=Ge?ne.get(Ge).bytesPerElement:1,da=Be.get(q).currentProgram.getUniforms();for(let pr=0;pr<xs;pr++)da.setValue(L,"_gl_DrawID",pr),Ht.render(Xe[pr]/Gr,Wi[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,Wi=Math.min(X.instanceCount,Xe);Ht.renderInstances(Rt,Qt,Wi)}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,Tc(A,B,X),A.side=an,A.needsUpdate=!0,Tc(A,B,X),A.side=Wr):Tc(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 xn(A){ir&&ir(A)}function l0(){ys.stop()}function c0(){ys.start()}const ys=new Dv;ys.setAnimationLoop(xn),typeof self<"u"&&ys.setContext(self),this.setAnimationLoop=function(A){ir=A,ee.setAnimationLoop(A),A===null?ys.stop():ys.start()},ee.addEventListener("sessionstart",l0),ee.addEventListener("sessionend",c0),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&&zd(me,B,-1/0,y.sortObjects)}zd(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];h0(q,F,A,Ge)}ce&&tt.render(A);for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];u0(v,A,Ge,Ge.viewport)}}else F.length>0&&h0(q,F,A,B),ce&&tt.render(A),u0(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 zd(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++)zd(F[me],B,X,q)}function u0(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&&Mc(F,B,X),me.length>0&&Mc(me,B,X),Ie.length>0&&Mc(Ie,B,X),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function h0(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:ji,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),Mc(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,d0(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 Mc(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)&&d0(Fe,B,X,Ge,Qe,Ze)}}function d0(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 Tc(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 m0(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),m0(A,Fe),q.needsLights=KS(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 p0(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=Uu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function m0(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 $S(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),Wi=f.state.lights;if(ie===!0&&(le===!0||A!==H)){const wr=A===H&&q.id===C;ve.setState(q,A,wr)}let xs=!1;q.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Wi.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)&&(xs=!0):(xs=!0,Xe.__version=q.version);let Gr=Xe.currentProgram;xs===!0&&(Gr=Tc(q,B,F));let da=!1,pr=!1,kd=!1;const ei=Gr.getUniforms(),Fn=Xe.uniforms;if(we.useProgram(Gr.program)&&(da=!0,pr=!0,kd=!0),q.id!==C&&(C=q.id,pr=!0),da||H!==A){Ue.reverseDepthBuffer?(be.copy(A.projectionMatrix),Dw(be),Uw(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,kd=!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 Hd=X.morphAttributes;if((Hd.position!==void 0||Hd.normal!==void 0||Hd.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&&(Fn.envMap.value=Ge,Fn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&B.environment!==null&&(Fn.envMapIntensity.value=B.environmentIntensity),pr&&(ei.setValue(L,"toneMappingExposure",y.toneMappingExposure),Xe.needsLights&&JS(Fn,kd),me&&q.fog===!0&&Ee.refreshFogUniforms(Fn,me),Ee.refreshMaterialUniforms(Fn,q,he,$,f.state.transmissionRenderTarget[A.id]),Uu.upload(L,p0(Xe),Fn,R)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Uu.upload(L,p0(Xe),Fn,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 Gd=0,ZS=wr.length;Gd<ZS;Gd++){const f0=wr[Gd];O.update(f0,Gr),O.bind(f0,Gr)}}return Gr}function JS(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 KS(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 Pw(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&&(cu("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&&(cu("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),Wi=A.isCompressedTexture?A.mipmaps[F]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Wi.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,Wi.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,F,Qe,Ze,Wi.width,Wi.height,Je,Wi.data):L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi),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&&(cu("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 Wi=L.getParameter(L.UNPACK_ROW_LENGTH),xs=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Gr=L.getParameter(L.UNPACK_SKIP_PIXELS),da=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,Wi),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,xs),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Gr),L.pixelStorei(L.UNPACK_SKIP_ROWS,da),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===su?"display-p3":"srgb",t.unpackColorSpace=vt.workingColorSpace===qo?"display-p3":"srgb"}}class Rd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Rd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let Kp=class qS{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 qS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Vu 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 ja{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Sa,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 On{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=Xi(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=Xi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xi(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 On(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 cl 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 Xa;const ul=new N,qa=new N,Ya=new N,$a=new J,hl=new J,uy=new Re,Bu=new N,dl=new N,zu=new N,hy=new J,Zp=new J,dy=new J;class Qp extends _t{constructor(e=new cl){if(super(),this.isSprite=!0,this.type="Sprite",Xa===void 0){Xa=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 ja(t,5);Xa.setIndex([0,1,2,0,2,3]),Xa.setAttribute("position",new On(i,3,0,!1)),Xa.setAttribute("uv",new On(i,2,3,!1))}this.geometry=Xa,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.'),qa.setFromMatrixScale(this.matrixWorld),uy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ya.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&qa.multiplyScalar(-Ya.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const a=this.center;ku(Bu.set(-.5,-.5,0),Ya,a,qa,r,s),ku(dl.set(.5,-.5,0),Ya,a,qa,r,s),ku(zu.set(.5,.5,0),Ya,a,qa,r,s),hy.set(0,0),Zp.set(1,0),dy.set(1,1);let o=e.ray.intersectTriangle(Bu,dl,zu,!1,ul);if(o===null&&(ku(dl.set(-.5,.5,0),Ya,a,qa,r,s),Zp.set(0,1),o=e.ray.intersectTriangle(Bu,zu,dl,!1,ul),o===null))return;const l=e.ray.origin.distanceTo(ul);l<e.near||l>e.far||t.push({distance:l,point:ul.clone(),uv:er.getInterpolation(ul,Bu,dl,zu,hy,Zp,dy,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 ku(n,e,t,i,r,s){$a.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(hl.x=s*$a.x-r*$a.y,hl.y=r*$a.x+s*$a.y):hl.copy($a),n.copy(e),n.x+=hl.x,n.y+=hl.y,n.applyMatrix4(uy)}const Hu=new N,py=new N;class em 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){Hu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Hu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Hu.setFromMatrixPosition(e.matrixWorld),py.setFromMatrixPosition(this.matrixWorld);const i=Hu.distanceTo(py)/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 my=new N,fy=new st,gy=new st,XR=new N,vy=new Re,Gu=new N,tm=new Ai,yy=new Re,im=new As;class rm extends Ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ep,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 Bi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Gu),this.boundingBox.expandByPoint(Gu)}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,Gu),this.boundingSphere.expandByPoint(Gu)}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(),tm.copy(this.boundingSphere),tm.applyMatrix4(r),e.ray.intersectsSphere(tm)!==!1&&(yy.copy(r).invert(),im.copy(e.ray).applyMatrix4(yy),!(this.boundingBox!==null&&im.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,im)))}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===ep?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===F0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;fy.fromBufferAttribute(r.attributes.skinIndex,e),gy.fromBufferAttribute(r.attributes.skinWeight,e),my.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=gy.getComponent(s);if(a!==0){const o=fy.getComponent(s);vy.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(XR.copy(my).applyMatrix4(vy),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Wu 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 xy=new Re,qR=new Re;class fc{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:qR;xy.multiplyMatrices(o,t[s]),xy.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new fc(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 Wu),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 Nn 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 Ja=new Re,_y=new Re,ju=[],My=new Bi,YR=new Re,pl=new Ft,ml=new Ai;class nm extends Ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Nn(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,YR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Bi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ja),My.copy(e.boundingBox).applyMatrix4(Ja),this.boundingBox.union(My)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ja),ml.copy(e.boundingSphere).applyMatrix4(Ja),this.boundingSphere.union(ml)}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(pl.geometry=this.geometry,pl.material=this.material,pl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ml.copy(this.boundingSphere),ml.applyMatrix4(i),e.ray.intersectsSphere(ml)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Ja),_y.multiplyMatrices(i,Ja),pl.matrixWorld=_y,pl.raycast(e,ju);for(let a=0,o=ju.length;a<o;a++){const l=ju[a];l.instanceId=s,l.object=this,t.push(l)}ju.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Nn(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,Uo,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 $R(n,e){return n.z-e.z}function JR(n,e){return e.z-n.z}class KR{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 is=new Re,sm=new Re,ZR=new Re,QR=new xe(1,1,1),Ty=new Re,am=new ka,Xu=new Bi,Vs=new Ai,fl=new N,by=new N,eI=new N,om=new KR,ki=new Ft,qu=[];function tI(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 lm 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,Oo,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 Bi);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,is),this.getBoundingBoxAt(s,Xu).applyMatrix4(is),e.union(Xu)}}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,is),this.getBoundingSphereAt(s,Vs).applyMatrix4(is),e.union(Vs)}}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;ZR.toArray(s,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(QR.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 Bi,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);tI(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(fl.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,Xu),Xu.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)),fl.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(fl))}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;ki.material=this.material,ki.geometry.index=a.index,ki.geometry.attributes=a.attributes,ki.geometry.boundingBox===null&&(ki.geometry.boundingBox=new Bi),ki.geometry.boundingSphere===null&&(ki.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];ki.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,ki.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,ki.geometry.boundingBox),this.getBoundingSphereAt(c,ki.geometry.boundingSphere),ki.raycast(e,qu);for(let h=0,d=qu.length;h<d;h++){const p=qu[h];p.object=this,p.batchId=o,t.push(p)}qu.length=0}ki.material=null,ki.geometry.index=null,ki.geometry.attributes={},ki.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&&(Ty.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),am.setFromProjectionMatrix(Ty,e.coordinateSystem));let v=0;if(this.sortObjects){sm.copy(this.matrixWorld).invert(),fl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(sm),by.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(sm);for(let x=0,y=l.length;x<y;x++)if(l[x].visible&&l[x].active){const _=l[x].geometryIndex;this.getMatrixAt(x,is),this.getBoundingSphereAt(_,Vs).applyMatrix4(is);let I=!1;if(d&&(I=!am.intersectsSphere(Vs)),!I){const T=eI.subVectors(Vs.center,fl).dot(by);om.push(h[_],T,x)}}const f=om.list,g=this.customSort;g===null?f.sort(s.transparent?JR:$R):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++}om.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,is),this.getBoundingSphereAt(x,Vs).applyMatrix4(is),y=!am.intersectsSphere(Vs)),!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 Yu=new N,$u=new N,Sy=new Re,gl=new As,Ju=new Ai,cm=new N,wy=new N;class Cn 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++)Yu.fromBufferAttribute(t,r-1),$u.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Yu.distanceTo($u);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(),Ju.copy(i.boundingSphere),Ju.applyMatrix4(r),Ju.radius+=s,e.ray.intersectsSphere(Ju)===!1)return;Sy.copy(r).invert(),gl.copy(e.ray).applyMatrix4(Sy);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=Ku(this,e,gl,l,f,g);x&&t.push(x)}if(this.isLineLoop){const m=u.getX(p-1),v=u.getX(d),f=Ku(this,e,gl,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=Ku(this,e,gl,l,m,m+1);f&&t.push(f)}if(this.isLineLoop){const m=Ku(this,e,gl,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 Ku(n,e,t,i,r,s){const a=n.geometry.attributes.position;if(Yu.fromBufferAttribute(a,r),$u.fromBufferAttribute(a,s),t.distanceSqToSegment(Yu,$u,cm,wy)>i)return;cm.applyMatrix4(n.matrixWorld);const o=e.ray.origin.distanceTo(cm);if(!(o<e.near||o>e.far))return{distance:o,point:wy.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const Ey=new N,Ay=new N;class Jr extends Cn{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)Ey.fromBufferAttribute(t,r),Ay.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ey.distanceTo(Ay);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class um extends Cn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Ka 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 Ny=new Re,hm=new As,Zu=new Ai,Qu=new N;class dm extends _t{constructor(e=new ct,t=new Ka){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(),Zu.copy(i.boundingSphere),Zu.applyMatrix4(r),Zu.radius+=s,e.ray.intersectsSphere(Zu)===!1)return;Ny.copy(r).invert(),hm.copy(e.ray).applyMatrix4(Ny);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);Qu.fromBufferAttribute(u,v),Cy(Qu,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++)Qu.fromBufferAttribute(u,p),Cy(Qu,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 Cy(n,e,t,i,r,s,a){const o=hm.distanceSqToPoint(n);if(o<t){const l=new N;hm.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 Ry 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 pm 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 vl 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 Iy extends vl{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 Ly extends vl{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 Py 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 eh 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 Dy extends eh{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function mm(){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 th=new N,fm=new mm,gm=new mm,vm=new mm;class ym 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]:(th.subVectors(r[0],r[1]).add(r[0]),c=th);const h=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(th.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=th),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),fm.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,v,f),gm.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,v,f),vm.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,v,f)}else this.curveType==="catmullrom"&&(fm.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),gm.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),vm.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(fm.calc(l),gm.calc(l),vm.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 Uy(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 iI(n,e){const t=1-n;return t*t*e}function rI(n,e){return 2*(1-n)*n*e}function nI(n,e){return n*n*e}function yl(n,e,t,i){return iI(n,e)+rI(n,t)+nI(n,i)}function sI(n,e){const t=1-n;return t*t*t*e}function aI(n,e){const t=1-n;return 3*t*t*n*e}function oI(n,e){return 3*(1-n)*n*n*e}function lI(n,e){return n*n*n*e}function xl(n,e,t,i,r){return sI(n,e)+aI(n,t)+oI(n,i)+lI(n,r)}class xm 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(xl(e,r.x,s.x,a.x,o.x),xl(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 Oy 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(xl(e,r.x,s.x,a.x,o.x),xl(e,r.y,s.y,a.y,o.y),xl(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 _m 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 Fy 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 Mm 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(yl(e,r.x,s.x,a.x),yl(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 Tm 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(yl(e,r.x,s.x,a.x),yl(e,r.y,s.y,a.y),yl(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 bm 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(Uy(o,l.x,c.x,u.x,h.x),Uy(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 ih=Object.freeze({__proto__:null,ArcCurve:Dy,CatmullRomCurve3:ym,CubicBezierCurve:xm,CubicBezierCurve3:Oy,EllipseCurve:eh,LineCurve:_m,LineCurve3:Fy,QuadraticBezierCurve:Mm,QuadraticBezierCurve3:Tm,SplineCurve:bm});class Vy 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 ih[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 ih[r.type]().fromJSON(r))}return this}}class _l extends Vy{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 _m(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 Mm(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 xm(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 bm(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 eh(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 gc 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 gc(e.points,e.segments,e.phiStart,e.phiLength)}}class Id extends gc{constructor(e=1,t=1,i=4,r=8){const s=new _l;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 Id(e.radius,e.length,e.capSegments,e.radialSegments)}}class Ld 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 Ld(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ha 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 ha(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Pd extends ha{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 Pd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class gs 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 gs(e.vertices,e.indices,e.radius,e.details)}}class Dd extends gs{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 Dd(e.radius,e.detail)}}const rh=new N,nh=new N,Sm=new N,sh=new er;class wm 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(Ss*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}=sh;if(m.fromBufferAttribute(a,l[0]),v.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),sh.getNormal(Sm),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=sh[c[g]],T=sh[c[x]],w=`${y}_${_}`,C=`${_}_${y}`;C in h&&h[C]?(Sm.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:Sm.clone()})}}for(const p in h)if(h[p]){const{index0:m,index1:v}=h[p];rh.fromBufferAttribute(a,m),nh.fromBufferAttribute(a,v),d.push(rh.x,rh.y,rh.z),d.push(nh.x,nh.y,nh.z)}this.setAttribute("position",new De(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class rs extends _l{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 _l().fromJSON(r))}return this}}const cI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=By(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=mI(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 Ml(s,a,t,o,l,p,0),a}};function By(n,e,t,i,r){let s,a;if(r===wI(n,e,t,i)>0)for(s=e;s<t;s+=i)a=Hy(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=Hy(s,n[s],n[s+1],a);return a&&ah(a,a.next)&&(bl(a),a=a.next),a}function Bs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(ah(t,t.next)||Xt(t.prev,t,t.next)===0)){if(bl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Ml(n,e,t,i,r,s,a){if(!n)return;!a&&s&&xI(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?hI(n,i,r,s):uI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),bl(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=dI(Bs(n),e,t),Ml(n,e,t,i,r,s,2)):a===2&&pI(n,e,t,i,r,s):Ml(Bs(n),e,t,i,r,s,1);break}}}function uI(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&&Za(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 hI(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=Em(p,m,e,t,i),x=Em(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&&Za(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&&Za(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&&Za(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&&Za(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function dI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!ah(r,s)&&zy(r,i,i.next,s)&&Tl(r,s)&&Tl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),bl(i),bl(i.next),i=n=s),i=i.next}while(i!==n);return Bs(i)}function pI(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&TI(a,o)){let l=ky(a,o);a=Bs(a,a.next),l=Bs(l,l.next),Ml(a,e,t,i,r,s,0),Ml(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function mI(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=By(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(MI(c));for(r.sort(fI),s=0;s<r.length;s++)t=gI(r[s],t);return t}function fI(n,e){return n.x-e.x}function gI(n,e){const t=vI(n,e);if(!t)return e;const i=ky(t,n);return Bs(i,i.next),Bs(t,t.next)}function vI(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&&Za(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),Tl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&yI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function yI(n,e){return Xt(n.prev,n,e.prev)<0&&Xt(e.next,n,n.next)<0}function xI(n,e,t,i){let r=n;do r.z===0&&(r.z=Em(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,_I(r)}function _I(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 Em(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 MI(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 Za(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 TI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!bI(n,e)&&(Tl(n,e)&&Tl(e,n)&&SI(n,e)&&(Xt(n.prev,n,e.prev)||Xt(n,e.prev,e))||ah(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 ah(n,e){return n.x===e.x&&n.y===e.y}function zy(n,e,t,i){const r=lh(Xt(n,e,t)),s=lh(Xt(n,e,i)),a=lh(Xt(t,i,n)),o=lh(Xt(t,i,e));return!!(r!==s&&a!==o||r===0&&oh(n,t,e)||s===0&&oh(n,i,e)||a===0&&oh(t,n,i)||o===0&&oh(t,e,i))}function oh(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 lh(n){return n>0?1:n<0?-1:0}function bI(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&&zy(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Tl(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 SI(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 ky(n,e){const t=new Am(n.i,n.x,n.y),i=new Am(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 Hy(n,e,t,i){const r=new Am(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 bl(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 Am(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 wI(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=[];Gy(e),Wy(i,e);let a=e.length;t.forEach(Gy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,Wy(i,t[l]);const o=cI.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Gy(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Wy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class vc extends ct{constructor(e=new rs([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:EI;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 AI(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 ih[r.type]().fromJSON(r)),new vc(i,e.options)}}const EI={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 AI(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 Ud extends gs{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 Ud(e.radius,e.detail)}}class wo extends gs{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 wo(e.radius,e.detail)}}class yc 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 yc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Od extends ct{constructor(e=new rs([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 NI(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 Od(i,e.curveSegments)}}function NI(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 Eo 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 Eo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Fd extends gs{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 Fd(e.radius,e.detail)}}class xc 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 xc(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Vd 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 Vd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Bd extends ct{constructor(e=new Tm(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 Bd(new ih[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Nm 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 Xy=Object.freeze({__proto__:null,BoxGeometry:yn,CapsuleGeometry:Id,CircleGeometry:Ld,ConeGeometry:Pd,CylinderGeometry:ha,DodecahedronGeometry:Dd,EdgesGeometry:wm,ExtrudeGeometry:vc,IcosahedronGeometry:Ud,LatheGeometry:gc,OctahedronGeometry:wo,PlaneGeometry:ua,PolyhedronGeometry:gs,RingGeometry:yc,ShapeGeometry:Od,SphereGeometry:Eo,TetrahedronGeometry:Fd,TorusGeometry:xc,TorusKnotGeometry:Vd,TubeGeometry:Bd,WireframeGeometry:Nm});class ch 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 Cm extends Pr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Sl 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 uh extends Sl{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 hh 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=pa,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 Rm 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 dh 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 ph 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=pa,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 Im 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 mh 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 zs(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 qy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Yy(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 Lm(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 Pm(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 CI(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=zs(h,c.times.constructor),c.values=zs(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 RI(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 qi().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")qi.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=cp,n}const II={convertArray:zs,isTypedArray:qy,getKeyframeOrder:Yy,sortedArray:Lm,flattenJSON:Pm,subclip:CI,makeClipAdditive:RI};class Qa{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 $y extends Qa{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:_s,endingEnd:_s}}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 Ms:s=e,o=2*t-i;break;case Xo: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 Ms:a=e,l=2*i-t;break;case Xo: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 Dm extends Qa{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 Jy extends Qa{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=zs(t,this.TimeBufferType),this.values=zs(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:zs(e.times,Array),values:zs(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Jy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Dm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new $y(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ba:t=this.InterpolantFactoryMethodDiscrete;break;case jo:t=this.InterpolantFactoryMethodLinear;break;case ru: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 ba;case this.InterpolantFactoryMethodLinear:return jo;case this.InterpolantFactoryMethodSmooth:return ru}}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&&qy(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()===ru,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=jo;class ns extends Fr{constructor(e,t,i){super(e,t,i)}}ns.prototype.ValueTypeName="bool",ns.prototype.ValueBufferType=Array,ns.prototype.DefaultInterpolation=ba,ns.prototype.InterpolantFactoryMethodLinear=void 0,ns.prototype.InterpolantFactoryMethodSmooth=void 0;class fh extends Fr{}fh.prototype.ValueTypeName="color";class eo extends Fr{}eo.prototype.ValueTypeName="number";class Ky extends Qa{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)qi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class to extends Fr{InterpolantFactoryMethodLinear(e){return new Ky(this.times,this.values,this.getValueSize(),e)}}to.prototype.ValueTypeName="quaternion",to.prototype.InterpolantFactoryMethodSmooth=void 0;class ks extends Fr{constructor(e,t,i){super(e,t,i)}}ks.prototype.ValueTypeName="string",ks.prototype.ValueBufferType=Array,ks.prototype.DefaultInterpolation=ba,ks.prototype.InterpolantFactoryMethodLinear=void 0,ks.prototype.InterpolantFactoryMethodSmooth=void 0;class io extends Fr{}io.prototype.ValueTypeName="vector";class ro{constructor(e="",t=-1,i=[],r=nu){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(PI(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=Yy(l);l=Lm(l,1,u),c=Lm(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new eo(".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=[];Pm(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 eo(".morphTargetInfluence["+m+"]",v,f))}l=d.length*a}else{const d=".bones["+t[u].name+"]";i(io,d+".position",h,"pos",r),i(to,d+".quaternion",h,"rot",r),i(io,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 LI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return eo;case"vector":case"vector2":case"vector3":case"vector4":return io;case"color":return fh;case"quaternion":return to;case"bool":case"boolean":return ns;case"string":return ks}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function PI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=LI(n.type);if(n.times===void 0){const t=[],i=[];Pm(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 Rn={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 gh{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 Um=new gh;class Hi{constructor(e){this.manager=e!==void 0?e:Um,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}}Hi.DEFAULT_MATERIAL_NAME="__DEFAULT";const In={};class DI extends Error{constructor(e,t){super(e),this.response=t}}class Kr extends Hi{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=Rn.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(In[e]!==void 0){In[e].push({onLoad:t,onProgress:i,onError:r});return}In[e]=[],In[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=In[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 DI(`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=>{Rn.add(e,c);const u=In[e];delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=In[e];if(u===void 0)throw this.manager.itemError(e),c;delete In[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 UI extends Hi{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=ro.parse(e[i]);t.push(r)}return t}}class OI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=[],o=new vl,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 wl extends Hi{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=Rn.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Zo("img");function l(){u(),Rn.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 FI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Cs;s.colorSpace=Fi;const a=new wl(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 Zy extends Hi{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=ji),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 Qy extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Wt,a=new wl(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 ss 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 vh extends ss{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 Om=new Re,ex=new N,tx=new N;class Fm{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 ka,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;ex.setFromMatrixPosition(e.matrixWorld),t.position.copy(ex),tx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(tx),t.updateMatrixWorld(),Om.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Om),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Om)}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 VI extends Fm{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=wa*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 El extends ss{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 VI}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 ix=new Re,Al=new N,Vm=new N;class BI extends Fm{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()),Al.setFromMatrixPosition(e.matrixWorld),i.position.copy(Al),Vm.copy(i.position),Vm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Vm),i.updateMatrixWorld(),r.makeTranslation(-Al.x,-Al.y,-Al.z),ix.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ix)}}class yh extends ss{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 BI}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 zI extends Fm{constructor(){super(new Ls(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xh extends ss{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 zI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _h extends ss{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Bm extends ss{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 rx{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 zm extends ss{constructor(e=new rx,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 _c extends Hi{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 _c.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ch,SpriteMaterial:cl,RawShaderMaterial:Cm,ShaderMaterial:Pr,PointsMaterial:Ka,MeshPhysicalMaterial:uh,MeshStandardMaterial:Sl,MeshPhongMaterial:hh,MeshToonMaterial:Rm,MeshNormalMaterial:dh,MeshLambertMaterial:ph,MeshDepthMaterial:Fu,MeshDistanceMaterial:qp,MeshBasicMaterial:$r,MeshMatcapMaterial:Im,LineDashedMaterial:mh,LineBasicMaterial:Ni,Material:hi};return new t[e]}}class Mh{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 km 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 nx extends Hi{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=Ea(m.type,v),g=new ja(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 km:new ct,o=e.data.index;if(o!==void 0){const d=Ea(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 On(v,p.itemSize,p.offset,p.normalized)}else{const v=Ea(p.type,p.array),f=p.isInstancedBufferAttribute?Nn: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 On(y,g.itemSize,g.offset,g.normalized)}else{const y=Ea(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 sx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=this.path===""?Mh.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===""?Mh.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 rs().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 fc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new nx;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 Xy?o=Xy[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 _c;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=ro.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:Ea(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new gh(t);s=new wl(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 $n(p)}else{const p=o(h.url);r[h.uuid]=new $n(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:Ea(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new wl(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 $n(u)}else{const u=await s(l.url);i[l.uuid]=new $n(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 Cs,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,kI)),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],ax),u.wrapT=i(o.wrap[1],ax)),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,ox)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,ox)),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 Vu,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 Kp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Rd(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 Ls(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 _h(e.color,e.intensity);break;case"DirectionalLight":a=new xh(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new yh(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Bm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new El(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new vh(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new zm().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),h=l(e.material),a=new rm(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 nm(u,h,d),a.instanceMatrix=new Nn(new Float32Array(p.array),16),m!==void 0&&(a.instanceColor=new Nn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),h=l(e.material),a=new lm(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 Bi;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 em;break;case"Line":a=new Cn(o(e.geometry),l(e.material));break;case"LineLoop":a=new um(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 dm(o(e.geometry),l(e.material));break;case"Sprite":a=new Qp(l(e.material));break;case"Group":a=new Os;break;case"Bone":a=new Wu;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 kI={UVMapping:Rc,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,EquirectangularReflectionMapping:zn,EquirectangularRefractionMapping:kn,CubeUVReflectionMapping:Hn},ax={RepeatWrapping:Gn,ClampToEdgeWrapping:gr,MirroredRepeatWrapping:ma},ox={NearestFilter:$t,NearestMipmapNearestFilter:Ic,NearestMipmapLinearFilter:Mn,LinearFilter:Lt,LinearMipmapNearestFilter:Wn,LinearMipmapLinearFilter:ji};class lx extends Hi{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=Rn.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 Rn.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Rn.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Rn.add(e,l),s.manager.itemStart(e)}}let Th;class bh{static getContext(){return Th===void 0&&(Th=new(window.AudioContext||window.webkitAudioContext)),Th}static setContext(e){Th=e}}class cx extends Hi{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);bh.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 ux=new Re,hx=new Re,Hs=new Re;class Hm{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,Hs.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,s=t.near*Math.tan(Ss*t.fov*.5)/t.zoom;let a,o;hx.elements[12]=-i,ux.elements[12]=i,a=-s*t.aspect+r,o=s*t.aspect+r,Hs.elements[0]=2*t.near/(o-a),Hs.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Hs),a=-s*t.aspect-r,o=s*t.aspect-r,Hs.elements[0]=2*t.near/(o-a),Hs.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Hs)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(hx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(ux)}}class Gm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=dx(),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=dx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function dx(){return performance.now()}const cn=new N,px=new qi,HI=new N,Gs=new N;let mx=class extends _t{constructor(){super(),this.type="AudioListener",this.context=bh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Gm}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(cn,px,HI),!(!Number.isFinite(cn.x)||!Number.isFinite(cn.y)||!Number.isFinite(cn.z)))if(Gs.set(0,0,-1).applyQuaternion(px),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(cn.x,i),e.positionY.linearRampToValueAtTime(cn.y,i),e.positionZ.linearRampToValueAtTime(cn.z,i),e.forwardX.linearRampToValueAtTime(Gs.x,i),e.forwardY.linearRampToValueAtTime(Gs.y,i),e.forwardZ.linearRampToValueAtTime(Gs.z,i),e.upX.linearRampToValueAtTime(t.x,i),e.upY.linearRampToValueAtTime(t.y,i),e.upZ.linearRampToValueAtTime(t.z,i)}else e.setPosition(cn.x,cn.y,cn.z),e.setOrientation(Gs.x,Gs.y,Gs.z,t.x,t.y,t.z)}};class Wm 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 Ws=new N,fx=new qi,GI=new N,js=new N;class gx extends Wm{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(Ws,fx,GI),js.set(0,0,1).applyQuaternion(fx);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ws.x,i),t.positionY.linearRampToValueAtTime(Ws.y,i),t.positionZ.linearRampToValueAtTime(Ws.z,i),t.orientationX.linearRampToValueAtTime(js.x,i),t.orientationY.linearRampToValueAtTime(js.y,i),t.orientationZ.linearRampToValueAtTime(js.z,i)}else t.setPosition(Ws.x,Ws.y,Ws.z),t.setOrientation(js.x,js.y,js.z)}}class WI{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 vx{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){qi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;qi.multiplyQuaternionsFlat(e,a,e,t,e,i),qi.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="\\[\\]\\.:\\/",jI=new RegExp("["+jm+"]","g"),Xm="[^"+jm+"]",XI="[^"+jm.replace("\\.","")+"]",qI=/((?:WC+[\/:])*)/.source.replace("WC",Xm),YI=/(WCOD+)?/.source.replace("WCOD",XI),$I=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Xm),JI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Xm),KI=new RegExp("^"+qI+YI+$I+JI+"$"),ZI=["material","materials","bones","map"];class QI{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(jI,"")}static parseTrackName(e){const t=KI.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);ZI.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=QI,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 e2{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 yx{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:_s,endingEnd:_s};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=lp,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 cp:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case nu: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===B0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===op){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=Ms,r.endingEnd=Ms):(e?r.endingStart=this.zeroSlopeAtStart?Ms:_s:r.endingStart=Xo,t?r.endingEnd=this.zeroSlopeAtEnd?Ms:_s:r.endingEnd=Xo)}_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 t2=new Float32Array(1);class xx 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 vx(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 Dm(new Float32Array(2),new Float32Array(2),1,t2),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"?ro.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=nu),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 yx(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"?ro.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 _x=class YS{constructor(e){this.value=e}clone(){return new YS(this.value.clone===void 0?this.value:this.value.clone())}},i2=0;class r2 extends vr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:i2++}),this.name="",this.usage=Sa,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 qm extends ja{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 n2{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 Mx=new Re;class Tx{constructor(e,t,i=0,r=1/0){this.ray=new As(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new rl,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 Mx.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Mx),this}intersectObject(e,t=!0,i=[]){return Ym(e,this,i,t),i.sort(bx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Ym(e[r],this,i,t);return i.sort(bx),i}}function bx(n,e){return n.distance-e.distance}function Ym(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++)Ym(s[a],e,t,!0)}}class Sx{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 s2{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 o0{constructor(e,t,i,r){o0.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 wx=new J;class a2{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=wx.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,wx).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 Ex=new N,Sh=new N;class Ax{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){Ex.subVectors(e,this.start),Sh.subVectors(this.end,this.start);const i=Sh.dot(Sh);let r=Sh.dot(Ex)/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 Nx=new N;class o2 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),Nx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Nx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const as=new N,wh=new Re,$m=new Re;class l2 extends Jr{constructor(e){const t=Cx(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");$m.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(wh.multiplyMatrices($m,o.matrixWorld),as.setFromMatrixPosition(wh),r.setXYZ(a,as.x,as.y,as.z),wh.multiplyMatrices($m,o.parent.matrixWorld),as.setFromMatrixPosition(wh),r.setXYZ(a+1,as.x,as.y,as.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Cx(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Cx(n.children[t]));return e}class c2 extends Ft{constructor(e,t,i){const r=new Eo(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 u2=new N,Rx=new xe,Ix=new xe;class h2 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 wo(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");Rx.copy(this.light.color),Ix.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Rx:Ix;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(u2.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Lx=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 d2 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 Px=new N,Eh=new N,Dx=new N;class Ux 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 Cn(r,s),this.add(this.lightPlane),r=new ct,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Cn(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),Px.setFromMatrixPosition(this.light.matrixWorld),Eh.setFromMatrixPosition(this.light.target.matrixWorld),Dx.subVectors(Eh,Px),this.lightPlane.lookAt(Eh),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(Eh),this.targetLine.scale.z=Dx.length()}}const Ah=new N,Kt=new ol;class Ox 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){Ah.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],Ah.x,Ah.y,Ah.z)}}const Nh=new Bi;class Fx 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&&Nh.setFromObject(this.object),Nh.isEmpty())return;const t=Nh.min,i=Nh.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 Vx 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 p2 extends Cn{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 Bx=new N;let Ch,Jm;class m2 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",Ch===void 0&&(Ch=new ct,Ch.setAttribute("position",new De([0,0,0,0,1,0],3)),Jm=new ha(0,.5,1,5,1),Jm.translate(0,-.5,0)),this.position.copy(t),this.line=new Cn(Ch,new Ni({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ft(Jm,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{Bx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Bx,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 zx=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 kx{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new _l,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 rs;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 rs,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 rs,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 Hx 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 f2 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 g2=["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 Gx{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=g2,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 Nl(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 Wx=n=>Nl(n),jx=n=>Nl(n),Km=(...n)=>Nl(n);function Zm(n,e=!1){const t=[];n.isNode===!0&&(t.push(n.id),n=n.getSelf());for(const{property:i,childNode:r}of Cl(n))t.push(t,Nl(i.slice(0,-4)),r.getCacheKey(e));return Nl(t)}function*Cl(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 Ln(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 Qm(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"?tf(e[0]):null}function ef(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 tf(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0)).buffer}var v2=Object.freeze({__proto__:null,arrayBufferToBase64:ef,base64ToArrayBuffer:tf,getCacheKey:Zm,getNodeChildren:Cl,getValueFromType:Qm,getValueType:Ln,hash:Km,hashArray:jx,hashString:Wx});const rf={VERTEX:"vertex",FRAGMENT:"fragment"},je={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},y2={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},nf=["fragment","vertex"],sf=["setup","analyze","generate"],af=[...nf,"compute"],no=["x","y","z","w"];let x2=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=lu.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:x2++})}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 Cl(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=Zm(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 Cl(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 os 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 of 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 Xx 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 _2=no.join("");class Rh 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(no.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===_2.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 qx 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=no[h];d===i[0]?(u.push(o),h+=i.length-1):u.push(l+"."+d)}return`${e.getType(s)}( ${u.join(", ")} )`}}class M2 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=no[h];d===t[u]?(c.push("1.0 - "+(o+"."+d)),u++):c.push(o+"."+d)}return`${e.getType(r)}( ${c.join(", ")} )`}}class lf 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?Ln(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=Ln(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=ef(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Qm(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 lf{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 so=null;const ao=new Map;function te(n,e){if(ao.has(n)){console.warn(`Redefinition of method chaining ${n}`);return}if(typeof e!="function")throw new Error(`Node element ${n} is not a function`);ao.set(n,e)}const Yx=n=>n.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),$x=n=>Yx(n).split("").sort().join(""),Jx={setup(n,e){const t=e.shift();return n(Ll(t),...e)},get(n,e,t){if(typeof e=="string"&&n[e]===void 0){if(n.isStackNode!==!0&&e==="assign")return(...i)=>(so.assign(t,...i),t);if(ao.has(e)){const i=ao.get(e);return n.isStackNode?(...r)=>t.add(i(...r)):(...r)=>i(t,...r)}else{if(e==="self")return n;if(e.endsWith("Assign")&&ao.has(e.slice(0,e.length-6))){const i=ao.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=Yx(e),G(new Rh(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(3).toLowerCase()),i=>G(new qx(n,e,i));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(4).toLowerCase()),()=>G(new M2(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 Rh(n,e));if(/^\d+$/.test(e)===!0)return G(new os(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)}},cf=new WeakMap,Kx=new WeakMap,T2=function(n,e=null){const t=Ln(n);if(t==="node"){let i=cf.get(n);return i===void 0&&(i=new Proxy(n,Jx),cf.set(n,i),cf.set(i,i)),i}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return G(pf(n,e));if(t==="shader")return U(n)}return n},b2=function(n,e=null){for(const t in n)n[t]=G(n[t],e);return n},S2=function(n,e=null){const t=n.length;for(let i=0;i<t;i++)n[i]=G(n[i],e);return n},w2=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(...Xs(s))):t!==null?(t=G(t),(...s)=>r(new n(e,...Xs(s),t))):(...s)=>r(new n(e,...Xs(s)))},E2=function(n,...e){return G(new n(...Xs(e)))};class A2 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=Kx.get(e.constructor);a===void 0&&(a=new WeakMap,Kx.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 N2 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 Ll(e),G(new A2(this,e))}setup(){return this.call()}}const C2=[!1,!0],R2=[0,1,2,3],I2=[-1,-2],Zx=[.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],uf=new Map;for(const n of C2)uf.set(n,new Vr(n));const hf=new Map;for(const n of R2)hf.set(n,new Vr(n,"uint"));const df=new Map([...hf].map(n=>new Vr(n.value,"int")));for(const n of I2)df.set(n,new Vr(n,"int"));const Ih=new Map([...df].map(n=>new Vr(n.value)));for(const n of Zx)Ih.set(n,new Vr(n));for(const n of Zx)Ih.set(-n,new Vr(-n));const Lh={bool:uf,uint:hf,ints:df,float:Ih},Qx=new Map([...uf,...Ih]),pf=(n,e)=>Qx.has(n)?Qx.get(n):n.isNode===!0?n:new Vr(n,e),L2=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=[Qm(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return G(e.get(t[0]));if(t.length===1){const r=pf(t[0],n);return L2(r)===n?G(r):G(new of(r,n))}const i=t.map(r=>pf(r));return G(new Xx(i,n))}},Rl=n=>typeof n=="object"&&n!==null?n.value:n,e_=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function Il(n,e){return new Proxy(new N2(n,e),Jx)}const G=(n,e=null)=>T2(n,e),Ll=(n,e=null)=>new b2(n,e),Xs=(n,e=null)=>new S2(n,e),K=(...n)=>new w2(...n),ge=(...n)=>new E2(...n),U=(n,e)=>{const t=new Il(n,e),i=(...r)=>{let s;return Ll(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},P2=(...n)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...n));te("toGlobal",n=>(n.global=!0,n));const Pl=n=>{so=n},mf=()=>so,Le=(...n)=>so.If(...n);function t_(n){return so&&so.add(n),n}te("append",t_);const i_=new oi("color"),E=new oi("float",Lh.float),P=new oi("int",Lh.ints),_e=new oi("uint",Lh.uint),ls=new oi("bool",Lh.bool),z=new oi("vec2"),un=new oi("ivec2"),r_=new oi("uvec2"),n_=new oi("bvec2"),D=new oi("vec3"),s_=new oi("ivec3"),oo=new oi("uvec3"),ff=new oi("bvec3"),ae=new oi("vec4"),a_=new oi("ivec4"),o_=new oi("uvec4"),l_=new oi("bvec4"),Dl=new oi("mat2"),yi=new oi("mat3"),qs=new oi("mat4"),D2=(n="")=>G(new Vr(n,"string")),U2=n=>G(new Vr(n,"ArrayBuffer"));te("toColor",i_),te("toFloat",E),te("toInt",P),te("toUint",_e),te("toBool",ls),te("toVec2",z),te("toIVec2",un),te("toUVec2",r_),te("toBVec2",n_),te("toVec3",D),te("toIVec3",s_),te("toUVec3",oo),te("toBVec3",ff),te("toVec4",ae),te("toIVec4",a_),te("toUVec4",o_),te("toBVec4",l_),te("toMat2",Dl),te("toMat3",yi),te("toMat4",qs);const c_=K(os),u_=(n,e)=>G(new of(G(n),e)),O2=(n,e)=>G(new Rh(G(n),e));te("element",c_),te("convert",u_);class gf 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 h_=n=>new gf(n),vf=(n,e=0)=>new gf(n,!0,e),F2=vf("frame"),xt=vf("render"),d_=h_("object");class Ys extends lf{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=d_}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=e_(e||n),i=n&&n.isNode===!0?n.node&&n.node.value||n.value:n;return G(new Ys(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"),yf=ge(Et,"vec3","EmissiveColor"),hn=ge(Et,"float","Roughness"),Ul=ge(Et,"float","Metalness"),Ph=ge(Et,"float","Clearcoat"),Ol=ge(Et,"float","ClearcoatRoughness"),$s=ge(Et,"vec3","Sheen"),Dh=ge(Et,"float","SheenRoughness"),Uh=ge(Et,"float","Iridescence"),xf=ge(Et,"float","IridescenceIOR"),_f=ge(Et,"float","IridescenceThickness"),Oh=ge(Et,"float","AlphaT"),cs=ge(Et,"float","Anisotropy"),Fl=ge(Et,"vec3","AnisotropyT"),Js=ge(Et,"vec3","AnisotropyB"),or=ge(Et,"color","SpecularColor"),Vl=ge(Et,"float","SpecularF90"),Fh=ge(Et,"float","Shininess"),Mf=ge(Et,"vec4","Output"),Ks=ge(Et,"float","dashSize"),Bl=ge(Et,"float","gapSize"),V2=ge(Et,"float","pointWidth"),zl=ge(Et,"float","IOR"),Vh=ge(Et,"float","Transmission"),Tf=ge(Et,"float","Thickness"),bf=ge(Et,"float","AttenuationDistance"),Sf=ge(Et,"color","AttenuationColor"),wf=ge(Et,"float","Dispersion");class p_ 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 no.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 m_=K(p_);te("assign",m_);class f_ 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 g_=(n,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Xs(e):Ll(e[0]),G(new f_(G(n),e)));te("call",g_);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,"/"),Ef=K(Gt,"%"),v_=K(Gt,"=="),y_=K(Gt,"!="),x_=K(Gt,"<"),Af=K(Gt,">"),__=K(Gt,"<="),M_=K(Gt,">="),T_=K(Gt,"&&"),b_=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,">>");te("add",zt),te("sub",Pt),te("mul",lt),te("div",Qr),te("modInt",Ef),te("equal",v_),te("notEqual",y_),te("lessThan",x_),te("greaterThan",Af),te("lessThanEqual",__),te("greaterThanEqual",M_),te("and",T_),te("or",b_),te("not",S_),te("xor",w_),te("bitAnd",E_),te("bitNot",A_),te("bitOr",N_),te("bitXor",C_),te("shiftLeft",R_),te("shiftRight",I_);const L_=(...n)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Ef(...n));te("remainder",L_);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 P_=E(1e-6),B2=E(1e6),Zs=E(Math.PI),z2=E(Math.PI*2),Nf=K(V,V.ALL),D_=K(V,V.ANY),U_=K(V,V.EQUALS),O_=K(V,V.RADIANS),F_=K(V,V.DEGREES),Cf=K(V,V.EXP),Bh=K(V,V.EXP2),Rf=K(V,V.LOG),kl=K(V,V.LOG2),en=K(V,V.SQRT),V_=K(V,V.INVERSE_SQRT),us=K(V,V.FLOOR),If=K(V,V.CEIL),Mr=K(V,V.NORMALIZE),hs=K(V,V.FRACT),Ci=K(V,V.SIN),Tr=K(V,V.COS),B_=K(V,V.TAN),z_=K(V,V.ASIN),zh=K(V,V.ACOS),k_=K(V,V.ATAN),It=K(V,V.ABS),Hl=K(V,V.SIGN),Qs=K(V,V.LENGTH),H_=K(V,V.NEGATE),G_=K(V,V.ONE_MINUS),W_=K(V,V.DFDX),j_=K(V,V.DFDY),X_=K(V,V.ROUND),q_=K(V,V.RECIPROCAL),Lf=K(V,V.TRUNC),Y_=K(V,V.FWIDTH),k2=K(V,V.BITCAST),$_=K(V,V.TRANSPOSE),J_=K(V,V.ATAN2),xi=K(V,V.MIN),ft=K(V,V.MAX),kh=K(V,V.MOD),Gl=K(V,V.STEP),K_=K(V,V.REFLECT),Z_=K(V,V.DISTANCE),Q_=K(V,V.DIFFERENCE),qt=K(V,V.DOT),lo=K(V,V.CROSS),Ji=K(V,V.POW),Pf=K(V,V.POW,2),eM=K(V,V.POW,3),tM=K(V,V.POW,4),iM=K(V,V.TRANSFORM_DIRECTION),rM=n=>lt(Hl(n),Ji(It(n),1/3)),Df=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))),nM=n=>li(n),Uf=K(V,V.REFRACT),Ki=K(V,V.SMOOTHSTEP),sM=K(V,V.FACEFORWARD),Of=U(([n])=>{const e=43758.5453,t=qt(n.xy,z(12.9898,78.233)),i=kh(t,Zs);return hs(Ci(i).mul(e))}),aM=(n,e,t)=>rt(e,t,n),oM=(n,e,t)=>Ki(e,t,n);te("all",Nf),te("any",D_),te("equals",U_),te("radians",O_),te("degrees",F_),te("exp",Cf),te("exp2",Bh),te("log",Rf),te("log2",kl),te("sqrt",en),te("inverseSqrt",V_),te("floor",us),te("ceil",If),te("normalize",Mr),te("fract",hs),te("sin",Ci),te("cos",Tr),te("tan",B_),te("asin",z_),te("acos",zh),te("atan",k_),te("abs",It),te("sign",Hl),te("length",Qs),te("lengthSq",Df),te("negate",H_),te("oneMinus",G_),te("dFdx",W_),te("dFdy",j_),te("round",X_),te("reciprocal",q_),te("trunc",Lf),te("fwidth",Y_),te("atan2",J_),te("min",xi),te("max",ft),te("mod",kh),te("step",Gl),te("reflect",K_),te("distance",Z_),te("dot",qt),te("cross",lo),te("pow",Ji),te("pow2",Pf),te("pow3",eM),te("pow4",tM),te("transformDirection",iM),te("mix",aM),te("clamp",li),te("refract",Uf),te("smoothstep",oM),te("faceForward",sM),te("difference",Q_),te("saturate",nM),te("cbrt",rM),te("transpose",$_),te("rand",Of);class H2 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(`
3848
3848
  ${e.tab}if ( ${u} ) {
3849
3849
 
3850
3850
  `).addFlowTab();let h=a.build(e,i);if(h&&(l?h=c+" = "+h+";":h="return "+h+";"),e.removeFlowTab().addFlowCode(e.tab+" "+h+`
@@ -3857,18 +3857,18 @@ ${e.tab}if ( ${u} ) {
3857
3857
 
3858
3858
  `)}else e.addFlowCode(`
3859
3859
 
3860
- `);return e.format(c,i,t)}}const Ri=K(H2);te("select",Ri);const lM=(...n)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ri(...n));te("cond",lM);class Ff 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 Vf=K(Ff),cM=(n,e)=>Vf(n,{label:e});te("context",Vf),te("label",cM);class uM 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 Bf=K(uM);te("temp",Bf),te("toVar",(...n)=>Bf(...n).append());class hM 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,rf.VERTEX);e.flowNodeFromShaderStage(rf.VERTEX,this.node,r,s),t.propertyName=s}return e.getPropertyName(i)}}const Ii=K(hM);te("varying",Ii);const Wl="WorkingColorSpace",zf="OutputColorSpace";function dM(n){let e=null;return n===nr?e="Linear":n===Fi&&(e="sRGB"),e}function Hh(n,e){return dM(n)+"To"+dM(e)}class jl 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===Wl?vt.workingColorSpace:t===zf?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=Hh(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 pM=n=>G(new jl(G(n),Wl,zf)),mM=n=>G(new jl(G(n),zf,Wl)),fM=(n,e)=>G(new jl(G(n),Wl,e)),kf=(n,e)=>G(new jl(G(n),e,Wl));te("toOutputColorSpace",pM),te("toWorkingColorSpace",mM),te("workingToColorSpace",fM),te("colorSpaceToWorking",kf);let G2=class extends as{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 gM 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 G2(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 W2=(n,e,t)=>G(new gM(n,e,t));class vM extends gM{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 yM=(n,e,t)=>G(new vM(n,e,t));class xM extends pt{static get type(){return"ToneMappingNode"}constructor(e,t=MM,i=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=i}getCacheKey(){return Km(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 _M=(n,e,t)=>G(new xM(n,G(e),G(t))),MM=yM("toneMappingExposure","float");te("toneMapping",(n,e,t)=>_M(e,t,n));class TM extends lf{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=Sa,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 ja(i,s),l=new On(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 Xl=(n,e,t,i)=>G(new TM(n,e,t,i)),bM=(n,e,t,i)=>Xl(n,e,t,i).setUsage(Ms),Gh=(n,e,t,i)=>Xl(n,e,t,i).setInstanced(!0),Hf=(n,e,t,i)=>bM(n,e,t,i).setInstanced(!0);te("toAttribute",n=>Xl(n.value));class SM 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 wM=(n,e,t)=>G(new SM(G(n),e,t));te("compute",wM);class EM 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 ql=(n,...e)=>G(new EM(G(n),...e));te("cache",ql);class AM 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 NM=K(AM);te("bypass",NM);class Gf 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 CM=K(Gf,null,null,{doClamp:!1}),RM=K(Gf);te("remap",CM),te("remapClamp",RM);class IM 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 hs=K(IM),LM=n=>(n?Ri(n,hs("discard")):hs("discard")).append(),j2=()=>hs("return").append();te("discard",LM);class PM 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 DM=(n,e=null,t=null)=>G(new PM(G(n),e,t));te("renderOutput",DM);function X2(n){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",n)}class Wf 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 Wf(n,e)),nt=n=>_i("uv"+(n>0?n:""),"vec2");class UM 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 ds=K(UM);class OM extends Ys{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 FM=K(OM);class dn extends Ys{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===ga?"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(ds(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=kf(hs(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(FM(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 ds(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(dn),Br=(...n)=>yt(...n).setSampler(!1),q2=n=>(n.isNode===!0?n:yt(n)).convert("sampler"),co=fe("float").label("cameraNear").setGroup(xt).onRenderUpdate(({camera:n})=>n.near),uo=fe("float").label("cameraFar").setGroup(xt).onRenderUpdate(({camera:n})=>n.far),VM=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),Y2=fe("mat4").label("cameraProjectionMatrixInverse").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrixInverse),cr=fe("mat4").label("cameraViewMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorldInverse),$2=fe("mat4").label("cameraWorldMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorld),J2=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 Ys(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 K2=K(St,St.DIRECTION),Z2=K(St,St.WORLD_MATRIX),Q2=K(St,St.POSITION),eL=K(St,St.SCALE),tL=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 iL=ge(tn,tn.DIRECTION),zr=ge(tn,tn.WORLD_MATRIX),rL=ge(tn,tn.POSITION),nL=ge(tn,tn.SCALE),sL=ge(tn,tn.VIEW_POSITION),BM=fe(new Ke).onObjectUpdate(({object:n},e)=>e.value.getNormalMatrix(n.matrixWorld)),zM=fe(new Re).onObjectUpdate(({object:n},e)=>e.value.copy(n.matrixWorld).invert()),pn=cr.mul(zr).toVar("modelViewMatrix_2"),aL=U(n=>(n.context.isHighPrecisionModelViewMatrix=!0,fe("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),oL=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"),Wh=Li.varying("positionPrevious"),jh=zr.mul(Zt).xyz.varying("v_positionWorld"),Xf=Zt.transformDirection(zr).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),Pi=pn.mul(Zt).xyz.varying("v_positionView"),Vt=Pi.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class kM 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 HM=ge(kM),Yl=E(HM).mul(2).sub(1),Xh=_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)):Xh,"vec3").once()().toVar("normalLocal"),GM=Pi.dFdx().cross(Pi.dFdy()).normalize().toVar("normalFlat"),hr=U(n=>{let e;return n.material.flatShading===!0?e=GM:e=Ii(Yf(ur),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),qh=Ii(hr.transformDirection(cr),"v_normalWorld").normalize().toVar("normalWorld"),Yt=U(n=>n.context.setupNormal(),"vec3").once()().mul(Yl).toVar("transformedNormalView"),qf=Yt.transformDirection(cr).toVar("transformedNormalWorld"),ho=U(n=>n.context.setupClearcoatNormal(),"vec3").once()().mul(Yl).toVar("transformedClearcoatNormalView"),WM=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}),Yf=U(([n],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(n);const i=BM.mul(n);return cr.transformDirection(i)}),jM=fe(0).onReference(({material:n})=>n).onRenderUpdate(({material:n})=>n.refractionRatio),XM=Vt.negate().reflect(Yt),qM=Vt.negate().refract(Yt,jM),YM=XM.transformDirection(cr).toVar("reflectVector"),$M=qM.transformDirection(cr).toVar("reflectVector");class JM extends dn{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?YM:e.mapping===Ar?$M:(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===Ts||!i.isRenderTargetTexture?D(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const Yh=K(JM);class $h extends Ys{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 $l=(n,e,t)=>G(new $h(n,e,t));class lL extends as{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 $f extends $h{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?Ln(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 lL(this,G(e)))}}const mn=(n,e)=>G(new $f(n,e)),cL=(n,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),G(new $f(n,e)));class uL extends as{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 Jl 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 uL(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=$l(null,e,this.count):Array.isArray(this.getValueFromReference())?t=mn(null,e):e==="texture"?t=yt(null):e==="cubeTexture"?t=Yh(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 Jl(n,e,t)),Jf=(n,e,t,i)=>G(new Jl(n,e,i,t));class KM extends Jl{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 KM(n,e,t)),Jh=U(n=>(n.geometry.hasAttribute("tangent")===!1&&n.geometry.computeTangents(),_i("tangent","vec4")))(),Kl=Jh.xyz.toVar("tangentLocal"),Zl=pn.mul(ae(Kl,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),ZM=Zl.transformDirection(cr).varying("v_tangentWorld").normalize().toVar("tangentWorld"),Kf=Zl.toVar("transformedTangentView"),hL=Kf.transformDirection(cr).normalize().toVar("transformedTangentWorld"),Ql=n=>n.mul(Jh.w).xyz,dL=Ii(Ql(Xh.cross(Jh)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),pL=Ii(Ql(ur.cross(Kl)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),QM=Ii(Ql(hr.cross(Zl)),"v_bitangentView").normalize().toVar("bitangentView"),mL=Ii(Ql(qh.cross(ZM)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),e1=Ql(Yt.cross(Kf)).normalize().toVar("transformedBitangentView"),fL=e1.transformDirection(cr).normalize().toVar("transformedBitangentWorld"),ea=yi(Zl,QM,hr),t1=Vt.mul(ea),gL=(n,e)=>n.sub(t1.mul(e)),i1=(()=>{let n=Js.cross(Vt);return n=n.cross(Js).normalize(),n=rt(n,Yt,ls.mul(hn.oneMinus()).oneMinus().pow2().pow2()).normalize(),n})(),vL=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=Yl.mul(m.inverseSqrt());return zt(d.mul(i.x,v),p.mul(i.y,v),c.mul(i.z)).normalize()});class r1 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===dp?s=Yf(r):t===on&&(e.hasGeometryAttribute("tangent")===!0?s=ea.mul(r).normalize():s=vL({eye_pos:Pi,surf_norm:hr,mapN:r,uv:nt()})),s}}const Zf=K(r1),yL=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)}),xL=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(Yl),u=c.sign().mul(i.x.mul(o).add(i.y.mul(l)));return c.abs().mul(t).sub(u).normalize()});class n1 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=yL({textureNode:this.textureNode,bumpScale:e});return xL({surf_pos:Pi,surf_norm:hr,dHdxy:t})}}const s1=K(n1),a1=new Map;class Z extends qe{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=a1.get(e);return i===void 0&&(i=rn(e,t),a1.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=Zf(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=s1(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=Zf(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=Dl(mo.x,mo.y,mo.y.negate(),mo.x).mul(s.rg.mul(2).sub(z(1)).normalize().mul(s.b))}else r=mo;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 o1=ge(Z,Z.ALPHA_TEST),po=ge(Z,Z.COLOR),l1=ge(Z,Z.SHININESS),c1=ge(Z,Z.EMISSIVE),Kh=ge(Z,Z.OPACITY),u1=ge(Z,Z.SPECULAR),Qf=ge(Z,Z.SPECULAR_INTENSITY),h1=ge(Z,Z.SPECULAR_COLOR),ec=ge(Z,Z.SPECULAR_STRENGTH),Zh=ge(Z,Z.REFLECTIVITY),d1=ge(Z,Z.ROUGHNESS),p1=ge(Z,Z.METALNESS),m1=ge(Z,Z.NORMAL).context({getUV:null}),f1=ge(Z,Z.CLEARCOAT),g1=ge(Z,Z.CLEARCOAT_ROUGHNESS),v1=ge(Z,Z.CLEARCOAT_NORMAL).context({getUV:null}),y1=ge(Z,Z.ROTATION),x1=ge(Z,Z.SHEEN),_1=ge(Z,Z.SHEEN_ROUGHNESS),M1=ge(Z,Z.ANISOTROPY),T1=ge(Z,Z.IRIDESCENCE),b1=ge(Z,Z.IRIDESCENCE_IOR),S1=ge(Z,Z.IRIDESCENCE_THICKNESS),w1=ge(Z,Z.TRANSMISSION),E1=ge(Z,Z.THICKNESS),A1=ge(Z,Z.IOR),N1=ge(Z,Z.ATTENUATION_DISTANCE),C1=ge(Z,Z.ATTENUATION_COLOR),Qh=ge(Z,Z.LINE_SCALE),eg=ge(Z,Z.LINE_DASH_SIZE),tg=ge(Z,Z.LINE_GAP_SIZE),ed=ge(Z,Z.LINE_WIDTH),ig=ge(Z,Z.LINE_DASH_OFFSET),R1=ge(Z,Z.POINT_WIDTH),I1=ge(Z,Z.DISPERSION),rg=ge(Z,Z.LIGHT_MAP),L1=ge(Z,Z.AO_MAP),mo=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 P1 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||pn;return lr.mul(i).mul(t)}}const ng=K(P1);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 D1=ge(Bt,Bt.VERTEX),tc=ge(Bt,Bt.INSTANCE),_L=ge(Bt,Bt.SUBGROUP),ML=ge(Bt,Bt.INVOCATION_SUBGROUP),TL=ge(Bt,Bt.INVOCATION_LOCAL),U1=ge(Bt,Bt.DRAW);class O1 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=$l(o.array,"mat4",Math.max(r.count,1)).element(tc);else{const l=new qm(o.array,16,1);this.buffer=l;const c=o.usage===Ms?Hf:Gh,u=[c(l,"vec4",16,0),c(l,"vec4",16,4),c(l,"vec4",16,8),c(l,"vec4",16,12)];t=qs(...u)}this.instanceMatrixNode=t}const s=r.instanceColor;if(s&&i===null){const o=new Nn(s.array,3),l=s.usage===Ms?Hf:Gh;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=WM(ur,t);ur.assign(o)}this.instanceColorNode!==null&&Zr("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==Ms&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==Ms&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const F1=K(O1);class V1 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=tc:this.batchingIdNode=U1);const t=U(([p])=>{const m=ds(Br(this.batchMesh._indirectTexture),0),v=P(p).modInt(P(m)),f=P(p).div(P(m));return Br(this.batchMesh._indirectTexture,un(v,f)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(P(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=ds(Br(i),0),s=E(t).mul(4).toInt().toVar(),a=s.modInt(r),o=s.div(P(r)),l=qs(Br(i,un(a,o)),Br(i,un(a.add(1),o)),Br(i,un(a.add(2),o)),Br(i,un(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){const p=U(([m])=>{const v=ds(Br(c),0).x,f=m,g=f.modInt(v),x=f.div(v);return Br(c,un(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")&&Kl.mulAssign(u)}}const B1=K(V1),z1=new WeakMap;class sg 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=Jf("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(i=fe(e.bindMatrix,"mat4"),r=fe(e.bindMatrixInverse,"mat4"),s=$l(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=Jf("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Wh)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&Wh.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")&&Kl.assign(i)}}generate(e,t){if(t!=="void")return Zt.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;z1.get(t)!==e.frameId&&(z1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const bL=n=>G(new sg(n)),k1=n=>G(new sg(n,!0));class H1 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]=hs(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?`
3860
+ `);return e.format(c,i,t)}}const Ri=K(H2);te("select",Ri);const lM=(...n)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ri(...n));te("cond",lM);class Ff 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 Vf=K(Ff),cM=(n,e)=>Vf(n,{label:e});te("context",Vf),te("label",cM);class uM 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 Bf=K(uM);te("temp",Bf),te("toVar",(...n)=>Bf(...n).append());class hM 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,rf.VERTEX);e.flowNodeFromShaderStage(rf.VERTEX,this.node,r,s),t.propertyName=s}return e.getPropertyName(i)}}const Ii=K(hM);te("varying",Ii);const Wl="WorkingColorSpace",zf="OutputColorSpace";function dM(n){let e=null;return n===nr?e="Linear":n===Fi&&(e="sRGB"),e}function Hh(n,e){return dM(n)+"To"+dM(e)}class jl 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===Wl?vt.workingColorSpace:t===zf?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=Hh(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 pM=n=>G(new jl(G(n),Wl,zf)),mM=n=>G(new jl(G(n),zf,Wl)),fM=(n,e)=>G(new jl(G(n),Wl,e)),kf=(n,e)=>G(new jl(G(n),e,Wl));te("toOutputColorSpace",pM),te("toWorkingColorSpace",mM),te("workingToColorSpace",fM),te("colorSpaceToWorking",kf);let G2=class extends os{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 gM 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 G2(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 W2=(n,e,t)=>G(new gM(n,e,t));class vM extends gM{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 yM=(n,e,t)=>G(new vM(n,e,t));class xM extends pt{static get type(){return"ToneMappingNode"}constructor(e,t=MM,i=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=i}getCacheKey(){return Km(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 _M=(n,e,t)=>G(new xM(n,G(e),G(t))),MM=yM("toneMappingExposure","float");te("toneMapping",(n,e,t)=>_M(e,t,n));class TM extends lf{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=Sa,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 ja(i,s),l=new On(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 Xl=(n,e,t,i)=>G(new TM(n,e,t,i)),bM=(n,e,t,i)=>Xl(n,e,t,i).setUsage(Ts),Gh=(n,e,t,i)=>Xl(n,e,t,i).setInstanced(!0),Hf=(n,e,t,i)=>bM(n,e,t,i).setInstanced(!0);te("toAttribute",n=>Xl(n.value));class SM 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 wM=(n,e,t)=>G(new SM(G(n),e,t));te("compute",wM);class EM 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 ql=(n,...e)=>G(new EM(G(n),...e));te("cache",ql);class AM 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 NM=K(AM);te("bypass",NM);class Gf 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 CM=K(Gf,null,null,{doClamp:!1}),RM=K(Gf);te("remap",CM),te("remapClamp",RM);class IM 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 ds=K(IM),LM=n=>(n?Ri(n,ds("discard")):ds("discard")).append(),j2=()=>ds("return").append();te("discard",LM);class PM 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 DM=(n,e=null,t=null)=>G(new PM(G(n),e,t));te("renderOutput",DM);function X2(n){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",n)}class Wf 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 Wf(n,e)),nt=n=>_i("uv"+(n>0?n:""),"vec2");class UM 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 ps=K(UM);class OM extends Ys{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 FM=K(OM);class dn extends Ys{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===ga?"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(ps(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=kf(ds(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(FM(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 ps(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(dn),Br=(...n)=>yt(...n).setSampler(!1),q2=n=>(n.isNode===!0?n:yt(n)).convert("sampler"),co=fe("float").label("cameraNear").setGroup(xt).onRenderUpdate(({camera:n})=>n.near),uo=fe("float").label("cameraFar").setGroup(xt).onRenderUpdate(({camera:n})=>n.far),VM=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),Y2=fe("mat4").label("cameraProjectionMatrixInverse").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrixInverse),cr=fe("mat4").label("cameraViewMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorldInverse),$2=fe("mat4").label("cameraWorldMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorld),J2=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 Ys(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 K2=K(St,St.DIRECTION),Z2=K(St,St.WORLD_MATRIX),Q2=K(St,St.POSITION),eL=K(St,St.SCALE),tL=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 iL=ge(tn,tn.DIRECTION),zr=ge(tn,tn.WORLD_MATRIX),rL=ge(tn,tn.POSITION),nL=ge(tn,tn.SCALE),sL=ge(tn,tn.VIEW_POSITION),BM=fe(new Ke).onObjectUpdate(({object:n},e)=>e.value.getNormalMatrix(n.matrixWorld)),zM=fe(new Re).onObjectUpdate(({object:n},e)=>e.value.copy(n.matrixWorld).invert()),pn=cr.mul(zr).toVar("modelViewMatrix_2"),aL=U(n=>(n.context.isHighPrecisionModelViewMatrix=!0,fe("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),oL=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"),Wh=Li.varying("positionPrevious"),jh=zr.mul(Zt).xyz.varying("v_positionWorld"),Xf=Zt.transformDirection(zr).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),Pi=pn.mul(Zt).xyz.varying("v_positionView"),Vt=Pi.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class kM 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 HM=ge(kM),Yl=E(HM).mul(2).sub(1),Xh=_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)):Xh,"vec3").once()().toVar("normalLocal"),GM=Pi.dFdx().cross(Pi.dFdy()).normalize().toVar("normalFlat"),hr=U(n=>{let e;return n.material.flatShading===!0?e=GM:e=Ii(Yf(ur),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),qh=Ii(hr.transformDirection(cr),"v_normalWorld").normalize().toVar("normalWorld"),Yt=U(n=>n.context.setupNormal(),"vec3").once()().mul(Yl).toVar("transformedNormalView"),qf=Yt.transformDirection(cr).toVar("transformedNormalWorld"),ho=U(n=>n.context.setupClearcoatNormal(),"vec3").once()().mul(Yl).toVar("transformedClearcoatNormalView"),WM=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}),Yf=U(([n],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(n);const i=BM.mul(n);return cr.transformDirection(i)}),jM=fe(0).onReference(({material:n})=>n).onRenderUpdate(({material:n})=>n.refractionRatio),XM=Vt.negate().reflect(Yt),qM=Vt.negate().refract(Yt,jM),YM=XM.transformDirection(cr).toVar("reflectVector"),$M=qM.transformDirection(cr).toVar("reflectVector");class JM extends dn{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?YM:e.mapping===Ar?$M:(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===bs||!i.isRenderTargetTexture?D(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const Yh=K(JM);class $h extends Ys{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 $l=(n,e,t)=>G(new $h(n,e,t));class lL extends os{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 $f extends $h{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?Ln(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 lL(this,G(e)))}}const mn=(n,e)=>G(new $f(n,e)),cL=(n,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),G(new $f(n,e)));class uL extends os{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 Jl 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 uL(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=$l(null,e,this.count):Array.isArray(this.getValueFromReference())?t=mn(null,e):e==="texture"?t=yt(null):e==="cubeTexture"?t=Yh(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 Jl(n,e,t)),Jf=(n,e,t,i)=>G(new Jl(n,e,i,t));class KM extends Jl{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 KM(n,e,t)),Jh=U(n=>(n.geometry.hasAttribute("tangent")===!1&&n.geometry.computeTangents(),_i("tangent","vec4")))(),Kl=Jh.xyz.toVar("tangentLocal"),Zl=pn.mul(ae(Kl,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),ZM=Zl.transformDirection(cr).varying("v_tangentWorld").normalize().toVar("tangentWorld"),Kf=Zl.toVar("transformedTangentView"),hL=Kf.transformDirection(cr).normalize().toVar("transformedTangentWorld"),Ql=n=>n.mul(Jh.w).xyz,dL=Ii(Ql(Xh.cross(Jh)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),pL=Ii(Ql(ur.cross(Kl)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),QM=Ii(Ql(hr.cross(Zl)),"v_bitangentView").normalize().toVar("bitangentView"),mL=Ii(Ql(qh.cross(ZM)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),e1=Ql(Yt.cross(Kf)).normalize().toVar("transformedBitangentView"),fL=e1.transformDirection(cr).normalize().toVar("transformedBitangentWorld"),ea=yi(Zl,QM,hr),t1=Vt.mul(ea),gL=(n,e)=>n.sub(t1.mul(e)),i1=(()=>{let n=Js.cross(Vt);return n=n.cross(Js).normalize(),n=rt(n,Yt,cs.mul(hn.oneMinus()).oneMinus().pow2().pow2()).normalize(),n})(),vL=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=Yl.mul(m.inverseSqrt());return zt(d.mul(i.x,v),p.mul(i.y,v),c.mul(i.z)).normalize()});class r1 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===dp?s=Yf(r):t===on&&(e.hasGeometryAttribute("tangent")===!0?s=ea.mul(r).normalize():s=vL({eye_pos:Pi,surf_norm:hr,mapN:r,uv:nt()})),s}}const Zf=K(r1),yL=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)}),xL=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(Yl),u=c.sign().mul(i.x.mul(o).add(i.y.mul(l)));return c.abs().mul(t).sub(u).normalize()});class n1 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=yL({textureNode:this.textureNode,bumpScale:e});return xL({surf_pos:Pi,surf_norm:hr,dHdxy:t})}}const s1=K(n1),a1=new Map;class Z extends qe{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=a1.get(e);return i===void 0&&(i=rn(e,t),a1.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=Zf(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=s1(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=Zf(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=Dl(mo.x,mo.y,mo.y.negate(),mo.x).mul(s.rg.mul(2).sub(z(1)).normalize().mul(s.b))}else r=mo;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 o1=ge(Z,Z.ALPHA_TEST),po=ge(Z,Z.COLOR),l1=ge(Z,Z.SHININESS),c1=ge(Z,Z.EMISSIVE),Kh=ge(Z,Z.OPACITY),u1=ge(Z,Z.SPECULAR),Qf=ge(Z,Z.SPECULAR_INTENSITY),h1=ge(Z,Z.SPECULAR_COLOR),ec=ge(Z,Z.SPECULAR_STRENGTH),Zh=ge(Z,Z.REFLECTIVITY),d1=ge(Z,Z.ROUGHNESS),p1=ge(Z,Z.METALNESS),m1=ge(Z,Z.NORMAL).context({getUV:null}),f1=ge(Z,Z.CLEARCOAT),g1=ge(Z,Z.CLEARCOAT_ROUGHNESS),v1=ge(Z,Z.CLEARCOAT_NORMAL).context({getUV:null}),y1=ge(Z,Z.ROTATION),x1=ge(Z,Z.SHEEN),_1=ge(Z,Z.SHEEN_ROUGHNESS),M1=ge(Z,Z.ANISOTROPY),T1=ge(Z,Z.IRIDESCENCE),b1=ge(Z,Z.IRIDESCENCE_IOR),S1=ge(Z,Z.IRIDESCENCE_THICKNESS),w1=ge(Z,Z.TRANSMISSION),E1=ge(Z,Z.THICKNESS),A1=ge(Z,Z.IOR),N1=ge(Z,Z.ATTENUATION_DISTANCE),C1=ge(Z,Z.ATTENUATION_COLOR),Qh=ge(Z,Z.LINE_SCALE),eg=ge(Z,Z.LINE_DASH_SIZE),tg=ge(Z,Z.LINE_GAP_SIZE),ed=ge(Z,Z.LINE_WIDTH),ig=ge(Z,Z.LINE_DASH_OFFSET),R1=ge(Z,Z.POINT_WIDTH),I1=ge(Z,Z.DISPERSION),rg=ge(Z,Z.LIGHT_MAP),L1=ge(Z,Z.AO_MAP),mo=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 P1 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||pn;return lr.mul(i).mul(t)}}const ng=K(P1);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 D1=ge(Bt,Bt.VERTEX),tc=ge(Bt,Bt.INSTANCE),_L=ge(Bt,Bt.SUBGROUP),ML=ge(Bt,Bt.INVOCATION_SUBGROUP),TL=ge(Bt,Bt.INVOCATION_LOCAL),U1=ge(Bt,Bt.DRAW);class O1 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=$l(o.array,"mat4",Math.max(r.count,1)).element(tc);else{const l=new qm(o.array,16,1);this.buffer=l;const c=o.usage===Ts?Hf:Gh,u=[c(l,"vec4",16,0),c(l,"vec4",16,4),c(l,"vec4",16,8),c(l,"vec4",16,12)];t=qs(...u)}this.instanceMatrixNode=t}const s=r.instanceColor;if(s&&i===null){const o=new Nn(s.array,3),l=s.usage===Ts?Hf:Gh;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=WM(ur,t);ur.assign(o)}this.instanceColorNode!==null&&Zr("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==Ts&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==Ts&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const F1=K(O1);class V1 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=tc:this.batchingIdNode=U1);const t=U(([p])=>{const m=ps(Br(this.batchMesh._indirectTexture),0),v=P(p).modInt(P(m)),f=P(p).div(P(m));return Br(this.batchMesh._indirectTexture,un(v,f)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(P(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=ps(Br(i),0),s=E(t).mul(4).toInt().toVar(),a=s.modInt(r),o=s.div(P(r)),l=qs(Br(i,un(a,o)),Br(i,un(a.add(1),o)),Br(i,un(a.add(2),o)),Br(i,un(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){const p=U(([m])=>{const v=ps(Br(c),0).x,f=m,g=f.modInt(v),x=f.div(v);return Br(c,un(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")&&Kl.mulAssign(u)}}const B1=K(V1),z1=new WeakMap;class sg 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=Jf("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(i=fe(e.bindMatrix,"mat4"),r=fe(e.bindMatrixInverse,"mat4"),s=$l(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=Jf("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Wh)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&Wh.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")&&Kl.assign(i)}}generate(e,t){if(t!=="void")return Zt.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;z1.get(t)!==e.frameId&&(z1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const bL=n=>G(new sg(n)),k1=n=>G(new sg(n,!0));class H1 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]=ds(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?`
3861
3861
  `:"")+e.tab+T+` {
3862
3862
 
3863
3863
  `).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
3864
3864
  `+e.tab+s);for(let o=0,l=this.params.length-1;o<l;o++)e.addFlowCode((o===0?"":e.tab)+`}
3865
3865
 
3866
- `).removeFlowTab();return e.addFlowTab(),a}}const gt=(...n)=>G(new H1(Xs(n,"int"))).append(),SL=()=>hs("continue").append(),td=()=>hs("break").append(),wL=(...n)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),gt(...n)),ag=new WeakMap,br=new st,G1=U(({bufferMap:n,influence:e,stride:t,width:i,depth:r,offset:s})=>{const a=P(D1).mul(t).add(s),o=a.div(i),l=a.sub(o.mul(i));return Br(n,un(l,o)).depth(r).mul(e)});function EL(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=ag.get(n);if(a===void 0||a.count!==s){let o=function(){f.dispose(),ag.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 el(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)},ag.set(n,a),n.addEventListener("dispose",o)}return a}class W1 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}=EL(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,un(P(h).add(1),P(tc))).r):d.assign(fi("morphTargetInfluences","float").element(h).toVar()),i===!0&&Zt.addAssign(G1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(0)})),r===!0&&ur.addAssign(G1({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(W1),AL=n=>n.sort((e,t)=>e.id-t.id),NL=(n,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===n)return t;return null},og=new WeakMap;class X1 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=AL(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=NL(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;og.has(a)?c=og.get(a):(c=new l(a),og.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 q1=K(X1);class ta extends qe{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class Y1 extends ta{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class $1 extends Ff{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 J1=K($1);class K1 extends ta{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let ic,rc;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?rc.copy(t.viewport):(e.getViewport(rc),rc.multiplyScalar(e.getPixelRatio())):t!==null?(ic.width=t.width,ic.height=t.height):e.getDrawingBufferSize(ic)}setup(){const e=this.scope;let t=null;return e===ri.SIZE?t=fe(ic||(ic=new J)):e===ri.VIEWPORT?t=fe(rc||(rc=new st)):t=z(go.div(fo)),t}generate(e){if(this.scope===ri.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(fo).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 ps=ge(ri,ri.UV),fo=ge(ri,ri.SIZE),go=ge(ri,ri.COORDINATE),Pn=ge(ri,ri.VIEWPORT),Z1=Pn.zw,Q1=go.sub(Pn.xy),CL=Q1.div(Z1),RL=U(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),fo),"vec2").once()(),IL=U(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ps),"vec2").once()(),LL=U(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ps.flipY()),"vec2").once()(),nc=new J;class sc extends dn{static get type(){return"ViewportTextureNode"}constructor(e=ps,t=null,i=null){i===null&&(i=new pm,i.minFilter=ji),super(i,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=je.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(nc);const i=this.value;(i.image.width!==nc.width||i.image.height!==nc.height)&&(i.image.width=nc.width,i.image.height=nc.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 PL=K(sc),eT=K(sc,null,null,{generateMipmaps:!0});let lg=null;class tT extends sc{static get type(){return"ViewportDepthTextureNode"}constructor(e=ps,t=null){lg===null&&(lg=new Ds),super(e,t,lg)}}const cg=K(tT);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=rT().assign(i));else if(t===Qi.DEPTH)e.isPerspectiveCamera?r=iT(Pi.z,co,uo):r=ac(Pi.z,co,uo);else if(t===Qi.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const s=ug(i,co,uo);r=ac(s,co,uo)}else r=i;else r=ac(Pi.z,co,uo);return r}}Qi.DEPTH_BASE="depthBase",Qi.DEPTH="depth",Qi.LINEAR_DEPTH="linearDepth";const ac=(n,e,t)=>n.add(e).div(e.sub(t)),DL=(n,e,t)=>e.sub(t).mul(n).sub(e),iT=(n,e,t)=>e.add(n).mul(t).div(t.sub(e).mul(n)),ug=(n,e,t)=>e.mul(t).div(t.sub(e).mul(n).sub(t)),rT=K(Qi,Qi.DEPTH_BASE),hg=ge(Qi,Qi.DEPTH),id=K(Qi,Qi.LINEAR_DEPTH),UL=id(cg());hg.assign=n=>rT(n);class gs extends qe{static get type(){return"ClippingNode"}constructor(e=gs.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===gs.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,a,o):this.setupDefault(t.planes,a,o)}setupAlphaToCoverage(e,t,i){return U(()=>{const r=mn(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=mn(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()}})()}}gs.ALPHA_TO_COVERAGE="alphaToCoverage",gs.DEFAULT="default";const OL=()=>G(new gs),FL=()=>G(new gs(gs.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+Zm(this)}build(e){this.setup(e)}setupObserver(e){return new Gx(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),Mf.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=FL():e.stack.add(OL())}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=ng().w.add(1).log2().mul(VM).mul(.5))}i!==null&&hg.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&&k1(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&&B1(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&F1(t).append(),this.positionNode!==null&&Zt.assign(this.positionNode);const r=ng();return e.context.vertex=e.removeStack(),e.context.mvp=r,r}setupDiffuseColor({object:e,geometry:t}){let i=this.colorNode?ae(this.colorNode):po;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):Kh;if(Nt.a.assign(Nt.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?E(this.alphaTestNode):o1;Nt.a.lessThanEqual(s).discard()}this.transparent===!1&&this.blending===_n&&this.alphaToCoverage===!1&&Nt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?D(0):Nt.rgb}setupNormal(){return this.normalNode?D(this.normalNode):m1}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 K1(rg)),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:L1;t.push(new Y1(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=q1([...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=J1(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)&&(yf.assign(D(s||c1)),o=o.add(yf)),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=Cl(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 VL=new Ka;class BL 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(VL),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(pn.mul(ae(r,1))),a=Pn.z.div(Pn.w),o=lr.mul(s),l=Li.xy.toVar();return l.mulAssign(this.pointWidthNode?this.pointWidthNode:R1),l.assign(l.div(Pn.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=Df(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(po):a=po,r.mulAssign(Kh),ae(a,r)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const zL=new Ni;class kL extends Tt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(zL),this.setValues(e)}}const HL=new mh;class GL extends Tt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(HL),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):Qh,i=this.dashSizeNode?E(this.dashSizeNode):eg,r=this.dashSizeNode?E(this.dashGapNode):tg;Ks.assign(i),Bl.assign(r);const s=Ii(_i("lineDistance").mul(t));(e?s.add(e):s).mod(Ks.add(Bl)).greaterThan(Ks).discard()}}const WL=new mh;class jL extends Tt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(WL),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(pn.mul(ae(l,1))).toVar("start"),h=ae(pn.mul(ae(c,1))).toVar("end");s&&(Zr("vec3","worldStart").assign(u.xyz),Zr("vec3","worldEnd").assign(h.xyz));const d=Pn.z.div(Pn.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=ed.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(ed)),_.assign(_.div(Pn.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):ig,d=this.dashScaleNode?E(this.dashScaleNode):Qh,p=this.dashSizeNode?E(this.dashSizeNode):eg,m=this.dashSizeNode?E(this.dashGapNode):tg;Ks.assign(p),Bl.assign(m);const v=_i("instanceDistanceStart"),f=_i("instanceDistanceEnd"),g=Li.y.lessThan(.5).select(d.mul(v),Qh.mul(f)),x=Ii(g.add(ig)),y=h?x.add(h):x;l.y.lessThan(-1).or(l.y.greaterThan(1)).discard(),y.mod(Ks.add(Bl)).greaterThan(Ks).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(ed);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(po)}else u=po;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 nT=n=>G(n).mul(.5).add(.5),XL=n=>G(n).mul(2).sub(1),qL=new dh;class YL extends Tt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(qL),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?E(this.opacityNode):Kh;Nt.assign(ae(nT(Yt),e))}}class sT extends pt{static get type(){return"EquirectUVNode"}constructor(e=Xf){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 dg=K(sT);class aT extends Cu{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 yn(5,5,5),a=dg(Xf),o=new Tt;o.colorNode=yt(t,a,0),o.side=si,o.blending=Er;const l=new Ft(s,o),c=new Vu;c.add(l),t.minFilter===ji&&(t.minFilter=Lt);const u=new Nu(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 oc=new WeakMap;class $L extends pt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Yh();const t=new Ns;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===zn||a===kn){if(oc.has(s)){const o=oc.get(s);lT(o,s.mapping),this._cubeTexture=o}else{const o=s.image;if(JL(o)){const l=new aT(o.height);l.fromEquirectangularTexture(t,s),lT(l.texture,s.mapping),this._cubeTexture=l.texture,oc.set(s,l.texture),s.addEventListener("dispose",oT)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function JL(n){return n==null?!1:n.height>0}function oT(n){const e=n.target;e.removeEventListener("dispose",oT);const t=oc.get(e);t!==void 0&&(oc.delete(e),t.dispose())}function lT(n,e){e===zn?n.mapping=fr:e===kn&&(n.mapping=Ar)}const KL=K($L);class rd extends ta{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=KL(this.envNode)}}class ZL extends ta{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 lc{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class cT extends lc{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 pa:s.rgb.assign(rt(s.rgb,s.rgb.mul(a.rgb),ec.mul(Zh)));break;case Kd:s.rgb.assign(rt(s.rgb,a.rgb,ec.mul(Zh)));break;case Zd:s.rgb.addAssign(a.rgb.mul(ec.mul(Zh)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const QL=new $r;class eP extends Tt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(QL),this.setValues(e)}setupNormal(){return hr}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new rd(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ZL(rg)),t}setupOutgoingLight(){return Nt.rgb}setupLightingModel(){return new cT}}const vo=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))}),ia=U(n=>n.diffuseColor.mul(1/Math.PI)),tP=()=>E(.25),iP=U(({dotNH:n})=>Fh.mul(E(.5)).add(1).mul(E(1/Math.PI)).mul(n.pow(Fh))),rP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(e).clamp(),i=Vt.dot(e).clamp(),r=vo({f0:or,f90:1,dotVH:i}),s=tP(),a=iP({dotNH:t});return r.mul(s).mul(a)});class pg extends cT{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(ia({diffuseColor:Nt.rgb}))),this.specular===!0&&i.directSpecular.addAssign(r.mul(rP({lightDirection:e})).mul(ec))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ia({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const nP=new ph;class sP extends Tt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(nP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new rd(t):null}setupLightingModel(){return new pg(!1)}}const aP=new hh;class oP extends Tt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(aP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new rd(t):null}setupLightingModel(){return new pg}setupVariants(){const e=(this.shininessNode?E(this.shininessNode):l1).max(1e-4);Fh.assign(e);const t=this.specularNode||u1;or.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const uT=U(()=>{const n=hr.dFdx().abs().max(hr.dFdy().abs());return n.x.max(n.y).max(n.z)}),mg=U(n=>{const{roughness:e}=n,t=uT();let i=e.max(.0525);return i=i.add(t),i=i.min(1),i}),hT=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(P_))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),lP=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"}]}),dT=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"}]}),cP=E(1/Math.PI),uP=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 cP.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"}]}),fg=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=vo({f0:t,f90:i,dotVH:m}),f,g;if(Rl(a)&&(v=Uh.mix(v,s)),Rl(o)){const x=Fl.dot(e),y=Fl.dot(Vt),_=Fl.dot(u),I=Js.dot(e),T=Js.dot(Vt),w=Js.dot(u);f=lP({alphaT:Oh,alphaB:c,dotTV:y,dotBV:T,dotTL:x,dotBL:I,dotNV:d,dotNL:h}),g=uP({alphaT:Oh,alphaB:c,dotNH:p,dotTH:_,dotBH:w})}else f=hT({alpha:c,dotNL:h,dotNV:d}),g=dT({alpha:c,dotNH:p});return v.mul(f).mul(g)}),gg=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"}]}),pT=U(n=>{const{dotNV:e,specularColor:t,specularF90:i,roughness:r}=n,s=gg({dotNV:e,roughness:r});return t.mul(s.x).add(i.mul(s.y))}),mT=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"}]}),hP=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"}]}),dP=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"}]}),pP=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=hP({roughness:Dh,dotNH:r}),a=dP({dotNV:i,dotNL:t});return $s.mul(s).mul(a)}),mP=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"}]}),fP=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"}]}),nd=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"}]}),fT=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(nd({v1:v,v2:f})),y.addAssign(nd({v1:f,v2:g})),y.addAssign(nd({v1:g,v2:x})),y.addAssign(nd({v1:x,v2:v})),h.assign(D(fP({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"}]}),sd=1/6,gT=n=>lt(sd,lt(n,lt(n,n.negate().add(3)).sub(3)).add(1)),vg=n=>lt(sd,lt(n,lt(n,lt(3,n).sub(6))).add(4)),vT=n=>lt(sd,lt(n,lt(n,lt(-3,n).add(3)).add(3)).add(1)),yg=n=>lt(sd,Ji(n,3)),yT=n=>gT(n).add(vg(n)),xT=n=>vT(n).add(yg(n)),_T=n=>zt(-1,vg(n).div(gT(n).add(vg(n)))),MT=n=>zt(1,yg(n).div(vT(n).add(yg(n)))),TT=(n,e,t)=>{const i=n.uvNode,r=lt(i,e.zw).add(.5),s=cs(r),a=us(r),o=yT(a.x),l=xT(a.x),c=_T(a.x),u=MT(a.x),h=_T(a.y),d=MT(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=yT(a.y).mul(zt(o.mul(n.uv(p).level(t)),l.mul(n.uv(m).level(t)))),x=xT(a.y).mul(zt(o.mul(n.uv(v).level(t)),l.mul(n.uv(f).level(t))));return g.add(x)},bT=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=TT(n,ae(r,t),cs(e)),o=TT(n,ae(s,i),If(e));return us(e).mix(a,o)}),ST=U(([n,e,t,i,r])=>{const s=D(Uf(e.negate(),Mr(n),Qr(1,i))),a=D(Qs(r[0].xyz),Qs(r[1].xyz),Qs(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"}]}),gP=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"}]}),vP=eT(),wT=U(([n,e,t])=>{const i=vP.uv(n),r=kl(E(fo.x)).mul(gP(e,t));return bT(i,r)}),ET=U(([n,e,t])=>(Le(t.notEqual(0),()=>{const i=Rf(e).negate().div(t);return Cf(i.negate().mul(n))}),D(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),yP=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=ST(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=wT(k,t,C);v.element(w).assign(j.element(w)),v.a.addAssign(j.a),f.element(w).assign(i.element(w).mul(ET(Qs(H),d,p).element(w)))}),v.a.divAssign(3)}else{const I=ST(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=wT(C,t,u),f=i.mul(ET(Qs(I),d,p))}const g=f.rgb.mul(v.rgb),x=n.dot(e).clamp(),y=D(pT({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())}),xP=yi(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),_P=n=>{const e=n.sqrt();return D(1).add(e).div(D(1).sub(e))},AT=(n,e)=>n.sub(e).div(n.add(e)).pow2(),MP=(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),xP.mul(o)},TP=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=AT(s,n),c=vo({f0:l,f90:1,dotVH:t}),u=c.oneMinus(),h=s.lessThan(n).select(Math.PI,0),d=E(Math.PI).sub(h),p=_P(r.clamp(0,.9999)),m=AT(p,s.toVec3()),v=vo({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=MP(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"}]}),bP=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()}),xg=D(.04),_g=E(1);class ad extends lc{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=TP({outsideIOR:E(1),eta2:xf,cosTheta1:t,thinFilmThickness:_f,baseF0:or}),this.iridescenceF0=mT({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=jh,i=jf.sub(jh).normalize(),r=qf;e.backdrop=yP(r,i,hn,Nt,or,Vl,t,zr,cr,lr,zl,Tf,Sf,bf,this.dispersion?wf:null),e.backdropAlpha=Vh,Nt.a.mulAssign(rt(1,e.backdrop.a,Vh))}}computeMultiscattering(e,t,i){const r=Yt.dot(Vt).clamp(),s=gg({roughness:hn,dotNV:r}),a=(this.iridescenceF0?Uh.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(pP({lightDirection:e}))),this.clearcoat===!0){const s=ho.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(fg({lightDirection:e,f0:xg,f90:_g,roughness:Ol,normalView:ho})))}i.directDiffuse.addAssign(r.mul(ia({diffuseColor:Nt.rgb}))),i.directSpecular.addAssign(r.mul(fg({lightDirection:e,f0:or,f90:1,roughness:hn,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=mP({N:d,V:p,roughness:hn}),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(fT({N:d,V:p,P:m,mInv:x,p0:l,p1:c,p2:u,p3:h}))),s.directDiffuse.addAssign(e.mul(Nt).mul(fT({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(ia({diffuseColor:Nt})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:i}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul($s,bP({normal:Yt,viewDir:Vt,roughness:Dh}))),this.clearcoat===!0){const c=ho.dot(Vt).clamp(),u=pT({dotNV:c,specularColor:xg,specularF90:_g,roughness:Ol});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,Vl);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=hn.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=ho.dot(Vt).clamp(),r=vo({dotVH:i,f0:xg,f90:_g}),s=t.mul(Ph.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Ph));t.assign(s)}if(this.sheen===!0){const i=$s.r.max($s.g).max($s.b).mul(.157).oneMinus(),r=t.mul(i).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const NT=E(1),Mg=E(-2),od=E(.8),Tg=E(-1),ld=E(.4),bg=E(2),cd=E(.305),Sg=E(3),CT=E(.21),SP=E(4),RT=E(4),wP=E(16),EP=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"}]}),AP=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"}]}),NP=U(([n])=>{const e=E(0).toVar();return Le(n.greaterThanEqual(od),()=>{e.assign(NT.sub(n).mul(Tg.sub(Mg)).div(NT.sub(od)).add(Mg))}).ElseIf(n.greaterThanEqual(ld),()=>{e.assign(od.sub(n).mul(bg.sub(Tg)).div(od.sub(ld)).add(Tg))}).ElseIf(n.greaterThanEqual(cd),()=>{e.assign(ld.sub(n).mul(Sg.sub(bg)).div(ld.sub(cd)).add(bg))}).ElseIf(n.greaterThanEqual(CT),()=>{e.assign(cd.sub(n).mul(SP.sub(Sg)).div(cd.sub(CT)).add(Sg))}).Else(()=>{e.assign(E(-2).mul(kl(lt(1.16,n))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),IT=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"}]}),LT=U(([n,e,t,i,r,s])=>{const a=E(t),o=D(e),l=li(NP(a),Mg,s),c=us(l),u=cs(l),h=D(wg(n,o,u,i,r,s)).toVar();return Le(c.notEqual(0),()=>{const d=D(wg(n,o,u.add(1),i,r,s)).toVar();h.assign(rt(h,d,c))}),h}),wg=U(([n,e,t,i,r,s])=>{const a=E(t).toVar(),o=D(e),l=E(EP(o)).toVar(),c=E(ft(RT.sub(a),0)).toVar();a.assign(ft(a,RT));const u=E(Bh(a)).toVar(),h=z(AP(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,wP))),h.y.addAssign(lt(4,Bh(s).sub(u))),h.x.mulAssign(i),h.y.mulAssign(r),n.uv(h).grad(z(),z())}),Eg=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 wg(n,c,e,s,a,o)}),PT=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,lo(t,i))).toVar();Le(Nf(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(Eg({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),()=>{td()});const v=E(a.mul(E(m))).toVar();p.addAssign(r.element(m).mul(Eg({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(Eg({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 ud=null;const DT=new WeakMap;function CP(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 RP(n){let e=DT.get(n);if((e!==void 0?e.pmremVersion:-1)!==n.pmremVersion){const t=n.image;if(n.isCubeTexture)if(IP(t))e=ud.fromCubemap(n,e);else return null;else if(LP(t))e=ud.fromEquirectangular(n,e);else return null;e.pmremVersion=n.pmremVersion,DT.set(n,e)}return e.texture}class UT 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=CP(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=RP(i),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ud===null&&(ud=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)),LT(this._texture,t,r,this._width,this._height,this._maxMip)}}function IP(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 LP(n){return n==null?!1:n.height>0}const OT=K(UT),FT=new WeakMap;class VT extends ta{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=FT.get(h);d===void 0&&(d=OT(h),FT.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?i1:Yt,a=i.context(BT(hn,s)).mul(r),o=i.context(PP(qf)).mul(Math.PI).mul(r),l=ql(a),c=ql(o);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(c);const u=e.context.lightingModel.clearcoatRadiance;if(u){const h=i.context(BT(Ol,ho)).mul(r),d=ql(h);u.addAssign(d)}}}const BT=(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}},PP=n=>({getUV:()=>n,getTextureLevel:()=>E(1)}),DP=new Sl;class zT 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(DP),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new VT(t):null}setupLightingModel(){return new ad}setupSpecular(){const e=rt(D(.04),Nt.rgb,Ul);or.assign(e),Vl.assign(1)}setupVariants(){const e=this.metalnessNode?E(this.metalnessNode):p1;Ul.assign(e);let t=this.roughnessNode?E(this.roughnessNode):d1;t=mg({roughness:t}),hn.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 UP=new uh;class kT extends zT{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(UP),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):A1;zl.assign(e),or.assign(rt(xi(Pf(zl.sub(1).div(zl.add(1))).mul(h1),D(1)).mul(Qf),Nt.rgb,Ul)),Vl.assign(rt(Qf,1,Ul))}setupLightingModel(){return new ad(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):f1,i=this.clearcoatRoughnessNode?E(this.clearcoatRoughnessNode):g1;Ph.assign(t),Ol.assign(mg({roughness:i}))}if(this.useSheen){const t=this.sheenNode?D(this.sheenNode):x1,i=this.sheenRoughnessNode?E(this.sheenRoughnessNode):_1;$s.assign(t),Dh.assign(i)}if(this.useIridescence){const t=this.iridescenceNode?E(this.iridescenceNode):T1,i=this.iridescenceIORNode?E(this.iridescenceIORNode):b1,r=this.iridescenceThicknessNode?E(this.iridescenceThicknessNode):S1;Uh.assign(t),xf.assign(i),_f.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?z(this.anisotropyNode):M1).toVar();ls.assign(t.length()),Le(ls.equal(0),()=>{t.assign(z(1,0))}).Else(()=>{t.divAssign(z(ls)),ls.assign(ls.saturate())}),Oh.assign(ls.pow2().mix(hn.pow2(),1)),Fl.assign(ea[0].mul(t.x).add(ea[1].mul(t.y))),Js.assign(ea[1].mul(t.x).sub(ea[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?E(this.transmissionNode):w1,i=this.thicknessNode?E(this.thicknessNode):E1,r=this.attenuationDistanceNode?E(this.attenuationDistanceNode):N1,s=this.attenuationColorNode?D(this.attenuationColorNode):C1;if(Vh.assign(t),Tf.assign(i),bf.assign(r),Sf.assign(s),this.useDispersion){const a=this.dispersionNode?E(this.dispersionNode):I1;wf.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?D(this.clearcoatNormalNode):v1}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 OP extends ad{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 FP extends kT{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 OP(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 VP=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 BP extends lc{direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){const a=VP({normal:Xh,lightDirection:e,builder:s}).mul(t);i.directDiffuse.addAssign(a.mul(ia({diffuseColor:Nt.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ia({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const zP=new Rm;class kP extends Tt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(zP),this.setValues(e)}setupLightingModel(){return new BP}}class HT 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 GT=ge(HT),HP=new Im;class GP extends Tt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(HP),this.setValues(e)}setupVariants(e){const t=GT;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 WP=new Ka;class jP extends Tt{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(WP),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class WT 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 Dl(r,s,s.negate(),r).mul(i)}else{const r=t,s=qs(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=qs(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=qs(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 Ag=K(WT),XP=new cl;class qP 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(XP),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=pn.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=W2("center","vec2");h=h.sub(v.sub(.5))}h=h.mul(u);const d=E(a||y1),p=Ag(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 YP extends lc{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 $P=new ch;class JP extends Tt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues($P),this.setValues(e)}setupLightingModel(){return new YP}}const KP=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 dn{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 KP({texture:this,uv:e})}}const XT=K(jT);class ZP 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=XT(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(zM.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),td()),o.addAssign(s.mul(c))}),u.a.equal(0).discard(),ae(u)})(),super.setup(e)}}class qT extends Hi{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 YT extends _c{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 QP extends sx{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 qT;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 YT;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 Ng{constructor(e,t,i=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=i}}class $T{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 Cg{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class JT extends Cg{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class KT{constructor(e,t,i=""){this.name=e,this.type=t,this.code=i,Object.defineProperty(this,"isNodeCode",{value:!0})}}let e3=0;class hd{constructor(e=null){this.id=e3++,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 Rg 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 t3=(n,e)=>G(new Rg(n,e));class Ig 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 dd=K(Ig),i3=(n,e)=>dd(n,e,"js"),r3=(n,e)=>dd(n,e,"wgsl"),n3=(n,e)=>dd(n,e,"glsl");class Lg extends Ig{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+`
3867
- `,t==="property"?o:e.format(`${o}()`,s,t)}}const ZT=(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 Lg(n,e,t)),r=(...s)=>i.call(...s);return r.functionNode=i,r},s3=(n,e)=>ZT(n,e,"glsl"),a3=(n,e)=>ZT(n,e,"wgsl");class ra{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 o3 extends ra{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class l3 extends ra{constructor(e,t=new J){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class c3 extends ra{constructor(e,t=new N){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class u3 extends ra{constructor(e,t=new st){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class h3 extends ra{constructor(e,t=new xe){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class d3 extends ra{constructor(e,t=new Ke){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class p3 extends ra{constructor(e,t=new Re){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class m3 extends o3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class f3 extends l3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class g3 extends c3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}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 QT 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 Il(t);return this._currentCond=Ri(e,i),this.add(this._currentCond)}ElseIf(e,t){const i=new Il(t),r=Ri(e,i);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Il(e),this}build(e,...t){const i=mf();Pl(this);for(const r of this.nodes)r.build(e,"void");return Pl(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 pd=K(QT);class M3{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 yo=4,eb=[.125,.215,.35,.446,.526,.582],na=20,Pg=new Is(-1,1,1,-1,0,1),T3=new di(90,1),tb=new xe;let Dg=null,Ug=0,Og=0;const sa=(1+Math.sqrt(5))/2,xo=1/sa,ib=[new N(-sa,xo,0),new N(sa,xo,0),new N(-xo,0,sa),new N(xo,0,sa),new N(0,sa,-xo),new N(0,sa,xo),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],b3=[3,1,5,0,4,2],Fg=IT(nt(),_i("faceIndex")).normalize(),Vg=D(Fg.x,Fg.y.negate(),Fg.z);class S3{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){Dg=this._renderer.getRenderTarget(),Ug=this._renderer.getActiveCubeFace(),Og=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=nb(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=sb(),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(Dg,Ug,Og),e.scissorTest=!1,md(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),Dg=this._renderer.getRenderTarget(),Ug=this._renderer.getActiveCubeFace(),Og=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=rb(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=rb(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=w3(s)),this._blurMaterial=E3(s,e,t)}return r}async _compileMaterial(e){const t=new Ft(this._lodPlanes[0],e);await this._renderer.compile(t,Pg)}_sceneToCubeUV(e,t,i,r){const s=T3;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(tb),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 yn,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(tb),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;md(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=nb(e)):this._equirectMaterial===null&&(this._equirectMaterial=sb(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const o=this._cubeSize;md(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Pg)}_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=ib[(r-s-1)%ib.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*na-1),v=s/m,f=isFinite(s)?1+Math.floor(u*v):na;f>na&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${na}`);const g=[];let x=0;for(let w=0;w<na;++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-yo?r-y+yo:0),T=4*(this._cubeSize-_);md(t,I,T,3*_,2*_),l.setRenderTarget(t),l.render(h,Pg)}}function w3(n){const e=[],t=[],i=[],r=[];let s=n;const a=n-yo+1+eb.length;for(let o=0;o<a;o++){const l=Math.pow(2,s);t.push(l);let c=1/l;o>n-yo?c=eb[o-n+yo-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=b3[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>yo&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i,lodMeshes:r}}function rb(n,e,t){const i=new ui(n,e,t);return i.texture.mapping=Hn,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function md(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Bg(n){const e=new Tt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Er,e.name=`PMREM_${n}`,e}function E3(n,e,t){const i=mn(new Array(na).fill(0)),r=fe(new N(0,1,0)),s=fe(0),a=E(na),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:Vg,dTheta:s,samples:l,envMap:c,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},v=Bg("blur");return v.uniforms=m,v.fragmentNode=PT({...m,latitudinal:o.equal(1)}),v}function nb(n){const e=Bg("cubemap");return e.fragmentNode=Yh(n,Vg),e}function sb(n){const e=Bg("equirect");return e.fragmentNode=yt(n,dg(Vg),0),e}let A3=0;class ab{constructor(e="",t=[],i=0,r=[]){this.name=e,this.bindings=t,this.index=i,this.bindingsReference=r,this.id=A3++}}const ob=new WeakMap,N3=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),C3=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),fd=n=>(n=Number(n),n+(n%1?"":".0"));class lb{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=pd(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new hd,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=ob.get(this.renderer);return e===void 0&&(e=new M3,ob.set(this.renderer,e)),e}createRenderTarget(e,t,i){return new ui(e,t,i)}createCubeRenderTarget(e,t){return new aT(e,t)}createPMREMGenerator(){return new S3(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 ab(e,r,this.bindingsIndexes[e].group,r),i.set(r,a))):a=new ab(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 af)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===Wn||e.magFilter===Mn||e.magFilter===ji||e.minFilter===Lt||e.minFilter===Wn||e.minFilter===Mn||e.minFilter===ji}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 hd(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 fd(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")}( ${fd(t.r)}, ${fd(t.g)}, ${fd(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 Ng(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===ga)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=N3.get(e);return(t==="float"?"":t[0])+i}getTypeFromArray(e){return C3.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 Av)&&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=pd(this.stack),this.stacks.push(mf()||this.stack),Pl(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Pl(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 Ng("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 $T(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 Cg(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 JT(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 KT("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+`;
3866
+ `).removeFlowTab();return e.addFlowTab(),a}}const gt=(...n)=>G(new H1(Xs(n,"int"))).append(),SL=()=>ds("continue").append(),td=()=>ds("break").append(),wL=(...n)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),gt(...n)),ag=new WeakMap,br=new st,G1=U(({bufferMap:n,influence:e,stride:t,width:i,depth:r,offset:s})=>{const a=P(D1).mul(t).add(s),o=a.div(i),l=a.sub(o.mul(i));return Br(n,un(l,o)).depth(r).mul(e)});function EL(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=ag.get(n);if(a===void 0||a.count!==s){let o=function(){f.dispose(),ag.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 el(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)},ag.set(n,a),n.addEventListener("dispose",o)}return a}class W1 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}=EL(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,un(P(h).add(1),P(tc))).r):d.assign(fi("morphTargetInfluences","float").element(h).toVar()),i===!0&&Zt.addAssign(G1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(0)})),r===!0&&ur.addAssign(G1({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(W1),AL=n=>n.sort((e,t)=>e.id-t.id),NL=(n,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===n)return t;return null},og=new WeakMap;class X1 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=AL(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=NL(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;og.has(a)?c=og.get(a):(c=new l(a),og.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 q1=K(X1);class ta extends qe{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class Y1 extends ta{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class $1 extends Ff{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 J1=K($1);class K1 extends ta{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let ic,rc;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?rc.copy(t.viewport):(e.getViewport(rc),rc.multiplyScalar(e.getPixelRatio())):t!==null?(ic.width=t.width,ic.height=t.height):e.getDrawingBufferSize(ic)}setup(){const e=this.scope;let t=null;return e===ri.SIZE?t=fe(ic||(ic=new J)):e===ri.VIEWPORT?t=fe(rc||(rc=new st)):t=z(go.div(fo)),t}generate(e){if(this.scope===ri.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(fo).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 ms=ge(ri,ri.UV),fo=ge(ri,ri.SIZE),go=ge(ri,ri.COORDINATE),Pn=ge(ri,ri.VIEWPORT),Z1=Pn.zw,Q1=go.sub(Pn.xy),CL=Q1.div(Z1),RL=U(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),fo),"vec2").once()(),IL=U(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ms),"vec2").once()(),LL=U(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ms.flipY()),"vec2").once()(),nc=new J;class sc extends dn{static get type(){return"ViewportTextureNode"}constructor(e=ms,t=null,i=null){i===null&&(i=new pm,i.minFilter=ji),super(i,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=je.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(nc);const i=this.value;(i.image.width!==nc.width||i.image.height!==nc.height)&&(i.image.width=nc.width,i.image.height=nc.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 PL=K(sc),eT=K(sc,null,null,{generateMipmaps:!0});let lg=null;class tT extends sc{static get type(){return"ViewportDepthTextureNode"}constructor(e=ms,t=null){lg===null&&(lg=new Us),super(e,t,lg)}}const cg=K(tT);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=rT().assign(i));else if(t===Qi.DEPTH)e.isPerspectiveCamera?r=iT(Pi.z,co,uo):r=ac(Pi.z,co,uo);else if(t===Qi.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const s=ug(i,co,uo);r=ac(s,co,uo)}else r=i;else r=ac(Pi.z,co,uo);return r}}Qi.DEPTH_BASE="depthBase",Qi.DEPTH="depth",Qi.LINEAR_DEPTH="linearDepth";const ac=(n,e,t)=>n.add(e).div(e.sub(t)),DL=(n,e,t)=>e.sub(t).mul(n).sub(e),iT=(n,e,t)=>e.add(n).mul(t).div(t.sub(e).mul(n)),ug=(n,e,t)=>e.mul(t).div(t.sub(e).mul(n).sub(t)),rT=K(Qi,Qi.DEPTH_BASE),hg=ge(Qi,Qi.DEPTH),id=K(Qi,Qi.LINEAR_DEPTH),UL=id(cg());hg.assign=n=>rT(n);class vs extends qe{static get type(){return"ClippingNode"}constructor(e=vs.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===vs.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,a,o):this.setupDefault(t.planes,a,o)}setupAlphaToCoverage(e,t,i){return U(()=>{const r=mn(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=mn(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()}})()}}vs.ALPHA_TO_COVERAGE="alphaToCoverage",vs.DEFAULT="default";const OL=()=>G(new vs),FL=()=>G(new vs(vs.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+Zm(this)}build(e){this.setup(e)}setupObserver(e){return new Gx(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),Mf.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=FL():e.stack.add(OL())}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=ng().w.add(1).log2().mul(VM).mul(.5))}i!==null&&hg.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&&k1(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&&B1(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&F1(t).append(),this.positionNode!==null&&Zt.assign(this.positionNode);const r=ng();return e.context.vertex=e.removeStack(),e.context.mvp=r,r}setupDiffuseColor({object:e,geometry:t}){let i=this.colorNode?ae(this.colorNode):po;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):Kh;if(Nt.a.assign(Nt.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?E(this.alphaTestNode):o1;Nt.a.lessThanEqual(s).discard()}this.transparent===!1&&this.blending===_n&&this.alphaToCoverage===!1&&Nt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?D(0):Nt.rgb}setupNormal(){return this.normalNode?D(this.normalNode):m1}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 K1(rg)),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:L1;t.push(new Y1(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=q1([...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=J1(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)&&(yf.assign(D(s||c1)),o=o.add(yf)),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=Cl(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 VL=new Ka;class BL 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(VL),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(pn.mul(ae(r,1))),a=Pn.z.div(Pn.w),o=lr.mul(s),l=Li.xy.toVar();return l.mulAssign(this.pointWidthNode?this.pointWidthNode:R1),l.assign(l.div(Pn.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=Df(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(po):a=po,r.mulAssign(Kh),ae(a,r)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const zL=new Ni;class kL extends Tt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(zL),this.setValues(e)}}const HL=new mh;class GL extends Tt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(HL),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):Qh,i=this.dashSizeNode?E(this.dashSizeNode):eg,r=this.dashSizeNode?E(this.dashGapNode):tg;Ks.assign(i),Bl.assign(r);const s=Ii(_i("lineDistance").mul(t));(e?s.add(e):s).mod(Ks.add(Bl)).greaterThan(Ks).discard()}}const WL=new mh;class jL extends Tt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(WL),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(pn.mul(ae(l,1))).toVar("start"),h=ae(pn.mul(ae(c,1))).toVar("end");s&&(Zr("vec3","worldStart").assign(u.xyz),Zr("vec3","worldEnd").assign(h.xyz));const d=Pn.z.div(Pn.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=ed.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(ed)),_.assign(_.div(Pn.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):ig,d=this.dashScaleNode?E(this.dashScaleNode):Qh,p=this.dashSizeNode?E(this.dashSizeNode):eg,m=this.dashSizeNode?E(this.dashGapNode):tg;Ks.assign(p),Bl.assign(m);const v=_i("instanceDistanceStart"),f=_i("instanceDistanceEnd"),g=Li.y.lessThan(.5).select(d.mul(v),Qh.mul(f)),x=Ii(g.add(ig)),y=h?x.add(h):x;l.y.lessThan(-1).or(l.y.greaterThan(1)).discard(),y.mod(Ks.add(Bl)).greaterThan(Ks).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(ed);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(po)}else u=po;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 nT=n=>G(n).mul(.5).add(.5),XL=n=>G(n).mul(2).sub(1),qL=new dh;class YL extends Tt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(qL),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?E(this.opacityNode):Kh;Nt.assign(ae(nT(Yt),e))}}class sT extends pt{static get type(){return"EquirectUVNode"}constructor(e=Xf){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 dg=K(sT);class aT extends Cu{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 yn(5,5,5),a=dg(Xf),o=new Tt;o.colorNode=yt(t,a,0),o.side=si,o.blending=Er;const l=new Ft(s,o),c=new Vu;c.add(l),t.minFilter===ji&&(t.minFilter=Lt);const u=new Nu(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 oc=new WeakMap;class $L extends pt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Yh();const t=new Cs;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===zn||a===kn){if(oc.has(s)){const o=oc.get(s);lT(o,s.mapping),this._cubeTexture=o}else{const o=s.image;if(JL(o)){const l=new aT(o.height);l.fromEquirectangularTexture(t,s),lT(l.texture,s.mapping),this._cubeTexture=l.texture,oc.set(s,l.texture),s.addEventListener("dispose",oT)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function JL(n){return n==null?!1:n.height>0}function oT(n){const e=n.target;e.removeEventListener("dispose",oT);const t=oc.get(e);t!==void 0&&(oc.delete(e),t.dispose())}function lT(n,e){e===zn?n.mapping=fr:e===kn&&(n.mapping=Ar)}const KL=K($L);class rd extends ta{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=KL(this.envNode)}}class ZL extends ta{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 lc{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class cT extends lc{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 pa:s.rgb.assign(rt(s.rgb,s.rgb.mul(a.rgb),ec.mul(Zh)));break;case Kd:s.rgb.assign(rt(s.rgb,a.rgb,ec.mul(Zh)));break;case Zd:s.rgb.addAssign(a.rgb.mul(ec.mul(Zh)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const QL=new $r;class eP extends Tt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(QL),this.setValues(e)}setupNormal(){return hr}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new rd(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ZL(rg)),t}setupOutgoingLight(){return Nt.rgb}setupLightingModel(){return new cT}}const vo=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))}),ia=U(n=>n.diffuseColor.mul(1/Math.PI)),tP=()=>E(.25),iP=U(({dotNH:n})=>Fh.mul(E(.5)).add(1).mul(E(1/Math.PI)).mul(n.pow(Fh))),rP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(e).clamp(),i=Vt.dot(e).clamp(),r=vo({f0:or,f90:1,dotVH:i}),s=tP(),a=iP({dotNH:t});return r.mul(s).mul(a)});class pg extends cT{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(ia({diffuseColor:Nt.rgb}))),this.specular===!0&&i.directSpecular.addAssign(r.mul(rP({lightDirection:e})).mul(ec))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ia({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const nP=new ph;class sP extends Tt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(nP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new rd(t):null}setupLightingModel(){return new pg(!1)}}const aP=new hh;class oP extends Tt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(aP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new rd(t):null}setupLightingModel(){return new pg}setupVariants(){const e=(this.shininessNode?E(this.shininessNode):l1).max(1e-4);Fh.assign(e);const t=this.specularNode||u1;or.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const uT=U(()=>{const n=hr.dFdx().abs().max(hr.dFdy().abs());return n.x.max(n.y).max(n.z)}),mg=U(n=>{const{roughness:e}=n,t=uT();let i=e.max(.0525);return i=i.add(t),i=i.min(1),i}),hT=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(P_))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),lP=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"}]}),dT=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"}]}),cP=E(1/Math.PI),uP=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 cP.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"}]}),fg=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=vo({f0:t,f90:i,dotVH:m}),f,g;if(Rl(a)&&(v=Uh.mix(v,s)),Rl(o)){const x=Fl.dot(e),y=Fl.dot(Vt),_=Fl.dot(u),I=Js.dot(e),T=Js.dot(Vt),w=Js.dot(u);f=lP({alphaT:Oh,alphaB:c,dotTV:y,dotBV:T,dotTL:x,dotBL:I,dotNV:d,dotNL:h}),g=uP({alphaT:Oh,alphaB:c,dotNH:p,dotTH:_,dotBH:w})}else f=hT({alpha:c,dotNL:h,dotNV:d}),g=dT({alpha:c,dotNH:p});return v.mul(f).mul(g)}),gg=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"}]}),pT=U(n=>{const{dotNV:e,specularColor:t,specularF90:i,roughness:r}=n,s=gg({dotNV:e,roughness:r});return t.mul(s.x).add(i.mul(s.y))}),mT=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"}]}),hP=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"}]}),dP=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"}]}),pP=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=hP({roughness:Dh,dotNH:r}),a=dP({dotNV:i,dotNL:t});return $s.mul(s).mul(a)}),mP=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"}]}),fP=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"}]}),nd=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"}]}),fT=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(nd({v1:v,v2:f})),y.addAssign(nd({v1:f,v2:g})),y.addAssign(nd({v1:g,v2:x})),y.addAssign(nd({v1:x,v2:v})),h.assign(D(fP({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"}]}),sd=1/6,gT=n=>lt(sd,lt(n,lt(n,n.negate().add(3)).sub(3)).add(1)),vg=n=>lt(sd,lt(n,lt(n,lt(3,n).sub(6))).add(4)),vT=n=>lt(sd,lt(n,lt(n,lt(-3,n).add(3)).add(3)).add(1)),yg=n=>lt(sd,Ji(n,3)),yT=n=>gT(n).add(vg(n)),xT=n=>vT(n).add(yg(n)),_T=n=>zt(-1,vg(n).div(gT(n).add(vg(n)))),MT=n=>zt(1,yg(n).div(vT(n).add(yg(n)))),TT=(n,e,t)=>{const i=n.uvNode,r=lt(i,e.zw).add(.5),s=us(r),a=hs(r),o=yT(a.x),l=xT(a.x),c=_T(a.x),u=MT(a.x),h=_T(a.y),d=MT(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=yT(a.y).mul(zt(o.mul(n.uv(p).level(t)),l.mul(n.uv(m).level(t)))),x=xT(a.y).mul(zt(o.mul(n.uv(v).level(t)),l.mul(n.uv(f).level(t))));return g.add(x)},bT=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=TT(n,ae(r,t),us(e)),o=TT(n,ae(s,i),If(e));return hs(e).mix(a,o)}),ST=U(([n,e,t,i,r])=>{const s=D(Uf(e.negate(),Mr(n),Qr(1,i))),a=D(Qs(r[0].xyz),Qs(r[1].xyz),Qs(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"}]}),gP=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"}]}),vP=eT(),wT=U(([n,e,t])=>{const i=vP.uv(n),r=kl(E(fo.x)).mul(gP(e,t));return bT(i,r)}),ET=U(([n,e,t])=>(Le(t.notEqual(0),()=>{const i=Rf(e).negate().div(t);return Cf(i.negate().mul(n))}),D(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),yP=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=ST(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=wT(k,t,C);v.element(w).assign(j.element(w)),v.a.addAssign(j.a),f.element(w).assign(i.element(w).mul(ET(Qs(H),d,p).element(w)))}),v.a.divAssign(3)}else{const I=ST(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=wT(C,t,u),f=i.mul(ET(Qs(I),d,p))}const g=f.rgb.mul(v.rgb),x=n.dot(e).clamp(),y=D(pT({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())}),xP=yi(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),_P=n=>{const e=n.sqrt();return D(1).add(e).div(D(1).sub(e))},AT=(n,e)=>n.sub(e).div(n.add(e)).pow2(),MP=(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),xP.mul(o)},TP=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=AT(s,n),c=vo({f0:l,f90:1,dotVH:t}),u=c.oneMinus(),h=s.lessThan(n).select(Math.PI,0),d=E(Math.PI).sub(h),p=_P(r.clamp(0,.9999)),m=AT(p,s.toVec3()),v=vo({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=MP(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"}]}),bP=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()}),xg=D(.04),_g=E(1);class ad extends lc{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=TP({outsideIOR:E(1),eta2:xf,cosTheta1:t,thinFilmThickness:_f,baseF0:or}),this.iridescenceF0=mT({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=jh,i=jf.sub(jh).normalize(),r=qf;e.backdrop=yP(r,i,hn,Nt,or,Vl,t,zr,cr,lr,zl,Tf,Sf,bf,this.dispersion?wf:null),e.backdropAlpha=Vh,Nt.a.mulAssign(rt(1,e.backdrop.a,Vh))}}computeMultiscattering(e,t,i){const r=Yt.dot(Vt).clamp(),s=gg({roughness:hn,dotNV:r}),a=(this.iridescenceF0?Uh.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(pP({lightDirection:e}))),this.clearcoat===!0){const s=ho.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(fg({lightDirection:e,f0:xg,f90:_g,roughness:Ol,normalView:ho})))}i.directDiffuse.addAssign(r.mul(ia({diffuseColor:Nt.rgb}))),i.directSpecular.addAssign(r.mul(fg({lightDirection:e,f0:or,f90:1,roughness:hn,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=mP({N:d,V:p,roughness:hn}),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(fT({N:d,V:p,P:m,mInv:x,p0:l,p1:c,p2:u,p3:h}))),s.directDiffuse.addAssign(e.mul(Nt).mul(fT({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(ia({diffuseColor:Nt})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:i}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul($s,bP({normal:Yt,viewDir:Vt,roughness:Dh}))),this.clearcoat===!0){const c=ho.dot(Vt).clamp(),u=pT({dotNV:c,specularColor:xg,specularF90:_g,roughness:Ol});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,Vl);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=hn.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=ho.dot(Vt).clamp(),r=vo({dotVH:i,f0:xg,f90:_g}),s=t.mul(Ph.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Ph));t.assign(s)}if(this.sheen===!0){const i=$s.r.max($s.g).max($s.b).mul(.157).oneMinus(),r=t.mul(i).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const NT=E(1),Mg=E(-2),od=E(.8),Tg=E(-1),ld=E(.4),bg=E(2),cd=E(.305),Sg=E(3),CT=E(.21),SP=E(4),RT=E(4),wP=E(16),EP=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"}]}),AP=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"}]}),NP=U(([n])=>{const e=E(0).toVar();return Le(n.greaterThanEqual(od),()=>{e.assign(NT.sub(n).mul(Tg.sub(Mg)).div(NT.sub(od)).add(Mg))}).ElseIf(n.greaterThanEqual(ld),()=>{e.assign(od.sub(n).mul(bg.sub(Tg)).div(od.sub(ld)).add(Tg))}).ElseIf(n.greaterThanEqual(cd),()=>{e.assign(ld.sub(n).mul(Sg.sub(bg)).div(ld.sub(cd)).add(bg))}).ElseIf(n.greaterThanEqual(CT),()=>{e.assign(cd.sub(n).mul(SP.sub(Sg)).div(cd.sub(CT)).add(Sg))}).Else(()=>{e.assign(E(-2).mul(kl(lt(1.16,n))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),IT=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"}]}),LT=U(([n,e,t,i,r,s])=>{const a=E(t),o=D(e),l=li(NP(a),Mg,s),c=hs(l),u=us(l),h=D(wg(n,o,u,i,r,s)).toVar();return Le(c.notEqual(0),()=>{const d=D(wg(n,o,u.add(1),i,r,s)).toVar();h.assign(rt(h,d,c))}),h}),wg=U(([n,e,t,i,r,s])=>{const a=E(t).toVar(),o=D(e),l=E(EP(o)).toVar(),c=E(ft(RT.sub(a),0)).toVar();a.assign(ft(a,RT));const u=E(Bh(a)).toVar(),h=z(AP(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,wP))),h.y.addAssign(lt(4,Bh(s).sub(u))),h.x.mulAssign(i),h.y.mulAssign(r),n.uv(h).grad(z(),z())}),Eg=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 wg(n,c,e,s,a,o)}),PT=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,lo(t,i))).toVar();Le(Nf(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(Eg({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),()=>{td()});const v=E(a.mul(E(m))).toVar();p.addAssign(r.element(m).mul(Eg({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(Eg({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 ud=null;const DT=new WeakMap;function CP(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 RP(n){let e=DT.get(n);if((e!==void 0?e.pmremVersion:-1)!==n.pmremVersion){const t=n.image;if(n.isCubeTexture)if(IP(t))e=ud.fromCubemap(n,e);else return null;else if(LP(t))e=ud.fromEquirectangular(n,e);else return null;e.pmremVersion=n.pmremVersion,DT.set(n,e)}return e.texture}class UT 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=CP(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=RP(i),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ud===null&&(ud=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)),LT(this._texture,t,r,this._width,this._height,this._maxMip)}}function IP(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 LP(n){return n==null?!1:n.height>0}const OT=K(UT),FT=new WeakMap;class VT extends ta{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=FT.get(h);d===void 0&&(d=OT(h),FT.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?i1:Yt,a=i.context(BT(hn,s)).mul(r),o=i.context(PP(qf)).mul(Math.PI).mul(r),l=ql(a),c=ql(o);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(c);const u=e.context.lightingModel.clearcoatRadiance;if(u){const h=i.context(BT(Ol,ho)).mul(r),d=ql(h);u.addAssign(d)}}}const BT=(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}},PP=n=>({getUV:()=>n,getTextureLevel:()=>E(1)}),DP=new Sl;class zT 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(DP),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new VT(t):null}setupLightingModel(){return new ad}setupSpecular(){const e=rt(D(.04),Nt.rgb,Ul);or.assign(e),Vl.assign(1)}setupVariants(){const e=this.metalnessNode?E(this.metalnessNode):p1;Ul.assign(e);let t=this.roughnessNode?E(this.roughnessNode):d1;t=mg({roughness:t}),hn.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 UP=new uh;class kT extends zT{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(UP),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):A1;zl.assign(e),or.assign(rt(xi(Pf(zl.sub(1).div(zl.add(1))).mul(h1),D(1)).mul(Qf),Nt.rgb,Ul)),Vl.assign(rt(Qf,1,Ul))}setupLightingModel(){return new ad(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):f1,i=this.clearcoatRoughnessNode?E(this.clearcoatRoughnessNode):g1;Ph.assign(t),Ol.assign(mg({roughness:i}))}if(this.useSheen){const t=this.sheenNode?D(this.sheenNode):x1,i=this.sheenRoughnessNode?E(this.sheenRoughnessNode):_1;$s.assign(t),Dh.assign(i)}if(this.useIridescence){const t=this.iridescenceNode?E(this.iridescenceNode):T1,i=this.iridescenceIORNode?E(this.iridescenceIORNode):b1,r=this.iridescenceThicknessNode?E(this.iridescenceThicknessNode):S1;Uh.assign(t),xf.assign(i),_f.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?z(this.anisotropyNode):M1).toVar();cs.assign(t.length()),Le(cs.equal(0),()=>{t.assign(z(1,0))}).Else(()=>{t.divAssign(z(cs)),cs.assign(cs.saturate())}),Oh.assign(cs.pow2().mix(hn.pow2(),1)),Fl.assign(ea[0].mul(t.x).add(ea[1].mul(t.y))),Js.assign(ea[1].mul(t.x).sub(ea[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?E(this.transmissionNode):w1,i=this.thicknessNode?E(this.thicknessNode):E1,r=this.attenuationDistanceNode?E(this.attenuationDistanceNode):N1,s=this.attenuationColorNode?D(this.attenuationColorNode):C1;if(Vh.assign(t),Tf.assign(i),bf.assign(r),Sf.assign(s),this.useDispersion){const a=this.dispersionNode?E(this.dispersionNode):I1;wf.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?D(this.clearcoatNormalNode):v1}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 OP extends ad{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 FP extends kT{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 OP(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 VP=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 BP extends lc{direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){const a=VP({normal:Xh,lightDirection:e,builder:s}).mul(t);i.directDiffuse.addAssign(a.mul(ia({diffuseColor:Nt.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ia({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const zP=new Rm;class kP extends Tt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(zP),this.setValues(e)}setupLightingModel(){return new BP}}class HT 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 GT=ge(HT),HP=new Im;class GP extends Tt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(HP),this.setValues(e)}setupVariants(e){const t=GT;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 WP=new Ka;class jP extends Tt{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(WP),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class WT 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 Dl(r,s,s.negate(),r).mul(i)}else{const r=t,s=qs(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=qs(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=qs(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 Ag=K(WT),XP=new cl;class qP 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(XP),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=pn.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=W2("center","vec2");h=h.sub(v.sub(.5))}h=h.mul(u);const d=E(a||y1),p=Ag(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 YP extends lc{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 $P=new ch;class JP extends Tt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues($P),this.setValues(e)}setupLightingModel(){return new YP}}const KP=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 dn{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 KP({texture:this,uv:e})}}const XT=K(jT);class ZP 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=XT(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(zM.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),td()),o.addAssign(s.mul(c))}),u.a.equal(0).discard(),ae(u)})(),super.setup(e)}}class qT extends Hi{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 YT extends _c{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 QP extends sx{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 qT;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 YT;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 Ng{constructor(e,t,i=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=i}}class $T{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 Cg{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class JT extends Cg{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class KT{constructor(e,t,i=""){this.name=e,this.type=t,this.code=i,Object.defineProperty(this,"isNodeCode",{value:!0})}}let e3=0;class hd{constructor(e=null){this.id=e3++,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 Rg 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 t3=(n,e)=>G(new Rg(n,e));class Ig 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 dd=K(Ig),i3=(n,e)=>dd(n,e,"js"),r3=(n,e)=>dd(n,e,"wgsl"),n3=(n,e)=>dd(n,e,"glsl");class Lg extends Ig{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+`
3867
+ `,t==="property"?o:e.format(`${o}()`,s,t)}}const ZT=(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 Lg(n,e,t)),r=(...s)=>i.call(...s);return r.functionNode=i,r},s3=(n,e)=>ZT(n,e,"glsl"),a3=(n,e)=>ZT(n,e,"wgsl");class ra{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 o3 extends ra{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class l3 extends ra{constructor(e,t=new J){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class c3 extends ra{constructor(e,t=new N){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class u3 extends ra{constructor(e,t=new st){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class h3 extends ra{constructor(e,t=new xe){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class d3 extends ra{constructor(e,t=new Ke){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class p3 extends ra{constructor(e,t=new Re){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class m3 extends o3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class f3 extends l3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class g3 extends c3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}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 QT 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 Il(t);return this._currentCond=Ri(e,i),this.add(this._currentCond)}ElseIf(e,t){const i=new Il(t),r=Ri(e,i);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Il(e),this}build(e,...t){const i=mf();Pl(this);for(const r of this.nodes)r.build(e,"void");return Pl(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 pd=K(QT);class M3{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 yo=4,eb=[.125,.215,.35,.446,.526,.582],na=20,Pg=new Ls(-1,1,1,-1,0,1),T3=new di(90,1),tb=new xe;let Dg=null,Ug=0,Og=0;const sa=(1+Math.sqrt(5))/2,xo=1/sa,ib=[new N(-sa,xo,0),new N(sa,xo,0),new N(-xo,0,sa),new N(xo,0,sa),new N(0,sa,-xo),new N(0,sa,xo),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],b3=[3,1,5,0,4,2],Fg=IT(nt(),_i("faceIndex")).normalize(),Vg=D(Fg.x,Fg.y.negate(),Fg.z);class S3{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){Dg=this._renderer.getRenderTarget(),Ug=this._renderer.getActiveCubeFace(),Og=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=nb(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=sb(),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(Dg,Ug,Og),e.scissorTest=!1,md(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),Dg=this._renderer.getRenderTarget(),Ug=this._renderer.getActiveCubeFace(),Og=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=rb(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=rb(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=w3(s)),this._blurMaterial=E3(s,e,t)}return r}async _compileMaterial(e){const t=new Ft(this._lodPlanes[0],e);await this._renderer.compile(t,Pg)}_sceneToCubeUV(e,t,i,r){const s=T3;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(tb),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 yn,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(tb),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;md(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=nb(e)):this._equirectMaterial===null&&(this._equirectMaterial=sb(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const o=this._cubeSize;md(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Pg)}_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=ib[(r-s-1)%ib.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*na-1),v=s/m,f=isFinite(s)?1+Math.floor(u*v):na;f>na&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${na}`);const g=[];let x=0;for(let w=0;w<na;++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-yo?r-y+yo:0),T=4*(this._cubeSize-_);md(t,I,T,3*_,2*_),l.setRenderTarget(t),l.render(h,Pg)}}function w3(n){const e=[],t=[],i=[],r=[];let s=n;const a=n-yo+1+eb.length;for(let o=0;o<a;o++){const l=Math.pow(2,s);t.push(l);let c=1/l;o>n-yo?c=eb[o-n+yo-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=b3[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>yo&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i,lodMeshes:r}}function rb(n,e,t){const i=new ui(n,e,t);return i.texture.mapping=Hn,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function md(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Bg(n){const e=new Tt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Er,e.name=`PMREM_${n}`,e}function E3(n,e,t){const i=mn(new Array(na).fill(0)),r=fe(new N(0,1,0)),s=fe(0),a=E(na),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:Vg,dTheta:s,samples:l,envMap:c,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},v=Bg("blur");return v.uniforms=m,v.fragmentNode=PT({...m,latitudinal:o.equal(1)}),v}function nb(n){const e=Bg("cubemap");return e.fragmentNode=Yh(n,Vg),e}function sb(n){const e=Bg("equirect");return e.fragmentNode=yt(n,dg(Vg),0),e}let A3=0;class ab{constructor(e="",t=[],i=0,r=[]){this.name=e,this.bindings=t,this.index=i,this.bindingsReference=r,this.id=A3++}}const ob=new WeakMap,N3=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),C3=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),fd=n=>(n=Number(n),n+(n%1?"":".0"));class lb{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=pd(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new hd,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=ob.get(this.renderer);return e===void 0&&(e=new M3,ob.set(this.renderer,e)),e}createRenderTarget(e,t,i){return new ui(e,t,i)}createCubeRenderTarget(e,t){return new aT(e,t)}createPMREMGenerator(){return new S3(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 ab(e,r,this.bindingsIndexes[e].group,r),i.set(r,a))):a=new ab(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 af)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===Wn||e.magFilter===Mn||e.magFilter===ji||e.minFilter===Lt||e.minFilter===Wn||e.minFilter===Mn||e.minFilter===ji}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 hd(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 fd(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")}( ${fd(t.r)}, ${fd(t.g)}, ${fd(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 Ng(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===ga)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=N3.get(e);return(t==="float"?"":t[0])+i}getTypeFromArray(e){return C3.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 Av)&&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=pd(this.stack),this.stacks.push(mf()||this.stack),Pl(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Pl(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 Ng("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 $T(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 Cg(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 JT(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 KT("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+`;
3868
3868
  `),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 Lg,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 Rg(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 hd,this.stack=pd();for(const c of sf)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};
3869
3869
  `),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+`
3870
3870
  `;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 sf){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of af){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 m3(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new f3(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new g3(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new v3(e);if(t==="color")return new y3(e);if(t==="mat3")return new x3(e);if(t==="mat4")return new _3(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 r169 - Node System
3871
- `}}class cb{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 zg{constructor(e,t,i=null,r="",s=!1){this.type=e,this.name=t,this.count=i,this.qualifier=r,this.isConst=s}}zg.isNodeFunctionInput=!0;class R3 extends qe{static get type(){return"StructTypeNode"}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class kg 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 R3(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 I3=K(kg);function Hg(n,e){for(let t=0;t<n.length;t++)if(n[t].name===e)return t;return-1}class ub extends kg{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 gd(t)}setup(e){const t=this.outputNodes,i=e.renderer.getRenderTarget(),r=[],s=i.textures;for(const a in t){const o=Hg(s,a);r[o]=ae(t[a])}return this.members=r,super.setup(e)}}const gd=K(ub);class hb 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 L3=K(hb),Di=n=>(...e)=>L3(n,...e);class Si extends Ys{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 Gg=(n,e=0)=>G(new Si(Si.LOCAL,n,e)),P3=(n,e=0)=>G(new Si(Si.GLOBAL,n,e)),D3=(n,e=0)=>G(new Si(Si.DELTA,n,e)),U3=ge(Si,Si.FRAME).toUint();class gi extends qe{static get type(){return"OscNode"}constructor(e=gi.SINE,t=Gg()){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 O3=K(gi,gi.SINE),F3=K(gi,gi.SQUARE),V3=K(gi,gi.TRIANGLE),B3=K(gi,gi.SAWTOOTH);class db 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 z3=K(db);class pb extends as{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 k3=K(pb);class mb 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 fb=K(mb),H3=(...n)=>fb(...n),_o=new ln,aa=new N,Mo=new N,Wg=new N,cc=new Re,vd=new N(0,0,-1),Dn=new st,uc=new N,yd=new N,hc=new st,xd=new J,gb=new ui,G3=ps.flipX();let jg=!1;class vb extends dn{static get type(){return"ReflectorNode"}constructor(e={}){super(gb.texture,G3);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(xd),e.setSize(Math.round(xd.width*i),Math.round(xd.height*i))}setup(e){return this._updateResolution(gb,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=V0,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(xd),this._updateResolution(l,r),Mo.setFromMatrixPosition(a.matrixWorld),Wg.setFromMatrixPosition(i.matrixWorld),cc.extractRotation(a.matrixWorld),aa.set(0,0,1),aa.applyMatrix4(cc),uc.subVectors(Mo,Wg),uc.dot(aa)>0)return;uc.reflect(aa).negate(),uc.add(Mo),cc.extractRotation(i.matrixWorld),vd.set(0,0,-1),vd.applyMatrix4(cc),vd.add(Wg),yd.subVectors(Mo,vd),yd.reflect(aa).negate(),yd.add(Mo),o.coordinateSystem=i.coordinateSystem,o.position.copy(uc),o.up.set(0,1,0),o.up.applyMatrix4(cc),o.up.reflect(aa),o.lookAt(yd),o.near=i.near,o.far=i.far,o.updateMatrixWorld(),o.projectionMatrix.copy(i.projectionMatrix),_o.setFromNormalAndCoplanarPoint(aa,Mo),_o.applyMatrix4(o.matrixWorldInverse),Dn.set(_o.normal.x,_o.normal.y,_o.normal.z,_o.constant);const c=o.projectionMatrix;hc.x=(Math.sign(Dn.x)+c.elements[8])/c.elements[0],hc.y=(Math.sign(Dn.y)+c.elements[9])/c.elements[5],hc.z=-1,hc.w=(1+c.elements[10])/c.elements[14],Dn.multiplyScalar(1/Dn.dot(hc));const u=0;c.elements[2]=Dn.x,c.elements[6]=Dn.y,c.elements[10]=Dn.z-u,c.elements[14]=Dn.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 W3=n=>G(new vb(n)),Xg=new Is(-1,1,1,-1,0,1);class j3 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 X3=new j3;class fn extends Ft{constructor(e=null){super(X3,e),this.camera=Xg,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,Xg)}render(e){e.render(this,Xg)}}const q3=new J;class yb extends dn{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 fn(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(q3);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 dn(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const xb=(n,...e)=>G(new yb(G(n),...e)),Zi=(n,...e)=>n.isTextureNode?n:xb(n,...e);class _b extends Wf{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 Y3=(...n)=>G(new _b(...n));class Mb 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 $3=ge(Mb);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 J3=ge(sn,sn.BACKGROUND_BLURRINESS),K3=ge(sn,sn.BACKGROUND_INTENSITY),Tb={Storage:"storage",ReadOnlyStorage:"read-only-storage"},qg={WriteOnly:"write-only",ReadOnly:"read-only"};class Yg extends $h{static get type(){return"StorageBufferNode"}constructor(e,t,i=0){super(e,t,i),this.isStorageBufferNode=!0,this.access=Tb.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 k3(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Tb.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=Xl(this.value),this._varying=Ii(this._attribute));const i=this._varying.build(e,t);return e.registerTransform(i,this._attribute),i}}const Z3=(n,e,t)=>G(new Yg(n,e,t)),Q3=(n,e,t)=>G(new Yg(n,e,t).setBufferObject(!0));class bb extends dn{static get type(){return"StorageTextureNode"}constructor(e,t,i=null){super(e,t),this.storeNode=i,this.isStorageTextureNode=!0,this.access=qg.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(qg.ReadOnly)}toWriteOnly(){return this.setAccess(qg.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 Sb=K(bb),eD=(n,e,t)=>{const i=Sb(n,e,t);return t!==null&&i.append(),i};class wb extends Jl{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 tD=(n,e,t)=>G(new wb(n,e,t));class Eb 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 iD=K(Eb);let $g=null;class Ab extends sc{static get type(){return"ViewportSharedTextureNode"}constructor(e=ps,t=null){$g===null&&($g=new pm),super(e,t,$g)}updateReference(){return this}}const rD=K(Ab),nD=new J;class Nb extends dn{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 Cb extends Nb{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 Ds;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 Cb(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 Cb(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=ug(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=ac(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(nD);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 sD=(n,e,t)=>G(new bi(bi.COLOR,n,e,t)),To=(n,e)=>G(new Nb(n,e)),aD=(n,e)=>G(new bi(bi.DEPTH,n,e)),Rb=new fn,Ib=new fn;class Lb 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=To(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;Rb.material=this._material,Ib.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),Rb.render(t),i.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),Ib.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 oD=(n,e,t)=>G(new Lb(Zi(n),e,t)),Jg=new J,Pb=new fn;class Db 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=To(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(Jg),this.setSize(Jg.x,Jg.y);const s=t.getRenderTarget(),a=i.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),Pb.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(Hl(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(),Pb.material=l;const c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const lD=(n,e)=>G(new Db(Zi(n),e)),cD=U(([n])=>Ui(n.rgb)),uD=U(([n,e=E(1)])=>e.mix(Ui(n.rgb),n.rgb)),hD=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)}),dD=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())))))}),pD=new N,Ui=(n,e=D(...vt.getLuminanceCoefficients(pD)))=>qt(n,e),Ub=(n,e)=>rt(D(0),n,Ui(n).sub(e).max(0)),Ob=new fn;class Fb 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=To(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;Ob.material=this._material,this.setSize(r.image.width,r.image.height),t.setRenderTarget(this._renderTarget),Ob.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=Ub(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 mD=(n,e=.9,t=3,i=32)=>G(new Fb(Zi(n),G(e),G(t),i));class Vb 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 fD=n=>G(new Vb(Zi(n)));class Bb 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 gD=(n,e,t=1,i=.025,r=1)=>G(new Bb(Zi(n),G(e),G(t),G(i),G(r)));class zb 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(fo).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 vD=(n,e,t,i)=>G(new zb(G(n),e,t,i));class kb 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 yD=(n,e,t)=>G(new kb(Zi(n),e,t));class Hb 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=Of(us(e.add(Gg())));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 xD=K(Hb);class Gb 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 _D=(n,e,t,i)=>G(new Gb(G(n),G(e),t,G(i))),Wb=new fn,jb=new xe,MD=new J;class Xb 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(TD()),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=To(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(MD),r=t.getRenderTarget(),s=t.getMRT();t.getClearColor(jb);const a=t.getClearAlpha();Wb.material=this._material,this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),Wb.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=ds(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(Zs),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(lo(H.xyz,M)),k=lo(b,M),j=Mr(h.sub(b.mul(qt(h,b)))),Y=lo(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,zh(re.y).sub(zh(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 TD(n=5){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=bD(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=Gn,s.wrapT=Gn,s.needsUpdate=!0,s}function bD(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 SD=(n,e,t)=>G(new Xb(G(n),G(e),t));class qb 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=mn(wD(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=ds(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(Zs))),y=Tr(g.element(this.index.mod(4).mul(2).mul(Zs))),_=z(x,y),I=Dl(_.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 wD(n,e,t){const i=ED(n,e,t),r=[];for(let s=0;s<n;s++){const a=i[s];r.push(a)}return r}function ED(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 AD=(n,e,t,i,r)=>G(new qb(Zi(n),G(e),G(t),G(i),r));class Yb 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)),()=>{td()})}),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 ND=n=>G(new Yb(Zi(n))),oa=new fn,CD=new xe(0,0,0),$b=new xe,RD=new J,ID=new J(1,0),LD=new J(0,1);class Jb 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=To(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(RD);this.setSize(i.width,i.height);const r=t.getRenderTarget(),s=t.getMRT();t.getClearColor($b);const a=t.getClearAlpha();this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(CD,0),t.setRenderTarget(this._renderTargetBright),oa.material=this._highPassFilterMaterial,oa.render(t);let o=this._renderTargetBright;for(let l=0;l<this._nMips;l++)oa.material=this._separableBlurMaterials[l],this._separableBlurMaterials[l].colorTexture.value=o.texture,this._separableBlurMaterials[l].direction.value=ID,t.setRenderTarget(this._renderTargetsHorizontal[l]),t.clear(),oa.render(t),this._separableBlurMaterials[l].colorTexture.value=this._renderTargetsHorizontal[l].texture,this._separableBlurMaterials[l].direction.value=LD,t.setRenderTarget(this._renderTargetsVertical[l]),t.clear(),oa.render(t),o=this._renderTargetsVertical[l];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),oa.material=this._compositeMaterial,oa.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor($b,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=mn([1,.8,.6,.4,.2]),s=mn([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=mn(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 PD=(n,e,t,i)=>G(new Jb(G(n),e,t,i));class Kb 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 DD=(n,e,t,i=0,r=.1,s=0)=>G(new Kb(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class UD 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))),cs(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(Hl(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)),Gl(.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 OD=(n,e,t,i=6,r=.3,s=.4)=>G(new UD(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class Zb 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=gd({output:Mf,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 OD(e,t,i,this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const FD=(n,e,t,i,r)=>G(new Zb(n,e,t,i,r)),VD=new J;class Qb 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 fn}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(VD);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=BD[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=Hg(this.sampleRenderTarget.textures,s);a>=0&&(r[s]=yt(this.sampleRenderTarget.textures[a]).mul(this.sampleWeight))}t=gd(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=Ao,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}}const BD=[[[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]]],zD=(n,e)=>G(new Qb(n,e)),kD=new J;class eS extends bi{static get type(){return"StereoPassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new Hm,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(kD);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 HD=(n,e)=>G(new eS(n,e)),GD=new J,tS=new fn;class iS extends bi{static get type(){return"StereoCompositePassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new Hm;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(GD);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),tS.material=this._material,tS.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}}class rS extends iS{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 WD=(n,e)=>G(new rS(n,e));class nS extends iS{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(kh(go.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 jD=(n,e)=>G(new nS(n,e));class sS 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(pn),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 XD=(n,e,t=new xe(0,0,0),i=.003,r=1)=>G(new sS(n,e,G(t),G(i),G(r)));class aS 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=ef(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=tf(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 _d=K(aS);class oS 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 qD{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 Md=new oS;class lS extends qe{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new oS,this._output=_d(),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]=_d(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]=_d(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 qD(this),r=Md.get("THREE"),s=Md.get("TSL"),a=this.getMethod(this.codeNode),o=[i,this._local,Md,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 = {};
3871
+ `}}class cb{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 zg{constructor(e,t,i=null,r="",s=!1){this.type=e,this.name=t,this.count=i,this.qualifier=r,this.isConst=s}}zg.isNodeFunctionInput=!0;class R3 extends qe{static get type(){return"StructTypeNode"}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class kg 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 R3(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 I3=K(kg);function Hg(n,e){for(let t=0;t<n.length;t++)if(n[t].name===e)return t;return-1}class ub extends kg{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 gd(t)}setup(e){const t=this.outputNodes,i=e.renderer.getRenderTarget(),r=[],s=i.textures;for(const a in t){const o=Hg(s,a);r[o]=ae(t[a])}return this.members=r,super.setup(e)}}const gd=K(ub);class hb 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 L3=K(hb),Di=n=>(...e)=>L3(n,...e);class Si extends Ys{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 Gg=(n,e=0)=>G(new Si(Si.LOCAL,n,e)),P3=(n,e=0)=>G(new Si(Si.GLOBAL,n,e)),D3=(n,e=0)=>G(new Si(Si.DELTA,n,e)),U3=ge(Si,Si.FRAME).toUint();class gi extends qe{static get type(){return"OscNode"}constructor(e=gi.SINE,t=Gg()){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 O3=K(gi,gi.SINE),F3=K(gi,gi.SQUARE),V3=K(gi,gi.TRIANGLE),B3=K(gi,gi.SAWTOOTH);class db 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 z3=K(db);class pb extends os{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 k3=K(pb);class mb 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 fb=K(mb),H3=(...n)=>fb(...n),_o=new ln,aa=new N,Mo=new N,Wg=new N,cc=new Re,vd=new N(0,0,-1),Dn=new st,uc=new N,yd=new N,hc=new st,xd=new J,gb=new ui,G3=ms.flipX();let jg=!1;class vb extends dn{static get type(){return"ReflectorNode"}constructor(e={}){super(gb.texture,G3);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(xd),e.setSize(Math.round(xd.width*i),Math.round(xd.height*i))}setup(e){return this._updateResolution(gb,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=V0,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(xd),this._updateResolution(l,r),Mo.setFromMatrixPosition(a.matrixWorld),Wg.setFromMatrixPosition(i.matrixWorld),cc.extractRotation(a.matrixWorld),aa.set(0,0,1),aa.applyMatrix4(cc),uc.subVectors(Mo,Wg),uc.dot(aa)>0)return;uc.reflect(aa).negate(),uc.add(Mo),cc.extractRotation(i.matrixWorld),vd.set(0,0,-1),vd.applyMatrix4(cc),vd.add(Wg),yd.subVectors(Mo,vd),yd.reflect(aa).negate(),yd.add(Mo),o.coordinateSystem=i.coordinateSystem,o.position.copy(uc),o.up.set(0,1,0),o.up.applyMatrix4(cc),o.up.reflect(aa),o.lookAt(yd),o.near=i.near,o.far=i.far,o.updateMatrixWorld(),o.projectionMatrix.copy(i.projectionMatrix),_o.setFromNormalAndCoplanarPoint(aa,Mo),_o.applyMatrix4(o.matrixWorldInverse),Dn.set(_o.normal.x,_o.normal.y,_o.normal.z,_o.constant);const c=o.projectionMatrix;hc.x=(Math.sign(Dn.x)+c.elements[8])/c.elements[0],hc.y=(Math.sign(Dn.y)+c.elements[9])/c.elements[5],hc.z=-1,hc.w=(1+c.elements[10])/c.elements[14],Dn.multiplyScalar(1/Dn.dot(hc));const u=0;c.elements[2]=Dn.x,c.elements[6]=Dn.y,c.elements[10]=Dn.z-u,c.elements[14]=Dn.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 W3=n=>G(new vb(n)),Xg=new Ls(-1,1,1,-1,0,1);class j3 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 X3=new j3;class fn extends Ft{constructor(e=null){super(X3,e),this.camera=Xg,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,Xg)}render(e){e.render(this,Xg)}}const q3=new J;class yb extends dn{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 fn(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(q3);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 dn(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const xb=(n,...e)=>G(new yb(G(n),...e)),Zi=(n,...e)=>n.isTextureNode?n:xb(n,...e);class _b extends Wf{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 Y3=(...n)=>G(new _b(...n));class Mb 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 $3=ge(Mb);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 J3=ge(sn,sn.BACKGROUND_BLURRINESS),K3=ge(sn,sn.BACKGROUND_INTENSITY),Tb={Storage:"storage",ReadOnlyStorage:"read-only-storage"},qg={WriteOnly:"write-only",ReadOnly:"read-only"};class Yg extends $h{static get type(){return"StorageBufferNode"}constructor(e,t,i=0){super(e,t,i),this.isStorageBufferNode=!0,this.access=Tb.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 k3(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Tb.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=Xl(this.value),this._varying=Ii(this._attribute));const i=this._varying.build(e,t);return e.registerTransform(i,this._attribute),i}}const Z3=(n,e,t)=>G(new Yg(n,e,t)),Q3=(n,e,t)=>G(new Yg(n,e,t).setBufferObject(!0));class bb extends dn{static get type(){return"StorageTextureNode"}constructor(e,t,i=null){super(e,t),this.storeNode=i,this.isStorageTextureNode=!0,this.access=qg.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(qg.ReadOnly)}toWriteOnly(){return this.setAccess(qg.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 Sb=K(bb),eD=(n,e,t)=>{const i=Sb(n,e,t);return t!==null&&i.append(),i};class wb extends Jl{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 tD=(n,e,t)=>G(new wb(n,e,t));class Eb 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 iD=K(Eb);let $g=null;class Ab extends sc{static get type(){return"ViewportSharedTextureNode"}constructor(e=ms,t=null){$g===null&&($g=new pm),super(e,t,$g)}updateReference(){return this}}const rD=K(Ab),nD=new J;class Nb extends dn{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 Cb extends Nb{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 Us;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 Cb(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 Cb(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=ug(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=ac(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(nD);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 sD=(n,e,t)=>G(new bi(bi.COLOR,n,e,t)),To=(n,e)=>G(new Nb(n,e)),aD=(n,e)=>G(new bi(bi.DEPTH,n,e)),Rb=new fn,Ib=new fn;class Lb 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=To(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;Rb.material=this._material,Ib.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),Rb.render(t),i.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),Ib.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 oD=(n,e,t)=>G(new Lb(Zi(n),e,t)),Jg=new J,Pb=new fn;class Db 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=To(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(Jg),this.setSize(Jg.x,Jg.y);const s=t.getRenderTarget(),a=i.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),Pb.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(Hl(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(),Pb.material=l;const c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const lD=(n,e)=>G(new Db(Zi(n),e)),cD=U(([n])=>Ui(n.rgb)),uD=U(([n,e=E(1)])=>e.mix(Ui(n.rgb),n.rgb)),hD=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)}),dD=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())))))}),pD=new N,Ui=(n,e=D(...vt.getLuminanceCoefficients(pD)))=>qt(n,e),Ub=(n,e)=>rt(D(0),n,Ui(n).sub(e).max(0)),Ob=new fn;class Fb 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=To(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;Ob.material=this._material,this.setSize(r.image.width,r.image.height),t.setRenderTarget(this._renderTarget),Ob.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=Ub(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 mD=(n,e=.9,t=3,i=32)=>G(new Fb(Zi(n),G(e),G(t),i));class Vb 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 fD=n=>G(new Vb(Zi(n)));class Bb 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 gD=(n,e,t=1,i=.025,r=1)=>G(new Bb(Zi(n),G(e),G(t),G(i),G(r)));class zb 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(fo).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 vD=(n,e,t,i)=>G(new zb(G(n),e,t,i));class kb 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 yD=(n,e,t)=>G(new kb(Zi(n),e,t));class Hb 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=Of(hs(e.add(Gg())));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 xD=K(Hb);class Gb 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 _D=(n,e,t,i)=>G(new Gb(G(n),G(e),t,G(i))),Wb=new fn,jb=new xe,MD=new J;class Xb 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(TD()),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=To(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(MD),r=t.getRenderTarget(),s=t.getMRT();t.getClearColor(jb);const a=t.getClearAlpha();Wb.material=this._material,this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),Wb.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=ps(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(Zs),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(lo(H.xyz,M)),k=lo(b,M),j=Mr(h.sub(b.mul(qt(h,b)))),Y=lo(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,zh(re.y).sub(zh(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 TD(n=5){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=bD(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=Gn,s.wrapT=Gn,s.needsUpdate=!0,s}function bD(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 SD=(n,e,t)=>G(new Xb(G(n),G(e),t));class qb 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=mn(wD(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=ps(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(Zs))),y=Tr(g.element(this.index.mod(4).mul(2).mul(Zs))),_=z(x,y),I=Dl(_.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 wD(n,e,t){const i=ED(n,e,t),r=[];for(let s=0;s<n;s++){const a=i[s];r.push(a)}return r}function ED(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 AD=(n,e,t,i,r)=>G(new qb(Zi(n),G(e),G(t),G(i),r));class Yb 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)),()=>{td()})}),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 ND=n=>G(new Yb(Zi(n))),oa=new fn,CD=new xe(0,0,0),$b=new xe,RD=new J,ID=new J(1,0),LD=new J(0,1);class Jb 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=To(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(RD);this.setSize(i.width,i.height);const r=t.getRenderTarget(),s=t.getMRT();t.getClearColor($b);const a=t.getClearAlpha();this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(CD,0),t.setRenderTarget(this._renderTargetBright),oa.material=this._highPassFilterMaterial,oa.render(t);let o=this._renderTargetBright;for(let l=0;l<this._nMips;l++)oa.material=this._separableBlurMaterials[l],this._separableBlurMaterials[l].colorTexture.value=o.texture,this._separableBlurMaterials[l].direction.value=ID,t.setRenderTarget(this._renderTargetsHorizontal[l]),t.clear(),oa.render(t),this._separableBlurMaterials[l].colorTexture.value=this._renderTargetsHorizontal[l].texture,this._separableBlurMaterials[l].direction.value=LD,t.setRenderTarget(this._renderTargetsVertical[l]),t.clear(),oa.render(t),o=this._renderTargetsVertical[l];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),oa.material=this._compositeMaterial,oa.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor($b,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=mn([1,.8,.6,.4,.2]),s=mn([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=mn(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 PD=(n,e,t,i)=>G(new Jb(G(n),e,t,i));class Kb 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 DD=(n,e,t,i=0,r=.1,s=0)=>G(new Kb(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class UD 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))),us(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(Hl(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)),Gl(.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 OD=(n,e,t,i=6,r=.3,s=.4)=>G(new UD(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class Zb 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=gd({output:Mf,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 OD(e,t,i,this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const FD=(n,e,t,i,r)=>G(new Zb(n,e,t,i,r)),VD=new J;class Qb 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 fn}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(VD);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=BD[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=Hg(this.sampleRenderTarget.textures,s);a>=0&&(r[s]=yt(this.sampleRenderTarget.textures[a]).mul(this.sampleWeight))}t=gd(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=Ao,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}}const BD=[[[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]]],zD=(n,e)=>G(new Qb(n,e)),kD=new J;class eS extends bi{static get type(){return"StereoPassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new Hm,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(kD);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 HD=(n,e)=>G(new eS(n,e)),GD=new J,tS=new fn;class iS extends bi{static get type(){return"StereoCompositePassNode"}constructor(e,t){super(bi.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new Hm;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(GD);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),tS.material=this._material,tS.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}}class rS extends iS{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 WD=(n,e)=>G(new rS(n,e));class nS extends iS{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(kh(go.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 jD=(n,e)=>G(new nS(n,e));class sS 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(pn),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 XD=(n,e,t=new xe(0,0,0),i=.003,r=1)=>G(new sS(n,e,G(t),G(i),G(r)));class aS 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=ef(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=tf(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 _d=K(aS);class oS 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 qD{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 Md=new oS;class lS extends qe{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new oS,this._output=_d(),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]=_d(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]=_d(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 qD(this),r=Md.get("THREE"),s=Md.get("TSL"),a=this.getMethod(this.codeNode),o=[i,this._local,Md,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 = {};
3872
3872
  `,r=`
3873
- 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=[Wx(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 YD=K(lS);class Td 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 $D=K(Td);class cS extends Td{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 JD=K(cS);class uS extends Td{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 KD=K(uS);let la=null,ca=null;class hS 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(Ln(this.minNode.value)),i=e.getTypeLength(Ln(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(Ln(r)),o=e.getTypeLength(Ln(s));la=la||new st,ca=ca||new st,la.setScalar(0),ca.setScalar(0),a===1?la.setScalar(r):r.isColor?la.set(r.r,r.g,r.b):la.set(r.x,r.y,r.z||0,r.w||0),o===1?ca.setScalar(s):s.isColor?ca.set(s.r,s.g,s.b):ca.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=la.getComponent(p),v=ca.getComponent(p);u[d]=lu.lerp(m,v,Math.random())}const h=this.getNodeType(e);if(t.count<=4096)i=$l(u,"vec4",t.count).element(tc).convert(h);else{const d=new Nn(u,4);e.geometry.setAttribute("__range"+this.id,d),i=Gh(d).convert(h)}}else i=E(0);return i}}const ZD=K(hS),QD=U(({depthTexture:n,shadowCoord:e})=>yt(n,e.xy).compare(e.z)),eU=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)}),tU=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=us(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)}),iU=U(({depthTexture:n,shadowCoord:e})=>{const t=E(1).toVar(),i=yt(n).uv(e.xy).rg,r=Gl(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}),rU=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(go.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)}),nU=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(go.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)}),sU=[QD,eU,tU,iU];let bo=null;const bd=new fn;class ms extends ta{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 Km(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){bo===null&&(bo=new Tt,bo.fragmentNode=ae(0,0,0,1),bo.isShadowNodeMaterial=!0,bo.name="ShadowMaterial");const s=i.shadowMap.type,a=this.light.shadow,o=new Ds;o.compareFunction=pp;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:va,type:wi}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:va,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=rU({samples:I,radius:T,size:w,shadowPass:y}).context(e.getSharedContext()),C.name="VSMVertical",C=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Tt),C.fragmentNode=nU({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||jh;let p=fe(a.matrix).setGroup(xt).mul(d.add(qh.mul(h)));p=p.xyz.div(p.w);let m=p.z.add(u);i.coordinateSystem===Ts&&(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||sU[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=bo,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),bd.material=this.vsmMaterialVertical,bd.render(i),i.setRenderTarget(this.vsmShadowMapHorizontal),bd.material=this.vsmMaterialHorizontal,bd.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 Kg=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 Sd;function Zg(n){Sd=Sd||new WeakMap;let e=Sd.get(n);return e===void 0&&Sd.set(n,e={}),e}function Qg(n){const e=Zg(n);return e.position||(e.position=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.matrixWorld)))}function dS(n){const e=Zg(n);return e.targetPosition||(e.targetPosition=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.target.matrixWorld)))}function wd(n){const e=Zg(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 e0=n=>cr.transformDirection(Qg(n).sub(dS(n))),aU=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)}),t0=(n,e)=>Ji(lt(4,n.mul(Pt(1,n))),e),oU=(n,e)=>n.lessThan(.5)?t0(n.mul(2),e).div(2):Pt(1,t0(lt(Pt(1,n),2),e).div(2)),lU=(n,e,t)=>Ji(Qr(Ji(n,e),zt(Ji(n,e),Ji(Pt(1,n),t))),1/e),cU=(n,e)=>Ci(Zs.mul(e.mul(n).sub(1))).div(Zs.mul(e.mul(n).sub(1))),gn=U(([n])=>n.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),pS=U(([n])=>D(gn(n.z.add(gn(n.y.mul(1)))),gn(n.z.add(gn(n.x.mul(1)))),gn(n.y.add(gn(n.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),uU=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(pS(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(gn(i.z.add(gn(i.x.add(gn(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"}]}),hU=U(([n,e,t=z(.5)])=>Ag(n.sub(t),e).add(t)),dU=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))}),pU=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 Rl(e)&&(r[0][0]=zr[0].length(),r[0][1]=0,r[0][2]=0),Rl(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)}),mU=U(([n=null])=>{const e=id();return id(cg(n)).sub(e).lessThan(0).select(ps,n)}),mS=new WeakMap;class fU 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=gS(i);this.previousModelWorldMatrix.value.copy(r);const s=fS(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}){gS(e).copy(e.matrixWorld)}setup(){const e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=lr.mul(pn).mul(Zt),i=this.previousProjectionMatrix.mul(e).mul(Wh),r=t.xy.div(t.w),s=i.xy.div(i.w);return Pt(r,s)}}function fS(n){let e=mS.get(n);return e===void 0&&(e={},mS.set(n,e)),e}function gS(n,e=0){const t=fS(n);let i=t[e];return i===void 0&&(t[e]=i=new Re),i}const gU=ge(fU),vU=U(([n,e])=>xi(1,n.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),yU=U(([n,e])=>xi(n.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),xU=U(([n,e])=>n.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_U=U(([n,e])=>rt(n.mul(2).mul(e),n.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Gl(.5,n))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),MU=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}),TU=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)}),bU=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)}),vS=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"}]}),yS=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"}]}),xS=U(([n,e])=>n.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_S=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"}]}),MS=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"}]}),SU=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)}),TS=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=SU(n),n=i.mul(n),n.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wU=yi(D(1.6605,-.1246,-.0182),D(-.5876,1.1329,-.1006),D(-.0728,-.0083,1.1187)),EU=yi(D(.6274,.0691,.0164),D(.3293,.9195,.088),D(.0433,.0113,.8956)),AU=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))))}),bS=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(EU.mul(t)),t.assign(i.mul(t)),t.assign(ft(t,1e-10)),t.assign(kl(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(li(t,0,1)),t.assign(AU(t)),t.assign(r.mul(t)),t.assign(Ji(ft(D(0),t),D(2.2))),t.assign(wU.mul(t)),t.assign(li(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SS=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 NU 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 Ed=(n,e)=>G(new NU(n,e)),CU=Ed("numWorkgroups","uvec3"),RU=Ed("workgroupId","uvec3"),IU=Ed("localId","uvec3"),LU=Ed("subgroupSize","uint");class PU 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
3874
- `):e.addLineFlowCode(`${t}Barrier()`,this)}}const i0=K(PU),DU=()=>i0("workgroup").append(),UU=()=>i0("storage").append(),OU=()=>i0("texture").append();class FU extends as{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 VU 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 FU(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const BU=(n,e)=>G(new VU("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 zU=K(Mi),Un=(n,e,t,i)=>{const r=zU(n,e,t,i);return r.append(),r},kU=(n,e,t=null)=>Un(Mi.ATOMIC_STORE,n,e,t),HU=(n,e,t=null)=>Un(Mi.ATOMIC_ADD,n,e,t),GU=(n,e,t=null)=>Un(Mi.ATOMIC_SUB,n,e,t),WU=(n,e,t=null)=>Un(Mi.ATOMIC_MAX,n,e,t),jU=(n,e,t=null)=>Un(Mi.ATOMIC_MIN,n,e,t),XU=(n,e,t=null)=>Un(Mi.ATOMIC_AND,n,e,t),qU=(n,e,t=null)=>Un(Mi.ATOMIC_OR,n,e,t),YU=(n,e,t=null)=>Un(Mi.ATOMIC_XOR,n,e,t),$U=U(([n=nt()])=>{const e=n.mul(2),t=e.x.floor(),i=e.y.floor();return t.add(i).mod(2).sign()}),dc=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=os(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"}]}),Ad=U(([n,e])=>{const t=os(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(cs(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))}),JU=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"}]}),KU=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"}]}),wS=Di([JU,KU]),ZU=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"}]}),QU=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"}]}),ES=Di([ZU,QU]),eO=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(dc(a.lessThan(_e(4)),r,i)).toVar(),l=E(lt(2,dc(a.lessThan(_e(4)),i,r))).toVar();return Ad(o,os(a.bitAnd(_e(1)))).add(Ad(l,os(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"}]}),tO=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(dc(l.lessThan(_e(8)),a,s)).toVar(),u=E(dc(l.lessThan(_e(4)),s,dc(l.equal(_e(12)).or(l.equal(_e(14))),a,r))).toVar();return Ad(c,os(l.bitAnd(_e(1)))).add(Ad(u,os(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([eO,tO]),iO=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=oo(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"}]}),rO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=oo(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([iO,rO]),nO=U(([n])=>{const e=E(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),sO=U(([n])=>{const e=E(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),aO=U(([n])=>{const e=D(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),AS=Di([nO,aO]),oO=U(([n])=>{const e=D(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),NS=Di([sO,oO]),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"}]}),CS=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)}),pc=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"}]}),Gi=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"}]}),vn=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"}]}),lO=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 pc(i.add(_e(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),cO=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)),pc(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),uO=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)),pc(o,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),hO=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)),CS(c,u,h),c.addAssign(_e(r)),pc(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"}]}),dO=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)),CS(h,d,p),h.addAssign(_e(a)),d.addAssign(_e(s)),pc(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([lO,cO,uO,hO,dO]),pO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(Ct(i,t)).toVar(),s=oo().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"}]}),mO=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=oo().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([pO,mO]),fO=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(vn(r)).toVar(),o=E(vn(s)).toVar(),l=E(wS(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 AS(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),gO=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(vn(s)).toVar(),c=E(vn(a)).toVar(),u=E(vn(o)).toVar(),h=E(ES(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 NS(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),r0=Di([fO,gO]),vO=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(vn(r)).toVar(),o=E(vn(s)).toVar(),l=D(wS(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 AS(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),yO=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(vn(s)).toVar(),c=E(vn(a)).toVar(),u=E(vn(o)).toVar(),h=D(ES(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 NS(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),n0=Di([vO,yO]),xO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return Gi(Ct(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),_O=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return Gi(Ct(t,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),MO=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 Gi(Ct(t,i,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),TO=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 Gi(Ct(t,i,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),bO=Di([xO,_O,MO,TO]),SO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return D(Gi(Ct(t,P(0))),Gi(Ct(t,P(1))),Gi(Ct(t,P(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),wO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return D(Gi(Ct(t,i,P(0))),Gi(Ct(t,i,P(1))),Gi(Ct(t,i,P(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),EO=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(Gi(Ct(t,i,r,P(0))),Gi(Ct(t,i,r,P(1))),Gi(Ct(t,i,r,P(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),AO=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(Gi(Ct(t,i,r,s,P(0))),Gi(Ct(t,i,r,s,P(1))),Gi(Ct(t,i,r,s,P(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),RS=Di([SO,wO,EO,AO]),Nd=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(r0(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"}]}),IS=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(n0(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"}]}),NO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar();return z(Nd(o,a,s,r),Nd(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"}]}),CO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(IS(o,a,s,r)).toVar(),c=E(Nd(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"}]}),RO=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(RS(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"}]}),IO=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(RS(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"}]}),So=Di([RO,IO]),LO=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(So(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"}]}),PO=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(So(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"}]}),DO=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(So(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"}]}),UO=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(So(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"}]}),OO=Di([LO,UO]),FO=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(So(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"}]}),VO=Di([PO,FO]),BO=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(So(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"}]}),zO=Di([DO,BO]),kO=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(cs(r)).mul(6).toVar();const s=P(Lf(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"}]}),HO=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"}]}),GO=U(([n])=>{const e=D(n).toVar(),t=ff(Af(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"}]}),LS=(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)},PS=(n,e,t,i)=>rt(n,e,t[i].clamp()),WO=(n,e,t=nt())=>PS(n,e,t,"x"),jO=(n,e,t=nt())=>PS(n,e,t,"y"),DS=(n,e,t,i,r)=>rt(n,e,LS(t,i[r])),XO=(n,e,t,i=nt())=>DS(n,e,t,i,"x"),qO=(n,e,t,i=nt())=>DS(n,e,t,i,"y"),YO=(n=1,e=0,t=nt())=>t.mul(n).add(e),$O=(n,e=1)=>(n=E(n),n.abs().pow(e).mul(n.sign())),JO=(n,e=1,t=.5)=>E(n).sub(t).mul(e).add(t),KO=(n=nt(),e=1,t=0)=>r0(n.convert("vec2|vec3")).mul(e).add(t),ZO=(n=nt(),e=1,t=0)=>n0(n.convert("vec2|vec3")).mul(e).add(t),QO=(n=nt(),e=1,t=0)=>(n=n.convert("vec2|vec3"),ae(n0(n),r0(n.add(z(19,73)))).mul(e).add(t)),eF=(n=nt(),e=1)=>OO(n.convert("vec2|vec3"),e,P(1)),tF=(n=nt(),e=1)=>VO(n.convert("vec2|vec3"),e,P(1)),iF=(n=nt(),e=1)=>zO(n.convert("vec2|vec3"),e,P(1)),rF=(n=nt())=>bO(n.convert("vec2|vec3")),nF=(n=nt(),e=3,t=2,i=.5,r=1)=>Nd(n,P(e),t,i).mul(r),sF=(n=nt(),e=3,t=2,i=.5,r=1)=>NO(n,P(e),t,i).mul(r),aF=(n=nt(),e=3,t=2,i=.5,r=1)=>IS(n,P(e),t,i).mul(r),oF=(n=nt(),e=3,t=2,i=.5,r=1)=>CO(n,P(e),t,i).mul(r),US=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 OS extends ms{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=wd(s).sub(Pi),l=o.normalize(),c=o.length(),u=Kg({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 FS extends ms{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,i=this.colorNode,r=e0(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:i,reflectedLight:s},e.stack,e)}}const s0=new Re,Cd=new Re;let mc=null;class VS extends ms{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;Cd.identity(),s0.copy(t.matrixWorld),s0.premultiply(i),Cd.extractRotation(s0),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Cd),this.halfHeight.value.applyMatrix4(Cd)}setup(e){super.setup(e);let t,i;e.isAvailable("float32Filterable")?(t=yt(mc.LTC_FLOAT_1),i=yt(mc.LTC_FLOAT_2)):(t=yt(mc.LTC_HALF_1),i=yt(mc.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,o=wd(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){mc=e}}class a0 extends ms{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=wd(a).sub(Pi),l=o.normalize(),c=l.dot(e0(a)),u=this.getSpotAttenuation(c),h=o.length(),d=Kg({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 BS extends a0{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 zS extends ms{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class kS extends ms{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=Qg(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 HS extends ms{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=mn(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=US(qh,this.lightProbe);e.context.irradiance.addAssign(t)}}class lF{parseFunction(){console.warn("Abstract function.")}}class GS{constructor(e,t,i="",r=""){this.type=e,this.inputs=t,this.name=i,this.precision=r}getCode(){console.warn("Abstract function.")}}GS.isNodeFunction=!0;const cF=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,uF=/[a-z_0-9]+/ig,WS="#pragma main",hF=n=>{n=n.trim();const e=n.indexOf(WS),t=e!==-1?n.slice(e+WS.length):n,i=t.match(cF);if(i!==null&&i.length===5){const r=i[4],s=[];let a=null;for(;(a=uF.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 zg(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 dF extends GS{constructor(e){const{type:t,inputs:i,name:r,precision:s,inputsCode:a,blockCode:o,headerCode:l}=hF(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 lF{parseFunction(e){return new dF(e)}}class pF{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 mF extends El{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 XS extends pF{constructor(){super(),this.addLight(OS,yh),this.addLight(FS,xh),this.addLight(VS,Bm),this.addLight(a0,El),this.addLight(zS,_h),this.addLight(kS,vh),this.addLight(HS,zm),this.addLight(BS,mF),this.addToneMapping(xS,wc),this.addToneMapping(_S,Ec),this.addToneMapping(MS,Qd),this.addToneMapping(TS,Ac),this.addToneMapping(bS,Nc),this.addToneMapping(SS,Cc),this.addColorSpace(yS,Hh(nr,Fi)),this.addColorSpace(vS,Hh(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 fF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Ac,AONode:Y1,AddEquation:Vn,AddOperation:Zd,AdditiveAnimationBlendMode:cp,AdditiveBlending:Ao,AfterImageNode:Db,AgXToneMapping:Nc,AlphaFormat:rp,AlwaysCompare:lv,AlwaysDepth:Co,AlwaysStencilFunc:au,AmbientLight:_h,AmbientLightNode:zS,AnaglyphPassNode:rS,AnalyticLightNode:ms,AnamorphicNode:Fb,AnimationAction:yx,AnimationClip:ro,AnimationLoader:UI,AnimationMixer:xx,AnimationObjectGroup:e2,AnimationUtils:II,ArcCurve:Dy,ArrayCamera:$p,ArrayElementNode:as,ArrowHelper:m2,AssignNode:p_,AttachedBindMode:ep,AttributeNode:Wf,Audio:Wm,AudioAnalyser:WI,AudioContext:bh,AudioListener:mx,AudioLoader:cx,AxesHelper:zx,BRDF_GGX:fg,BRDF_Lambert:ia,BackSide:si,BasicDepthPacking:up,BasicEnvironmentNode:rd,BasicNodeLibrary:XS,BasicShadowMap:tw,BatchNode:V1,BatchedMesh:lm,BloomNode:Jb,Bone:Wu,BooleanKeyframeTrack:zs,Box2:a2,Box3:Bi,Box3Helper:Vx,BoxGeometry:yn,BoxHelper:Fx,Break:td,BufferAttribute:wt,BufferAttributeNode:TM,BufferGeometry:ct,BufferGeometryLoader:nx,BufferNode:$h,BumpMapNode:n1,BypassNode:AM,ByteType:tp,Cache:Rn,CacheNode:EM,Camera:ol,CameraHelper:Ox,CanvasTexture:Py,CapsuleGeometry:Id,CatmullRomCurve3:ym,CineonToneMapping:Qd,CircleGeometry:Ld,ClampToEdgeWrapping:gr,Clock:Gm,CodeNode:Ig,Color:xe,ColorKeyframeTrack:fh,ColorManagement:vt,ColorSpaceNode:jl,CompressedArrayTexture:Iy,CompressedCubeTexture:Ly,CompressedTexture:vl,CompressedTextureLoader:OI,ComputeNode:SM,ConeGeometry:Pd,ConstNode:Vr,ConstantAlphaFactor:D0,ConstantColorFactor:L0,ContextNode:Ff,Continue:SL,Controls:Hx,ConvertNode:of,CubeCamera:Nu,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,CubeTexture:Ns,CubeTextureLoader:FI,CubeTextureNode:JM,CubeUVReflectionMapping:Hn,CubicBezierCurve:xm,CubicBezierCurve3:Oy,CubicInterpolant:$y,CullFaceBack:Wd,CullFaceFront:x0,CullFaceFrontBack:ew,CullFaceNone:y0,Curve:Or,CurvePath:Vy,CustomBlending:$d,CustomToneMapping:O0,CylinderGeometry:ha,Cylindrical:s2,DFGApprox:gg,D_GGX:dT,Data3DTexture:uu,DataArrayTexture:el,DataTexture:Ur,DataTextureLoader:Zy,DataUtils:Ev,DecrementStencilOp:X0,DecrementWrapStencilOp:Y0,DefaultLoadingManager:Um,DenoiseNode:qb,DepthFormat:Xn,DepthOfFieldNode:Bb,DepthStencilFormat:qn,DepthTexture:Ds,DetachedBindMode:F0,DirectionalLight:xh,DirectionalLightHelper:Ux,DirectionalLightNode:FS,Discard:LM,DiscreteInterpolant:Jy,DisplayP3ColorSpace:su,DodecahedronGeometry:Dd,DotScreenNode:zb,DoubleSide:Wr,DstAlphaFactor:A0,DstColorFactor:C0,DynamicCopyUsage:pw,DynamicDrawUsage:Ms,DynamicReadUsage:uw,EPSILON:P_,EdgesGeometry:wm,EllipseCurve:eh,EnvironmentNode:VT,EqualCompare:nv,EqualDepth:Io,EqualStencilFunc:Z0,EquirectUVNode:sT,EquirectangularReflectionMapping:zn,EquirectangularRefractionMapping:kn,Euler:dr,EventDispatcher:vr,ExpressionNode:IM,ExtrudeGeometry:vc,FXAANode:Yb,F_Schlick:vo,FileLoader:Kr,FilmNode:Hb,Float16BufferAttribute:Av,Float32BufferAttribute:De,FloatType:Oi,Fn:U,Fog:Kp,FogExp2:Rd,FogExp2Node:uS,FogNode:Td,FogRangeNode:cS,FramebufferTexture:pm,FrontFacingNode:kM,FrontSide:an,Frustum:ka,FunctionCallNode:f_,FunctionNode:Lg,FunctionOverloadingNode:hb,GLBufferAttribute:n2,GLSL1:fw,GLSL3:ou,GLSLNodeParser:jS,GTAONode:Xb,GaussianBlurNode:Lb,GreaterCompare:sv,GreaterDepth:Po,GreaterEqualCompare:ov,GreaterEqualDepth:Lo,GreaterEqualStencilFunc:iv,GreaterStencilFunc:ev,GridHelper:Lx,Group:Us,HalfFloatType:wi,HemisphereLight:vh,HemisphereLightHelper:h2,HemisphereLightNode:kS,IESSpotLightNode:BS,INFINITY:B2,IcosahedronGeometry:Ud,If:Le,ImageBitmapLoader:lx,ImageLoader:wl,ImageUtils:fv,IncrementStencilOp:j0,IncrementWrapStencilOp:q0,IndexNode:Bt,InstanceNode:O1,InstancedBufferAttribute:Nn,InstancedBufferGeometry:km,InstancedInterleavedBuffer:qm,InstancedMesh:nm,InstancedPointsNodeMaterial:BL,Int16BufferAttribute:Qw,Int32BufferAttribute:eE,Int8BufferAttribute:Jw,IntType:ga,InterleavedBuffer:ja,InterleavedBufferAttribute:On,Interpolant:Qa,InterpolateDiscrete:ba,InterpolateLinear:jo,InterpolateSmooth:ru,InvertStencilOp:$0,IrradianceNode:K1,JoinNode:Xx,KeepStencilOp:Yn,KeyframeTrack:Fr,LOD:em,LatheGeometry:gc,Layers:rl,LessCompare:pp,LessDepth:Ro,LessEqualCompare:mp,LessEqualDepth:Bn,LessEqualStencilFunc:Q0,LessStencilFunc:K0,Light:ns,LightProbe:zm,LightProbeNode:HS,LightingContextNode:$1,LightingModel:lc,LightingNode:ta,LightsNode:X1,Line:Cn,Line2NodeMaterial:jL,Line3:Ax,LineBasicMaterial:Ni,LineBasicNodeMaterial:kL,LineCurve:_m,LineCurve3:Fy,LineDashedMaterial:mh,LineDashedNodeMaterial:GL,LineLoop:um,LineSegments:Jr,LinearDisplayP3ColorSpace:qo,LinearFilter:Lt,LinearInterpolant:Dm,LinearMipMapLinearFilter:V0,LinearMipMapNearestFilter:nw,LinearMipmapLinearFilter:ji,LinearMipmapNearestFilter:Wn,LinearSRGBColorSpace:nr,LinearToneMapping:wc,LinearTransfer:Yo,Loader:Hi,LoaderUtils:Mh,LoadingManager:gh,Loop:gt,LoopNode:H1,LoopOnce:op,LoopPingPong:B0,LoopRepeat:lp,LuminanceAlphaFormat:sp,LuminanceFormat:np,Lut3DNode:Gb,MOUSE:g0,MRTNode:ub,MatcapUVNode:HT,Material:hi,MaterialLoader:_c,MaterialNode:Z,MaterialReferenceNode:KM,MathUtils:lu,Matrix2:o0,Matrix3:Ke,Matrix4:Re,MaxEquation:Jd,MaxMipLevelNode:OM,Mesh:Ft,MeshBasicMaterial:$r,MeshBasicNodeMaterial:eP,MeshDepthMaterial:Fu,MeshDistanceMaterial:qp,MeshLambertMaterial:ph,MeshLambertNodeMaterial:sP,MeshMatcapMaterial:Im,MeshMatcapNodeMaterial:GP,MeshNormalMaterial:dh,MeshNormalNodeMaterial:YL,MeshPhongMaterial:hh,MeshPhongNodeMaterial:oP,MeshPhysicalMaterial:uh,MeshPhysicalNodeMaterial:kT,MeshSSSNodeMaterial:FP,MeshStandardMaterial:Sl,MeshStandardNodeMaterial:zT,MeshToonMaterial:Rm,MeshToonNodeMaterial:kP,MinEquation:T0,MirroredRepeatWrapping:ma,MixOperation:Kd,ModelNode:tn,ModelViewProjectionNode:P1,MorphNode:W1,MultiplyBlending:Yd,MultiplyOperation:pa,NearestFilter:$t,NearestMipMapLinearFilter:rw,NearestMipMapNearestFilter:iw,NearestMipmapLinearFilter:Mn,NearestMipmapNearestFilter:Ic,NeutralToneMapping:Cc,NeverCompare:rv,NeverDepth:No,NeverStencilFunc:J0,NoBlending:Er,NoColorSpace:Cr,NoToneMapping:mr,Node:qe,NodeAttribute:Ng,NodeBuilder:lb,NodeCache:hd,NodeCode:KT,NodeFrame:cb,NodeFunctionInput:zg,NodeLoader:qT,NodeMaterial:Tt,NodeMaterialLoader:YT,NodeMaterialObserver:Gx,NodeObjectLoader:QP,NodeShaderStage:rf,NodeType:y2,NodeUniform:$T,NodeUpdateType:je,NodeUtils:v2,NodeVar:Cg,NodeVarying:JT,NormalAnimationBlendMode:nu,NormalBlending:_n,NormalMapNode:r1,NotEqualCompare:av,NotEqualDepth:Do,NotEqualStencilFunc:tv,NumberKeyframeTrack:eo,Object3D:_t,Object3DNode:St,ObjectLoader:sx,ObjectSpaceNormalMap:dp,OctahedronGeometry:wo,OneFactor:S0,OneMinusConstantAlphaFactor:U0,OneMinusConstantColorFactor:P0,OneMinusDstAlphaFactor:N0,OneMinusDstColorFactor:R0,OneMinusSrcAlphaFactor:Sc,OneMinusSrcColorFactor:E0,OrthographicCamera:Is,OscNode:gi,OutputStructNode:kg,P3Primaries:Jo,PCFShadowMap:jd,PCFSoftShadowMap:Xd,PI:Zs,PI2:z2,PMREMGenerator:Lu,PMREMNode:UT,ParallaxBarrierPassNode:nS,ParameterNode:Rg,PassNode:bi,Path:_l,PerspectiveCamera:di,PhongLightingModel:pg,PhysicalLightingModel:ad,PixelationPassNode:Zb,Plane:ln,PlaneGeometry:ua,PlaneHelper:p2,PointLight:yh,PointLightHelper:c2,PointLightNode:OS,PointUVNode:Mb,Points:dm,PointsMaterial:Ka,PointsNodeMaterial:jP,PolarGridHelper:d2,PolyhedronGeometry:fs,PositionalAudio:gx,PosterizeNode:Eb,PropertyBinding:bt,PropertyMixer:vx,PropertyNode:Et,QuadraticBezierCurve:Mm,QuadraticBezierCurve3:Tm,Quaternion:qi,QuaternionKeyframeTrack:to,QuaternionLinearInterpolant:Ky,RED_GREEN_RGTC2_Format:tu,RED_RGTC1_Format:ap,REVISION:"169",RGBADepthPacking:hp,RGBAFormat:Ei,RGBAIntegerFormat:Vc,RGBA_ASTC_10x10_Format:Jc,RGBA_ASTC_10x5_Format:qc,RGBA_ASTC_10x6_Format:Yc,RGBA_ASTC_10x8_Format:$c,RGBA_ASTC_12x10_Format:Kc,RGBA_ASTC_12x12_Format:Zc,RGBA_ASTC_4x4_Format:Ho,RGBA_ASTC_5x4_Format:kc,RGBA_ASTC_5x5_Format:Hc,RGBA_ASTC_6x5_Format:Gc,RGBA_ASTC_6x6_Format:Go,RGBA_ASTC_8x5_Format:Wc,RGBA_ASTC_8x6_Format:jc,RGBA_ASTC_8x8_Format:Xc,RGBA_BPTC_Format:Ta,RGBA_ETC2_EAC_Format:ko,RGBA_PVRTC_2BPPV1_Format:zc,RGBA_PVRTC_4BPPV1_Format:Vo,RGBA_S3TC_DXT1_Format:xa,RGBA_S3TC_DXT3_Format:_a,RGBA_S3TC_DXT5_Format:Ma,RGBDepthPacking:aw,RGBFormat:Oc,RGBIntegerFormat:sw,RGBShiftNode:kb,RGB_BPTC_SIGNED_Format:Qc,RGB_BPTC_UNSIGNED_Format:Wo,RGB_ETC1_Format:Bo,RGB_ETC2_Format:zo,RGB_PVRTC_2BPPV1_Format:Bc,RGB_PVRTC_4BPPV1_Format:Fo,RGB_S3TC_DXT1_Format:ya,RGDepthPacking:ow,RGFormat:va,RGIntegerFormat:Fc,RTTNode:yb,RangeNode:hS,RawShaderMaterial:Cm,Ray:Es,Raycaster:Tx,Rec709Primaries:$o,RectAreaLight:Bm,RectAreaLightNode:VS,RedFormat:Uo,RedIntegerFormat:Oo,ReferenceNode:Jl,ReflectorNode:vb,ReinhardToneMapping:Ec,RemapNode:Gf,RenderOutputNode:PM,RenderTarget:ui,RendererReferenceNode:vM,RepeatWrapping:Gn,ReplaceStencilOp:W0,Return:j2,ReverseSubtractEquation:M0,RingGeometry:yc,RotateNode:WT,SIGNED_RED_GREEN_RGTC2_Format:iu,SIGNED_RED_RGTC1_Format:eu,SRGBColorSpace:Fi,SRGBTransfer:Ot,SSAAPassNode:Qb,Scene:Vu,SceneNode:sn,Schlick_to_F0:mT,ScreenNode:ri,ScriptableNode:lS,ScriptableValueNode:aS,SetNode:qx,ShaderChunk:dt,ShaderLib:Dr,ShaderMaterial:Pr,ShaderNode:Il,ShadowMaterial:ch,ShadowNodeMaterial:JP,Shape:rs,ShapeGeometry:Od,ShapePath:kx,ShapeUtils:nn,ShortType:ip,Skeleton:fc,SkeletonHelper:l2,SkinnedMesh:rm,SkinningNode:sg,SobelOperatorNode:Vb,Source:$n,Sphere:Ai,SphereGeometry:Eo,Spherical:Sx,SphericalHarmonics3:rx,SplineCurve:bm,SplitNode:Rh,SpotLight:El,SpotLightHelper:o2,SpotLightNode:a0,Sprite:Qp,SpriteMaterial:cl,SpriteNodeMaterial:qP,SpriteSheetUVNode:db,SrcAlphaFactor:bc,SrcAlphaSaturateFactor:I0,SrcColorFactor:w0,StackNode:QT,StaticCopyUsage:dw,StaticDrawUsage:Sa,StaticReadUsage:cw,StereoCamera:Hm,StereoPassNode:eS,StorageArrayElementNode:pb,StorageBufferNode:Yg,StorageTextureNode:bb,StreamCopyUsage:mw,StreamDrawUsage:lw,StreamReadUsage:hw,StringKeyframeTrack:ks,SubtractEquation:_0,SubtractiveBlending:qd,TBNViewMatrix:ea,TOUCH:v0,TangentSpaceNormalMap:on,TempNode:pt,TetrahedronGeometry:Fd,Texture:Wt,Texture3DNode:jT,TextureLoader:Qy,TextureNode:dn,TextureSizeNode:UM,TextureUtils:OR,TimerNode:Si,ToneMappingNode:xM,ToonOutlinePassNode:sS,TorusGeometry:xc,TorusKnotGeometry:Vd,TransitionNode:Kb,Triangle:er,TriangleFanDrawMode:H0,TriangleStripDrawMode:k0,TrianglesDrawMode:z0,TriplanarTexturesNode:mb,TubeGeometry:Bd,UVMapping:Rc,Uint16BufferAttribute:_u,Uint32BufferAttribute:Dp,Uint8BufferAttribute:Kw,Uint8ClampedBufferAttribute:Zw,Uniform:_x,UniformArrayNode:$f,UniformGroupNode:gf,UniformNode:Ys,UniformsGroup:r2,UniformsLib:Me,UniformsUtils:Fp,UnsignedByteType:jr,UnsignedInt101111Type:Uc,UnsignedInt248Type:jn,UnsignedInt5999Type:Dc,UnsignedIntType:Nr,UnsignedShort4444Type:Lc,UnsignedShort5551Type:Pc,UnsignedShortType:fa,UserDataNode:wb,VSMShadowMap:rr,V_GGX_SmithCorrelated:hT,VarNode:uM,VaryingNode:hM,Vector2:J,Vector3:N,Vector4:st,VectorKeyframeTrack:io,VertexColorNode:_b,VideoTexture:Ry,ViewportDepthNode:Qi,ViewportDepthTextureNode:tT,ViewportSharedTextureNode:Ab,ViewportTextureNode:sc,VolumeNodeMaterial:ZP,WebGL3DRenderTarget:zw,WebGLArrayRenderTarget:Bw,WebGLCoordinateSystem:Rr,WebGLCubeRenderTarget:Cu,WebGLMultipleRenderTargets:f2,WebGLRenderTarget:Ir,WebGLRenderer:cy,WebGLUtils:ly,WebGPUCoordinateSystem:Ts,WireframeGeometry:Nm,WrapAroundEnding:Xo,ZeroCurvatureEnding:xs,ZeroFactor:b0,ZeroSlopeEnding:_s,ZeroStencilOp:G0,abs:It,acesFilmicToneMapping:TS,acos:zh,add:zt,addMethodChaining:te,addNodeElement:X2,afterImage:lD,agxToneMapping:bS,all:Nf,alphaT:Oh,anaglyphPass:WD,anamorphic:mD,and:T_,anisotropy:ls,anisotropyB:Js,anisotropyT:Fl,any:D_,ao:SD,append:t_,arrayBuffer:U2,asin:z_,assign:m_,atan:k_,atan2:J_,atomicAdd:HU,atomicAnd:XU,atomicFunc:Un,atomicMax:WU,atomicMin:jU,atomicOr:qU,atomicStore:kU,atomicSub:GU,atomicXor:YU,attenuationColor:Sf,attenuationDistance:bf,attribute:_i,backgroundBlurriness:J3,backgroundIntensity:K3,batch:B1,billboarding:pU,bitAnd:E_,bitNot:A_,bitOr:N_,bitXor:C_,bitangentGeometry:dL,bitangentLocal:pL,bitangentView:QM,bitangentWorld:mL,bitcast:k2,bleach:TU,bloom:PD,blur:PT,bool:os,buffer:$l,bufferAttribute:Xl,bumpMap:s1,burn:vU,bvec2:n_,bvec3:ff,bvec4:l_,bypass:NM,cache:ql,call:g_,cameraFar:uo,cameraLogDepth:VM,cameraNear:co,cameraNormalMatrix:J2,cameraPosition:jf,cameraProjectionMatrix:lr,cameraProjectionMatrixInverse:Y2,cameraViewMatrix:cr,cameraWorldMatrix:$2,cbrt:rM,ceil:If,checker:$U,cineonToneMapping:MS,clamp:li,clearcoat:Ph,clearcoatRoughness:Ol,code:dd,color:i_,colorSpaceToWorking:kf,colorToDirection:XL,compute:wM,cond:lM,context:Vf,convert:u_,convertToTexture:Zi,cos:Tr,createCanvasElement:hv,cross:lo,cubeTexture:Yh,dFdx:W_,dFdy:j_,dashSize:Ks,defaultBuildStages:sf,defaultShaderStages:nf,defined:Rl,degrees:F_,denoise:AD,densityFog:KD,depth:hg,depthPass:aD,difference:Q_,diffuseColor:Nt,directionToColor:nT,dispersion:wf,distance:Z_,div:Qr,dodge:yU,dof:gD,dot:qt,dotScreen:vD,drawIndex:U1,dynamicBufferAttribute:bM,element:c_,emissive:yf,equal:v_,equals:U_,equirectUV:dg,exp:Cf,exp2:Bh,expression:hs,faceDirection:Yl,faceForward:sM,film:xD,float:E,floor:cs,fog:$D,fract:us,frameGroup:F2,frameId:U3,frontFacing:HM,fwidth:Y_,fxaa:ND,gain:oU,gapSize:Bl,gaussianBlur:oD,getColorSpaceMethod:Hh,getConstNodeType:e_,getCurrentStack:mf,getDirection:IT,getDistanceAttenuation:Kg,getGeometryRoughness:uT,getRoughness:mg,getShIrradianceAt:US,getTextureIndex:Hg,global:Md,glsl:n3,glslFn:s3,grayscale:cD,greaterThan:Af,greaterThanEqual:M_,hash:aU,highPrecisionModelNormalViewMatrix:oL,highPrecisionModelViewMatrix:aL,hue:dD,instance:F1,instanceIndex:tc,instancedBufferAttribute:Gh,instancedDynamicBufferAttribute:Hf,int:P,inverseSqrt:V_,invocationLocalIndex:TL,invocationSubgroupIndex:ML,ior:zl,iridescence:Uh,iridescenceIOR:xf,iridescenceThickness:_f,ivec2:un,ivec3:s_,ivec4:a_,js:i3,label:cM,length:Qs,lengthSq:Df,lessThan:x_,lessThanEqual:__,lightPosition:Qg,lightTargetDirection:e0,lightTargetPosition:dS,lightViewPosition:wd,lightingContext:J1,lights:q1,linearDepth:id,linearSRGBTosRGB:yS,linearToneMapping:xS,localId:IU,log:Rf,log2:kl,loop:wL,luminance:Ui,lut3D:_D,mat2:Dl,mat3:yi,mat4:qs,matcapUV:GT,materialAOMap:L1,materialAlphaTest:o1,materialAnisotropy:M1,materialAnisotropyVector:mo,materialAttenuationColor:C1,materialAttenuationDistance:N1,materialClearcoat:f1,materialClearcoatNormal:v1,materialClearcoatRoughness:g1,materialColor:po,materialDispersion:I1,materialEmissive:c1,materialIOR:A1,materialIridescence:T1,materialIridescenceIOR:b1,materialIridescenceThickness:S1,materialLightMap:rg,materialLineDashOffset:ig,materialLineDashSize:eg,materialLineGapSize:tg,materialLineScale:Qh,materialLineWidth:ed,materialMetalness:p1,materialNormal:m1,materialOpacity:Kh,materialPointWidth:R1,materialReference:rn,materialReflectivity:Zh,materialRefractionRatio:jM,materialRotation:y1,materialRoughness:d1,materialSheen:x1,materialSheenRoughness:_1,materialShininess:l1,materialSpecular:u1,materialSpecularColor:h1,materialSpecularIntensity:Qf,materialSpecularStrength:ec,materialThickness:E1,materialTransmission:w1,max:ft,maxMipLevel:FM,metalness:Ul,min:xi,mix:rt,mixElement:aM,mod:kh,modInt:Ef,modelDirection:iL,modelNormalMatrix:BM,modelPosition:rL,modelScale:nL,modelViewMatrix:pn,modelViewPosition:sL,modelViewProjection:ng,modelWorldMatrix:zr,modelWorldMatrixInverse:zM,morphReference:j1,motionBlur:MU,mrt:gd,mul:lt,mx_aastep:LS,mx_cell_noise_float:rF,mx_contrast:JO,mx_fractal_noise_float:nF,mx_fractal_noise_vec2:sF,mx_fractal_noise_vec3:aF,mx_fractal_noise_vec4:oF,mx_hsvtorgb:kO,mx_noise_float:KO,mx_noise_vec3:ZO,mx_noise_vec4:QO,mx_ramplr:WO,mx_ramptb:jO,mx_rgbtohsv:HO,mx_safepower:$O,mx_splitlr:XO,mx_splittb:qO,mx_srgb_texture_to_lin_rec709:GO,mx_transform_uv:YO,mx_worley_noise_float:eF,mx_worley_noise_vec2:tF,mx_worley_noise_vec3:iF,negate:H_,neutralToneMapping:SS,nodeArray:Xs,nodeImmutable:ge,nodeObject:G,nodeObjects:Ll,nodeProxy:K,normalFlat:GM,normalGeometry:Xh,normalLocal:ur,normalMap:Zf,normalView:hr,normalWorld:qh,normalize:Mr,not:S_,notEqual:y_,numWorkgroups:CU,objectDirection:K2,objectGroup:d_,objectPosition:Q2,objectScale:eL,objectViewPosition:tL,objectWorldMatrix:Z2,oneMinus:G_,or:b_,orthographicDepthToViewZ:DL,oscSawtooth:B3,oscSine:O3,oscSquare:F3,oscTriangle:V3,output:Mf,outputStruct:I3,overlay:_U,overloadingFn:Di,parabola:t0,parallaxBarrierPass:jD,parallaxDirection:t1,parallaxUV:gL,parameter:t3,pass:sD,passTexture:To,pcurve:lU,perspectiveDepthToViewZ:ug,pixelationPass:FD,pmremTexture:OT,pointUV:$3,pointWidth:V2,positionGeometry:Li,positionLocal:Zt,positionPrevious:Wh,positionView:Pi,positionViewDirection:Vt,positionWorld:jh,positionWorldDirection:Xf,posterize:iD,pow:Ji,pow2:Pf,pow3:eM,pow4:tM,property:ar,radians:O_,rand:Of,range:ZD,rangeFog:JD,reciprocal:q_,reference:fi,referenceBuffer:Jf,reflect:K_,reflectVector:YM,reflectView:XM,reflector:W3,refract:Uf,refractVector:$M,refractView:qM,reinhardToneMapping:_S,remainder:L_,remap:CM,remapClamp:RM,renderGroup:xt,renderOutput:DM,rendererReference:yM,rgbShift:yD,rotate:Ag,rotateUV:hU,roughness:hn,round:X_,rtt:xb,sRGBToLinearSRGB:vS,sampler:q2,saturate:nM,saturation:uD,screen:xU,screenCoordinate:go,screenSize:fo,screenUV:ps,scriptable:YD,scriptableValue:_d,select:Ri,sepia:bU,setCurrentStack:Pl,shaderStages:af,sharedUniformGroup:vf,sheen:$s,sheenRoughness:Dh,shiftLeft:R_,shiftRight:I_,shininess:Fh,sign:Hl,sin:Ci,sinc:cU,skinning:bL,skinningReference:k1,smoothstep:Ki,smoothstepElement:oM,sobel:fD,specularColor:or,specularF90:Vl,spherizeUV:dU,split:O2,spritesheetUV:z3,sqrt:en,ssaaPass:zD,stack:pd,step:Gl,stereoPass:HD,storage:Z3,storageBarrier:UU,storageObject:Q3,storageTexture:Sb,string:D2,sub:Pt,subgroupIndex:_L,subgroupSize:LU,tan:B_,tangentGeometry:Jh,tangentLocal:Kl,tangentView:Zl,tangentWorld:ZM,temp:Bf,texture:yt,texture3D:XT,textureBarrier:OU,textureBicubic:bT,textureCubeUV:LT,textureLoad:Br,textureSize:ds,textureStore:eD,thickness:Tf,threshold:Ub,timerDelta:D3,timerGlobal:P3,timerLocal:Gg,toOutputColorSpace:pM,toWorkingColorSpace:mM,toneMapping:_M,toneMappingExposure:MM,toonOutlinePass:XD,transformDirection:iM,transformNormal:WM,transformNormalToView:Yf,transformedBentNormalView:i1,transformedBitangentView:e1,transformedBitangentWorld:fL,transformedClearcoatNormalView:ho,transformedNormalView:Yt,transformedNormalWorld:qf,transformedTangentView:Kf,transformedTangentWorld:hL,transition:DD,transmission:Vh,transpose:$_,tri:gn,tri3:pS,triNoise3D:uU,triplanarTexture:H3,triplanarTextures:fb,trunc:Lf,tslFn:P2,uint:_e,uniform:fe,uniformArray:mn,uniformGroup:h_,uniforms:cL,userData:tD,uv:nt,uvec2:r_,uvec3:oo,uvec4:o_,varying:Ii,varyingProperty:Zr,vec2:z,vec3:D,vec4:ae,vectorComponents:no,velocity:gU,vertexColor:Y3,vertexIndex:D1,vibrance:hD,viewZToOrthographicDepth:ac,viewZToPerspectiveDepth:iT,viewport:Pn,viewportBottomLeft:LL,viewportCoordinate:Q1,viewportDepthTexture:cg,viewportLinearDepth:UL,viewportMipTexture:eT,viewportResolution:RL,viewportSafeUV:mU,viewportSharedTexture:rD,viewportSize:Z1,viewportTexture:PL,viewportTopLeft:IL,viewportUV:CL,wgsl:r3,wgslFn:a3,workgroupArray:BU,workgroupBarrier:DU,workgroupId:RU,workingToColorSpace:fM,xor:w_},Symbol.toStringTag,{value:"Module"}));export{Ac as ACESFilmicToneMapping,Ao as AdditiveBlending,Nc as AgXToneMapping,Co as AlwaysDepth,au as AlwaysStencilFunc,_h as AmbientLight,ro as AnimationClip,xx as AnimationMixer,$p as ArrayCamera,Wm as Audio,bh as AudioContext,mx as AudioListener,cx as AudioLoader,zx as AxesHelper,si as BackSide,up as BasicDepthPacking,XS as BasicNodeLibrary,lm as BatchedMesh,Wu as Bone,Bi as Box3,Vx as Box3Helper,yn as BoxGeometry,Fx as BoxHelper,wt as BufferAttribute,ct as BufferGeometry,ol as Camera,Ox as CameraHelper,Py as CanvasTexture,ym as CatmullRomCurve3,gr as ClampToEdgeWrapping,Gm as Clock,xe as Color,fh as ColorKeyframeTrack,vt as ColorManagement,Iy as CompressedArrayTexture,Ly as CompressedCubeTexture,vl as CompressedTexture,Hx as Controls,Nu as CubeCamera,Ns as CubeTexture,Hn as CubeUVReflectionMapping,Or as Curve,$d as CustomBlending,ha as CylinderGeometry,uu as Data3DTexture,Ur as DataTexture,Zy as DataTextureLoader,Ev as DataUtils,X0 as DecrementStencilOp,Y0 as DecrementWrapStencilOp,Um as DefaultLoadingManager,Xn as DepthFormat,qn as DepthStencilFormat,Ds as DepthTexture,xh as DirectionalLight,Ux as DirectionalLightHelper,Wr as DoubleSide,Ms as DynamicDrawUsage,wm as EdgesGeometry,Io as EqualDepth,Z0 as EqualStencilFunc,zn as EquirectangularReflectionMapping,kn as EquirectangularRefractionMapping,dr as Euler,vr as EventDispatcher,vc as ExtrudeGeometry,Kr as FileLoader,De as Float32BufferAttribute,Oi as FloatType,Kp as Fog,an as FrontSide,ka as Frustum,ou as GLSL3,jS as GLSLNodeParser,Po as GreaterDepth,Lo as GreaterEqualDepth,iv as GreaterEqualStencilFunc,ev as GreaterStencilFunc,Lx as GridHelper,Us as Group,wi as HalfFloatType,vh as HemisphereLight,lx as ImageBitmapLoader,j0 as IncrementStencilOp,q0 as IncrementWrapStencilOp,Nn as InstancedBufferAttribute,km as InstancedBufferGeometry,qm as InstancedInterleavedBuffer,nm as InstancedMesh,ja as InterleavedBuffer,On as InterleavedBufferAttribute,Qa as Interpolant,ba as InterpolateDiscrete,jo as InterpolateLinear,$0 as InvertStencilOp,Yn as KeepStencilOp,Fr as KeyframeTrack,em as LOD,rl as Layers,Ro as LessDepth,Bn as LessEqualDepth,Q0 as LessEqualStencilFunc,K0 as LessStencilFunc,Cn as Line,Ax as Line3,Ni as LineBasicMaterial,um as LineLoop,Jr as LineSegments,Lt as LinearFilter,ji as LinearMipmapLinearFilter,Wn as LinearMipmapNearestFilter,nr as LinearSRGBColorSpace,wc as LinearToneMapping,Hi as Loader,Mh as LoaderUtils,gh as LoadingManager,op as LoopOnce,lp as LoopRepeat,g0 as MOUSE,hi as Material,lu as MathUtils,Ke as Matrix3,Re as Matrix4,Jd as MaxEquation,Ft as Mesh,$r as MeshBasicMaterial,Fu as MeshDepthMaterial,ph as MeshLambertMaterial,dh as MeshNormalMaterial,hh as MeshPhongMaterial,uh as MeshPhysicalMaterial,Sl as MeshStandardMaterial,ma as MirroredRepeatWrapping,$t as NearestFilter,Mn as NearestMipmapLinearFilter,Ic as NearestMipmapNearestFilter,Cc as NeutralToneMapping,No as NeverDepth,J0 as NeverStencilFunc,Er as NoBlending,Cr as NoColorSpace,mr as NoToneMapping,qe as Node,lb as NodeBuilder,cb as NodeFrame,_n as NormalBlending,Do as NotEqualDepth,tv as NotEqualStencilFunc,eo as NumberKeyframeTrack,_t as Object3D,wo as OctahedronGeometry,Is as OrthographicCamera,Xd as PCFSoftShadowMap$1,Lu as PMREMGenerator$1,di as PerspectiveCamera,ln as Plane,ua as PlaneGeometry,yh as PointLight,dm as Points,Ka as PointsMaterial,gx as PositionalAudio,bt as PropertyBinding,qi as Quaternion,to as QuaternionKeyframeTrack,QS as REVISION,hp as RGBADepthPacking,Ei as RGBAFormat,Ho as RGBA_ASTC_4x4_Format,Go as RGBA_ASTC_6x6_Format,Ta as RGBA_BPTC_Format,ko as RGBA_ETC2_EAC_Format,Vo as RGBA_PVRTC_4BPPV1_Format,xa as RGBA_S3TC_DXT1_Format,_a as RGBA_S3TC_DXT3_Format,Ma as RGBA_S3TC_DXT5_Format,Oc as RGBFormat,Wo as RGB_BPTC_UNSIGNED_Format,Bo as RGB_ETC1_Format,zo as RGB_ETC2_Format,Fo as RGB_PVRTC_4BPPV1_Format,ya as RGB_S3TC_DXT1_Format,va as RGFormat,Cm as RawShaderMaterial,Es as Ray,Tx as Raycaster,Uo as RedFormat,Ec as ReinhardToneMapping,Gn as RepeatWrapping,W0 as ReplaceStencilOp,yc as RingGeometry,Fi as SRGBColorSpace,Vu as Scene,dt as ShaderChunk,Dr as ShaderLib,Pr as ShaderMaterial,ch as ShadowMaterial,rs as Shape,kx as ShapePath,nn as ShapeUtils,fc as Skeleton,rm as SkinnedMesh,$n as Source,Ai as Sphere,Eo as SphereGeometry,Sx as Spherical,El as SpotLight,Qp as Sprite,cl as SpriteMaterial,fF as THREE,v0 as TOUCH,Wt as Texture,Qy as TextureLoader,xc as TorusGeometry,er as Triangle,H0 as TriangleFanDrawMode,k0 as TriangleStripDrawMode,z0 as TrianglesDrawMode,_u as Uint16BufferAttribute,_x as Uniform$1,Me as UniformsLib,Fp as UniformsUtils,jr as UnsignedByteType,Uc as UnsignedInt101111Type,jn as UnsignedInt248Type,Dc as UnsignedInt5999Type,Nr as UnsignedIntType,J as Vector2,N as Vector3,st as Vector4,io as VectorKeyframeTrack,Ry as VideoTexture,Cu as WebGLCubeRenderTarget,Ir as WebGLRenderTarget,cy as WebGLRenderer,Nm as WireframeGeometry,G0 as ZeroStencilOp,nf as defaultShaderStages,hr as normalView};
3873
+ 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=[Wx(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 YD=K(lS);class Td 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 $D=K(Td);class cS extends Td{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 JD=K(cS);class uS extends Td{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 KD=K(uS);let la=null,ca=null;class hS 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(Ln(this.minNode.value)),i=e.getTypeLength(Ln(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(Ln(r)),o=e.getTypeLength(Ln(s));la=la||new st,ca=ca||new st,la.setScalar(0),ca.setScalar(0),a===1?la.setScalar(r):r.isColor?la.set(r.r,r.g,r.b):la.set(r.x,r.y,r.z||0,r.w||0),o===1?ca.setScalar(s):s.isColor?ca.set(s.r,s.g,s.b):ca.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=la.getComponent(p),v=ca.getComponent(p);u[d]=lu.lerp(m,v,Math.random())}const h=this.getNodeType(e);if(t.count<=4096)i=$l(u,"vec4",t.count).element(tc).convert(h);else{const d=new Nn(u,4);e.geometry.setAttribute("__range"+this.id,d),i=Gh(d).convert(h)}}else i=E(0);return i}}const ZD=K(hS),QD=U(({depthTexture:n,shadowCoord:e})=>yt(n,e.xy).compare(e.z)),eU=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)}),tU=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=hs(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)}),iU=U(({depthTexture:n,shadowCoord:e})=>{const t=E(1).toVar(),i=yt(n).uv(e.xy).rg,r=Gl(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}),rU=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(go.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)}),nU=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(go.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)}),sU=[QD,eU,tU,iU];let bo=null;const bd=new fn;class fs extends ta{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 Km(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){bo===null&&(bo=new Tt,bo.fragmentNode=ae(0,0,0,1),bo.isShadowNodeMaterial=!0,bo.name="ShadowMaterial");const s=i.shadowMap.type,a=this.light.shadow,o=new Us;o.compareFunction=pp;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:va,type:wi}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:va,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=rU({samples:I,radius:T,size:w,shadowPass:y}).context(e.getSharedContext()),C.name="VSMVertical",C=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Tt),C.fragmentNode=nU({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||jh;let p=fe(a.matrix).setGroup(xt).mul(d.add(qh.mul(h)));p=p.xyz.div(p.w);let m=p.z.add(u);i.coordinateSystem===bs&&(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||sU[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=bo,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),bd.material=this.vsmMaterialVertical,bd.render(i),i.setRenderTarget(this.vsmShadowMapHorizontal),bd.material=this.vsmMaterialHorizontal,bd.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 Kg=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 Sd;function Zg(n){Sd=Sd||new WeakMap;let e=Sd.get(n);return e===void 0&&Sd.set(n,e={}),e}function Qg(n){const e=Zg(n);return e.position||(e.position=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.matrixWorld)))}function dS(n){const e=Zg(n);return e.targetPosition||(e.targetPosition=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.target.matrixWorld)))}function wd(n){const e=Zg(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 e0=n=>cr.transformDirection(Qg(n).sub(dS(n))),aU=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)}),t0=(n,e)=>Ji(lt(4,n.mul(Pt(1,n))),e),oU=(n,e)=>n.lessThan(.5)?t0(n.mul(2),e).div(2):Pt(1,t0(lt(Pt(1,n),2),e).div(2)),lU=(n,e,t)=>Ji(Qr(Ji(n,e),zt(Ji(n,e),Ji(Pt(1,n),t))),1/e),cU=(n,e)=>Ci(Zs.mul(e.mul(n).sub(1))).div(Zs.mul(e.mul(n).sub(1))),gn=U(([n])=>n.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),pS=U(([n])=>D(gn(n.z.add(gn(n.y.mul(1)))),gn(n.z.add(gn(n.x.mul(1)))),gn(n.y.add(gn(n.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),uU=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(pS(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(gn(i.z.add(gn(i.x.add(gn(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"}]}),hU=U(([n,e,t=z(.5)])=>Ag(n.sub(t),e).add(t)),dU=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))}),pU=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 Rl(e)&&(r[0][0]=zr[0].length(),r[0][1]=0,r[0][2]=0),Rl(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)}),mU=U(([n=null])=>{const e=id();return id(cg(n)).sub(e).lessThan(0).select(ms,n)}),mS=new WeakMap;class fU 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=gS(i);this.previousModelWorldMatrix.value.copy(r);const s=fS(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}){gS(e).copy(e.matrixWorld)}setup(){const e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=lr.mul(pn).mul(Zt),i=this.previousProjectionMatrix.mul(e).mul(Wh),r=t.xy.div(t.w),s=i.xy.div(i.w);return Pt(r,s)}}function fS(n){let e=mS.get(n);return e===void 0&&(e={},mS.set(n,e)),e}function gS(n,e=0){const t=fS(n);let i=t[e];return i===void 0&&(t[e]=i=new Re),i}const gU=ge(fU),vU=U(([n,e])=>xi(1,n.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),yU=U(([n,e])=>xi(n.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),xU=U(([n,e])=>n.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_U=U(([n,e])=>rt(n.mul(2).mul(e),n.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Gl(.5,n))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),MU=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}),TU=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)}),bU=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)}),vS=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"}]}),yS=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"}]}),xS=U(([n,e])=>n.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_S=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"}]}),MS=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"}]}),SU=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)}),TS=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=SU(n),n=i.mul(n),n.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wU=yi(D(1.6605,-.1246,-.0182),D(-.5876,1.1329,-.1006),D(-.0728,-.0083,1.1187)),EU=yi(D(.6274,.0691,.0164),D(.3293,.9195,.088),D(.0433,.0113,.8956)),AU=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))))}),bS=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(EU.mul(t)),t.assign(i.mul(t)),t.assign(ft(t,1e-10)),t.assign(kl(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(li(t,0,1)),t.assign(AU(t)),t.assign(r.mul(t)),t.assign(Ji(ft(D(0),t),D(2.2))),t.assign(wU.mul(t)),t.assign(li(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SS=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 NU 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 Ed=(n,e)=>G(new NU(n,e)),CU=Ed("numWorkgroups","uvec3"),RU=Ed("workgroupId","uvec3"),IU=Ed("localId","uvec3"),LU=Ed("subgroupSize","uint");class PU 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
3874
+ `):e.addLineFlowCode(`${t}Barrier()`,this)}}const i0=K(PU),DU=()=>i0("workgroup").append(),UU=()=>i0("storage").append(),OU=()=>i0("texture").append();class FU extends os{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 VU 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 FU(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const BU=(n,e)=>G(new VU("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 zU=K(Mi),Un=(n,e,t,i)=>{const r=zU(n,e,t,i);return r.append(),r},kU=(n,e,t=null)=>Un(Mi.ATOMIC_STORE,n,e,t),HU=(n,e,t=null)=>Un(Mi.ATOMIC_ADD,n,e,t),GU=(n,e,t=null)=>Un(Mi.ATOMIC_SUB,n,e,t),WU=(n,e,t=null)=>Un(Mi.ATOMIC_MAX,n,e,t),jU=(n,e,t=null)=>Un(Mi.ATOMIC_MIN,n,e,t),XU=(n,e,t=null)=>Un(Mi.ATOMIC_AND,n,e,t),qU=(n,e,t=null)=>Un(Mi.ATOMIC_OR,n,e,t),YU=(n,e,t=null)=>Un(Mi.ATOMIC_XOR,n,e,t),$U=U(([n=nt()])=>{const e=n.mul(2),t=e.x.floor(),i=e.y.floor();return t.add(i).mod(2).sign()}),dc=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=ls(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"}]}),Ad=U(([n,e])=>{const t=ls(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(us(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))}),JU=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"}]}),KU=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"}]}),wS=Di([JU,KU]),ZU=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"}]}),QU=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"}]}),ES=Di([ZU,QU]),eO=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(dc(a.lessThan(_e(4)),r,i)).toVar(),l=E(lt(2,dc(a.lessThan(_e(4)),i,r))).toVar();return Ad(o,ls(a.bitAnd(_e(1)))).add(Ad(l,ls(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"}]}),tO=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(dc(l.lessThan(_e(8)),a,s)).toVar(),u=E(dc(l.lessThan(_e(4)),s,dc(l.equal(_e(12)).or(l.equal(_e(14))),a,r))).toVar();return Ad(c,ls(l.bitAnd(_e(1)))).add(Ad(u,ls(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([eO,tO]),iO=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=oo(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"}]}),rO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=oo(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([iO,rO]),nO=U(([n])=>{const e=E(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),sO=U(([n])=>{const e=E(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),aO=U(([n])=>{const e=D(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),AS=Di([nO,aO]),oO=U(([n])=>{const e=D(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),NS=Di([sO,oO]),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"}]}),CS=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)}),pc=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"}]}),Gi=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"}]}),vn=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"}]}),lO=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 pc(i.add(_e(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),cO=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)),pc(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),uO=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)),pc(o,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),hO=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)),CS(c,u,h),c.addAssign(_e(r)),pc(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"}]}),dO=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)),CS(h,d,p),h.addAssign(_e(a)),d.addAssign(_e(s)),pc(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([lO,cO,uO,hO,dO]),pO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(Ct(i,t)).toVar(),s=oo().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"}]}),mO=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=oo().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([pO,mO]),fO=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(vn(r)).toVar(),o=E(vn(s)).toVar(),l=E(wS(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 AS(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),gO=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(vn(s)).toVar(),c=E(vn(a)).toVar(),u=E(vn(o)).toVar(),h=E(ES(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 NS(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),r0=Di([fO,gO]),vO=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(vn(r)).toVar(),o=E(vn(s)).toVar(),l=D(wS(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 AS(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),yO=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(vn(s)).toVar(),c=E(vn(a)).toVar(),u=E(vn(o)).toVar(),h=D(ES(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 NS(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),n0=Di([vO,yO]),xO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return Gi(Ct(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),_O=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return Gi(Ct(t,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),MO=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 Gi(Ct(t,i,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),TO=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 Gi(Ct(t,i,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),bO=Di([xO,_O,MO,TO]),SO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return D(Gi(Ct(t,P(0))),Gi(Ct(t,P(1))),Gi(Ct(t,P(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),wO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return D(Gi(Ct(t,i,P(0))),Gi(Ct(t,i,P(1))),Gi(Ct(t,i,P(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),EO=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(Gi(Ct(t,i,r,P(0))),Gi(Ct(t,i,r,P(1))),Gi(Ct(t,i,r,P(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),AO=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(Gi(Ct(t,i,r,s,P(0))),Gi(Ct(t,i,r,s,P(1))),Gi(Ct(t,i,r,s,P(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),RS=Di([SO,wO,EO,AO]),Nd=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(r0(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"}]}),IS=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(n0(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"}]}),NO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar();return z(Nd(o,a,s,r),Nd(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"}]}),CO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(IS(o,a,s,r)).toVar(),c=E(Nd(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"}]}),RO=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(RS(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"}]}),IO=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(RS(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"}]}),So=Di([RO,IO]),LO=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(So(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"}]}),PO=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(So(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"}]}),DO=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(So(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"}]}),UO=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(So(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"}]}),OO=Di([LO,UO]),FO=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(So(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"}]}),VO=Di([PO,FO]),BO=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(So(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"}]}),zO=Di([DO,BO]),kO=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(us(r)).mul(6).toVar();const s=P(Lf(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"}]}),HO=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"}]}),GO=U(([n])=>{const e=D(n).toVar(),t=ff(Af(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"}]}),LS=(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)},PS=(n,e,t,i)=>rt(n,e,t[i].clamp()),WO=(n,e,t=nt())=>PS(n,e,t,"x"),jO=(n,e,t=nt())=>PS(n,e,t,"y"),DS=(n,e,t,i,r)=>rt(n,e,LS(t,i[r])),XO=(n,e,t,i=nt())=>DS(n,e,t,i,"x"),qO=(n,e,t,i=nt())=>DS(n,e,t,i,"y"),YO=(n=1,e=0,t=nt())=>t.mul(n).add(e),$O=(n,e=1)=>(n=E(n),n.abs().pow(e).mul(n.sign())),JO=(n,e=1,t=.5)=>E(n).sub(t).mul(e).add(t),KO=(n=nt(),e=1,t=0)=>r0(n.convert("vec2|vec3")).mul(e).add(t),ZO=(n=nt(),e=1,t=0)=>n0(n.convert("vec2|vec3")).mul(e).add(t),QO=(n=nt(),e=1,t=0)=>(n=n.convert("vec2|vec3"),ae(n0(n),r0(n.add(z(19,73)))).mul(e).add(t)),eF=(n=nt(),e=1)=>OO(n.convert("vec2|vec3"),e,P(1)),tF=(n=nt(),e=1)=>VO(n.convert("vec2|vec3"),e,P(1)),iF=(n=nt(),e=1)=>zO(n.convert("vec2|vec3"),e,P(1)),rF=(n=nt())=>bO(n.convert("vec2|vec3")),nF=(n=nt(),e=3,t=2,i=.5,r=1)=>Nd(n,P(e),t,i).mul(r),sF=(n=nt(),e=3,t=2,i=.5,r=1)=>NO(n,P(e),t,i).mul(r),aF=(n=nt(),e=3,t=2,i=.5,r=1)=>IS(n,P(e),t,i).mul(r),oF=(n=nt(),e=3,t=2,i=.5,r=1)=>CO(n,P(e),t,i).mul(r),US=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 OS extends fs{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=wd(s).sub(Pi),l=o.normalize(),c=o.length(),u=Kg({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 FS extends fs{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,i=this.colorNode,r=e0(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:i,reflectedLight:s},e.stack,e)}}const s0=new Re,Cd=new Re;let mc=null;class VS extends fs{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;Cd.identity(),s0.copy(t.matrixWorld),s0.premultiply(i),Cd.extractRotation(s0),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Cd),this.halfHeight.value.applyMatrix4(Cd)}setup(e){super.setup(e);let t,i;e.isAvailable("float32Filterable")?(t=yt(mc.LTC_FLOAT_1),i=yt(mc.LTC_FLOAT_2)):(t=yt(mc.LTC_HALF_1),i=yt(mc.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,o=wd(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){mc=e}}class a0 extends fs{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=wd(a).sub(Pi),l=o.normalize(),c=l.dot(e0(a)),u=this.getSpotAttenuation(c),h=o.length(),d=Kg({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 BS extends a0{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 zS extends fs{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class kS extends fs{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=Qg(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 HS extends fs{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=mn(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=US(qh,this.lightProbe);e.context.irradiance.addAssign(t)}}class lF{parseFunction(){console.warn("Abstract function.")}}class GS{constructor(e,t,i="",r=""){this.type=e,this.inputs=t,this.name=i,this.precision=r}getCode(){console.warn("Abstract function.")}}GS.isNodeFunction=!0;const cF=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,uF=/[a-z_0-9]+/ig,WS="#pragma main",hF=n=>{n=n.trim();const e=n.indexOf(WS),t=e!==-1?n.slice(e+WS.length):n,i=t.match(cF);if(i!==null&&i.length===5){const r=i[4],s=[];let a=null;for(;(a=uF.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 zg(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 dF extends GS{constructor(e){const{type:t,inputs:i,name:r,precision:s,inputsCode:a,blockCode:o,headerCode:l}=hF(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 lF{parseFunction(e){return new dF(e)}}class pF{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 mF extends El{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 XS extends pF{constructor(){super(),this.addLight(OS,yh),this.addLight(FS,xh),this.addLight(VS,Bm),this.addLight(a0,El),this.addLight(zS,_h),this.addLight(kS,vh),this.addLight(HS,zm),this.addLight(BS,mF),this.addToneMapping(xS,wc),this.addToneMapping(_S,Ec),this.addToneMapping(MS,Qd),this.addToneMapping(TS,Ac),this.addToneMapping(bS,Nc),this.addToneMapping(SS,Cc),this.addColorSpace(yS,Hh(nr,Fi)),this.addColorSpace(vS,Hh(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 fF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Ac,AONode:Y1,AddEquation:Vn,AddOperation:Zd,AdditiveAnimationBlendMode:cp,AdditiveBlending:Ao,AfterImageNode:Db,AgXToneMapping:Nc,AlphaFormat:rp,AlwaysCompare:lv,AlwaysDepth:Co,AlwaysStencilFunc:au,AmbientLight:_h,AmbientLightNode:zS,AnaglyphPassNode:rS,AnalyticLightNode:fs,AnamorphicNode:Fb,AnimationAction:yx,AnimationClip:ro,AnimationLoader:UI,AnimationMixer:xx,AnimationObjectGroup:e2,AnimationUtils:II,ArcCurve:Dy,ArrayCamera:$p,ArrayElementNode:os,ArrowHelper:m2,AssignNode:p_,AttachedBindMode:ep,AttributeNode:Wf,Audio:Wm,AudioAnalyser:WI,AudioContext:bh,AudioListener:mx,AudioLoader:cx,AxesHelper:zx,BRDF_GGX:fg,BRDF_Lambert:ia,BackSide:si,BasicDepthPacking:up,BasicEnvironmentNode:rd,BasicNodeLibrary:XS,BasicShadowMap:tw,BatchNode:V1,BatchedMesh:lm,BloomNode:Jb,Bone:Wu,BooleanKeyframeTrack:ns,Box2:a2,Box3:Bi,Box3Helper:Vx,BoxGeometry:yn,BoxHelper:Fx,Break:td,BufferAttribute:wt,BufferAttributeNode:TM,BufferGeometry:ct,BufferGeometryLoader:nx,BufferNode:$h,BumpMapNode:n1,BypassNode:AM,ByteType:tp,Cache:Rn,CacheNode:EM,Camera:ol,CameraHelper:Ox,CanvasTexture:Py,CapsuleGeometry:Id,CatmullRomCurve3:ym,CineonToneMapping:Qd,CircleGeometry:Ld,ClampToEdgeWrapping:gr,Clock:Gm,CodeNode:Ig,Color:xe,ColorKeyframeTrack:fh,ColorManagement:vt,ColorSpaceNode:jl,CompressedArrayTexture:Iy,CompressedCubeTexture:Ly,CompressedTexture:vl,CompressedTextureLoader:OI,ComputeNode:SM,ConeGeometry:Pd,ConstNode:Vr,ConstantAlphaFactor:D0,ConstantColorFactor:L0,ContextNode:Ff,Continue:SL,Controls:Hx,ConvertNode:of,CubeCamera:Nu,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,CubeTexture:Cs,CubeTextureLoader:FI,CubeTextureNode:JM,CubeUVReflectionMapping:Hn,CubicBezierCurve:xm,CubicBezierCurve3:Oy,CubicInterpolant:$y,CullFaceBack:Wd,CullFaceFront:x0,CullFaceFrontBack:ew,CullFaceNone:y0,Curve:Or,CurvePath:Vy,CustomBlending:$d,CustomToneMapping:O0,CylinderGeometry:ha,Cylindrical:s2,DFGApprox:gg,D_GGX:dT,Data3DTexture:uu,DataArrayTexture:el,DataTexture:Ur,DataTextureLoader:Zy,DataUtils:Ev,DecrementStencilOp:X0,DecrementWrapStencilOp:Y0,DefaultLoadingManager:Um,DenoiseNode:qb,DepthFormat:Xn,DepthOfFieldNode:Bb,DepthStencilFormat:qn,DepthTexture:Us,DetachedBindMode:F0,DirectionalLight:xh,DirectionalLightHelper:Ux,DirectionalLightNode:FS,Discard:LM,DiscreteInterpolant:Jy,DisplayP3ColorSpace:su,DodecahedronGeometry:Dd,DotScreenNode:zb,DoubleSide:Wr,DstAlphaFactor:A0,DstColorFactor:C0,DynamicCopyUsage:pw,DynamicDrawUsage:Ts,DynamicReadUsage:uw,EPSILON:P_,EdgesGeometry:wm,EllipseCurve:eh,EnvironmentNode:VT,EqualCompare:nv,EqualDepth:Io,EqualStencilFunc:Z0,EquirectUVNode:sT,EquirectangularReflectionMapping:zn,EquirectangularRefractionMapping:kn,Euler:dr,EventDispatcher:vr,ExpressionNode:IM,ExtrudeGeometry:vc,FXAANode:Yb,F_Schlick:vo,FileLoader:Kr,FilmNode:Hb,Float16BufferAttribute:Av,Float32BufferAttribute:De,FloatType:Oi,Fn:U,Fog:Kp,FogExp2:Rd,FogExp2Node:uS,FogNode:Td,FogRangeNode:cS,FramebufferTexture:pm,FrontFacingNode:kM,FrontSide:an,Frustum:ka,FunctionCallNode:f_,FunctionNode:Lg,FunctionOverloadingNode:hb,GLBufferAttribute:n2,GLSL1:fw,GLSL3:ou,GLSLNodeParser:jS,GTAONode:Xb,GaussianBlurNode:Lb,GreaterCompare:sv,GreaterDepth:Po,GreaterEqualCompare:ov,GreaterEqualDepth:Lo,GreaterEqualStencilFunc:iv,GreaterStencilFunc:ev,GridHelper:Lx,Group:Os,HalfFloatType:wi,HemisphereLight:vh,HemisphereLightHelper:h2,HemisphereLightNode:kS,IESSpotLightNode:BS,INFINITY:B2,IcosahedronGeometry:Ud,If:Le,ImageBitmapLoader:lx,ImageLoader:wl,ImageUtils:fv,IncrementStencilOp:j0,IncrementWrapStencilOp:q0,IndexNode:Bt,InstanceNode:O1,InstancedBufferAttribute:Nn,InstancedBufferGeometry:km,InstancedInterleavedBuffer:qm,InstancedMesh:nm,InstancedPointsNodeMaterial:BL,Int16BufferAttribute:Qw,Int32BufferAttribute:eE,Int8BufferAttribute:Jw,IntType:ga,InterleavedBuffer:ja,InterleavedBufferAttribute:On,Interpolant:Qa,InterpolateDiscrete:ba,InterpolateLinear:jo,InterpolateSmooth:ru,InvertStencilOp:$0,IrradianceNode:K1,JoinNode:Xx,KeepStencilOp:Yn,KeyframeTrack:Fr,LOD:em,LatheGeometry:gc,Layers:rl,LessCompare:pp,LessDepth:Ro,LessEqualCompare:mp,LessEqualDepth:Bn,LessEqualStencilFunc:Q0,LessStencilFunc:K0,Light:ss,LightProbe:zm,LightProbeNode:HS,LightingContextNode:$1,LightingModel:lc,LightingNode:ta,LightsNode:X1,Line:Cn,Line2NodeMaterial:jL,Line3:Ax,LineBasicMaterial:Ni,LineBasicNodeMaterial:kL,LineCurve:_m,LineCurve3:Fy,LineDashedMaterial:mh,LineDashedNodeMaterial:GL,LineLoop:um,LineSegments:Jr,LinearDisplayP3ColorSpace:qo,LinearFilter:Lt,LinearInterpolant:Dm,LinearMipMapLinearFilter:V0,LinearMipMapNearestFilter:nw,LinearMipmapLinearFilter:ji,LinearMipmapNearestFilter:Wn,LinearSRGBColorSpace:nr,LinearToneMapping:wc,LinearTransfer:Yo,Loader:Hi,LoaderUtils:Mh,LoadingManager:gh,Loop:gt,LoopNode:H1,LoopOnce:op,LoopPingPong:B0,LoopRepeat:lp,LuminanceAlphaFormat:sp,LuminanceFormat:np,Lut3DNode:Gb,MOUSE:g0,MRTNode:ub,MatcapUVNode:HT,Material:hi,MaterialLoader:_c,MaterialNode:Z,MaterialReferenceNode:KM,MathUtils:lu,Matrix2:o0,Matrix3:Ke,Matrix4:Re,MaxEquation:Jd,MaxMipLevelNode:OM,Mesh:Ft,MeshBasicMaterial:$r,MeshBasicNodeMaterial:eP,MeshDepthMaterial:Fu,MeshDistanceMaterial:qp,MeshLambertMaterial:ph,MeshLambertNodeMaterial:sP,MeshMatcapMaterial:Im,MeshMatcapNodeMaterial:GP,MeshNormalMaterial:dh,MeshNormalNodeMaterial:YL,MeshPhongMaterial:hh,MeshPhongNodeMaterial:oP,MeshPhysicalMaterial:uh,MeshPhysicalNodeMaterial:kT,MeshSSSNodeMaterial:FP,MeshStandardMaterial:Sl,MeshStandardNodeMaterial:zT,MeshToonMaterial:Rm,MeshToonNodeMaterial:kP,MinEquation:T0,MirroredRepeatWrapping:ma,MixOperation:Kd,ModelNode:tn,ModelViewProjectionNode:P1,MorphNode:W1,MultiplyBlending:Yd,MultiplyOperation:pa,NearestFilter:$t,NearestMipMapLinearFilter:rw,NearestMipMapNearestFilter:iw,NearestMipmapLinearFilter:Mn,NearestMipmapNearestFilter:Ic,NeutralToneMapping:Cc,NeverCompare:rv,NeverDepth:No,NeverStencilFunc:J0,NoBlending:Er,NoColorSpace:Cr,NoToneMapping:mr,Node:qe,NodeAttribute:Ng,NodeBuilder:lb,NodeCache:hd,NodeCode:KT,NodeFrame:cb,NodeFunctionInput:zg,NodeLoader:qT,NodeMaterial:Tt,NodeMaterialLoader:YT,NodeMaterialObserver:Gx,NodeObjectLoader:QP,NodeShaderStage:rf,NodeType:y2,NodeUniform:$T,NodeUpdateType:je,NodeUtils:v2,NodeVar:Cg,NodeVarying:JT,NormalAnimationBlendMode:nu,NormalBlending:_n,NormalMapNode:r1,NotEqualCompare:av,NotEqualDepth:Do,NotEqualStencilFunc:tv,NumberKeyframeTrack:eo,Object3D:_t,Object3DNode:St,ObjectLoader:sx,ObjectSpaceNormalMap:dp,OctahedronGeometry:wo,OneFactor:S0,OneMinusConstantAlphaFactor:U0,OneMinusConstantColorFactor:P0,OneMinusDstAlphaFactor:N0,OneMinusDstColorFactor:R0,OneMinusSrcAlphaFactor:Sc,OneMinusSrcColorFactor:E0,OrthographicCamera:Ls,OscNode:gi,OutputStructNode:kg,P3Primaries:Jo,PCFShadowMap:jd,PCFSoftShadowMap:Xd,PI:Zs,PI2:z2,PMREMGenerator:Lu,PMREMNode:UT,ParallaxBarrierPassNode:nS,ParameterNode:Rg,PassNode:bi,Path:_l,PerspectiveCamera:di,PhongLightingModel:pg,PhysicalLightingModel:ad,PixelationPassNode:Zb,Plane:ln,PlaneGeometry:ua,PlaneHelper:p2,PointLight:yh,PointLightHelper:c2,PointLightNode:OS,PointUVNode:Mb,Points:dm,PointsMaterial:Ka,PointsNodeMaterial:jP,PolarGridHelper:d2,PolyhedronGeometry:gs,PositionalAudio:gx,PosterizeNode:Eb,PropertyBinding:bt,PropertyMixer:vx,PropertyNode:Et,QuadraticBezierCurve:Mm,QuadraticBezierCurve3:Tm,Quaternion:qi,QuaternionKeyframeTrack:to,QuaternionLinearInterpolant:Ky,RED_GREEN_RGTC2_Format:tu,RED_RGTC1_Format:ap,REVISION:"169",RGBADepthPacking:hp,RGBAFormat:Ei,RGBAIntegerFormat:Vc,RGBA_ASTC_10x10_Format:Jc,RGBA_ASTC_10x5_Format:qc,RGBA_ASTC_10x6_Format:Yc,RGBA_ASTC_10x8_Format:$c,RGBA_ASTC_12x10_Format:Kc,RGBA_ASTC_12x12_Format:Zc,RGBA_ASTC_4x4_Format:Ho,RGBA_ASTC_5x4_Format:kc,RGBA_ASTC_5x5_Format:Hc,RGBA_ASTC_6x5_Format:Gc,RGBA_ASTC_6x6_Format:Go,RGBA_ASTC_8x5_Format:Wc,RGBA_ASTC_8x6_Format:jc,RGBA_ASTC_8x8_Format:Xc,RGBA_BPTC_Format:Ta,RGBA_ETC2_EAC_Format:ko,RGBA_PVRTC_2BPPV1_Format:zc,RGBA_PVRTC_4BPPV1_Format:Vo,RGBA_S3TC_DXT1_Format:xa,RGBA_S3TC_DXT3_Format:_a,RGBA_S3TC_DXT5_Format:Ma,RGBDepthPacking:aw,RGBFormat:Oc,RGBIntegerFormat:sw,RGBShiftNode:kb,RGB_BPTC_SIGNED_Format:Qc,RGB_BPTC_UNSIGNED_Format:Wo,RGB_ETC1_Format:Bo,RGB_ETC2_Format:zo,RGB_PVRTC_2BPPV1_Format:Bc,RGB_PVRTC_4BPPV1_Format:Fo,RGB_S3TC_DXT1_Format:ya,RGDepthPacking:ow,RGFormat:va,RGIntegerFormat:Fc,RTTNode:yb,RangeNode:hS,RawShaderMaterial:Cm,Ray:As,Raycaster:Tx,Rec709Primaries:$o,RectAreaLight:Bm,RectAreaLightNode:VS,RedFormat:Uo,RedIntegerFormat:Oo,ReferenceNode:Jl,ReflectorNode:vb,ReinhardToneMapping:Ec,RemapNode:Gf,RenderOutputNode:PM,RenderTarget:ui,RendererReferenceNode:vM,RepeatWrapping:Gn,ReplaceStencilOp:W0,Return:j2,ReverseSubtractEquation:M0,RingGeometry:yc,RotateNode:WT,SIGNED_RED_GREEN_RGTC2_Format:iu,SIGNED_RED_RGTC1_Format:eu,SRGBColorSpace:Fi,SRGBTransfer:Ot,SSAAPassNode:Qb,Scene:Vu,SceneNode:sn,Schlick_to_F0:mT,ScreenNode:ri,ScriptableNode:lS,ScriptableValueNode:aS,SetNode:qx,ShaderChunk:dt,ShaderLib:Dr,ShaderMaterial:Pr,ShaderNode:Il,ShadowMaterial:ch,ShadowNodeMaterial:JP,Shape:rs,ShapeGeometry:Od,ShapePath:kx,ShapeUtils:nn,ShortType:ip,Skeleton:fc,SkeletonHelper:l2,SkinnedMesh:rm,SkinningNode:sg,SobelOperatorNode:Vb,Source:$n,Sphere:Ai,SphereGeometry:Eo,Spherical:Sx,SphericalHarmonics3:rx,SplineCurve:bm,SplitNode:Rh,SpotLight:El,SpotLightHelper:o2,SpotLightNode:a0,Sprite:Qp,SpriteMaterial:cl,SpriteNodeMaterial:qP,SpriteSheetUVNode:db,SrcAlphaFactor:bc,SrcAlphaSaturateFactor:I0,SrcColorFactor:w0,StackNode:QT,StaticCopyUsage:dw,StaticDrawUsage:Sa,StaticReadUsage:cw,StereoCamera:Hm,StereoPassNode:eS,StorageArrayElementNode:pb,StorageBufferNode:Yg,StorageTextureNode:bb,StreamCopyUsage:mw,StreamDrawUsage:lw,StreamReadUsage:hw,StringKeyframeTrack:ks,SubtractEquation:_0,SubtractiveBlending:qd,TBNViewMatrix:ea,TOUCH:v0,TangentSpaceNormalMap:on,TempNode:pt,TetrahedronGeometry:Fd,Texture:Wt,Texture3DNode:jT,TextureLoader:Qy,TextureNode:dn,TextureSizeNode:UM,TextureUtils:OR,TimerNode:Si,ToneMappingNode:xM,ToonOutlinePassNode:sS,TorusGeometry:xc,TorusKnotGeometry:Vd,TransitionNode:Kb,Triangle:er,TriangleFanDrawMode:H0,TriangleStripDrawMode:k0,TrianglesDrawMode:z0,TriplanarTexturesNode:mb,TubeGeometry:Bd,UVMapping:Rc,Uint16BufferAttribute:_u,Uint32BufferAttribute:Dp,Uint8BufferAttribute:Kw,Uint8ClampedBufferAttribute:Zw,Uniform:_x,UniformArrayNode:$f,UniformGroupNode:gf,UniformNode:Ys,UniformsGroup:r2,UniformsLib:Me,UniformsUtils:Fp,UnsignedByteType:jr,UnsignedInt101111Type:Uc,UnsignedInt248Type:jn,UnsignedInt5999Type:Dc,UnsignedIntType:Nr,UnsignedShort4444Type:Lc,UnsignedShort5551Type:Pc,UnsignedShortType:fa,UserDataNode:wb,VSMShadowMap:rr,V_GGX_SmithCorrelated:hT,VarNode:uM,VaryingNode:hM,Vector2:J,Vector3:N,Vector4:st,VectorKeyframeTrack:io,VertexColorNode:_b,VideoTexture:Ry,ViewportDepthNode:Qi,ViewportDepthTextureNode:tT,ViewportSharedTextureNode:Ab,ViewportTextureNode:sc,VolumeNodeMaterial:ZP,WebGL3DRenderTarget:zw,WebGLArrayRenderTarget:Bw,WebGLCoordinateSystem:Rr,WebGLCubeRenderTarget:Cu,WebGLMultipleRenderTargets:f2,WebGLRenderTarget:Ir,WebGLRenderer:cy,WebGLUtils:ly,WebGPUCoordinateSystem:bs,WireframeGeometry:Nm,WrapAroundEnding:Xo,ZeroCurvatureEnding:_s,ZeroFactor:b0,ZeroSlopeEnding:Ms,ZeroStencilOp:G0,abs:It,acesFilmicToneMapping:TS,acos:zh,add:zt,addMethodChaining:te,addNodeElement:X2,afterImage:lD,agxToneMapping:bS,all:Nf,alphaT:Oh,anaglyphPass:WD,anamorphic:mD,and:T_,anisotropy:cs,anisotropyB:Js,anisotropyT:Fl,any:D_,ao:SD,append:t_,arrayBuffer:U2,asin:z_,assign:m_,atan:k_,atan2:J_,atomicAdd:HU,atomicAnd:XU,atomicFunc:Un,atomicMax:WU,atomicMin:jU,atomicOr:qU,atomicStore:kU,atomicSub:GU,atomicXor:YU,attenuationColor:Sf,attenuationDistance:bf,attribute:_i,backgroundBlurriness:J3,backgroundIntensity:K3,batch:B1,billboarding:pU,bitAnd:E_,bitNot:A_,bitOr:N_,bitXor:C_,bitangentGeometry:dL,bitangentLocal:pL,bitangentView:QM,bitangentWorld:mL,bitcast:k2,bleach:TU,bloom:PD,blur:PT,bool:ls,buffer:$l,bufferAttribute:Xl,bumpMap:s1,burn:vU,bvec2:n_,bvec3:ff,bvec4:l_,bypass:NM,cache:ql,call:g_,cameraFar:uo,cameraLogDepth:VM,cameraNear:co,cameraNormalMatrix:J2,cameraPosition:jf,cameraProjectionMatrix:lr,cameraProjectionMatrixInverse:Y2,cameraViewMatrix:cr,cameraWorldMatrix:$2,cbrt:rM,ceil:If,checker:$U,cineonToneMapping:MS,clamp:li,clearcoat:Ph,clearcoatRoughness:Ol,code:dd,color:i_,colorSpaceToWorking:kf,colorToDirection:XL,compute:wM,cond:lM,context:Vf,convert:u_,convertToTexture:Zi,cos:Tr,createCanvasElement:hv,cross:lo,cubeTexture:Yh,dFdx:W_,dFdy:j_,dashSize:Ks,defaultBuildStages:sf,defaultShaderStages:nf,defined:Rl,degrees:F_,denoise:AD,densityFog:KD,depth:hg,depthPass:aD,difference:Q_,diffuseColor:Nt,directionToColor:nT,dispersion:wf,distance:Z_,div:Qr,dodge:yU,dof:gD,dot:qt,dotScreen:vD,drawIndex:U1,dynamicBufferAttribute:bM,element:c_,emissive:yf,equal:v_,equals:U_,equirectUV:dg,exp:Cf,exp2:Bh,expression:ds,faceDirection:Yl,faceForward:sM,film:xD,float:E,floor:us,fog:$D,fract:hs,frameGroup:F2,frameId:U3,frontFacing:HM,fwidth:Y_,fxaa:ND,gain:oU,gapSize:Bl,gaussianBlur:oD,getColorSpaceMethod:Hh,getConstNodeType:e_,getCurrentStack:mf,getDirection:IT,getDistanceAttenuation:Kg,getGeometryRoughness:uT,getRoughness:mg,getShIrradianceAt:US,getTextureIndex:Hg,global:Md,glsl:n3,glslFn:s3,grayscale:cD,greaterThan:Af,greaterThanEqual:M_,hash:aU,highPrecisionModelNormalViewMatrix:oL,highPrecisionModelViewMatrix:aL,hue:dD,instance:F1,instanceIndex:tc,instancedBufferAttribute:Gh,instancedDynamicBufferAttribute:Hf,int:P,inverseSqrt:V_,invocationLocalIndex:TL,invocationSubgroupIndex:ML,ior:zl,iridescence:Uh,iridescenceIOR:xf,iridescenceThickness:_f,ivec2:un,ivec3:s_,ivec4:a_,js:i3,label:cM,length:Qs,lengthSq:Df,lessThan:x_,lessThanEqual:__,lightPosition:Qg,lightTargetDirection:e0,lightTargetPosition:dS,lightViewPosition:wd,lightingContext:J1,lights:q1,linearDepth:id,linearSRGBTosRGB:yS,linearToneMapping:xS,localId:IU,log:Rf,log2:kl,loop:wL,luminance:Ui,lut3D:_D,mat2:Dl,mat3:yi,mat4:qs,matcapUV:GT,materialAOMap:L1,materialAlphaTest:o1,materialAnisotropy:M1,materialAnisotropyVector:mo,materialAttenuationColor:C1,materialAttenuationDistance:N1,materialClearcoat:f1,materialClearcoatNormal:v1,materialClearcoatRoughness:g1,materialColor:po,materialDispersion:I1,materialEmissive:c1,materialIOR:A1,materialIridescence:T1,materialIridescenceIOR:b1,materialIridescenceThickness:S1,materialLightMap:rg,materialLineDashOffset:ig,materialLineDashSize:eg,materialLineGapSize:tg,materialLineScale:Qh,materialLineWidth:ed,materialMetalness:p1,materialNormal:m1,materialOpacity:Kh,materialPointWidth:R1,materialReference:rn,materialReflectivity:Zh,materialRefractionRatio:jM,materialRotation:y1,materialRoughness:d1,materialSheen:x1,materialSheenRoughness:_1,materialShininess:l1,materialSpecular:u1,materialSpecularColor:h1,materialSpecularIntensity:Qf,materialSpecularStrength:ec,materialThickness:E1,materialTransmission:w1,max:ft,maxMipLevel:FM,metalness:Ul,min:xi,mix:rt,mixElement:aM,mod:kh,modInt:Ef,modelDirection:iL,modelNormalMatrix:BM,modelPosition:rL,modelScale:nL,modelViewMatrix:pn,modelViewPosition:sL,modelViewProjection:ng,modelWorldMatrix:zr,modelWorldMatrixInverse:zM,morphReference:j1,motionBlur:MU,mrt:gd,mul:lt,mx_aastep:LS,mx_cell_noise_float:rF,mx_contrast:JO,mx_fractal_noise_float:nF,mx_fractal_noise_vec2:sF,mx_fractal_noise_vec3:aF,mx_fractal_noise_vec4:oF,mx_hsvtorgb:kO,mx_noise_float:KO,mx_noise_vec3:ZO,mx_noise_vec4:QO,mx_ramplr:WO,mx_ramptb:jO,mx_rgbtohsv:HO,mx_safepower:$O,mx_splitlr:XO,mx_splittb:qO,mx_srgb_texture_to_lin_rec709:GO,mx_transform_uv:YO,mx_worley_noise_float:eF,mx_worley_noise_vec2:tF,mx_worley_noise_vec3:iF,negate:H_,neutralToneMapping:SS,nodeArray:Xs,nodeImmutable:ge,nodeObject:G,nodeObjects:Ll,nodeProxy:K,normalFlat:GM,normalGeometry:Xh,normalLocal:ur,normalMap:Zf,normalView:hr,normalWorld:qh,normalize:Mr,not:S_,notEqual:y_,numWorkgroups:CU,objectDirection:K2,objectGroup:d_,objectPosition:Q2,objectScale:eL,objectViewPosition:tL,objectWorldMatrix:Z2,oneMinus:G_,or:b_,orthographicDepthToViewZ:DL,oscSawtooth:B3,oscSine:O3,oscSquare:F3,oscTriangle:V3,output:Mf,outputStruct:I3,overlay:_U,overloadingFn:Di,parabola:t0,parallaxBarrierPass:jD,parallaxDirection:t1,parallaxUV:gL,parameter:t3,pass:sD,passTexture:To,pcurve:lU,perspectiveDepthToViewZ:ug,pixelationPass:FD,pmremTexture:OT,pointUV:$3,pointWidth:V2,positionGeometry:Li,positionLocal:Zt,positionPrevious:Wh,positionView:Pi,positionViewDirection:Vt,positionWorld:jh,positionWorldDirection:Xf,posterize:iD,pow:Ji,pow2:Pf,pow3:eM,pow4:tM,property:ar,radians:O_,rand:Of,range:ZD,rangeFog:JD,reciprocal:q_,reference:fi,referenceBuffer:Jf,reflect:K_,reflectVector:YM,reflectView:XM,reflector:W3,refract:Uf,refractVector:$M,refractView:qM,reinhardToneMapping:_S,remainder:L_,remap:CM,remapClamp:RM,renderGroup:xt,renderOutput:DM,rendererReference:yM,rgbShift:yD,rotate:Ag,rotateUV:hU,roughness:hn,round:X_,rtt:xb,sRGBToLinearSRGB:vS,sampler:q2,saturate:nM,saturation:uD,screen:xU,screenCoordinate:go,screenSize:fo,screenUV:ms,scriptable:YD,scriptableValue:_d,select:Ri,sepia:bU,setCurrentStack:Pl,shaderStages:af,sharedUniformGroup:vf,sheen:$s,sheenRoughness:Dh,shiftLeft:R_,shiftRight:I_,shininess:Fh,sign:Hl,sin:Ci,sinc:cU,skinning:bL,skinningReference:k1,smoothstep:Ki,smoothstepElement:oM,sobel:fD,specularColor:or,specularF90:Vl,spherizeUV:dU,split:O2,spritesheetUV:z3,sqrt:en,ssaaPass:zD,stack:pd,step:Gl,stereoPass:HD,storage:Z3,storageBarrier:UU,storageObject:Q3,storageTexture:Sb,string:D2,sub:Pt,subgroupIndex:_L,subgroupSize:LU,tan:B_,tangentGeometry:Jh,tangentLocal:Kl,tangentView:Zl,tangentWorld:ZM,temp:Bf,texture:yt,texture3D:XT,textureBarrier:OU,textureBicubic:bT,textureCubeUV:LT,textureLoad:Br,textureSize:ps,textureStore:eD,thickness:Tf,threshold:Ub,timerDelta:D3,timerGlobal:P3,timerLocal:Gg,toOutputColorSpace:pM,toWorkingColorSpace:mM,toneMapping:_M,toneMappingExposure:MM,toonOutlinePass:XD,transformDirection:iM,transformNormal:WM,transformNormalToView:Yf,transformedBentNormalView:i1,transformedBitangentView:e1,transformedBitangentWorld:fL,transformedClearcoatNormalView:ho,transformedNormalView:Yt,transformedNormalWorld:qf,transformedTangentView:Kf,transformedTangentWorld:hL,transition:DD,transmission:Vh,transpose:$_,tri:gn,tri3:pS,triNoise3D:uU,triplanarTexture:H3,triplanarTextures:fb,trunc:Lf,tslFn:P2,uint:_e,uniform:fe,uniformArray:mn,uniformGroup:h_,uniforms:cL,userData:tD,uv:nt,uvec2:r_,uvec3:oo,uvec4:o_,varying:Ii,varyingProperty:Zr,vec2:z,vec3:D,vec4:ae,vectorComponents:no,velocity:gU,vertexColor:Y3,vertexIndex:D1,vibrance:hD,viewZToOrthographicDepth:ac,viewZToPerspectiveDepth:iT,viewport:Pn,viewportBottomLeft:LL,viewportCoordinate:Q1,viewportDepthTexture:cg,viewportLinearDepth:UL,viewportMipTexture:eT,viewportResolution:RL,viewportSafeUV:mU,viewportSharedTexture:rD,viewportSize:Z1,viewportTexture:PL,viewportTopLeft:IL,viewportUV:CL,wgsl:r3,wgslFn:a3,workgroupArray:BU,workgroupBarrier:DU,workgroupId:RU,workingToColorSpace:fM,xor:w_},Symbol.toStringTag,{value:"Module"}));export{Ac as ACESFilmicToneMapping,Ao as AdditiveBlending,Nc as AgXToneMapping,Co as AlwaysDepth,au as AlwaysStencilFunc,_h as AmbientLight,ro as AnimationClip,xx as AnimationMixer,$p as ArrayCamera,Wm as Audio,bh as AudioContext,mx as AudioListener,cx as AudioLoader,zx as AxesHelper,si as BackSide,up as BasicDepthPacking,XS as BasicNodeLibrary,lm as BatchedMesh,Wu as Bone,ns as BooleanKeyframeTrack,Bi as Box3,Vx as Box3Helper,yn as BoxGeometry,Fx as BoxHelper,wt as BufferAttribute,ct as BufferGeometry,ol as Camera,Ox as CameraHelper,Py as CanvasTexture,ym as CatmullRomCurve3,gr as ClampToEdgeWrapping,Gm as Clock,xe as Color,fh as ColorKeyframeTrack,vt as ColorManagement,Iy as CompressedArrayTexture,Ly as CompressedCubeTexture,vl as CompressedTexture,Hx as Controls,Nu as CubeCamera,Cs as CubeTexture,Hn as CubeUVReflectionMapping,Or as Curve,$d as CustomBlending,ha as CylinderGeometry,uu as Data3DTexture,Ur as DataTexture,Zy as DataTextureLoader,Ev as DataUtils,X0 as DecrementStencilOp,Y0 as DecrementWrapStencilOp,Um as DefaultLoadingManager,Xn as DepthFormat,qn as DepthStencilFormat,Us as DepthTexture,xh as DirectionalLight,Ux as DirectionalLightHelper,Wr as DoubleSide,Ts as DynamicDrawUsage,wm as EdgesGeometry,Io as EqualDepth,Z0 as EqualStencilFunc,zn as EquirectangularReflectionMapping,kn as EquirectangularRefractionMapping,dr as Euler,vr as EventDispatcher,vc as ExtrudeGeometry,Kr as FileLoader,De as Float32BufferAttribute,Oi as FloatType,Kp as Fog,an as FrontSide,ka as Frustum,ou as GLSL3,jS as GLSLNodeParser,Po as GreaterDepth,Lo as GreaterEqualDepth,iv as GreaterEqualStencilFunc,ev as GreaterStencilFunc,Lx as GridHelper,Os as Group,wi as HalfFloatType,vh as HemisphereLight,lx as ImageBitmapLoader,j0 as IncrementStencilOp,q0 as IncrementWrapStencilOp,Nn as InstancedBufferAttribute,km as InstancedBufferGeometry,qm as InstancedInterleavedBuffer,nm as InstancedMesh,ja as InterleavedBuffer,On as InterleavedBufferAttribute,Qa as Interpolant,ba as InterpolateDiscrete,jo as InterpolateLinear,$0 as InvertStencilOp,Yn as KeepStencilOp,Fr as KeyframeTrack,em as LOD,rl as Layers,Ro as LessDepth,Bn as LessEqualDepth,Q0 as LessEqualStencilFunc,K0 as LessStencilFunc,Cn as Line,Ax as Line3,Ni as LineBasicMaterial,um as LineLoop,Jr as LineSegments,Lt as LinearFilter,ji as LinearMipmapLinearFilter,Wn as LinearMipmapNearestFilter,nr as LinearSRGBColorSpace,wc as LinearToneMapping,Hi as Loader,Mh as LoaderUtils,gh as LoadingManager,op as LoopOnce,lp as LoopRepeat,g0 as MOUSE,hi as Material,lu as MathUtils,Ke as Matrix3,Re as Matrix4,Jd as MaxEquation,Ft as Mesh,$r as MeshBasicMaterial,Fu as MeshDepthMaterial,ph as MeshLambertMaterial,dh as MeshNormalMaterial,hh as MeshPhongMaterial,uh as MeshPhysicalMaterial,Sl as MeshStandardMaterial,ma as MirroredRepeatWrapping,$t as NearestFilter,Mn as NearestMipmapLinearFilter,Ic as NearestMipmapNearestFilter,Cc as NeutralToneMapping,No as NeverDepth,J0 as NeverStencilFunc,Er as NoBlending,Cr as NoColorSpace,mr as NoToneMapping,qe as Node,lb as NodeBuilder,cb as NodeFrame,_n as NormalBlending,Do as NotEqualDepth,tv as NotEqualStencilFunc,eo as NumberKeyframeTrack,_t as Object3D,wo as OctahedronGeometry,Ls as OrthographicCamera,Xd as PCFSoftShadowMap$1,Lu as PMREMGenerator$1,di as PerspectiveCamera,ln as Plane,ua as PlaneGeometry,yh as PointLight,dm as Points,Ka as PointsMaterial,gx as PositionalAudio,bt as PropertyBinding,qi as Quaternion,to as QuaternionKeyframeTrack,QS as REVISION,hp as RGBADepthPacking,Ei as RGBAFormat,Ho as RGBA_ASTC_4x4_Format,Go as RGBA_ASTC_6x6_Format,Ta as RGBA_BPTC_Format,ko as RGBA_ETC2_EAC_Format,Vo as RGBA_PVRTC_4BPPV1_Format,xa as RGBA_S3TC_DXT1_Format,_a as RGBA_S3TC_DXT3_Format,Ma as RGBA_S3TC_DXT5_Format,Oc as RGBFormat,Wo as RGB_BPTC_UNSIGNED_Format,Bo as RGB_ETC1_Format,zo as RGB_ETC2_Format,Fo as RGB_PVRTC_4BPPV1_Format,ya as RGB_S3TC_DXT1_Format,va as RGFormat,Cm as RawShaderMaterial,As as Ray,Tx as Raycaster,Uo as RedFormat,Ec as ReinhardToneMapping,Gn as RepeatWrapping,W0 as ReplaceStencilOp,yc as RingGeometry,Fi as SRGBColorSpace,Vu as Scene,dt as ShaderChunk,Dr as ShaderLib,Pr as ShaderMaterial,ch as ShadowMaterial,rs as Shape,kx as ShapePath,nn as ShapeUtils,fc as Skeleton,rm as SkinnedMesh,$n as Source,Ai as Sphere,Eo as SphereGeometry,Sx as Spherical,El as SpotLight,Qp as Sprite,cl as SpriteMaterial,fF as THREE,v0 as TOUCH,Wt as Texture,Qy as TextureLoader,xc as TorusGeometry,er as Triangle,H0 as TriangleFanDrawMode,k0 as TriangleStripDrawMode,z0 as TrianglesDrawMode,_u as Uint16BufferAttribute,_x as Uniform$1,Me as UniformsLib,Fp as UniformsUtils,jr as UnsignedByteType,Uc as UnsignedInt101111Type,jn as UnsignedInt248Type,Dc as UnsignedInt5999Type,Nr as UnsignedIntType,J as Vector2,N as Vector3,st as Vector4,io as VectorKeyframeTrack,Ry as VideoTexture,Cu as WebGLCubeRenderTarget,Ir as WebGLRenderTarget,cy as WebGLRenderer,Nm as WireframeGeometry,G0 as ZeroStencilOp,nf as defaultShaderStages,hr as normalView};